Exemple #1
0
        private static string GetCodecStreamName(byte streamNumber, MovieEntry movieEntry, IEnumerable <HeaderList> headerLists)
        {
            StringBuilder codecStreamName = new StringBuilder();

            codecStreamName.AppendFormat(CultureInfo.CurrentCulture, "Stream {0}", streamNumber);

            if (movieEntry != null)
            {
                // The Stream Type
                codecStreamName.AppendFormat(CultureInfo.CurrentCulture, ", {0}", Enum.GetName(typeof(InformationType), movieEntry.StreamType));

                if (movieEntry.StreamType == InformationType.AudioData)
                {
                    Pair <AviStreamFormat, AviStreamHeader> aviStreamFormatAndHeader = GetAviStreamFormatAndHeader(headerLists, StreamType.Audio);

                    if (aviStreamFormatAndHeader != null)
                    {
                        AviStreamFormat aviStreamFormat = aviStreamFormatAndHeader.First;

                        if (Enum.IsDefined(typeof(AviStreamFormat.FormatTag), (int)aviStreamFormat.FormatTagValue))
                        {
                            codecStreamName.AppendFormat(CultureInfo.CurrentCulture, ", {0}", Enum.GetName(typeof(AviStreamFormat.FormatTag), (int)aviStreamFormat.FormatTagValue).ToLower().Replace('_', ' '));
                        }
                    }
                }
                else if (movieEntry.StreamType == InformationType.CompressedVideoFrame ||
                         movieEntry.StreamType == InformationType.UncompressedVideoFrame)
                {
                    Pair <AviStreamFormat, AviStreamHeader> aviStreamFormatAndHeader = GetAviStreamFormatAndHeader(headerLists, StreamType.Video);
                    if (aviStreamFormatAndHeader != null)
                    {
                        AviStreamFormat aviStreamFormat = aviStreamFormatAndHeader.First;
                        AviStreamHeader aviStreamHeader = aviStreamFormatAndHeader.Second;

                        string handler     = aviStreamHeader.Handler.ToString4CC().ToLower(CultureInfo.CurrentCulture);
                        string compression = aviStreamFormat.Compression.ToString4CC().ToLower(CultureInfo.CurrentCulture);

                        if (!string.IsNullOrEmpty(handler))
                        {
                            codecStreamName.AppendFormat(CultureInfo.CurrentCulture, ", {0}", handler);
                            codecStreamName.AppendDescriptiveCodecName(handler);
                        }
                        if (compression != handler && !string.IsNullOrEmpty(compression))
                        {
                            codecStreamName.AppendFormat(CultureInfo.CurrentCulture, ", {0}", compression);
                            codecStreamName.AppendDescriptiveCodecName(compression);
                        }
                    }
                }
            }

            return(codecStreamName.ToString());
        }
Exemple #2
0
        private static void AddMovieEntries(IDataBlockBuilder dataBlockBuilder, IDictionary <byte, ICodecStreamBuilder> codecStreamBuilders, IResultNode chunk, IEnumerable <HeaderList> headerLists)
        {
            MovieEntry movieEntry = chunk as MovieEntry;

            if (movieEntry != null)
            {
                AddMovieEntry(dataBlockBuilder, codecStreamBuilders, movieEntry, headerLists);
            }

            foreach (AviChunk child in chunk.Children)
            {
                AddMovieEntries(dataBlockBuilder, codecStreamBuilders, child, headerLists);
            }
        }
Exemple #3
0
        private static void AddMovieEntry(IDataBlockBuilder dataBlockBuilder, IDictionary <byte, ICodecStreamBuilder> codecStreamBuilders, MovieEntry movieEntry, IEnumerable <HeaderList> headerLists)
        {
            if (movieEntry.StreamType != InformationType.AudioData &&
                movieEntry.StreamType != InformationType.UncompressedVideoFrame &&
                movieEntry.StreamType != InformationType.CompressedVideoFrame)
            {
                //if (movieEntry.StreamType == InformationType.PaletteChanged) { TODO ask Rikkert }
                return;
            }

            IDataPacket streamData = movieEntry.StreamData;

            if (streamData == null)
            {
                return;
            }

            byte channel = movieEntry.Channel;

            if (codecStreamBuilders.ContainsKey(channel))
            {
                ICodecStreamBuilder codecStreamBuilder = codecStreamBuilders[channel];
                codecStreamBuilder.Data = codecStreamBuilder.Data.Append(streamData);
            }
            else
            {
                ICodecStreamBuilder codecStreamBuilder = dataBlockBuilder.AddCodecStream();
                codecStreamBuilder.Name = GetCodecStreamName(channel, movieEntry, headerLists);
                codecStreamBuilder.AbsoluteStartOffset = streamData.StartOffset;
                codecStreamBuilder.Data = streamData;

                // The DataFormat will be set by the codec detector (if one exists)
                //codecStreamBuilder.DataFormat = GetDataFormat(headerLists);
                codecStreamBuilders.Add(channel, codecStreamBuilder);
            }
        }