示例#1
0
        private void Config()
        {
            int hr = 0;
            ITuningSpaceContainer tsCont = (ITuningSpaceContainer) new SystemTuningSpaces();

            hr = tsCont.get_EnumTuningSpaces(out enumTS);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(tsCont);
        }
示例#2
0
        private void Config()
        {
            int hr = 0;

            ITuningSpaceContainer tsContainer = (ITuningSpaceContainer) new SystemTuningSpaces();

            hr = tsContainer.get_Item(3, out tuningSpace);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(tsContainer);
        }
示例#3
0
        private void Config()
        {
            int hr = 0;
            ITuningSpaceContainer tsContainer = (ITuningSpaceContainer) new SystemTuningSpaces();
            ITuningSpace          ts          = null;

            // The third System TuningSpace is an ATSC one...
            // see HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Tuning Spaces\3
            hr = tsContainer.get_Item(3, out ts);
            DsError.ThrowExceptionForHR(hr);

            tuningSpace = (IATSCTuningSpace)ts;

            Marshal.ReleaseComObject(tsContainer);
        }
示例#4
0
        /// <summary>
        /// Finds the ATSC Tuning space in the System Tuning Spaces and returns it
        /// </summary>
        /// <returns>an ITuningSpace, which is the System Tuning Spaces</returns>
        private ITuningSpace GetTuningSpace()
        {
            ITuningSpaceContainer system = (ITuningSpaceContainer) new SystemTuningSpaces();

            try
            {
                IEnumTuningSpaces systemEnum;
                int hr = system.get_EnumTuningSpaces(out systemEnum);
                DsError.ThrowExceptionForHR(hr);

                IntPtr retreivedSpaceCount = Marshal.AllocCoTaskMem(4);
                try
                {
                    ITuningSpace[] retreivedSpaces = new ITuningSpace[1];
                    do
                    {
                        hr = systemEnum.Next(1, retreivedSpaces, retreivedSpaceCount);
                        DsError.ThrowExceptionForHR(hr);

                        if (Marshal.ReadInt32(retreivedSpaceCount) > 0)
                        {
                            Guid networkType;
                            hr = retreivedSpaces[0].get__NetworkType(out networkType);
                            DsError.ThrowExceptionForHR(hr);
                            if (networkType.Equals(CLSID_ATSCNetworkProvider))
                            {
                                return(retreivedSpaces[0]);
                            }
                        }
                    } while (Marshal.ReadInt32(retreivedSpaceCount) > 0);
                }
                finally
                {
                    Marshal.FreeCoTaskMem(retreivedSpaceCount);
                }

                throw new Exception("Could not locate ATSC Tuning Space!");
            }
            finally
            {
                Marshal.ReleaseComObject(system);
            }
        }
        public void DoTests()
        {
            try
            {
                tsContainer = (ITuningSpaceContainer) new SystemTuningSpaces();

                TestCount();
                TestFindID();
                TestMaxCount();
                TestTuningSpacesForCLSID();
                TestTuningSpacesForName();
                TestEnums();
                TestItem();
                TestAddRemove();
            }
            finally
            {
                Marshal.ReleaseComObject(tsContainer);
            }
        }
