예제 #1
0
        public DVBTTuning()
        {
            int hr = 0;

            this.tuningSpace = (IDVBTuningSpace) new DVBTuningSpace();
            hr = this.tuningSpace.put_UniqueName("DVBT TuningSpace");
            hr = this.tuningSpace.put_FriendlyName("DVBT TuningSpace");
            hr = this.tuningSpace.put__NetworkType(typeof(DVBTNetworkProvider).GUID);
            hr = this.tuningSpace.put_SystemType(DVBSystemType.Terrestrial);

            ITuneRequest tr = null;

            hr = this.tuningSpace.CreateTuneRequest(out tr);
            DsError.ThrowExceptionForHR(hr);

            this.tuneRequest = (IDVBTuneRequest)tr;

            hr = this.tuneRequest.put_ONID(-1);
            hr = this.tuneRequest.put_TSID(-1);
            hr = this.tuneRequest.put_SID(-1);

            IDVBTLocator locator = (IDVBTLocator) new DVBTLocator();

            hr = locator.put_CarrierFrequency(754000);
            hr = tr.put_Locator(locator as ILocator);
        }
        private void Config()
        {
            int hr = 0;
            IAnalogTVTuningSpace ts = (IAnalogTVTuningSpace) new AnalogTVTuningSpace();
            ITuneRequest         tr = null;

            hr = ts.put_CountryCode(33);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.put_InputType(TunerInputType.Cable);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.put_MaxChannel(50);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.put_MinChannel(5);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.CreateTuneRequest(out tr);
            DsError.ThrowExceptionForHR(hr);

            channelTR = (IChannelTuneRequest)tr;

            Marshal.ReleaseComObject(ts);
        }
예제 #3
0
        public void SubmitTuneRequest(ITuneRequest tuneRequest)
        {
            int hr = 0;

            hr = (this.networkProvider as ITuner).put_TuneRequest(tuneRequest);
            DsError.ThrowExceptionForHR(hr);
        }
예제 #4
0
        public DVBSTuning()
        {
            InitializeComponent();

            int hr = 0;

            this.tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace();
            hr = this.tuningSpace.put_UniqueName("DVBS TuningSpace");
            hr = this.tuningSpace.put_FriendlyName("DVBS TuningSpace");
            hr = this.tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID);
            hr = this.tuningSpace.put_SystemType(DVBSystemType.Satellite);
            hr = this.tuningSpace.put_LowOscillator(9750000);
            hr = this.tuningSpace.put_HighOscillator(10600000);

            ITuneRequest tr = null;

            hr = this.tuningSpace.CreateTuneRequest(out tr);
            DsError.ThrowExceptionForHR(hr);

            this.tuneRequest = (IDVBTuneRequest)tr;

            hr = this.tuneRequest.put_ONID(-1);
            hr = this.tuneRequest.put_TSID(-1);
            hr = this.tuneRequest.put_SID(-1);

            IDVBSLocator locator = (IDVBSLocator) new DVBSLocator();

            hr = locator.put_CarrierFrequency(-1);
            hr = locator.put_SymbolRate(-1);
            hr = tr.put_Locator(locator as ILocator);
        }
예제 #5
0
        internal static DVBS2HandlerBase GetDVBS2Handler(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest, Tuner tuner)
        {
            DVBS2HandlerBase dvbs2Handler = getDVBS2Handler(tunerFilter, tuner);
            if (dvbs2Handler == null)
            {
                Logger.Instance.Write("No DVB-S2 handler available - parameters not set");
                return (null);
            }

            Logger.Instance.Write("Created " + dvbs2Handler.Description + " DVB-S2 handler");

            return(dvbs2Handler);
        }
예제 #6
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
                return (true);

            IBDA_DigitalDemodulator demodulator = FindDemodulator("Twinhan/TechniSat", tunerFilter);
            if (demodulator == null)
            {
                Logger.Instance.Write("Twinhan/TechniSat DVB-S2 handler: Demodulator not located");
                return (false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (modulationType)
            {
                case ModulationType.ModQpsk:
                    modulationType = ModulationType.Mod8Vsb;
                    break;
                case ModulationType.Mod8Psk:
                    modulationType = ModulationType.Mod8Vsb;
                    break;
                case ModulationType.Mod16Apsk:
                    modulationType = ModulationType.Mod16Vsb;
                    break;
                case ModulationType.Mod32Apsk:
                    modulationType = ModulationType.ModOqpsk;
                    break;
                default:
                    break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("Twinhan/TechniSat DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return (false);
                }
                else
                    Logger.Instance.Write("Twinhan/TechniSat DVB-S2 handler: Modulation type changed to " + modulationType);
            }
            else
                Logger.Instance.Write("Twinhan/TechniSat DVB-S2 handler: Modulation type not changed");

            return (true);
        }
예제 #7
0
        public static ITuneRequest CreateTuneRequest(ITuningSpace ts)
        {
            int          hr = 0;
            ITuneRequest tr = null;
            Guid         networkType;

            hr = ts.CreateTuneRequest(out tr);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.get__NetworkType(out networkType);

            if (networkType == typeof(ATSCNetworkProvider).GUID)
            {
                // I know nothing about ATSC so thoses lines are pure speculation
                hr = (tr as IATSCChannelTuneRequest).put_Channel(-1);

                IATSCLocator locator = (IATSCLocator) new ATSCLocator();
                hr = locator.put_CarrierFrequency(-1);
                hr = tr.put_Locator(locator as ILocator);
            }
            else if (networkType == typeof(DVBTNetworkProvider).GUID)
            {
                hr = (tr as IDVBTuneRequest).put_ONID(-1);
                hr = (tr as IDVBTuneRequest).put_TSID(-1);
                hr = (tr as IDVBTuneRequest).put_SID(-1);

                IDVBTLocator locator = (IDVBTLocator) new DVBTLocator();
                hr = locator.put_CarrierFrequency(-1);
                hr = tr.put_Locator(locator as ILocator);
            }
            else if (networkType == typeof(DVBSNetworkProvider).GUID)
            {
                hr = (tr as IDVBTuneRequest).put_ONID(-1);
                hr = (tr as IDVBTuneRequest).put_TSID(-1);
                hr = (tr as IDVBTuneRequest).put_SID(-1);

                IDVBSLocator locator = (IDVBSLocator) new DVBSLocator();
                hr = locator.put_CarrierFrequency(-1);
                hr = locator.put_SymbolRate(-1);
                hr = tr.put_Locator(locator as ILocator);
            }

            return(tr);
        }
예제 #8
0
        private void Config()
        {
            int hr = 0;
            IATSCTuningSpace ts = (IATSCTuningSpace) new ATSCTuningSpace();
            ITuneRequest     tr = null;

            hr = ts.put_MaxChannel(50);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.put_MinChannel(5);
            DsError.ThrowExceptionForHR(hr);

            hr = ts.CreateTuneRequest(out tr);
            DsError.ThrowExceptionForHR(hr);

            atscChannelTR = (IATSCChannelTuneRequest)tr;

            Marshal.ReleaseComObject(ts);
        }
            /// <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);
                }
            }
