Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericBDAS"/> class.
        /// </summary>
        /// <param name="tunerFilter">The tuner filter.</param>
        public GenericBDAS(IBaseFilter tunerFilter)
        {
            _TunerDevice = (IBDA_Topology)tunerFilter;
            //check if the BDA driver supports DiSEqC
            IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport");

            if (pin != null)
            {
                _propertySet = pin as IKsPropertySet;
                if (_propertySet != null)
                {
                    KSPropertySupport supported;
                    _propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported);
                    if ((supported & KSPropertySupport.Set) != 0)
                    {
                        Log.Log.Debug(FormatMessage("DiSEqC capable card found!"));
                        _isGenericBDAS = true;
                    }
                }
            }
            else
            {
                Log.Log.Info(FormatMessage("tuner pin not found!"));
            }
        }
Exemplo n.º 2
0
        public void DoTests()
        {
            try
            {
                BuildGraph();

                topology = (IBDA_Topology)bdaTuner;

                TestGetPinTypes();
                TestGetNodeTypes();
                TestCreatePin();
                TestCreateTopology();
                TestGetControlNode();
                TestGetNodeInterfaces();
                TestGetTemplateConnections();
                TestGetNodeDescriptors();
                TestSetMediaType();
                TestSetMedium();

                TestDeletePin();
            }
            finally
            {
                Marshal.ReleaseComObject(bdaTuner);
                Marshal.ReleaseComObject(graphBuilder);
            }
        }
