/// <summary>
            /// Erzeugt ein neue Zustandsinformation.
            /// </summary>
            /// <param name="pipeline">Die zugehörige Gesamtliste aller Aktionen gleicher Art.</param>
            /// <param name="location">Der Ursprung für die angegebene Quellgruppe.</param>
            /// <param name="group">Die neue Quellgruppe.</param>
            /// <returns>Die gewünschte Information.</returns>
            /// <exception cref="ArgumentNullException">Es wurde kein Graph übergeben.</exception>
            internal static TuneToken Create(ActionPipeline <TuneToken> pipeline, GroupLocation location, SourceGroup group)
            {
                // Create new
                var token = new TuneToken(pipeline, location, group);

                // Configure
                IDVBTuningSpace2  tuningSpace;
                Action <ILocator> initializer;

                switch (pipeline.Graph.DVBType)
                {
                case DVBSystemType.Terrestrial: tuningSpace = token.PrepareTerrestrial(out initializer); break;

                case DVBSystemType.Satellite: tuningSpace = token.PrepareSatellite(out initializer); break;

                case DVBSystemType.Cable: tuningSpace = token.PrepareCable(out initializer); break;

                default: throw new NotImplementedException(pipeline.Graph.DVBType.ToString());
                }

                // With cleanup
                try
                {
                    // Create a new tune request
                    token.CreateTuneRequest(tuningSpace, initializer);
                }
                finally
                {
                    // No longer used
                    BDAEnvironment.Release(ref tuningSpace);
                }

                // Report
                return(token);
            }
Example #2
0
            /// <summary>
            /// Erzeugt ein neue Zustandsinformation.
            /// </summary>
            /// <param name="pipeline">Die zugehörige Gesamtliste aller Aktionen gleicher Art.</param>
            /// <returns>Die gewünschte Information.</returns>
            /// <exception cref="ArgumentNullException">Es wurde kein Graph übergeben.</exception>
            internal static SignalToken Create(ActionPipeline <SignalToken> pipeline)
            {
                // Status to use
                BDASignalStatus status   = null;
                int?            strength = null;

                // See if something is provided
                var tuner = pipeline.Graph.TunerFilter;

                if (tuner != null)
                {
                    // Ask network provider for signal information
                    using (var filter = pipeline.Graph.NetworkProvider.MarshalToManaged())
                        try
                        {
                            // Attach to the primary interface and read the strength if provided - may be more current than the signal statistics
                            var tunerInterface = filter.Object as ITuner;
                            if (tunerInterface != null)
                            {
                                strength = tunerInterface.SignalStrength;
                            }
                        }
                        catch
                        {
                            // Just ignore any error
                        }

                    // Attach to interface
                    var statistics = tuner.GetSignalStatistics();
                    if (statistics != null)
                    {
                        try
                        {
                            // Report
                            status = new BDASignalStatus(statistics.SignalLocked != 0, statistics.SignalStrength, statistics.SignalQuality / 100.0);
                        }
                        catch
                        {
                            // Just ignore any error
                        }
                        finally
                        {
                            // Back to COM
                            BDAEnvironment.Release(ref statistics);
                        }
                    }
                }

                // Create new
                return(new SignalToken(pipeline, status, strength));
            }
        /// <summary>
        /// Beendet die Anmeldung endfültig.
        /// </summary>
        public void Dispose()
        {
            // Check registration
            if (m_Register.HasValue)
            {
                // Unregister
                m_ROT.Revoke(m_Register.Value);

                // Forget
                m_Register = null;
            }

            // Forget
            BDAEnvironment.Release(ref m_ROT);
        }
        /// <summary>
        /// Erzeugt eine neue Referenz unter Angabe eines eindeutigen Namens.
        /// </summary>
        /// <typeparam name="T">Die Art des verwalteten Objektes.</typeparam>
        /// <param name="moniker">Der eindeutige Namen zum Objekt.</param>
        /// <returns>Die gewünschte Referenz.</returns>
        public static TypedComIdentity <T> Create <T>(string moniker) where T : class
        {
            // Create
            var instance = Marshal.BindToMoniker(moniker);

            try
            {
                // Report
                return(Create((T)instance));
            }
            finally
            {
                // Cleanup
                BDAEnvironment.Release(ref instance);
            }
        }
        /// <summary>
        /// Erzeugt eine neue Anmeldung.
        /// </summary>
        /// <param name="comObject">Ein beliebiges Objekt.</param>
        /// <exception cref="ArgumentNullException">Es wurde kein Objekt angegeben.</exception>
        public ROTRegister(object comObject)
        {
            // Validate
            if (comObject == null)
            {
                throw new ArgumentNullException("comObject");
            }

            // Attach to ROT
            if (GetRunningObjectTable(0, out m_ROT) < 0)
            {
                return;
            }

            // Attach to COM interface
            IntPtr unk = Marshal.GetIUnknownForObject(comObject);

            try
            {
                // Create the name
                string moniker = string.Format("FilterGraph {0:x8} pid {1:x8}", unk.ToInt32(), Process.GetCurrentProcess().Id);

                // Create the item moniker for the format
                comTypes.IMoniker mon;
                if (CreateItemMoniker("!", moniker, out mon) >= 0)
                {
                    try
                    {
                        // Register
                        m_Register = m_ROT.Register(1, comObject, mon);
                    }
                    finally
                    {
                        // Back to COM
                        BDAEnvironment.Release(ref mon);
                    }
                }
            }
            finally
            {
                // Back to COM
                BDAEnvironment.Release(ref unk);
            }
        }