예제 #10
0
        internal static DVBS2HandlerBase GetDVBS2Handler(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest, Tuner tuner)
        {
            DVBS2HandlerBase dvbs2Handler = getDVBS2Handler(tunerFilter, tuner);

            if (dvbs2Handler == null)
            {
                Logger.Instance.Write("No DVB-S2 handler available - parameters not set");
                return(null);
            }

            Logger.Instance.Write("Created " + dvbs2Handler.Description + " DVB-S2 handler");

            return(dvbs2Handler);
        }
예제 #11
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
                return (true);

            IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter);
            if (demodulator == null)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located");
                return (false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (tuningSpec.Modulation)
            {
                case Modulation.QPSK:
                    BinaryConvolutionCodeRate codeRate;
                    reply = demodulator.get_InnerFECRate(out codeRate);
                    if (reply != 0)
                    {
                        Logger.Instance.Write("Hauppauge DVB-S2 handler: Get FEC rate failed error code 0x" + reply.ToString("X"));
                        return (false);
                    }

                    if (codeRate == BinaryConvolutionCodeRate.Rate9_10)
                        modulationType = ModulationType.Mod32Qam;
                    else
                    {
                        if (codeRate == BinaryConvolutionCodeRate.Rate8_9)
                            modulationType = ModulationType.Mod16Qam;
                        else
                            modulationType = ModulationType.ModBpsk;
                    }
                    break;
                case Modulation.PSK8:
                    modulationType = ModulationType.ModNbc8Psk;
                    break;
                default:
                    break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return (false);
                }
                else
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type changed to " + modulationType);
            }
            else
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type not changed");

            IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024);
            IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            string setting;

            if (frequency.SymbolRate != 30000)
            {
                Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativePilot(frequency.Pilot));
                setting = frequency.Pilot.ToString();
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Setting pilot to off for symbol rate of 30000");
                Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.Off);
                setting = "Off";
            }
            reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4);
            if (reply != 0)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
                return (false);
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to " + setting);

                Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativeRollOff(frequency.RollOff));
                reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_ROLL_OFF, instanceBuffer, 32, commandBuffer, 4);
                if (reply != 0)
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X"));
                    return (false);
                }
                else
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Rolloff set to " + frequency.RollOff);
            }

            return (true);
        }
예제 #12
0
    /// <summary>
    /// submits a tune request to the card.
    /// throws an TvException if card cannot tune to the channel requested
    /// </summary>
    /// <param name="subChannelId">The sub channel id.</param>
    /// <param name="channel">The channel.</param>
    /// <param name="tuneRequest">tune requests</param>
    /// <param name="performTune">Indicates if a tune is required</param>
    /// <returns></returns>
    protected virtual ITvSubChannel SubmitTuneRequest(int subChannelId, IChannel channel, ITuneRequest tuneRequest,
                                              bool performTune)
    {
      Log.Log.Info("dvb:Submiting tunerequest Channel:{0} subChannel:{1} ", channel.Name, subChannelId);
      bool newSubChannel = false;
      if (_mapSubChannels.ContainsKey(subChannelId) == false)
      {
        Log.Log.Info("dvb:Getting new subchannel");
        newSubChannel = true;
        subChannelId = GetNewSubChannel(channel);
      }
      else
      {
        Log.Log.Info("dvb:using existing subchannel:{0}", subChannelId);
      }
      Log.Log.Info("dvb:Submit tunerequest size:{0} new:{1}", _mapSubChannels.Count, subChannelId);

      _mapSubChannels[subChannelId].CurrentChannel = channel;
      try
      {         
        _mapSubChannels[subChannelId].OnBeforeTune();        
        if (_interfaceEpgGrabber != null)
        {
          _interfaceEpgGrabber.Reset();
        }
        if (performTune)
        {
          if (useInternalNetworkProvider)
          {
            PerformInternalNetworkProviderTuning(channel);
          }
          else
          {
            // HW provider supported tuning methods (i.e. TeVii API)
            if (_conditionalAccess != null &&
                _conditionalAccess.HWProvider != null &&
                _conditionalAccess.HWProvider is ICustomTuning &&
                (_conditionalAccess.HWProvider as ICustomTuning).SupportsTuningForChannel(channel))
            {
              Log.Log.WriteFile("dvb:Custom tune method detected");
              bool res = (_conditionalAccess.HWProvider as ICustomTuning).CustomTune(channel, _parameters);
              Log.Log.WriteFile("dvb:Custom tune method finished with result {0}", res);
              if (!res)
              {
                throw new TvException("Unable to tune to channel");
              }
            }
            else
            {
              Log.Log.WriteFile("dvb:Submit tunerequest calling put_TuneRequest");
              if (_cancelTune)
              {
                throw new TvExceptionTuneCancelled();
              }
              int hr = ((ITuner)_filterNetworkProvider).put_TuneRequest(tuneRequest);
              Log.Log.WriteFile("dvb:Submit tunerequest done calling put_TuneRequest");

              //  NOTE
              //  After mantis 3469 is confirmed working in 1.2.0 beta remove these comments and everything:
              //  ***** FROM HERE *****
              var revert = false;

              try
              {
                var revertFile = new System.IO.FileInfo(@"c:\revertputtunerequest.txt");

                if (revertFile.Exists)
                  revert = true;

                if (revert)
                  Log.Log.WriteFile("dvb:Reverting put_tuneRequest error catch to pre-1.2.0 beta");
              }
              catch (Exception)
              {
                //  Make sure no new errors are introduced
              }

              if ((!revert && hr < 0) || (revert && hr != 0))
              
              //  ***** TO HERE *****
              //  AND uncomment this line:
              //  if(hr < 0)
              {
                Log.Log.WriteFile("dvb:SubmitTuneRequest  returns:0x{0:X} - {1}{2}", hr, HResult.GetDXErrorString(hr),
                                  DsError.GetErrorText(hr));
                throw new TvException("Unable to tune to channel");
              }
            }
          }
        }
        _lastSignalUpdate = DateTime.MinValue;
        _mapSubChannels[subChannelId].OnAfterTune();
      }
      catch (Exception ex)
      {        
        if (newSubChannel)
        {
          Log.Log.WriteFile("dvb:SubmitTuneRequest  failed - removing subchannel: {0}, {1} - {2}", subChannelId, ex.Message, ex.StackTrace);
          if (_mapSubChannels.ContainsKey(subChannelId))
          {
            _mapSubChannels.Remove(subChannelId);
          }
        }
        else
        {
          Log.Log.WriteFile("dvb:SubmitTuneRequest  failed - subchannel: {0}", subChannelId);
        }

        throw;
      }

      return _mapSubChannels[subChannelId];
    }      
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
                return (true);

            IBDA_DigitalDemodulator demodulator = FindDemodulator("DigitalEverywhere", tunerFilter);
            if (demodulator == null)
            {
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Demodulator not located");
                return (false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (tuningSpec.Modulation)
            {
                case Modulation.QPSK:
                    modulationType = ModulationType.ModNbcQpsk;
                    break;
                case Modulation.PSK8:
                    modulationType = ModulationType.ModNbc8Psk;
                    break;
                default:
                    break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return (false);
                }
                else
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type changed to " + modulationType);
            }
            else
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type not changed");

            BinaryConvolutionCodeRate oldCodeRate;
            reply = demodulator.get_InnerFECRate(out oldCodeRate);
            if (reply != 0)
            {
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Get FEC Rate failed error code 0x" + reply.ToString("X"));
                return (false);
            }

            SatelliteFrequency satelliteFrequency = tuningSpec.Frequency as SatelliteFrequency;

            BinaryConvolutionCodeRate newCodeRate = oldCodeRate;

            if (satelliteFrequency.Pilot == DomainObjects.Pilot.Off)
                newCodeRate+= 64;
            else
            {
                if (satelliteFrequency.Pilot == DomainObjects.Pilot.On)
                    newCodeRate+= 128;
            }

            switch (satelliteFrequency.RollOff)
            {
                case DomainObjects.RollOff.RollOff20:
                    newCodeRate += 16;
                    break;
                case DomainObjects.RollOff.RollOff25:
                    newCodeRate += 32;
                    break;
                case DomainObjects.RollOff.RollOff35:
                    newCodeRate += 48;
                    break;
                default:
                    break;
            }

            if (oldCodeRate != newCodeRate)
            {
                reply = demodulator.put_InnerFECRate(newCodeRate);
                if (reply != 0)
                {
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set FEC Rate failed error code 0x" + reply.ToString("X"));
                    return (false);
                }

                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: FEC Rate changed from " + oldCodeRate + " to " + newCodeRate);
            }

            return (true);
        }
