Beispiel #1
0
        /// <summary>
        /// Führt die DiSEqC Steuerung aus.
        /// </summary>
        /// <param name="token">Die aktuellen Informationen zum Wechsel der Quellgruppe.</param>
        /// <returns>Meldet, wie die weitere Abarbeitung zu erfolgen hat.</returns>
        private static PipelineResult ApplyDiSEqC(DataGraph.TuneToken token)
        {
            // Check mode
            var location = (token == null) ? null : token.GroupLocation as SatelliteLocation;

            if (location == null)
            {
                return(PipelineResult.Continue);
            }

            // Load tuner
            var tuner = token.Pipeline.Graph.TunerFilter;

            if (tuner == null)
            {
                return(PipelineResult.Continue);
            }

            // Verify that grpah is created
            if (token.Pipeline.Graph.TransportStreamAnalyser == null)
            {
                return(PipelineResult.Continue);
            }

            // Initial
            uint positionOption;

            switch (location.LNB)
            {
            case DiSEqCLocations.DiSEqC1: positionOption = 0x0000; break;

            case DiSEqCLocations.DiSEqC2: positionOption = 0x0001; break;

            case DiSEqCLocations.DiSEqC3: positionOption = 0x0100; break;

            case DiSEqCLocations.DiSEqC4: positionOption = 0x0101; break;

            default: positionOption = uint.MaxValue; break;
            }

            // Request interface
            var filter = tuner.GetFrequencyFilter();

            if (filter != null)
            {
                // Do it the more or less modern way
                try
                {
                    // Load
                    filter.Range = positionOption;
                }
                finally
                {
                    // Cleanup
                    BDAEnvironment.Release(ref filter);
                }
            }
            else
            {
                // Attach to the tuning space
                var space = token.TuneRequest.TuningSpace;
                try
                {
                    // Store
                    ((IDVBSTuningSpace)space).InputRange = positionOption.ToString();
                }
                finally
                {
                    // Cleanup
                    BDAEnvironment.Release(ref space);
                }
            }

            // Next
            return(PipelineResult.Continue);
        }
        /// <summary>
        /// Führt die DiSEqC Steuerung aus.
        /// </summary>
        /// <param name="token">Die aktuellen Informationen zum Wechsel der Quellgruppe.</param>
        /// <returns>Meldet, wie die weitere Abarbeitung zu erfolgen hat.</returns>
        private PipelineResult ApplyDiSEqC(DataGraph.TuneToken token)
        {
            // Not active
            var diseqc = (token == null) ? null : token.DiSEqCMessage;

            if (diseqc == null)
            {
                // Reset request - or first call at all
                m_LastDiSEqC = null;

                // Next
                return(PipelineResult.Continue);
            }

            // Attach to tuner
            var tuner = token.Pipeline.Graph.TunerFilter;

            if (tuner == null)
            {
                return(PipelineResult.Continue);
            }

            // Verify that grpah is created
            if (token.Pipeline.Graph.TransportStreamAnalyser == null)
            {
                return(PipelineResult.Continue);
            }

            // Request the message to send
            if (diseqc.Equals(m_LastDiSEqC))
            {
                return(PipelineResult.Continue);
            }

            // Attach to the one input pin of the tuner
            using (var input = tuner.GetSinglePin(PinDirection.Input))
                using (var propertySet = KsPropertySet.Create <DiSEqCMessage>(input.Interface))
                    if (propertySet != null)
                    {
                        // Create the identifier of the property to use
                        var nodeReference = KsPNode.Create(TunerExtensionPropertiesS2, TunerExtensionProperties.DiSEqC, 0);

                        // Check for support of the property
                        if (!propertySet.DoesSupport(nodeReference, PropertySetSupportedTypes.Set))
                        {
                            return(PipelineResult.Continue);
                        }

                        // Create structures
                        var message = new DiSEqCMessage();

                        // Create a copy
                        var command = (byte[])diseqc.Request.Clone();

                        // As long as necessary
                        try
                        {
                            // Prepare the message
                            message.Request = new byte[151];

                            // Fill the message
                            command.CopyTo(message.Request, 0);

                            // Configure
                            message.RequestLength = (byte)command.Length;
                            message.LastMessage   = true;
                            message.Power         = 0;

                            // Send the message
                            propertySet.Set(nodeReference, message);
                        }
                        catch
                        {
                            // Reset
                            m_LastDiSEqC = null;

                            // Forward
                            throw;
                        }

                        // Remember
                        m_LastDiSEqC = diseqc.Clone();
                    }

            // Next
            return(PipelineResult.Continue);
        }