Example #6
0
        /// <summary>
        /// Ermittelt über die COM Schnittstelle eines Feldelementes eine .NET Schnittstelle.
        /// </summary>
        /// <typeparam name="T">Die gewünschte Art der .NET Schnittstelle.</typeparam>
        /// <param name="index">Die 0-basierte laufende Nummer des Elementes.</param>
        /// <returns>Das zugehörige .NET Objekt.</returns>
        public T GetObject <T>(int index)
        {
            // Load
            var instance = GetObject(index);

            try
            {
                // Change type
                return((T)instance);
            }
            catch
            {
                // Cleanup
                BDAEnvironment.Release(ref instance);

                // Forward
                throw;
            }
        }
Example #7
0
        /// <summary>
        /// Erzeugt eine .NET Schnittstelle zum verwalteten COM Objekt.
        /// </summary>
        /// <returns>Das gewünschte Objekt für den .NET Zugriff</returns>
        public Incarnation MarshalToManaged()
        {
            // Create
            var instance = Marshal.GetObjectForIUnknown(Interface);

            try
            {
                // Just change type type
                return(new Incarnation((T)instance));
            }
            catch
            {
                // Cleanup
                BDAEnvironment.Release(ref instance);

                // Forward
                throw;
            }
        }
            /// <summary>
            /// Erzeugt die eigentliche Anfrage zum Wechseln der Quellgruppe.
            /// </summary>
            /// <param name="tuningSpace">Der zu verwendende Namensraum.</param>
            /// <param name="initializer">Methode zur Übertragung der aktuellen Quellgruppenparameter.</param>
            private void CreateTuneRequest(IDVBTuningSpace2 tuningSpace, Action <ILocator> initializer)
            {
                // Create from tuning space
                m_Request = tuningSpace.CreateTuneRequest();

                // Reset internally - just in case
                m_Request.ONID = -1;
                m_Request.TSID = -1;
                m_Request.SID  = -1;

                // Attach to the default locator
                var @default = tuningSpace.DefaultLocator;

                try
                {
                    // Clone the default locator
                    var locator = @default.Clone();
                    try
                    {
                        // Set it up
                        initializer?.Invoke(locator);

                        // Attach locator
                        m_Request.Locator = locator;
                    }
                    finally
                    {
                        // Detach from clone
                        BDAEnvironment.Release(ref locator);
                    }
                }
                finally
                {
                    // Detach
                    BDAEnvironment.Release(ref @default);
                }
            }