示例#6
0
文件: ATSCTuner.cs 项目: ewin66/media
        protected override ITuningSpace GetTuningSpace()
        {
            ITuningSpaceContainer system = (ITuningSpaceContainer) new SystemTuningSpaces();

            IntPtr retreivedSpaceCount = Marshal.AllocCoTaskMem(4);

            try
            {
                IEnumTuningSpaces systemEnum;
                int hr = system.get_EnumTuningSpaces(out systemEnum);
                DsError.ThrowExceptionForHR(hr);

                ITuningSpace[] retreivedSpaces = new ITuningSpace[1];
                do
                {
                    hr = systemEnum.Next(1, retreivedSpaces, retreivedSpaceCount);
                    DsError.ThrowExceptionForHR(hr);

                    if (Marshal.ReadInt32(retreivedSpaceCount) > 0)
                    {
                        Guid networkType;
                        hr = retreivedSpaces[0].get__NetworkType(out networkType);
                        //string name;
                        //retreivedSpaces[0].get_FriendlyName(out name);
                        //Debug.WriteLine("  found \"" + name + "\", network type: " + networkType.ToString());
                        DsError.ThrowExceptionForHR(hr);
                        if (networkType.Equals(CLSID_ATSCNetworkProvider))
                        {
                            return(retreivedSpaces[0]);
                        }
                    }
                } while (Marshal.ReadInt32(retreivedSpaceCount) > 0);

                throw new Exception("Could not locate ATSC Tuning Space!");
            }
            finally
            {
                ReleaseComObject(system);
                Marshal.FreeCoTaskMem(retreivedSpaceCount);
            }
        }
        public void DoTests()
        {
            int hr = 0;

            try
            {
                Guid searchClsid = typeof(ATSCTuningSpace).GUID;
                tsContainer = (ITuningSpaceContainer) new SystemTuningSpaces();

                hr = tsContainer._TuningSpacesForCLSID(searchClsid, out tuningSpaces);
                DsError.ThrowExceptionForHR(hr);

                Testget__NewEnum();
                Testget_Count();
                Testget_EnumTuningSpaces();
                Testget_Item();
            }
            finally
            {
                Marshal.ReleaseComObject(tsContainer);
                Marshal.ReleaseComObject(tuningSpaces);
            }
        }
示例#8
0
        /// <summary>
        /// Creates the tuning space.
        /// </summary>
        protected void CreateTuningSpace()
        {
            Log.Log.WriteFile("dvbt:CreateTuningSpace()");
            ITuner                tuner = (ITuner)_filterNetworkProvider;
            SystemTuningSpaces    systemTuningSpaces = new SystemTuningSpaces();
            ITuningSpaceContainer container          = systemTuningSpaces as ITuningSpaceContainer;

            if (container == null)
            {
                Log.Log.Error("CreateTuningSpace() Failed to get ITuningSpaceContainer");
                return;
            }
            IEnumTuningSpaces enumTuning;

            ITuningSpace[] spaces = new ITuningSpace[2];
            ITuneRequest   request;

            container.get_EnumTuningSpaces(out enumTuning);
            while (true)
            {
                int fetched;
                enumTuning.Next(1, spaces, out fetched);
                if (fetched != 1)
                {
                    break;
                }
                string name;
                spaces[0].get_UniqueName(out name);
                if (name == "MediaPortal DVBT TuningSpace")
                {
                    Log.Log.WriteFile("dvbt:found correct tuningspace {0}", name);
                    _tuningSpace = (IDVBTuningSpace)spaces[0];
                    tuner.put_TuningSpace(_tuningSpace);
                    _tuningSpace.CreateTuneRequest(out request);
                    _tuneRequest = (IDVBTuneRequest)request;
                    return;
                }
                Release.ComObject("ITuningSpace", spaces[0]);
            }
            Release.ComObject("IEnumTuningSpaces", enumTuning);
            Log.Log.WriteFile("dvbt:Create new tuningspace");
            _tuningSpace = (IDVBTuningSpace) new DVBTuningSpace();
            IDVBTuningSpace tuningSpace = (IDVBTuningSpace)_tuningSpace;

            tuningSpace.put_UniqueName("MediaPortal DVBT TuningSpace");
            tuningSpace.put_FriendlyName("MediaPortal DVBT TuningSpace");
            tuningSpace.put__NetworkType(typeof(DVBTNetworkProvider).GUID);
            tuningSpace.put_SystemType(DVBSystemType.Terrestrial);

            IDVBTLocator locator = (IDVBTLocator) new DVBTLocator();

            locator.put_CarrierFrequency(-1);
            locator.put_InnerFEC(FECMethod.MethodNotSet);
            locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_Modulation(ModulationType.ModNotSet);
            locator.put_OuterFEC(FECMethod.MethodNotSet);
            locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_SymbolRate(-1);
            object newIndex;

            _tuningSpace.put_DefaultLocator(locator);
            container.Add(_tuningSpace, out newIndex);
            tuner.put_TuningSpace(_tuningSpace);
            Release.ComObject("ITuningSpaceContainer", container);
            _tuningSpace.CreateTuneRequest(out request);
            _tuneRequest = request;
        }