예제 #14
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
            {
                return(true);
            }

            IBDA_DigitalDemodulator demodulator = FindDemodulator("GenPix", tunerFilter);

            if (demodulator == null)
            {
                Logger.Instance.Write("GenPix DVB-S2 handler: Demodulator not located");
                return(false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (modulationType)
            {
            case ModulationType.ModQpsk:
                modulationType = ModulationType.Mod8Vsb;
                break;

            case ModulationType.Mod8Psk:
                modulationType = ModulationType.Mod8Vsb;
                break;

            case ModulationType.Mod16Apsk:
                modulationType = ModulationType.Mod16Vsb;
                break;

            case ModulationType.Mod32Apsk:
                modulationType = ModulationType.ModOqpsk;
                break;

            default:
                break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("GenPix DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return(false);
                }
                else
                {
                    Logger.Instance.Write("GenPix DVB-S2 handler: Modulation type changed to " + modulationType);
                }
            }
            else
            {
                Logger.Instance.Write("GenPix DVB-S2 handler: Modulation type not changed");
            }

            return(true);
        }
예제 #15
0
파일: EPG.cs 프로젝트: dgis/CodeTV
        public void UpdateService(ITuneRequest tuneRequest, IGuideData guideData)
        {
            Trace.WriteLineIf(trace.TraceInfo, "EPG.UpdateService(" + tuneRequest.ToString() + ")");
            //if (guideData != null)
            //{
            //    IEnumGuideDataProperties ppEnumProperties;
            //    int hr = guideData.GetServiceProperties(tuneRequest, out ppEnumProperties);
            //    if (ppEnumProperties != null)
            //    {
            //        Hashtable hashtable = new Hashtable();
            //        IGuideDataProperty[] ppProp = new IGuideDataProperty[1];
            //        //22 int pcelt = 1;
            //        //22 while (ppEnumProperties.Next(1, ppProp, out pcelt) == 0 && pcelt > 0)
            //        IntPtr p = Marshal.AllocCoTaskMem(4);
            //        try
            //        {
            //            while (ppEnumProperties.Next(1, ppProp, p) == 0)
            //            {
            //                int language;
            //                ppProp[0].get_Language(out language);
            //                string name;
            //                ppProp[0].get_Name(out name);
            //                object value;
            //                ppProp[0].get_Value(out value);

            //                //  name: 'Description.ID', value: '8442:6:1537'
            //                //  name: 'Description.Name', value: 'TF1'
            //                //  name: 'Provider.Name', value: ''
            //                //  name: 'Provider.NetworkName', value: 'Réseau Numérique Terrestre Français'

            //                hashtable[name] = value;

            //                Trace.WriteLineIf(trace.TraceVerbose, "  name: '" + name + "', value: '" + value.ToString() + "', language: " + language);
            //                Marshal.ReleaseComObject(ppProp[0]);
            //                ppProp[0] = null;
            //            }
            //        }
            //        finally
            //        {
            //            Marshal.FreeCoTaskMem(p);
            //        }

            //        EPGProvider provider = (EPGProvider)providers[hashtable["Provider.Name"]];
            //        if (provider == null)
            //        {
            //            provider = new EPGProvider();
            //            provider.Name = (string)hashtable["Provider.Name"];
            //            provider.NetworkName = (string)hashtable["Provider.NetworkName"];
            //            providers[provider.Name] = provider;
            //        }
            //        EPGService service = (EPGService)services[hashtable["Description.ID"]];
            //        if (service == null)
            //        {
            //            service = new EPGService();
            //            service.ServiceId = (string)hashtable["Description.ID"];
            //            services[service.ServiceId] = service;
            //        }
            //        service.Name = (string)hashtable["Description.Name"];
            //        service.ProviderName = provider.Name;

            //        Marshal.ReleaseComObject(ppEnumProperties);
            //    }
            //}
        }
예제 #16
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;
                        }
                    }
                }
            }
        }