Example #9
0
            /// <summary>
            /// Bereitet die internen Strukturen für die Konfiguration einer Quellgruppe für den
            /// Satellitenempfang vor.
            /// </summary>
            /// <param name="initializer">Methode zur Übernahme der Parameter der Quellgruppe.</param>
            /// <returns>Ein neuer Namensraum.</returns>
            private IDVBTuningSpace2 PrepareSatellite(out Action <ILocator> initializer)
            {
                // Get native types
                var location = GroupLocation as SatelliteLocation;
                var group    = SourceGroup as SatelliteGroup;

                // Create DiSEqC message
                if (location != null)
                {
                    if (group != null)
                    {
                        DiSEqCMessage = StandardDiSEqC.FromSourceGroup(group, location);
                    }
                }

                // Create tuning space
                var space = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBSTuningSpaceClassIdentifier));

                try
                {
                    // Change type
                    var tuningSpace = (IDVBSTuningSpace)space;

                    // Configure
                    tuningSpace.UniqueName   = "DVBNET Satellite";
                    tuningSpace.FriendlyName = "DVB.NET Satellite Tuning Space";
                    tuningSpace.NetworkType  = "{FA4B375A-45B4-4D45-8440-263957B11623}";
                    tuningSpace.SystemType   = DVBSystemType.Satellite;

                    // Configure location
                    if (location != null)
                    {
                        // Configure
                        tuningSpace.LNBSwitch         = checked ((int)location.SwitchFrequency);
                        tuningSpace.HighOscillator    = checked ((int)location.Frequency2);
                        tuningSpace.LowOscillator     = checked ((int)location.Frequency1);
                        tuningSpace.SpectralInversion = SpectralInversion.Automatic;
                        tuningSpace.FrequencyMapping  = string.Empty;
                        tuningSpace.InputRange        = string.Empty;
                        tuningSpace.NetworkID         = -1;
                    }

                    // Create locator
                    var locator = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBSLocatorClassIdentifier));
                    try
                    {
                        // Configure group
                        if (group == null)
                        {
                            initializer = null;
                        }
                        else
                        {
                            initializer = clone =>
                            {
                                // Change type
                                var dvbs = (IDVBSLocator)clone;

                                // Configure
                                dvbs.Modulation         = group.UsesS2Modulation ? ModulationType.VSB8 : ModulationType.QPSK;
                                dvbs.SymbolRate         = checked ((int)(group.SymbolRate / 1000));
                                dvbs.CarrierFrequency   = checked ((int)group.Frequency);
                                dvbs.InnerFECRate       = BinaryConvolutionCodeRate.NotSet;
                                dvbs.OuterFECRate       = BinaryConvolutionCodeRate.NotSet;
                                dvbs.SignalPolarisation = Polarisation.NotSet;
                                dvbs.WestPosition       = group.IsWestPosition;
                                dvbs.OuterFEC           = FECMethod.NotSet;
                                dvbs.InnerFEC           = FECMethod.NotSet;
                                dvbs.OrbitalPosition    = -1;
                                dvbs.Elevation          = -1;
                                dvbs.Azimuth            = 0;

                                // Set polarisation
                                switch (group.Polarization)
                                {
                                case Polarizations.Horizontal: dvbs.SignalPolarisation = Polarisation.Horizontal; break;

                                case Polarizations.Vertical: dvbs.SignalPolarisation = Polarisation.Vertical; break;
                                }

                                // Set rate
                                switch (group.InnerFEC)
                                {
                                case InnerForwardErrorCorrectionModes.Conv1_2: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate1_2; break;

                                case InnerForwardErrorCorrectionModes.Conv2_3: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate2_3; break;

                                case InnerForwardErrorCorrectionModes.Conv3_4: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate3_4; break;

                                case InnerForwardErrorCorrectionModes.Conv3_5: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate3_5; break;

                                case InnerForwardErrorCorrectionModes.Conv4_5: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate4_5; break;

                                case InnerForwardErrorCorrectionModes.Conv5_6: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate5_6; break;

                                case InnerForwardErrorCorrectionModes.Conv7_8: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate7_8; break;

                                case InnerForwardErrorCorrectionModes.Conv8_9: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate8_9; break;

                                case InnerForwardErrorCorrectionModes.Conv9_10: dvbs.InnerFEC = FECMethod.Viterbi; dvbs.InnerFECRate = BinaryConvolutionCodeRate.Rate9_10; break;
                                }
                            }
                        };

                        // Change type - actually test it
                        tuningSpace.DefaultLocator = (ILocator)locator;
                    }
                    finally
                    {
                        // Cleanup
                        BDAEnvironment.Release(ref locator);
                    }

                    // Report
                    return((IDVBTuningSpace2)tuningSpace);
                }
                catch
                {
                    // Cleanup
                    BDAEnvironment.Release(ref space);

                    // Forward
                    throw;
                }
            }
