Exemple #1
0
        private static Pair <AviStreamFormat, AviStreamHeader> GetAviStreamFormatAndHeader(IEnumerable <HeaderList> headerLists, StreamType streamType)
        {
            foreach (IResultNode headerList in headerLists)
            {
                AviStreamFormat aviStreamFormat = null;
                AviStreamHeader aviStreamHeader = null;

                foreach (AviChunk child in headerList.Children)
                {
                    if (child is AviStreamFormat)
                    {
                        aviStreamFormat = (AviStreamFormat)child;
                    }
                    if (child is AviStreamHeader && ((AviStreamHeader)child).StreamType == (uint)streamType)
                    {
                        aviStreamHeader = (AviStreamHeader)child;
                    }
                    if (aviStreamFormat != null && aviStreamHeader != null)
                    {
                        return(new Pair <AviStreamFormat, AviStreamHeader>(aviStreamFormat, aviStreamHeader));
                    }
                }
            }
            return(null);
        }
Exemple #2
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 #3
0
        public AviStreamFormat(AviChunk previousHeader)
            : base(previousHeader, AviChunkName.AviStreamFormat)
        {
            AviStreamHeader aviStreamHeader = previousHeader as AviStreamHeader;

            if (aviStreamHeader != null)
            {
                if (aviStreamHeader.StreamType == (uint)StreamType.Video)
                {
                    _aviStreamFormatType = AviStreamFormatType.Video;
                }
                if (aviStreamHeader.StreamType == (uint)StreamType.Audio)
                {
                    _aviStreamFormatType = AviStreamFormatType.Audio;
                }
            }
        }