예제 #17
0
 internal abstract bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest);
예제 #18
0
 internal virtual bool ClearDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
 {
     Logger.Instance.Write("No DVB-S2 processing required");
     return (true);
 }
예제 #19
0
 internal abstract bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest);
예제 #20
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
            {
                return(true);
            }

            IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter);

            if (demodulator == null)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located");
                return(false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (tuningSpec.Modulation)
            {
            case Modulation.QPSK:
                BinaryConvolutionCodeRate codeRate;
                reply = demodulator.get_InnerFECRate(out codeRate);
                if (reply != 0)
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Get FEC rate failed error code 0x" + reply.ToString("X"));
                    return(false);
                }

                if (codeRate == BinaryConvolutionCodeRate.Rate9_10)
                {
                    modulationType = ModulationType.Mod32Qam;
                }
                else
                {
                    if (codeRate == BinaryConvolutionCodeRate.Rate8_9)
                    {
                        modulationType = ModulationType.Mod16Qam;
                    }
                    else
                    {
                        modulationType = ModulationType.ModBpsk;
                    }
                }
                break;

            case Modulation.PSK8:
                modulationType = ModulationType.ModNbc8Psk;
                break;

            default:
                break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return(false);
                }
                else
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type changed to " + modulationType);
                }
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type not changed");
            }

            IntPtr commandBuffer  = Marshal.AllocCoTaskMem(1024);
            IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            string setting;

            if (frequency.SymbolRate != 30000)
            {
                Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativePilot(frequency.Pilot));
                setting = frequency.Pilot.ToString();
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Setting pilot to off for symbol rate of 30000");
                Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.Off);
                setting = "Off";
            }
            reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4);
            if (reply != 0)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
                return(false);
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to " + setting);

                Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativeRollOff(frequency.RollOff));
                reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_ROLL_OFF, instanceBuffer, 32, commandBuffer, 4);
                if (reply != 0)
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X"));
                    return(false);
                }
                else
                {
                    Logger.Instance.Write("Hauppauge DVB-S2 handler: Rolloff set to " + frequency.RollOff);
                }
            }

            return(true);
        }
예제 #21
0
        internal override bool ClearDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
            {
                return(true);
            }

            IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter);

            if (demodulator == null)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located");
                return(false);
            }

            ModulationType modulationType = tuningSpec.NativeModulation;

            reply = demodulator.put_ModulationType(ref modulationType);
            if (reply != 0)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                return(false);
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type set to " + modulationType);
            }

            IntPtr commandBuffer  = Marshal.AllocCoTaskMem(1024);
            IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.NotSet);
            reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4);
            if (reply != 0)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
            }
            else
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to off");
            }

            return(reply == 0);
        }
예제 #22
0
    /// <summary>
    /// Actually tune to a channel.
    /// </summary>
    /// <param name="channel">The channel to tune to.</param>
    protected override ITvSubChannel SubmitTuneRequest(int subChannelId, IChannel channel, ITuneRequest tuneRequest, bool performTune)
    {
      ATSCChannel atscChannel = channel as ATSCChannel;
      if (atscChannel == null)
      {
        throw new TvException("DRI CC: received tune request for unsupported channel");
      }
      Log.Log.Info("DRI CC: tune channel {0} \"{1}\", sub channel ID {2}", atscChannel.MajorChannel, channel.Name, subChannelId);

      bool newSubChannel = false;
      BaseSubChannel subChannel;
      if (!_mapSubChannels.TryGetValue(subChannelId, out subChannel))
      {
        Log.Log.Debug("  new subchannel");
        newSubChannel = true;
        subChannelId = GetNewSubChannel(channel);
        subChannel = _mapSubChannels[subChannelId];
      }
      else
      {
        Log.Log.Debug("  existing subchannel {0}", subChannelId);
      }

      subChannel.CurrentChannel = channel;
      try
      {
        subChannel.OnBeforeTune();
        if (_interfaceEpgGrabber != null)
        {
          _interfaceEpgGrabber.Reset();
        }

        if (performTune)
        {
          Log.Log.Debug("DRI CC: tuning...");
          // Note that this call is not blocking, so usually the isPcrLocked
          // variable return value is false... then shortly afterwards we'll
          // receive an update if the tuner locks on signal. It may be possible
          // to use the Tuner service TimeToBlock SV to delay long enough to
          // get lock, however that is probably slower on average than
          // receiving asynchronous updates.
          _eventSignalLock.Reset();
          _casService.SetChannel((uint)atscChannel.MajorChannel, 0, DriCasCaptureMode.Live, out _tunerLocked);
        }
        else
        {
          Log.Log.Info("DRI CC: already tuned");
        }

        if (_transportState != UpnpAvTransportState.PLAYING)
        {
          Log.Log.Debug("DRI CC: play...");
          ((IFileSourceFilter)_filterStreamSource).Load(_streamUrl, _mpeg2TransportStream);
          _avTransportService.Play((uint)_avTransportId, "1");
          _transportState = UpnpAvTransportState.PLAYING;
        }

        _lastSignalUpdate = DateTime.MinValue;
        subChannel.OnAfterTune();
      }
      catch (Exception)
      {
        if (newSubChannel)
        {
          Log.Log.Info("DRI CC: tuning failed, removing subchannel");
          _mapSubChannels.Remove(subChannelId);
        }
        throw;
      }

      return subChannel;
    }