Example #10
0
            /// <summary>
            /// Bereitet die internen Strukturen für die Konfiguration einer Quellgruppe für den
            /// Antennenempfang vor.
            /// </summary>
            /// <param name="initializer">Methode zur Übernahme der Parameter der Quellgruppe.</param>
            /// <returns>Der zu verwendende Namensraum.</returns>
            private IDVBTuningSpace2 PrepareTerrestrial(out Action <ILocator> initializer)
            {
                // Create tuning space
                var space = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBTTuningSpaceClassIdentifier));

                try
                {
                    // Remember
                    var tuningSpace = (IDVBTuningSpace2)space;

                    // Configure
                    tuningSpace.UniqueName   = "DVBNET Terrestrial";
                    tuningSpace.FriendlyName = "DVB.NET Terrestrial Tuning Space";
                    tuningSpace.NetworkType  = "{216C62DF-6D7F-4E9A-8571-05F14EDB766A}";
                    tuningSpace.SystemType   = DVBSystemType.Terrestrial;

                    // Create locator
                    var locator = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBTLocatorClassIdentifier));
                    try
                    {
                        // See if we are tuning
                        var group = SourceGroup as TerrestrialGroup;
                        if (group == null)
                        {
                            initializer = null;
                        }
                        else
                        {
                            initializer = clone =>
                            {
                                // Change type
                                var dvbt = (IDVBTLocator)clone;

                                // Configure
                                dvbt.LPInnerFECRate      = BinaryConvolutionCodeRate.NotSet;
                                dvbt.InnerFECRate        = BinaryConvolutionCodeRate.NotSet;
                                dvbt.OuterFECRate        = BinaryConvolutionCodeRate.NotSet;
                                dvbt.CarrierFrequency    = (int)group.Frequency;
                                dvbt.Modulation          = ModulationType.NotSet;
                                dvbt.HAlpha              = HierarchyAlpha.NotSet;
                                dvbt.Mode                = TransmissionMode.NotSet;
                                dvbt.LPInnerFEC          = FECMethod.NotSet;
                                dvbt.Guard               = GuardInterval.NotSet;
                                dvbt.InnerFEC            = FECMethod.NotSet;
                                dvbt.OtherFrequencyInUse = false;
                                dvbt.OuterFEC            = FECMethod.NotSet;
                                dvbt.SymbolRate          = -1;
                                dvbt.Bandwidth           = -1;

                                // Check bandwidth
                                switch (group.Bandwidth)
                                {
                                case Bandwidths.Six: dvbt.Bandwidth = 6; break;

                                case Bandwidths.Seven: dvbt.Bandwidth = 7; break;

                                case Bandwidths.Eight: dvbt.Bandwidth = 8; break;
                                }
                            }
                        };

                        // Remember - and test the locator type
                        tuningSpace.DefaultLocator = (ILocator)locator;
                    }
                    finally
                    {
                        // Cleanup
                        BDAEnvironment.Release(ref locator);
                    }

                    // Report
                    return(tuningSpace);
                }
                catch
                {
                    // Cleanup
                    BDAEnvironment.Release(ref space);

                    // Forward
                    throw;
                }
            }
            /// <summary>
            /// Bereitet die internen Strukturen für die Konfiguration einer Quellgruppe für den
            /// Kabelempfang vor.
            /// </summary>
            /// <param name="initializer">Methode zur Übernahme der Parameter der Quellgruppe.</param>
            /// <returns>Der zu verwendende Namensraum.</returns>
            private IDVBTuningSpace2 PrepareCable(out Action <ILocator> initializer)
            {
                // Create tuning space
                var space = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBCTuningSpaceClassIdentifier));

                try
                {
                    // Remember
                    var tuningSpace = (IDVBTuningSpace2)space;

                    // Configure
                    tuningSpace.UniqueName   = "DVBNET Cable";
                    tuningSpace.FriendlyName = "DVB.NET Cable Tuning Space";
                    tuningSpace.NetworkType  = "{DC0C0FE7-0485-4266-B93F-68FBF80ED834}";
                    tuningSpace.SystemType   = DVBSystemType.Cable;

                    // Create locator
                    var locator = Activator.CreateInstance(Type.GetTypeFromCLSID(DVBCLocatorClassIdentifier));
                    try
                    {
                        // Check group
                        var group = SourceGroup as CableGroup;
                        if (group == null)
                        {
                            initializer = null;
                        }
                        else
                        {
                            initializer = clone =>
                            {
                                // Change type
                                var dvbc = (IDVBCLocator)clone;

                                // Configure
                                dvbc.SymbolRate       = checked ((int)(group.SymbolRate / 1000));
                                dvbc.CarrierFrequency = checked ((int)group.Frequency);
                                dvbc.InnerFECRate     = BinaryConvolutionCodeRate.NotSet;
                                dvbc.OuterFECRate     = BinaryConvolutionCodeRate.NotSet;
                                dvbc.Modulation       = ModulationType.NotSet;
                                dvbc.InnerFEC         = FECMethod.NotSet;
                                dvbc.OuterFEC         = FECMethod.NotSet;

                                // Check modulation
                                switch (group.Modulation)
                                {
                                case CableModulations.QAM16: dvbc.Modulation = ModulationType.QAM16; break;

                                case CableModulations.QAM32: dvbc.Modulation = ModulationType.QAM32; break;

                                case CableModulations.QAM64: dvbc.Modulation = ModulationType.QAM64; break;

                                case CableModulations.QAM128: dvbc.Modulation = ModulationType.QAM128; break;

                                case CableModulations.QAM256: dvbc.Modulation = ModulationType.QAM256; break;
                                }

                                // See if tuner is available
                                var tuner = Pipeline.Graph.TunerFilter;
                                if (tuner != null)
                                {
                                    // Attach to the demodulator interface
                                    var demodulator = tuner.GetDigitalDemodulator();
                                    if (demodulator != null)
                                    {
                                        try
                                        {
                                            // Strange API needs helpers - sets values using pointers
                                            var inversion = SpectralInversion.NotSet;

                                            // Check spectral inversion
                                            switch (group.SpectrumInversion)
                                            {
                                            case SpectrumInversions.Auto: inversion = SpectralInversion.Automatic; break;

                                            case SpectrumInversions.Off: inversion = SpectralInversion.Normal; break;

                                            case SpectrumInversions.On: inversion = SpectralInversion.Inverted; break;
                                            }

                                            // Set inversion
                                            demodulator.SetSpectralInversion(ref inversion);
                                        }
                                        finally
                                        {
                                            // Cleanup
                                            BDAEnvironment.Release(ref demodulator);
                                        }
                                    }
                                }
                            }
                        };

                        // Remember - acutally test the type
                        tuningSpace.DefaultLocator = (ILocator)locator;
                    }
                    finally
                    {
                        // Cleanup
                        BDAEnvironment.Release(ref locator);
                    }

                    // Report
                    return(tuningSpace);
                }
                catch
                {
                    // Cleanup
                    BDAEnvironment.Release(ref space);

                    // Forward
                    throw;
                }
            }
