Пример #1
0
        private void ConfigureAudioStream(IMediaParserMediaStream audio)
        {
            IAudioConfigurationSource configurationSource            = (IAudioConfigurationSource)audio.ConfigurationSource;
            Dictionary <MediaStreamAttributeKeys, string> dictionary = new Dictionary <MediaStreamAttributeKeys, string>();
            string codecPrivateData = configurationSource.CodecPrivateData;

            Debug.WriteLine("TsMediaStreamSource.ConfigureAudioStream(): CodecPrivateData: " + codecPrivateData);
            if (!string.IsNullOrWhiteSpace(codecPrivateData))
            {
                dictionary[MediaStreamAttributeKeys.CodecPrivateData] = codecPrivateData;
            }
            MediaStreamDescription streamDescription = new MediaStreamDescription(MediaStreamType.Audio, (IDictionary <MediaStreamAttributeKeys, string>)dictionary);

            lock (this._streamConfigurationLock)
            {
                this._audioStreamSource      = audio.StreamSource;
                this._audioStreamDescription = streamDescription;
            }
        }
Пример #2
0
        private void ConfigureVideoStream(IMediaParserMediaStream video)
        {
            IVideoConfigurationSource configurationSource            = (IVideoConfigurationSource)video.ConfigurationSource;
            Dictionary <MediaStreamAttributeKeys, string> dictionary = new Dictionary <MediaStreamAttributeKeys, string>();

            dictionary[MediaStreamAttributeKeys.VideoFourCC] = configurationSource.VideoFourCc;
            string codecPrivateData = configurationSource.CodecPrivateData;

            Debug.WriteLine("MediaStreamConfigurator.ConfigureVideoStream(): CodecPrivateData: " + codecPrivateData);
            if (!string.IsNullOrWhiteSpace(codecPrivateData))
            {
                dictionary[MediaStreamAttributeKeys.CodecPrivateData] = codecPrivateData;
            }
            dictionary[MediaStreamAttributeKeys.Height] = configurationSource.Height.ToString();
            dictionary[MediaStreamAttributeKeys.Width]  = configurationSource.Width.ToString();
            MediaStreamDescription streamDescription = new MediaStreamDescription(MediaStreamType.Video, (IDictionary <MediaStreamAttributeKeys, string>)dictionary);

            lock (this._streamConfigurationLock)
            {
                this._videoStreamSource      = video.StreamSource;
                this._videoStreamDescription = streamDescription;
            }
        }
Пример #3
0
        bool DumpStream(IMediaParserMediaStream stream)
        {
            var streamSource = stream.StreamSource;

            if (null == streamSource)
                return false;

            Console.WriteLine("Stream " + stream.ConfigurationSource.Name);

            var sawData = false;

            var sb = new StringBuilder();

            for (; ; )
            {
                var packet = streamSource.GetNextSample();

                if (null == packet)
                {
                    if (streamSource.IsEof)
                        Console.WriteLine("EOF");

                    return sawData;
                }

                sawData = true;

                sb.AppendFormat("{0}/{1} {2} {3}", packet.PresentationTimestamp, packet.DecodeTimestamp, packet.Duration, packet.Length);
                sb.AppendLine();

                for (var i = 0; i < packet.Length; ++i)
                {
                    if (i > 0 && 0 == (i & 0x03))
                    {
                        if (0 == (i & 0x1f))
                            sb.AppendLine();
                        else
                            sb.Append(' ');
                    }

                    sb.Append(packet.Buffer[packet.Index + i].ToString("x2"));
                }

                Console.WriteLine(sb);
                sb.Clear();

                streamSource.FreeSample(packet);
            }
        }