예제 #23
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
                return (true);

            IntPtr commandBuffer = Marshal.AllocCoTaskMem(commandBufferLength);

            for (int index = 0; index < commandBufferLength; ++index)
                Marshal.WriteByte(commandBuffer, index, 0x00);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            switch (frequency.RollOff)
            {
                case DomainObjects.RollOff.RollOff20:
                    Marshal.WriteInt32(commandBuffer, 0, 0);
                    break;
                case DomainObjects.RollOff.RollOff25:
                    Marshal.WriteInt32(commandBuffer, 0, 1);
                    break;
                case DomainObjects.RollOff.RollOff35:
                    Marshal.WriteInt32(commandBuffer, 0, 2);
                    break;
                default:
                    Marshal.WriteInt32(commandBuffer, 0, 0xff);
                    break;
            }

            switch (frequency.Pilot)
            {
                case DomainObjects.Pilot.Off:
                    Marshal.WriteInt32(commandBuffer, 4, 0);
                    break;
                case DomainObjects.Pilot.On:
                    Marshal.WriteInt32(commandBuffer, 4, 1);
                    break;
                default:
                    Marshal.WriteInt32(commandBuffer, 4, 1);
                    break;
            }

            Marshal.WriteInt32(commandBuffer, 8, 2);            // 0 = auto 1 = DVB-S 2 = DVB-S2
            Marshal.WriteInt32(commandBuffer, 12, (int)tuningSpec.NativeFECRate);
            Marshal.WriteInt32(commandBuffer, 16, (int)ModulationType.ModBpsk);            //

            StringBuilder commandString = new StringBuilder("TBS DVB-S2 handler: sending command 0x");
            byte[] commandBytes = new byte[20];
            for (int index = 0; index < 20; ++index)
            {
                int commandByte = Marshal.ReadByte(commandBuffer, index);
                if (commandByte < 0x10)
                    commandString.Append("0" + commandByte.ToString("X"));
                else
                    commandString.Append(commandByte.ToString("X"));
            }
            Logger.Instance.Write(commandString.ToString());

            string getSet;

            if (useGet)
            {
                int bytesReturned;
                reply = propertySet.Get(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength, out bytesReturned);
                getSet = "Get";
            }
            else
            {
                reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength);
                getSet = "Set";
            }

            if (reply != 0)
                Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command failed error code 0x" + reply.ToString("X"));
            else
                Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command succeeded");

            return (reply == 0);
        }
예제 #24
0
        protected override ITvSubChannel SubmitTuneRequest(int subChannelId, IChannel channel, ITuneRequest tuneRequest,
                                                           bool performTune)
        {
            Log.Log.Info("PBDA CC: tune channel \"{0}\", sub channel ID {1}", channel.Name, subChannelId);
            RunGraph(-1);
            bool           newSubChannel = false;
            BaseSubChannel subChannel;

            if (!_mapSubChannels.TryGetValue(subChannelId, out subChannel))
            {
                Log.Log.Debug("  new subchannel");
                newSubChannel = true;
                subChannelId  = GetNewSubChannel(channel);
                subChannel    = _mapSubChannels[subChannelId];
            }
            else
            {
                Log.Log.Debug("  existing subchannel {0}", subChannelId);
            }

            subChannel.CurrentChannel = channel;
            try
            {
                subChannel.OnBeforeTune();
                if (_interfaceEpgGrabber != null)
                {
                    _interfaceEpgGrabber.Reset();
                }
                if (performTune)
                {
                    Log.Log.Info("PBDA CC: tuning...");
                    int hr = _bdaCa.TuneByChannel((ushort)(channel as ATSCChannel).MajorChannel);
                    if (hr != 0)
                    {
                        Log.Log.Error("  tuning failed, hr = 0x{0:x}", hr);
                        throw new TvException("Unable to tune to channel");
                    }
                }
                else
                {
                    Log.Log.WriteFile("PBDA CC: already tuned");
                }
                _lastSignalUpdate = DateTime.MinValue;
                subChannel.OnAfterTune();
            }
            catch (Exception)
            {
                if (newSubChannel)
                {
                    Log.Log.Info("PBDA CC: tuning failed, removing subchannel");
                    _mapSubChannels.Remove(subChannelId);
                }
                throw;
            }

            return(subChannel);
        }
예제 #25
0
        private void buttonCapture_Click(object sender, RoutedEventArgs e)
        {
            _extractFolder = txtTsLocation.Text;

            if (Directory.Exists(_extractFolder))
            {
                if (Properties.Settings.Default.ExtractDirectory != _extractFolder)
                {
                    Properties.Settings.Default.ExtractDirectory = _extractFolder;
                    Properties.Settings.Default.Save();
                }

                txtTsLocation.IsEnabled = false;
                buttonBrowse.IsEnabled  = false;

                // List already downloaded items
                DirectoryInfo extractDir = new DirectoryInfo(_extractFolder);

                foreach (DirectoryInfo fwFolder in extractDir.EnumerateDirectories())
                {
                    FirmwareFile fwFile = new FirmwareFile(fwFolder.FullName);

                    CompletedFiles.Add(string.Format("{0:X2}-{1:X2}-{2:X2}", fwFile.VendorId, fwFile.ModelId, fwFile.VersionId), fwFile);
                    CompletedFileList.Add(fwFile);
                }

                timer.Interval = new TimeSpan(0, 0, 1);
                timer.Tick    += new EventHandler(timer_Tick);
                timer.Start();

                try
                {
                    // Start BDA Capture
                    int hr = 0;
                    IDVBSTuningSpace tuningSpace;

                    tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace();
                    hr          = tuningSpace.put_UniqueName("DVBS TuningSpace");
                    hr          = tuningSpace.put_FriendlyName("DVBS TuningSpace");
                    hr          = tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID);
                    hr          = tuningSpace.put_SystemType(DVBSystemType.Satellite);
                    hr          = tuningSpace.put_LowOscillator(9750000);
                    hr          = tuningSpace.put_HighOscillator(10600000);

                    ITuneRequest tr = null;

                    hr = tuningSpace.CreateTuneRequest(out tr);
                    DsError.ThrowExceptionForHR(hr);

                    IDVBTuneRequest tuneRequest = (IDVBTuneRequest)tr;

                    hr = tuneRequest.put_ONID(2);
                    hr = tuneRequest.put_TSID(2004);
                    hr = tuneRequest.put_SID(4190);

                    IDVBSLocator locator = (IDVBSLocator) new DVBSLocator();
                    hr = locator.put_CarrierFrequency(11778000);
                    hr = locator.put_SymbolRate(27500000);
                    hr = locator.put_Modulation(ModulationType.ModQpsk);
                    hr = (locator as IDVBSLocator).put_SignalPolarisation(Polarisation.LinearV);
                    hr = (locator as IDVBSLocator).put_InnerFEC(FECMethod.Viterbi);
                    hr = (locator as IDVBSLocator).put_InnerFECRate(BinaryConvolutionCodeRate.Rate2_3);
                    hr = (locator as IDVBSLocator).put_OuterFEC(FECMethod.Viterbi);
                    hr = (locator as IDVBSLocator).put_OuterFECRate(BinaryConvolutionCodeRate.Rate2_3);

                    hr = tr.put_Locator(locator as ILocator);
                    Marshal.ReleaseComObject(locator);

                    this.bdaGraphBuilder = new BDAGraphBuilder();
                    this.bdaGraphBuilder.BuildGraph(tuningSpace);
                    this.bdaGraphBuilder.SubmitTuneRequest(tr);

                    // We have to do this to make it actually tune!
                    this.bdaGraphBuilder.RunGraph();
                    this.bdaGraphBuilder.StopGraph();

                    TsGrabber grabber = new TsGrabber();
                    grabber.Callback = new TsGrabber.ProcessBufferDelegate(ProcessBuffer);

                    this.bdaGraphBuilder.SetUpForTs(grabber, 1);

                    this.bdaGraphBuilder.RunGraph();

                    this.buttonCapture.IsEnabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Error connecting to DVB-S:\n{0}", ex), "Connection error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Cannot find extract directory specified!");
            }
        }