示例#9
0
        /// <summary>
        /// Creates the tuning space.
        /// </summary>
        protected void CreateTuningSpace()
        {
            Log.Log.WriteFile("atsc:CreateTuningSpace()");
            ITuner                tuner = (ITuner)_filterNetworkProvider;
            SystemTuningSpaces    systemTuningSpaces = new SystemTuningSpaces();
            ITuningSpaceContainer container          = systemTuningSpaces as ITuningSpaceContainer;

            if (container == null)
            {
                Log.Log.Error("CreateTuningSpace() Failed to get ITuningSpaceContainer");
                return;
            }
            IEnumTuningSpaces enumTuning;

            ITuningSpace[] spaces = new ITuningSpace[2];
            ITuneRequest   request;

            container.get_EnumTuningSpaces(out enumTuning);
            while (true)
            {
                int fetched;
                enumTuning.Next(1, spaces, out fetched);
                if (fetched != 1)
                {
                    break;
                }
                string name;
                spaces[0].get_UniqueName(out name);
                if (name == "MediaPortal ATSC TuningSpace")
                {
                    Log.Log.WriteFile("atsc:found correct tuningspace {0}", name);
                    _tuningSpace = (IATSCTuningSpace)spaces[0];
                    tuner.put_TuningSpace(_tuningSpace);
                    _tuningSpace.CreateTuneRequest(out request);
                    _tuneRequest = (IATSCChannelTuneRequest)request;
                    return;
                }
                Release.ComObject("ITuningSpace", spaces[0]);
            }
            Release.ComObject("IEnumTuningSpaces", enumTuning);
            Log.Log.WriteFile("atsc:Create new tuningspace");
            _tuningSpace = (IATSCTuningSpace) new ATSCTuningSpace();
            IATSCTuningSpace tuningSpace = (IATSCTuningSpace)_tuningSpace;

            tuningSpace.put_UniqueName("MediaPortal ATSC TuningSpace");
            tuningSpace.put_FriendlyName("MediaPortal ATSC TuningSpace");
            tuningSpace.put__NetworkType(typeof(ATSCNetworkProvider).GUID);
            tuningSpace.put_CountryCode(0);
            tuningSpace.put_InputType(TunerInputType.Antenna);
            tuningSpace.put_MaxMinorChannel(999);    //minor channels per major
            tuningSpace.put_MaxPhysicalChannel(158); //69 for OTA 158 for QAM
            tuningSpace.put_MaxChannel(99);          //major channels
            tuningSpace.put_MinMinorChannel(0);
            tuningSpace.put_MinPhysicalChannel(1);   //OTA 1, QAM 2
            tuningSpace.put_MinChannel(1);

            IATSCLocator locator = (IATSCLocator) new ATSCLocator();

            locator.put_CarrierFrequency(-1);
            locator.put_InnerFEC(FECMethod.MethodNotSet);
            locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_Modulation(ModulationType.Mod8Vsb); //OTA modultation, QAM = .Mod256Qam
            locator.put_OuterFEC(FECMethod.MethodNotSet);
            locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_PhysicalChannel(-1);
            locator.put_SymbolRate(-1);
            locator.put_TSID(-1);
            object newIndex;

            _tuningSpace.put_DefaultLocator(locator);
            container.Add(_tuningSpace, out newIndex);
            tuner.put_TuningSpace(_tuningSpace);
            Release.ComObject("TuningSpaceContainer", container);
            _tuningSpace.CreateTuneRequest(out request);
            _tuneRequest = (IATSCChannelTuneRequest)request;
        }