Exemplo n.º 3
0
        internal Win7APIDVBS2Handler(IBaseFilter tunerFilter)
        {
            IBDA_Topology topology = tunerFilter as IBDA_Topology;

            if (topology == null)
            {
                return;
            }

            this.tunerFilter = tunerFilter;

            int nodeTypeCount = 0;

            int[] nodeTypes = new int[10];

            int reply = topology.GetNodeTypes(out nodeTypeCount, 10, nodeTypes);

            DsError.ThrowExceptionForHR(reply);

            for (int nodeTypeIndex = 0; nodeTypeIndex < nodeTypeCount; nodeTypeIndex++)
            {
                int    interfaceCount;
                Guid[] interfaces = new Guid[32];
                reply = topology.GetNodeInterfaces(nodeTypes[nodeTypeIndex], out interfaceCount, 32, interfaces);
                DsError.ThrowExceptionForHR(reply);

                for (int searchIndex = 0; searchIndex < interfaceCount; searchIndex++)
                {
                    if (interfaces[searchIndex] == typeof(IBDA_DigitalDemodulator2).GUID)
                    {
                        if (RunParameters.Instance.TraceIDs.Contains("BDA"))
                        {
                            Logger.Instance.Write("BDA DVB-S2 interface located for node type " + nodeTypes[nodeTypeIndex]);
                        }

                        object controlNode;
                        reply = topology.GetControlNode(0, 1, nodeTypes[nodeTypeIndex], out controlNode);
                        DsError.ThrowExceptionForHR(reply);

                        commandInterface = controlNode as IBDA_DigitalDemodulator2;
                        if (commandInterface == null)
                        {
                            if (RunParameters.Instance.TraceIDs.Contains("BDA"))
                            {
                                Logger.Instance.Write("BDA Can't use DVB-S2 interface: cast of control node failed");
                            }
                        }
                        else
                        {
                            if (RunParameters.Instance.TraceIDs.Contains("BDA"))
                            {
                                Logger.Instance.Write("BDA DVB-S2 interface available");
                            }
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected IBDA_DigitalDemodulator FindDemodulator(string identifier, IBaseFilter tunerFilter)
        {
            IBDA_Topology topology = tunerFilter as IBDA_Topology;

            if (topology == null)
            {
                return(null);
            }

            int nodeTypeCount = 0;

            int[] nodeTypes = new int[10];

            int reply = topology.GetNodeTypes(out nodeTypeCount, 10, nodeTypes);

            DsError.ThrowExceptionForHR(reply);

            for (int nodeTypeIndex = 0; nodeTypeIndex < nodeTypeCount; nodeTypeIndex++)
            {
                int    interfaceCount;
                Guid[] interfaces = new Guid[32];
                reply = topology.GetNodeInterfaces(nodeTypes[nodeTypeIndex], out interfaceCount, 32, interfaces);
                DsError.ThrowExceptionForHR(reply);
            }

            for (int nodeTypeIndex = 0; nodeTypeIndex < nodeTypeCount; nodeTypeIndex++)
            {
                int    interfaceCount;
                Guid[] interfaces = new Guid[32];
                reply = topology.GetNodeInterfaces(nodeTypes[nodeTypeIndex], out interfaceCount, 32, interfaces);
                DsError.ThrowExceptionForHR(reply);

                for (int searchIndex = 0; searchIndex < interfaceCount; searchIndex++)
                {
                    if (interfaces[searchIndex] == typeof(IBDA_DigitalDemodulator).GUID)
                    {
                        object controlNode;
                        reply = topology.GetControlNode(0, 1, nodeTypes[nodeTypeIndex], out controlNode);
                        DsError.ThrowExceptionForHR(reply);

                        IBDA_DigitalDemodulator demodulator = controlNode as IBDA_DigitalDemodulator;
                        if (demodulator == null)
                        {
                            Logger.Instance.Write(identifier + " DVB-S2 handler: Can't get demodulator: cast of control node failed");
                        }
                        else
                        {
                            Logger.Instance.Write(identifier + " DVB-S2 handler: Demodulator interface located");
                            return(demodulator);
                        }
                    }
                }
            }

            Logger.Instance.Write(identifier + " DVB-S2 handler: Failed to find demodulator interface");

            return(null);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericBDAS"/> class.
 /// </summary>
 /// <param name="tunerFilter">The tuner filter.</param>
 public GenericBDAS(IBaseFilter tunerFilter)
 {
   _TunerDevice = (IBDA_Topology)tunerFilter;
   //check if the BDA driver supports DiSEqC
   IPin pin = DsFindPin.ByName(tunerFilter, "MPEG2 Transport");
   if (pin != null)
   {
     _propertySet = pin as IKsPropertySet;
     if (_propertySet != null)
     {
       KSPropertySupport supported;
       _propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported);
       if ((supported & KSPropertySupport.Set) != 0)
       {
         Log.Log.Debug(FormatMessage("DiSEqC capable card found!"));
         _isGenericBDAS = true;
       }
     }
   }
   else
     Log.Log.Info(FormatMessage("tuner pin not found!"));
 }
        private void Config()
        {
            int hr = 0;

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

            // Assume that the first device in this category IS a BDA device...
            DsDevice[] devices = DsDevice.GetDevicesOfCat(FilterCategory.BDASourceFiltersCategory);

            hr = graphBuilder.AddSourceFilterForMoniker(devices[0].Mon, null, devices[0].Name, out bdaTuner);
            DsError.ThrowExceptionForHR(hr);

            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_AutoDemodulate supported by this node ?
                    if (nodeGuid[j] == typeof(IBDA_AutoDemodulate).GUID)
                    {
                        Console.WriteLine("nodetype : " + nodeTypes[i]);
                        // 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)
                        autoDemodulate = ctrlNode as IBDA_AutoDemodulate;

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

                // If already found a SignalStatistics object, exit the for i loop
                if (autoDemodulate != null)
                {
                    break;
                }
            }
        }
Exemplo n.º 7
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_LNBInfo supported by this node ?
                            if (nodeGuid[j] == typeof(IBDA_LNBInfo).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)
                                lnbInfo = ctrlNode as IBDA_LNBInfo;

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

                        // If already found a SignalStatistics object, exit the for i loop
                        if (lnbInfo != null)
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void Config()
        {
            int hr = 0;

            graph = new BdaGraph();
            graph.InitializeGraph();
            graph.MakeTuneRequest();
            // graph.RunGraph();

            IBDA_Topology topo = (IBDA_Topology)graph.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_AutoDemodulate supported by this node ?
                    if (nodeGuid[j] == typeof(IBDA_AutoDemodulateEx).GUID)
                    {
                        Console.WriteLine("nodetype : " + nodeTypes[i]);
                        // 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)
                        autoDemodulateEx = ctrlNode as IBDA_AutoDemodulateEx;

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

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

            Debug.Assert(autoDemodulateEx != null, "Can't find a node supporting IBDA_AutoDemodulateEx");
        }