예제 #26
0
        public void SubmitTuneRequest(ITuneRequest tuneRequest)
        {
            int hr = 0;

              hr = (this.networkProvider as ITuner).put_TuneRequest(tuneRequest);
              DsError.ThrowExceptionForHR(hr);
        }
예제 #27
0
    protected override ITvSubChannel SubmitTuneRequest(int subChannelId, IChannel channel, ITuneRequest tuneRequest,
                                              bool performTune)
    {
      Log.Log.Info("PBDA CC: tune channel \"{0}\", sub channel ID {1}", channel.Name, subChannelId);
      RunGraph(-1);
      bool newSubChannel = false;
      BaseSubChannel subChannel;
      if (!_mapSubChannels.TryGetValue(subChannelId, out subChannel))
      {
        Log.Log.Debug("  new subchannel");
        newSubChannel = true;
        subChannelId = GetNewSubChannel(channel);
        subChannel = _mapSubChannels[subChannelId];
      }
      else
      {
        Log.Log.Debug("  existing subchannel {0}", subChannelId);
      }

      subChannel.CurrentChannel = channel;
      try
      {
        subChannel.OnBeforeTune();        
        if (_interfaceEpgGrabber != null)
        {
          _interfaceEpgGrabber.Reset();
        }
        if (performTune)
        {
          Log.Log.Info("PBDA CC: tuning...");
          int hr = _bdaCa.TuneByChannel((ushort)(channel as ATSCChannel).MajorChannel);
          if (hr != 0)
          {
            Log.Log.Error("  tuning failed, hr = 0x{0:x}", hr);
            throw new TvException("Unable to tune to channel");
          }
        }
        else
        {
          Log.Log.WriteFile("PBDA CC: already tuned");
        }
        _lastSignalUpdate = DateTime.MinValue;
        subChannel.OnAfterTune();
      }
      catch (Exception)
      {        
        if (newSubChannel)
        {
          Log.Log.Info("PBDA CC: tuning failed, removing subchannel");
          _mapSubChannels.Remove(subChannelId);
        }
        throw;
      }

      return subChannel;
    }
예제 #28
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
            {
                return(true);
            }

            IntPtr commandBuffer = Marshal.AllocCoTaskMem(commandBufferLength);

            for (int index = 0; index < commandBufferLength; ++index)
            {
                Marshal.WriteByte(commandBuffer, index, 0x00);
            }

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            switch (frequency.RollOff)
            {
            case DomainObjects.RollOff.RollOff20:
                Marshal.WriteInt32(commandBuffer, 0, 0);
                break;

            case DomainObjects.RollOff.RollOff25:
                Marshal.WriteInt32(commandBuffer, 0, 1);
                break;

            case DomainObjects.RollOff.RollOff35:
                Marshal.WriteInt32(commandBuffer, 0, 2);
                break;

            default:
                Marshal.WriteInt32(commandBuffer, 0, 0xff);
                break;
            }

            switch (frequency.Pilot)
            {
            case DomainObjects.Pilot.Off:
                Marshal.WriteInt32(commandBuffer, 4, 0);
                break;

            case DomainObjects.Pilot.On:
                Marshal.WriteInt32(commandBuffer, 4, 1);
                break;

            default:
                Marshal.WriteInt32(commandBuffer, 4, 1);
                break;
            }

            Marshal.WriteInt32(commandBuffer, 8, 2);                            // 0 = auto 1 = DVB-S 2 = DVB-S2
            Marshal.WriteInt32(commandBuffer, 12, (int)tuningSpec.NativeFECRate);
            Marshal.WriteInt32(commandBuffer, 16, (int)ModulationType.ModBpsk); //

            StringBuilder commandString = new StringBuilder("TBS DVB-S2 handler: sending command 0x");

            byte[] commandBytes = new byte[20];
            for (int index = 0; index < 20; ++index)
            {
                int commandByte = Marshal.ReadByte(commandBuffer, index);
                if (commandByte < 0x10)
                {
                    commandString.Append("0" + commandByte.ToString("X"));
                }
                else
                {
                    commandString.Append(commandByte.ToString("X"));
                }
            }
            Logger.Instance.Write(commandString.ToString());

            string getSet;

            if (useGet)
            {
                int bytesReturned;
                reply  = propertySet.Get(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength, out bytesReturned);
                getSet = "Get";
            }
            else
            {
                reply  = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength);
                getSet = "Set";
            }

            if (reply != 0)
            {
                Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command failed error code 0x" + reply.ToString("X"));
            }
            else
            {
                Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command succeeded");
            }

            return(reply == 0);
        }
예제 #29
0
        /// <summary>
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (commandInterface == null)
            {
                return(false);
            }

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            DirectShowAPI.Pilot pilot = DsUtils.GetNativePilot(frequency.Pilot);
            reply = commandInterface.put_Pilot(pilot);
            if (reply != 0)
            {
                Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
            }
            else
            {
                Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command succeeded");

                DirectShowAPI.RollOff rollOff = DsUtils.GetNativeRollOff(frequency.RollOff);
                reply = commandInterface.put_RollOff(ref rollOff);
                if (reply != 0)
                {
                    Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X"));
                }
                else
                {
                    Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command succeeded");
                }
            }

            return(reply == 0);
        }