Example #12
0
        /// <summary>
        /// Erzeugt einen Graphen und startet ihn.
        /// </summary>
        /// <param name="location">Der Ursprung, über den die Quellgruppe empfangen wird.</param>
        /// <param name="group">Die gewünschte Quellgruppe.</param>
        /// <exception cref="ArgumentException">Es wurden nicht alle Parameter gesetzt.</exception>
        public void Create(GroupLocation location, SourceGroup group)
        {
            // Get rid of it
            Destroy();

            // Create new graph builder
            var graph = Activator.CreateInstance(Type.GetTypeFromCLSID(BDAEnvironment.GraphBuilderClassIdentifier));

            try
            {
                // Convert interface
                m_Graph = (IMediaFilter)graph;
            }
            catch
            {
                // Cleanup
                BDAEnvironment.Release(ref graph);

                // Forward
                throw;
            }

            // See if we should register the graph
            m_ExternalRegistration = BDASettings.RegisterBDAGRaph(m_Graph, false);

            // Attach to alternate interface
            var builder = (IGraphBuilder)m_Graph;

            // Check log
            var logFile = BDASettings.BDALogPath;

            if (logFile != null)
            {
                // Open path
                m_LogFile = new FileStream(logFile.FullName, FileMode.Create, FileAccess.Write, FileShare.Read);

                // Enable logging on graph builder
                builder.SetLogFile(m_LogFile.SafeFileHandle);
            }

            // Start with network provider
            NetworkProvider = AddFilter("Network Provider", BDAEnvironment.GetNetworkProviderMoniker(DVBType));

            // Initialize provider
            Tune(location, group);

            // Always create the tuner
            if (TunerInformation != null)
            {
                TunerFilter = AddFilter("Tuner", TunerInformation);
            }
            else
            {
                throw new ArgumentException(Properties.Resources.Exception_MissingTuner, "Tuner");
            }

            // Optionally create capture
            if (CaptureInformation != null)
            {
                CaptureFilter = AddFilter("Capture", CaptureInformation);
            }

            // Add additional filter
            foreach (var additionalFilter in AdditionalFilterInformations)
            {
                if (additionalFilter == null)
                {
                    throw new ArgumentNullException("AdditionalFilters");
                }
                else
                {
                    AdditionalFilters.Add(AddFilter(additionalFilter.DisplayName, additionalFilter));
                }
            }

            // Connect network provider to streaming instance
            Connect(NetworkProvider, CaptureFilter ?? TunerFilter);

            // Initialize provider
            Tune(location, group);

            // Create the primary filter and add it
            AddFilter("TS", TransportStreamAnalyser = new InputFilter());

            // Connect device output for analysis
            Connect(CaptureFilter ?? TunerFilter, TransportStreamAnalyser);

            // Create the demultiplexer - needed to keep the infrastructure alive
            using (var demux = AddFilter("TIF", BDAEnvironment.MicrosoftDemultiplexerMoniker))
            {
                // Connect to the dedicated pin of our analyser
                TransportStreamAnalyser.DataManager.TIFConnector.Connect(demux, BDAEnvironment.TransportStreamMediaType1);

                // Pins to remove
                var remove = new List <string>();

                // Prepare the demultiplexer pins
                demux.InspectAllPins(pin =>
                {
                    // See if this is the SI pin
                    bool isSectionPin = false;
                    pin.InspectAllMediaTypes(type =>
                    {
                        // Check major
                        if (!type.MajorType.Equals(BDAEnvironment.DataFormatTypeSections))
                        {
                            return(true);
                        }

                        // Check minor
                        isSectionPin = type.SubType.Equals(BDAEnvironment.DataFormatSubtypeSI);

                        // Report
                        return(!isSectionPin);
                    });

                    // Check the mode
                    if (isSectionPin)
                    {
                        // Connect
                        using (var comPin = ComIdentity.Create(pin))
                            builder.Render(comPin.Interface);

                        // Load connection data
                        IntPtr tifIn = IntPtr.Zero;
                        if (pin.ConnectedTo(ref tifIn) < 0)
                        {
                            throw new InvalidOperationException(Properties.Resources.Exception_TIF);
                        }

                        // Reconstruct
                        var tifPin = Marshal.GetObjectForIUnknown(tifIn);
                        try
                        {
                            // Request pin context
                            var info = new PinInfo();
                            ((IPin)tifPin).QueryPinInfo(ref info);

                            // Request from pin
                            m_TIF = info.GetAndDisposeFilter();
                        }
                        finally
                        {
                            // Cleanup
                            BDAEnvironment.Release(ref tifPin);
                        }
                    }
                    else if (pin.QueryDirection() == PinDirection.Output)
                    {
                        // Prepare to kill
                        remove.Add(pin.QueryId());
                    }
                });

                // Prepare to remove all unconnected pins
                if (remove.Count > 0)
                {
                    using (var demuxInstance = demux.MarshalToManaged())
                    {
                        // Change type
                        var mpeg2 = (IMpeg2Demultiplexer)demuxInstance.Object;

                        // Remove all
                        foreach (var id in remove)
                        {
                            mpeg2.DeleteOutputPin(id);
                        }
                    }
                }
            }

            // Install the PMT watchdog
            TransportStreamAnalyser.DataManager.TSParser.PMTFound += ProcessPMT;
        }