示例#10
0
        /// <summary>
        /// Creates the tuning space.
        /// </summary>
        protected void CreateTuningSpace()
        {
            Log.Log.WriteFile("dvbs:CreateTuningSpace()");
            ITuner                tuner = (ITuner)_filterNetworkProvider;
            SystemTuningSpaces    systemTuningSpaces = new SystemTuningSpaces();
            ITuningSpaceContainer container          = systemTuningSpaces as ITuningSpaceContainer;

            if (container == null)
            {
                Log.Log.Error("CreateTuningSpace() Failed to get ITuningSpaceContainer");
                return;
            }
            IEnumTuningSpaces enumTuning;

            ITuningSpace[] spaces = new ITuningSpace[2];
            int            lowOsc;
            int            hiOsc;
            int            lnbSwitch;

            if (_parameters.UseDefaultLnbFrequencies)
            {
                lowOsc    = 9750;
                hiOsc     = 10600;
                lnbSwitch = 11700;
            }
            else
            {
                lowOsc    = _parameters.LnbLowFrequency;
                hiOsc     = _parameters.LnbHighFrequency;
                lnbSwitch = _parameters.LnbSwitchFrequency;
            }
            ITuneRequest request;

            container.get_EnumTuningSpaces(out enumTuning);
            IDVBSTuningSpace tuningSpace;

            while (true)
            {
                int fetched;
                enumTuning.Next(1, spaces, out fetched);
                if (fetched != 1)
                {
                    break;
                }
                string name;
                spaces[0].get_UniqueName(out name);
                if (name == "MediaPortal DVBS TuningSpace")
                {
                    Log.Log.WriteFile("dvbs:found correct tuningspace {0}", name);

                    _tuningSpace = (IDVBSTuningSpace)spaces[0];
                    tuningSpace  = (IDVBSTuningSpace)_tuningSpace;
                    tuningSpace.put_LNBSwitch(lnbSwitch * 1000);
                    tuningSpace.put_SpectralInversion(SpectralInversion.Automatic);
                    tuningSpace.put_LowOscillator(lowOsc * 1000);
                    tuningSpace.put_HighOscillator(hiOsc * 1000);
                    tuner.put_TuningSpace(tuningSpace);
                    tuningSpace.CreateTuneRequest(out request);
                    _tuneRequest = (IDVBTuneRequest)request;
                    return;
                }
                Release.ComObject("ITuningSpace", spaces[0]);
            }
            Release.ComObject("IEnumTuningSpaces", enumTuning);
            Log.Log.WriteFile("dvbs:Create new tuningspace");
            _tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace();
            tuningSpace  = (IDVBSTuningSpace)_tuningSpace;
            tuningSpace.put_UniqueName("MediaPortal DVBS TuningSpace");
            tuningSpace.put_FriendlyName("MediaPortal DVBS TuningSpace");
            tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID);
            tuningSpace.put_SystemType(DVBSystemType.Satellite);
            tuningSpace.put_LNBSwitch(lnbSwitch * 1000);
            tuningSpace.put_LowOscillator(lowOsc * 1000);
            tuningSpace.put_HighOscillator(hiOsc * 1000);
            IDVBSLocator locator = (IDVBSLocator) new DVBSLocator();

            locator.put_CarrierFrequency(-1);
            locator.put_InnerFEC(FECMethod.MethodNotSet);
            locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_Modulation(ModulationType.ModNotSet);
            locator.put_OuterFEC(FECMethod.MethodNotSet);
            locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_SymbolRate(-1);
            object newIndex;

            _tuningSpace.put_DefaultLocator(locator);
            container.Add(_tuningSpace, out newIndex);
            tuner.put_TuningSpace(_tuningSpace);
            Release.ComObject("TuningSpaceContainer", container);
            _tuningSpace.CreateTuneRequest(out request);
            _tuneRequest = (IDVBTuneRequest)request;
        }