예제 #30
0
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
            {
                return(true);
            }

            IBDA_DigitalDemodulator demodulator = FindDemodulator("DigitalEverywhere", tunerFilter);

            if (demodulator == null)
            {
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Demodulator not located");
                return(false);
            }

            ModulationType modulationType = ModulationType.ModNotSet;

            switch (tuningSpec.Modulation)
            {
            case Modulation.QPSK:
                modulationType = ModulationType.ModNbcQpsk;
                break;

            case Modulation.PSK8:
                modulationType = ModulationType.ModNbc8Psk;
                break;

            default:
                break;
            }

            if (modulationType != ModulationType.ModNotSet)
            {
                reply = demodulator.put_ModulationType(ref modulationType);
                if (reply != 0)
                {
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                    return(false);
                }
                else
                {
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type changed to " + modulationType);
                }
            }
            else
            {
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type not changed");
            }

            BinaryConvolutionCodeRate oldCodeRate;

            reply = demodulator.get_InnerFECRate(out oldCodeRate);
            if (reply != 0)
            {
                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Get FEC Rate failed error code 0x" + reply.ToString("X"));
                return(false);
            }

            SatelliteFrequency satelliteFrequency = tuningSpec.Frequency as SatelliteFrequency;

            BinaryConvolutionCodeRate newCodeRate = oldCodeRate;

            if (satelliteFrequency.Pilot == DomainObjects.Pilot.Off)
            {
                newCodeRate += 64;
            }
            else
            {
                if (satelliteFrequency.Pilot == DomainObjects.Pilot.On)
                {
                    newCodeRate += 128;
                }
            }

            switch (satelliteFrequency.RollOff)
            {
            case DomainObjects.RollOff.RollOff20:
                newCodeRate += 16;
                break;

            case DomainObjects.RollOff.RollOff25:
                newCodeRate += 32;
                break;

            case DomainObjects.RollOff.RollOff35:
                newCodeRate += 48;
                break;

            default:
                break;
            }

            if (oldCodeRate != newCodeRate)
            {
                reply = demodulator.put_InnerFECRate(newCodeRate);
                if (reply != 0)
                {
                    Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set FEC Rate failed error code 0x" + reply.ToString("X"));
                    return(false);
                }

                Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: FEC Rate changed from " + oldCodeRate + " to " + newCodeRate);
            }

            return(true);
        }
예제 #31
0
        /// <summary>
        internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (commandInterface == null)
                return (false);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            DirectShowAPI.Pilot pilot = DsUtils.GetNativePilot(frequency.Pilot);
            reply = commandInterface.put_Pilot(pilot);
            if (reply != 0)
                Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
            else
            {
                Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command succeeded");

                DirectShowAPI.RollOff rollOff = DsUtils.GetNativeRollOff(frequency.RollOff);
                reply = commandInterface.put_RollOff(ref rollOff);
                if (reply != 0)
                    Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X"));
                else
                    Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command succeeded");
            }

            return (reply == 0);
        }
예제 #32
0
        public void MakeTuneRequest()
        {
            int      hr = 0;
            ILocator locator;

            // 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);
            //DsError.ThrowExceptionForHR(hr);

            if (networkType == BDANetworkType.DVBT)
            {
                // Those values are valid for me but must be modified to be valid depending on your location
                hr = tuneRequest.get_Locator(out locator);
                DsError.ThrowExceptionForHR(hr);

                hr = locator.put_CarrierFrequency(586166);
                DsError.ThrowExceptionForHR(hr);

                hr = tuneRequest.put_Locator(locator);
                DsError.ThrowExceptionForHR(hr);

                Marshal.ReleaseComObject(locator);

                hr = (tuneRequest as IDVBTuneRequest).put_ONID(8442);
                DsError.ThrowExceptionForHR(hr);
                hr = (tuneRequest as IDVBTuneRequest).put_TSID(1);
                DsError.ThrowExceptionForHR(hr);
                hr = (tuneRequest as IDVBTuneRequest).put_SID(259);
                DsError.ThrowExceptionForHR(hr);

/*
 *      hr = locator.put_CarrierFrequency(522166);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = tuneRequest.put_Locator(locator);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      Marshal.ReleaseComObject(locator);
 *
 *      hr = (tuneRequest as IDVBTuneRequest).put_ONID(8442);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_TSID(3);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_SID(769);
 *      DsError.ThrowExceptionForHR(hr);
 */
/*
 *      hr = locator.put_CarrierFrequency(562166);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = tuneRequest.put_Locator(locator);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      Marshal.ReleaseComObject(locator);
 *
 *      hr = (tuneRequest as IDVBTuneRequest).put_ONID(8442);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_TSID(6);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_SID(1537);
 *      DsError.ThrowExceptionForHR(hr);
 */
            }

            if (networkType == BDANetworkType.DVBS)
            {
                // Those values are valid for me but must be modified to be valid depending on your Satellite dish

/*
 *      hr = tuneRequest.get_Locator(out locator);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = locator.put_CarrierFrequency(11591000);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = (locator as IDVBSLocator).put_SignalPolarisation(Polarisation.LinearV);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = locator.put_SymbolRate(20000);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      hr = tuneRequest.put_Locator(locator);
 *      DsError.ThrowExceptionForHR(hr);
 *
 *      Marshal.ReleaseComObject(locator);
 *
 *      hr = (tuneRequest as IDVBTuneRequest).put_ONID(8442);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_TSID(1);
 *      DsError.ThrowExceptionForHR(hr);
 *      hr = (tuneRequest as IDVBTuneRequest).put_SID(260);
 *      DsError.ThrowExceptionForHR(hr);
 */

                hr = tuneRequest.get_Locator(out locator);
                DsError.ThrowExceptionForHR(hr);

                hr = locator.put_CarrierFrequency(11607000);
                DsError.ThrowExceptionForHR(hr);

                hr = (locator as IDVBSLocator).put_SignalPolarisation(Polarisation.LinearV);
                DsError.ThrowExceptionForHR(hr);

                hr = locator.put_SymbolRate(6944);
                DsError.ThrowExceptionForHR(hr);

                hr = tuneRequest.put_Locator(locator);
                DsError.ThrowExceptionForHR(hr);

                Marshal.ReleaseComObject(locator);

                hr = (tuneRequest as IDVBTuneRequest).put_ONID(144);
                DsError.ThrowExceptionForHR(hr);
                hr = (tuneRequest as IDVBTuneRequest).put_TSID(100);
                DsError.ThrowExceptionForHR(hr);
                hr = (tuneRequest as IDVBTuneRequest).put_SID(289);
                DsError.ThrowExceptionForHR(hr);
            }

            hr = tuner.put_TuneRequest(tuneRequest);
            if (hr < 0)
            {
                Debug.Fail("TuneRequest is not valid");
            }
        }