Example #13
0
        /// <summary>
        /// Wählt eine neue Quellgruppe aus.
        /// </summary>
        /// <param name="location">Der Ursprung, über den die Quellgruppe empfangen wird.</param>
        /// <param name="group">Die gewünschte Quellgruppe.</param>
        /// <exception cref="NotSupportedException">Der Graph wurde noch nicht erzeugt.</exception>
        public void Tune(GroupLocation location, SourceGroup group)
        {
            // Validate
            if (NetworkProvider == null)
            {
                throw new NotSupportedException(Properties.Resources.Exception_NotStarted);
            }

            // PAT wait configuration - will use 1/10sec per retry
            var patRetries   = Configuration.MinimumPATCountWaitTime;
            var patsExpected = Configuration.MinimumPATCount;

            // Attach to helper
            var analyser = TransportStreamAnalyser;
            var manager  = (analyser == null) ? null : analyser.DataManager;
            var parser   = (manager == null) ? null : manager.TSParser;

            // May want to retry at least four times
            for (var outerRetry = 4; outerRetry-- > 0; patsExpected += 5, patRetries += 25)
            {
                // Always stop raw dump
                if (manager != null)
                {
                    manager.StopDump();
                }

                // Report
                if (BDASettings.BDATraceSwitch.Enabled)
                {
                    Trace.WriteLine(string.Format(Properties.Resources.Trace_TuneStart, location, group), BDASettings.BDATraceSwitch.DisplayName);
                }

                // Route request through the current pipeline
                using (var tune = TuneToken.Create(TunePipeline, location, group))
                    tune.Execute();

                // Not yet up
                if (analyser == null)
                {
                    return;
                }

                // Attach to statistics interface
                var statistics = TunerFilter.GetSignalStatistics();
                if (statistics != null)
                {
                    try
                    {
                        // Set counter
                        var tuneRetry = 10;

                        // Wait
                        for (; tuneRetry-- > 0; Thread.Sleep(100))
                        {
                            // Load the signal information
                            var locked = statistics.SignalLocked;
                            if (locked != 0)
                            {
                                break;
                            }
                        }

                        // Report
                        if (BDASettings.BDATraceSwitch.Enabled)
                        {
                            Trace.WriteLine(string.Format(Properties.Resources.Trace_Lock, 10 - tuneRetry, tuneRetry, BDASettings.FastTune), BDASettings.BDATraceSwitch.DisplayName);
                        }

                        // Final check
                        if (BDASettings.FastTune)
                        {
                            if (statistics.SignalLocked == 0)
                            {
                                return;
                            }
                        }
                    }
                    catch
                    {
                        // Just ignore any error
                    }
                    finally
                    {
                        // Back to COM
                        BDAEnvironment.Release(ref statistics);
                    }
                }

                // Check for dump
                StartDump();

                // Reset PAT detection
                parser.RestartPATCounter();

                // Request the number of bytes currently processed
                var bytes = parser.BytesReceived;
                var limit = patsExpected;
                var retry = patRetries;

                // Wait a bit
                for (; (parser.ValidPATCount < limit) && (retry-- > 0);)
                {
                    Thread.Sleep(100);
                }

                // Report
                if (BDASettings.BDATraceSwitch.Enabled)
                {
                    Trace.WriteLine(string.Format(Properties.Resources.Trace_StreamOk, patRetries - retry, retry, parser.ValidPATCount, parser.BytesReceived - bytes), BDASettings.BDATraceSwitch.DisplayName);
                }

                // Disable retry if PATs are received
                if (parser.ValidPATCount >= limit)
                {
                    break;
                }

                // Disable retry if no data is on the transponder
                if (bytes == parser.BytesReceived)
                {
                    if (outerRetry != 3)
                    {
                        break;
                    }
                }

                // Report for debugging purposes
                if (BDASettings.BDATraceSwitch.Enabled)
                {
                    Trace.WriteLine(Properties.Resources.Trace_TuneFailed, BDASettings.BDATraceSwitch.DisplayName);
                }

                // Inform all helpers on reset
                SendEmptyTuneRequest(DisableCIResetOnTuneFailure);
            }
        }
 /// <summary>
 /// Beendet die Nutzung dieser Instanz endgültig.
 /// </summary>
 public void Dispose() => BDAEnvironment.Release(ref m_Request);
Example #15
0
 /// <summary>
 /// Beendet die Nutzung dieser Instanz endgültig.
 /// </summary>
 public void Dispose()
 {
     // Cleanup
     BDAEnvironment.Release(ref m_Object);
 }
Example #16
0
 /// <summary>
 /// Beendet die Nutzung dieser Instanz endgültig.
 /// </summary>
 public override void Dispose()
 {
     // Check interface
     BDAEnvironment.Release(ref m_Interface);
 }