示例#1
0
        /// <summary>
        /// Erzeugt ein Datenformat für den Ton.
        /// </summary>
        /// <param name="ac3">Gesetzt für Dolby Digital.</param>
        /// <returns>Das gewünschte Format.</returns>
        private static MediaType CreateAudioType( bool ac3 )
        {
            // Create format
            var fakeFormat =
                new AudioFormat
                    {
                        SamplesPerSec = 48000,
                        Channels = 2,
                        Size = 22,
                    };

            // Create format information
            var type = new MediaType( Constants.KSDATAFORMAT_TYPE_AUDIO, ac3 ? Constants.KSDATAFORMAT_SUBTYPE_AC3_AUDIO : Constants.KSDATAFORMAT_SUBTYPE_MPEG2_AUDIO, Constants.FORMAT_WaveFormatEx, true, 0x10000 );

            // Finish
            type.SetFormat( fakeFormat );

            // Report
            return type;
        }
示例#2
0
        /// <summary>
        /// Versucht den DVB.NET Datenstrom direkt mit dem zugehörigen Decoder zu verbinden.
        /// </summary>
        /// <param name="decoder">Ein manuell angelegter Decoder.</param>
        /// <param name="source">Der zu verwendende Ausgang.</param>
        /// <param name="mediaType">Das verwendete Format.</param>
        /// <returns>Gesetzt, wenn die Verbindung aufgebaut wurde.</returns>
        private bool TryDirectConnect( TypedComIdentity<IBaseFilter> decoder, OutputPin source, MediaType mediaType )
        {
            // In normal cases we should directly connect to the filter so try
            var connected = false;

            // Try manual connect
            decoder.InspectAllPins( p => p.QueryDirection() == PinDirection.Input,
                pin =>
                {
                    // Skip on error
                    try
                    {
                        // Get the raw interface for the media type
                        var type = mediaType.GetReference();

                        // Process
                        using (var iFace = ComIdentity.Create<IPin>( pin ))
                            source.Connect( iFace.Interface, type );

                        // Did it
                        connected = true;
                    }
                    catch (Exception)
                    {
                    }

                    // First pin only - even if it can not be used!
                    return false;
                } );

            // Failed
            if (!connected)
                return false;

            // Find the output of the decoder and render it
            decoder.InspectAllPins( p => p.QueryDirection() == PinDirection.Output,
                pin =>
                {
                    // Create helper
                    using (var pinWrapper = ComIdentity.Create<IPin>( pin ))
                        DirectShowObject.Render( pinWrapper.Interface );

                    // Did it
                    return false;
                } );

            // Report
            return connected;
        }
示例#3
0
        /// <summary>
        /// Erzeugt den Datentyp für ein Bildsignal.
        /// </summary>
        /// <param name="mpeg4">Gesetzt für HDTV.</param>
        /// <param name="useCyberlink">Gesetzt für die Nutzung des Cyberlink Formates.</param>
        /// <returns>Das gewünschte Datenformat.</returns>
        private static MediaType CreateVideoType( bool mpeg4, bool? useCyberlink )
        {
            // Create format
            var fakeFormat = new MPEG2VideoInfo { BitmpapSize = 40 };

            // Resulting media type
            MediaType type;

            // Check mode
            if (mpeg4)
            {
                // Set it up
                fakeFormat.BitmapWidth = 1980;
                fakeFormat.BitmapHeight = 1088;

                // Check flag
                if (!useCyberlink.HasValue)
                {
                    // See if we should use cyberlink format specs
                    string cl = ConfigurationManager.AppSettings["UseCyberLink"];

                    // Copy if set
                    useCyberlink = (!string.IsNullOrEmpty( cl ) && bool.Parse( cl ));
                }

                // Check mode
                if (useCyberlink.Value)
                {
                    // Create media type for video
                    type = new MediaType( Constants.KSDATAFORMAT_TYPE_VIDEO, Constants.KSDATAFORMAT_SUBTYPE_H264_VIDEO_Cyberlink, Constants.FORMAT_MPEG2_VIDEO, true, 0x10000 );
                }
                else
                {
                    // Create media type for video
                    type = new MediaType( Constants.KSDATAFORMAT_TYPE_VIDEO, Constants.KSDATAFORMAT_SUBTYPE_H264_VIDEO, Constants.FORMAT_MPEG2_VIDEO, true, 0x10000 );
                }
            }
            else
            {
                // Set it up
                fakeFormat.BitmapWidth = 720;
                fakeFormat.BitmapHeight = 576;

                // Create media type for video
                type = new MediaType( Constants.KSDATAFORMAT_TYPE_VIDEO, Constants.KSDATAFORMAT_SUBTYPE_MPEG2_VIDEO, Constants.FORMAT_MPEG2_VIDEO, true, 0x10000 );
            }

            // Finish
            type.SetFormat( fakeFormat );

            // Report
            return type;
        }
示例#4
0
 /// <summary>
 /// Erzeugt eine neue Auflistung.
 /// </summary>
 /// <param name="types">Die Datenformate der Auflistung.</param>
 public TypeEnum( MediaType[] types )
 {
     // Remember
     m_Types = types;
 }
示例#5
0
        /// <summary>
        /// Erzeugt eine neue Einspieleinheit.
        /// </summary>
        /// <param name="filter">Der zugehörige Filter.</param>
        /// <param name="name">Der Name dieser Einheit.</param>
        /// <param name="type">Die Beschreibung des Datenstromformates.</param>
        public ESInjector( TSFilter filter, string name, MediaType type )
            : base( 1000, 8 * 1024 )
        {
            // Remember
            m_MajorType = type.MajorType;
            m_MinorType = type.SubType;
            m_Filter = filter;

            // Create the pin
            m_Pin = new LivePin( filter, name, type );

            // Connect sink to injector base
            SetSink( m_Pin.Receive );

            // Create stream
            CreateConsumer();
        }
示例#6
0
 /// <summary>
 /// Erzeugt einen neuen Live Pin.
 /// </summary>
 /// <param name="filter">Der zugehörige Filter.</param>
 /// <param name="name">Der Name des Pins.</param>
 /// <param name="mediaType">Der Datentyp, der durch den Pin fließt.</param>
 public LivePin( TypedComIdentity<IBaseFilter> filter, string name, MediaType mediaType )
     : base( filter, name, mediaType )
 {
 }
示例#7
0
 /// <summary>
 /// Legt das Format der Daten fest.
 /// </summary>
 /// <param name="type">Das gewünschte Datenformat.</param>
 protected void SetMediaType( MediaType type )
 {
     // Remember
     m_Type = type;
     m_SendType = true;
 }