예제 #33
0
파일: EPG.cs 프로젝트: zhiqiang-li/CodeTV
        public void UpdateService(ITuneRequest tuneRequest, IGuideData guideData)
        {
            Trace.WriteLineIf(trace.TraceInfo, "EPG.UpdateService(" + tuneRequest.ToString() + ")");
            //if (guideData != null)
            //{
            //    IEnumGuideDataProperties ppEnumProperties;
            //    int hr = guideData.GetServiceProperties(tuneRequest, out ppEnumProperties);
            //    if (ppEnumProperties != null)
            //    {
            //        Hashtable hashtable = new Hashtable();
            //        IGuideDataProperty[] ppProp = new IGuideDataProperty[1];
            //        //22 int pcelt = 1;
            //        //22 while (ppEnumProperties.Next(1, ppProp, out pcelt) == 0 && pcelt > 0)
            //        IntPtr p = Marshal.AllocCoTaskMem(4);
            //        try
            //        {
            //            while (ppEnumProperties.Next(1, ppProp, p) == 0)
            //            {
            //                int language;
            //                ppProp[0].get_Language(out language);
            //                string name;
            //                ppProp[0].get_Name(out name);
            //                object value;
            //                ppProp[0].get_Value(out value);

            //                //  name: 'Description.ID', value: '8442:6:1537'
            //                //  name: 'Description.Name', value: 'TF1'
            //                //  name: 'Provider.Name', value: ''
            //                //  name: 'Provider.NetworkName', value: 'Réseau Numérique Terrestre Français'

            //                hashtable[name] = value;

            //                Trace.WriteLineIf(trace.TraceVerbose, "  name: '" + name + "', value: '" + value.ToString() + "', language: " + language);
            //                Marshal.ReleaseComObject(ppProp[0]);
            //                ppProp[0] = null;
            //            }
            //        }
            //        finally
            //        {
            //            Marshal.FreeCoTaskMem(p);
            //        }

            //        EPGProvider provider = (EPGProvider)providers[hashtable["Provider.Name"]];
            //        if (provider == null)
            //        {
            //            provider = new EPGProvider();
            //            provider.Name = (string)hashtable["Provider.Name"];
            //            provider.NetworkName = (string)hashtable["Provider.NetworkName"];
            //            providers[provider.Name] = provider;
            //        }
            //        EPGService service = (EPGService)services[hashtable["Description.ID"]];
            //        if (service == null)
            //        {
            //            service = new EPGService();
            //            service.ServiceId = (string)hashtable["Description.ID"];
            //            services[service.ServiceId] = service;
            //        }
            //        service.Name = (string)hashtable["Description.Name"];
            //        service.ProviderName = provider.Name;

            //        Marshal.ReleaseComObject(ppEnumProperties);
            //    }
            //}
        }
예제 #34
0
        internal override bool ClearDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
        {
            if (!dvbs2Capable)
                return (true);

            IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter);
            if (demodulator == null)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located");
                return (false);
            }

            ModulationType modulationType = tuningSpec.NativeModulation;
            reply = demodulator.put_ModulationType(ref modulationType);
            if (reply != 0)
            {
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X"));
                return (false);
            }
            else
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type set to " + modulationType);

            IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024);
            IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024);

            SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency;

            Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.NotSet);
            reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4);
            if (reply != 0)
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X"));
            else
                Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to off");

            return (reply == 0);
        }
예제 #35
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);
                        }
                    }
                }
            }
        }
예제 #36
0
        /// <summary>
        /// Dispose of the filters created by this graph.
        /// </summary>
        public override void Dispose()
        {
            if (CaptureGraphBuilder == null)
            {
                LogMessage("No graph components exist for disposal");
                return;
            }

            base.Dispose();

            LogMessage("Releasing Network Provider");
            Marshal.ReleaseComObject(networkProviderFilter);
            networkProviderFilter = null;

            LogMessage("Releasing MPEG2 Demux");
            Marshal.ReleaseComObject(mpeg2DemuxFilter);
            mpeg2DemuxFilter = null;

            LogMessage("Releasing Tuner");
            Marshal.ReleaseComObject(tunerFilter);
            tunerFilter = null;

            if (captureFilter != null)
            {
                LogMessage("Releasing Capture Filter");
                Marshal.ReleaseComObject(captureFilter);
                captureFilter = null;
            }

            if (demodulatorFilter != null)
            {
                LogMessage("Releasing Demodulator");
                Marshal.ReleaseComObject(demodulatorFilter);
                demodulatorFilter = null;
            }

            if (tifFilter != null)
            {
                LogMessage("Releasing TIF Filter");
                Marshal.ReleaseComObject(tifFilter);
                tifFilter = null;
            }

            if (secTabFilter != null)
            {
                LogMessage("Releasing Sections And Tables Filter");
                Marshal.ReleaseComObject(secTabFilter);
                secTabFilter = null;
            }

            if (infiniteTeeFilter != null)
            {
                LogMessage("Releasing Infinite Tee Filter");
                Marshal.ReleaseComObject(infiniteTeeFilter);
                infiniteTeeFilter = null;
            }

            if (psiMemoryFilter != null)
            {
                LogMessage("Releasing PSI Memory Filter");

                IntPtr pointer = Marshal.GetIUnknownForObject(psiMemoryFilter);

                Marshal.ReleaseComObject(psiMemoryFilter);
                Marshal.Release(pointer);

                psiMemoryFilter = null;
            }

            if (tuningSpace != null)
            {
                LogMessage("Releasing Tuning Space");
                Marshal.ReleaseComObject(tuningSpace);
                tuningSpace = null;
            }

            if (tuneRequest != null)
            {
                LogMessage("Releasing Tune Request");
                Marshal.ReleaseComObject(tuneRequest);
                tuneRequest = null;
            }

            if (currentLocator != null)
            {
                LogMessage("Releasing Locator");
                Marshal.ReleaseComObject(currentLocator);
                currentLocator = null;
            }
        }
예제 #37
0
 internal virtual bool ClearDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest)
 {
     Logger.Instance.Write("No DVB-S2 processing required");
     return(true);
 }