コード例 #1
0
ファイル: KNCAPI.cs プロジェクト: thomasr3/MediaPortal-1
        /// <summary>
        /// Sends the DiSEqC command.
        /// </summary>
        /// <param name="ulRange">The DisEqCPort</param>
        /// <returns>true if succeeded, otherwise false</returns>
        protected bool SendDiSEqCCommand(ulong ulRange)
        {
            Log.Log.Info("KNC:  SendDiSEqC Command {0}", ulRange);
            // get ControlNode of tuner control node
            object ControlNode;
            int    hr = ((IBDA_Topology)m_tunerFilter).GetControlNode(0, 1, 0, out ControlNode);

            if (hr == 0)
            // retrieve the BDA_DeviceControl interface
            {
                IBDA_DeviceControl DecviceControl = (IBDA_DeviceControl)m_tunerFilter;
                if (DecviceControl != null)
                {
                    if (ControlNode != null)
                    {
                        IBDA_FrequencyFilter FrequencyFilter = ControlNode as IBDA_FrequencyFilter;
                        hr = DecviceControl.StartChanges();
                        if (hr == 0)
                        {
                            if (FrequencyFilter != null)
                            {
                                hr = FrequencyFilter.put_Range(ulRange);
                                Log.Log.Info("KNC:  put_Range:{0} success:{1}", ulRange, hr);
                                if (hr == 0)
                                {
                                    // did it accept the changes?
                                    hr = DecviceControl.CheckChanges();
                                    if (hr == 0)
                                    {
                                        hr = DecviceControl.CommitChanges();
                                        if (hr == 0)
                                        {
                                            Log.Log.Info("KNC:  CommitChanges() Succeeded");
                                            return(true);
                                        }
                                        // reset configuration
                                        Log.Log.Info("KNC:  CommitChanges() Failed!");
                                        DecviceControl.StartChanges();
                                        DecviceControl.CommitChanges();
                                        return(false);
                                    }
                                    Log.Log.Info("KNC:  CheckChanges() Failed!");
                                    return(false);
                                }
                                Log.Log.Info("KNC:  put_Range Failed!");
                                return(false);
                            }
                        }
                    }
                }
            }
            Log.Log.Info("KNC:  GetControlNode Failed!");
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// gets the diseqc reply
        /// </summary>
        /// <param name="pulRange">The DisEqCPort Port.</param>
        /// <returns>true if succeeded, otherwise false</returns>
        protected bool ReadDiSEqCCommand(out ulong pulRange)
        {
            // get ControlNode of tuner control node
            object ControlNode;
            int    hr = _TunerDevice.GetControlNode(0, 1, 0, out ControlNode);

            if (hr == 0)
            // retrieve the BDA_DeviceControl interface
            {
                IBDA_DeviceControl DecviceControl = (IBDA_DeviceControl)_TunerDevice;
                if (DecviceControl != null)
                {
                    if (ControlNode != null)
                    {
                        IBDA_FrequencyFilter FrequencyFilter = ControlNode as IBDA_FrequencyFilter;
                        hr = DecviceControl.StartChanges();
                        if (hr == 0)
                        {
                            if (FrequencyFilter != null)
                            {
                                hr = FrequencyFilter.get_Range(out pulRange);
                                Log.Log.Info(FormatMessage("  get_Range:{0} success:{1}"), pulRange, hr);
                                if (hr == 0)
                                {
                                    return(true);
                                }
                                Log.Log.Info(FormatMessage("  get_Range Failed!"));
                                return(false);
                            }
                        }
                    }
                }
            }
            Log.Log.Info(FormatMessage("  GetControlNode Failed!"));
            pulRange = 0;
            return(false);
        }
コード例 #3
0
        private bool sendRangeCommand(int range)
        {
            object controlNode;

            reply = ((IBDA_Topology)tunerFilter).GetControlNode(0, 1, 0, out controlNode);
            if (reply == 0)
            {
                IBDA_DeviceControl deviceControl = (IBDA_DeviceControl)tunerFilter;
                if (deviceControl != null)
                {
                    if (controlNode != null)
                    {
                        IBDA_FrequencyFilter frequencyFilter = controlNode as IBDA_FrequencyFilter;
                        reply = deviceControl.StartChanges();
                        if (reply == 0)
                        {
                            if (frequencyFilter != null)
                            {
                                Logger.Instance.Write("Generic DiSEqC Handler: Setting range: 0x" + range.ToString("X"));
                                reply = frequencyFilter.put_Range(range);
                                if (reply == 0)
                                {
                                    reply = deviceControl.CheckChanges();
                                    if (reply == 0)
                                    {
                                        reply = deviceControl.CommitChanges();
                                        if (reply == 0)
                                        {
                                            return(true);
                                        }

                                        Logger.Instance.Write("Generic DiSEqC Handler: Commit Changes failed with reply 0x" + reply.ToString("X"));

                                        deviceControl.StartChanges();
                                        deviceControl.CommitChanges();

                                        return(false);
                                    }
                                    else
                                    {
                                        Logger.Instance.Write("Generic DiSEqC Handler: Check Changes failed with reply 0x" + reply.ToString("X"));
                                        return(false);
                                    }
                                }
                                else
                                {
                                    Logger.Instance.Write("Generic DiSEqC Handler: Set Range failed with reply 0x" + reply.ToString("X"));
                                    return(false);
                                }
                            }
                            else
                            {
                                Logger.Instance.Write("Generic DiSEqC Handler: failed to get frequency filter interface");
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Generic DiSEqC Handler: Start Changes failed with reply 0x" + reply.ToString("X"));
                        }
                    }
                    else
                    {
                        Logger.Instance.Write("Generic DiSEqC Handler: failed to get control node");
                    }
                }
                else
                {
                    Logger.Instance.Write("Generic DiSEqC Handler: failed to get device control interface");
                }
            }
            else
            {
                Logger.Instance.Write("Generic DiSEqC Handler: failed to get control node");
            }

            return(false);
        }
コード例 #4
0
        private void BuildGraph()
        {
            int hr = 0;

            graphBuilder = (IFilterGraph2) new FilterGraph();
            rot          = new DsROTEntry(graphBuilder);

            ICaptureGraphBuilder2 capBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            capBuilder.SetFiltergraph(graphBuilder);

            // Get the BDA network provider specific for this given network type
            networkProvider = BDAUtils.GetNetworkProvider(networkType);

            hr = graphBuilder.AddFilter(networkProvider, "BDA Network Provider");
            DsError.ThrowExceptionForHR(hr);

            tuner = (ITuner)networkProvider;

            // Get a tuning space for this network type
            tuningSpace = BDAUtils.GetTuningSpace(networkType);

            hr = tuner.put_TuningSpace(tuningSpace);
            DsError.ThrowExceptionForHR(hr);

            // Create a tune request from this tuning space
            tuneRequest = BDAUtils.CreateTuneRequest(tuningSpace);

            // Is it okay ?
            hr = tuner.Validate(tuneRequest);
            if (hr == 0)
            {
                // Set it
                hr = tuner.put_TuneRequest(tuneRequest);
                DsError.ThrowExceptionForHR(hr);

                // found a BDA Tuner and a BDA Capture that can connect to this network provider
                BDAUtils.AddBDATunerAndDemodulatorToGraph(graphBuilder, networkProvider, out bdaTuner, out bdaCapture);

                if ((bdaTuner != null) && (bdaCapture != null))
                {
                    // Create and add the mpeg2 demux
                    mpeg2Demux = (IBaseFilter) new MPEG2Demultiplexer();

                    hr = graphBuilder.AddFilter(mpeg2Demux, "MPEG2 Demultiplexer");
                    DsError.ThrowExceptionForHR(hr);

                    // connect it to the BDA Capture
                    hr = capBuilder.RenderStream(null, null, bdaCapture, null, mpeg2Demux);
                    DsError.ThrowExceptionForHR(hr);

                    // Add the two mpeg2 transport stream helper filters
                    BDAUtils.AddTransportStreamFiltersToGraph(graphBuilder, out bdaTIF, out bdaSecTab);

                    if ((bdaTIF != null) && (bdaSecTab != null))
                    {
                        // Render all the output pins of the demux (missing filters are added)
                        for (int i = 0; i < 5; i++)
                        {
                            IPin pin = DsFindPin.ByDirection(mpeg2Demux, PinDirection.Output, i);

                            hr = graphBuilder.Render(pin);
                            Marshal.ReleaseComObject(pin);
                        }
                    }

                    IBDA_Topology topo      = (IBDA_Topology)bdaTuner;
                    int[]         nodeTypes = new int[10];
                    int           nodeTypesCount;

                    // Get all nodes in the BDA Tuner
                    hr = topo.GetNodeTypes(out nodeTypesCount, nodeTypes.Length, nodeTypes);
                    DsError.ThrowExceptionForHR(hr);

                    // For each nodes types
                    for (int i = 0; i < nodeTypesCount; i++)
                    {
                        Guid[] nodeGuid = new Guid[10];
                        int    nodeGuidCount;

                        // Get its exposed interfaces
                        hr = topo.GetNodeInterfaces(nodeTypes[i], out nodeGuidCount, nodeGuid.Length, nodeGuid);
                        DsError.ThrowExceptionForHR(hr);

                        // For each exposed interfaces
                        for (int j = 0; j < nodeGuidCount; j++)
                        {
                            Debug.WriteLine(string.Format("node {0}/{1} : {2}", i, j, nodeGuid[j]));
                            Console.WriteLine(string.Format("node {0}/{1} : {2}", i, j, nodeGuid[j]));

                            // Is IBDA_FrequencyFilter supported by this node ?
                            if (nodeGuid[j] == typeof(IBDA_FrequencyFilter).GUID)
                            {
                                // Yes, retrieve this node
                                object ctrlNode;
                                hr = topo.GetControlNode(0, 1, nodeTypes[i], out ctrlNode);
                                DsError.ThrowExceptionForHR(hr);

                                // Do the cast (it should not fail)
                                freqFilter = ctrlNode as IBDA_FrequencyFilter;

                                // Exit the for j loop if found a SignalStatistics object
                                if (freqFilter != null)
                                {
                                    break;
                                }
                            }
                        }

                        // If already found a SignalStatistics object, exit the for i loop
                        if (freqFilter != null)
                        {
                            break;
                        }
                    }
                }
            }
        }