예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TvCardDvbB2C2"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public TvCardDvbB2C2(DsDevice device, DeviceInfo deviceInfo)
            : base(device)
        {
            _deviceInfo = deviceInfo;
            _devicePath = deviceInfo.DevicePath;
            _name       = deviceInfo.Name;
            GetPreloadBitAndCardId();

            _useDISEqCMotor = false;
            TvBusinessLayer layer = new TvBusinessLayer();
            Card            card  = layer.GetCardByDevicePath(_devicePath);

            if (card != null)
            {
                Setting setting = layer.GetSetting("dvbs" + card.IdCard + "motorEnabled", "no");
                if (setting.Value == "yes")
                {
                    _useDISEqCMotor = true;
                }
            }
            _conditionalAccess = new ConditionalAccess(null, null, null, this);
            _ptrDisEqc         = Marshal.AllocCoTaskMem(20);
            _disEqcMotor       = new DiSEqCMotor(this);
            GetTunerCapabilities();
        }
예제 #2
0
        /// <summary>
        /// Build graph
        /// </summary>
        public override void BuildGraph()
        {
            try
            {
                if (_graphState != GraphState.Idle)
                {
                    throw new TvException("Graph already build");
                }
                Log.Log.WriteFile("BuildGraph");

                _graphBuilder = (IFilterGraph2) new FilterGraph();

                _capBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
                _capBuilder.SetFiltergraph(_graphBuilder);
                _rotEntry = new DsROTEntry(_graphBuilder);

                _infTeeMain = (IBaseFilter) new InfTee();
                int hr = _graphBuilder.AddFilter(_infTeeMain, "Inf Tee");
                if (hr != 0)
                {
                    Log.Log.Error("dvbip:Add main InfTee returns:0x{0:X}", hr);
                    throw new TvException("Unable to add  mainInfTee");
                }

                AddTsWriterFilterToGraph();
                AddStreamSourceFilter(_defaultUrl);
                IBaseFilter lastFilter = _filterStreamSource;
                AddMdPlugs(ref lastFilter);
                if (!ConnectTsWriter(lastFilter))
                {
                    throw new TvExceptionGraphBuildingFailed("Graph building failed");
                }

                _conditionalAccess = new ConditionalAccess(_filterStreamSource, _filterTsWriter, null, this);
                _graphState        = GraphState.Created;
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
                Dispose();
                _graphState = GraphState.Idle;
                throw ex;
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TvCardDvbSS2"/> class.
        /// </summary>
        /// <param name="epgEvents">The EPG events interface.</param>
        /// <param name="device">The device.</param>
        public TvCardDvbSS2(IEpgEvents epgEvents, DsDevice device)
            : base(epgEvents, device)
        {
            _useDISEqCMotor = false;
            TvBusinessLayer layer = new TvBusinessLayer();
            Card            card  = layer.GetCardByDevicePath(device.DevicePath);

            if (card != null)
            {
                Setting setting = layer.GetSetting("dvbs" + card.IdCard + "motorEnabled", "no");
                if (setting.Value == "yes")
                {
                    _useDISEqCMotor = true;
                }
            }
            _conditionalAccess = new ConditionalAccess(null, null, null, this);
            _ptrDisEqc         = Marshal.AllocCoTaskMem(20);
            _disEqcMotor       = new DiSEqCMotor(this);
            GetTunerCapabilities();
        }
예제 #4
0
    /// <summary>
    /// Initializes a new instance of the <see cref="TvCardDvbB2C2"/> class.
    /// </summary>
    /// <param name="device">The device.</param>
    public TvCardDvbB2C2(DsDevice device, DeviceInfo deviceInfo)
      : base(device)
    {
      _deviceInfo = deviceInfo;
      _devicePath = deviceInfo.DevicePath;
      _name = deviceInfo.Name;
      GetPreloadBitAndCardId();

      _useDISEqCMotor = false;
      TvBusinessLayer layer = new TvBusinessLayer();
      Card card = layer.GetCardByDevicePath(_devicePath);
      if (card != null)
      {
        Setting setting = layer.GetSetting("dvbs" + card.IdCard + "motorEnabled", "no");
        if (setting.Value == "yes")
          _useDISEqCMotor = true;
      }
      _conditionalAccess = new ConditionalAccess(null, null, null, this);
      _ptrDisEqc = Marshal.AllocCoTaskMem(20);
      _disEqcMotor = new DiSEqCMotor(this);
      GetTunerCapabilities();
    }
예제 #5
0
 /// <summary>
 /// Complete the BDA filter graph.
 /// ...[last filter]->{ [WinTV-CI] / [Infinite Tee]->[MD plugin 1]->..[MD plugin n] / [Digital Devices CI 1]->..[Digital Devices CI n] }->[Infinite Tee]
 /// There are two branches from the final infinite tee.
 ///       -->[MPEG Demultiplexor]->[BDA TIF]
 ///       -->[TsWriter]
 /// The demux branch is only created when a Microsoft network provider is in use.
 /// </summary>
 /// <param name="lastFilter">A reference to the last hardware-specific filter successfully connected into in the graph.</param>
 protected void CompleteGraph(ref IBaseFilter lastFilter)
 {
   // Add additional filters after the capture/tuner device
   AddWinTvCIModule(ref lastFilter);
   AddDigitalDevicesCIModule(ref lastFilter);
   AddMdPlugs(ref lastFilter);
   // Now connect the required filters if not using the internal network provider
   if (!useInternalNetworkProvider)
   {
     // Connect the inf tee and demux to the last filter (saves one inf tee)
     ConnectMpeg2DemuxToInfTee(ref lastFilter);
     // Connect and add the filters to the demux
     AddBdaTransportFiltersToGraph();
   }
   // Render the last filter with the tswriter
   if (!ConnectTsWriter(lastFilter))
   {
     throw new TvExceptionGraphBuildingFailed("Graph building of DVB card failed");
   }
   Log.Log.WriteFile("dvb: Checking for hardware specific extensions");
   _conditionalAccess = new ConditionalAccess(_filterTuner, _filterTsWriter, _filterWinTvUsb, this);
 }
예제 #6
0
    /// <summary>
    /// Build graph
    /// </summary>
    public override void BuildGraph()
    {
      try
      {
        if (_graphState != GraphState.Idle)
        {
          throw new TvException("Graph already build");
        }
        Log.Log.WriteFile("BuildGraph");

        _graphBuilder = (IFilterGraph2)new FilterGraph();

        _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
        _capBuilder.SetFiltergraph(_graphBuilder);
        _rotEntry = new DsROTEntry(_graphBuilder);

        _infTeeMain = (IBaseFilter)new InfTee();
        int hr = _graphBuilder.AddFilter(_infTeeMain, "Inf Tee");
        if (hr != 0)
        {
          Log.Log.Error("dvbip:Add main InfTee returns:0x{0:X}", hr);
          throw new TvException("Unable to add  mainInfTee");
        }

        AddTsWriterFilterToGraph();
        AddStreamSourceFilter(_defaultUrl);
        IBaseFilter lastFilter = _filterStreamSource;
        AddMdPlugs(ref lastFilter);
        if (!ConnectTsWriter(lastFilter))
        {
          throw new TvExceptionGraphBuildingFailed("Graph building failed");
        }

        _conditionalAccess = new ConditionalAccess(_filterStreamSource, _filterTsWriter, null, this);
        _graphState = GraphState.Created;
      }
      catch (Exception ex)
      {
        Log.Log.Write(ex);
        Dispose();
        _graphState = GraphState.Idle;
        throw ex;
      }
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="TvDvbChannel"/> class.
    /// </summary>
    /// <param name="graphBuilder">The graph builder.</param>
    /// <param name="ca">The ca.</param>
    /// <param name="mdplugs">The mdplugs class.</param>
    /// <param name="tif">The tif filter.</param>
    /// <param name="tsWriter">The ts writer filter.</param>
    /// <param name="subChannelId">The subchannel id</param>
    /// <param name="channel">The corresponding channel</param>
    public TvDvbChannel(IFilterGraph2 graphBuilder, ConditionalAccess ca, MDPlugs mdplugs, IBaseFilter tif,
                        IBaseFilter tsWriter, int subChannelId, IChannel channel)
    {
      _cancelled = false;
      _listenCA = false;
      _eventPMT = new ManualResetEvent(false);
      _eventCA = new ManualResetEvent(false);
      _graphState = GraphState.Created;
      _graphBuilder = graphBuilder;
      _conditionalAccess = ca;
      _mdplugs = mdplugs;
      _filterTIF = tif;
      _teletextDecoder = new DVBTeletext();
      _packetHeader = new TSHelperTools.TSHeader();
      _tsHelper = new TSHelperTools();
      _channelInfo = new ChannelInfo();
      _pmtPid = -1;
      _subChannelIndex = -1;
      _tsFilterInterface = (ITsFilter)tsWriter;
      _tsFilterInterface.AddChannel(ref _subChannelIndex);

      Log.Log.WriteFile("TvDvbChannel ctor new subchIndex:{0}", _subChannelIndex);

      _subChannelId = subChannelId;
      _conditionalAccess.AddSubChannel(_subChannelId, channel);
      _timeshiftFileName = "";
      _recordingFileName = "";
      _pmtData = null;
      _pmtLength = 0;
    }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TvCardDvbSS2"/> class.
 /// </summary>
 /// <param name="epgEvents">The EPG events interface.</param>
 /// <param name="device">The device.</param>
 public TvCardDvbSS2(IEpgEvents epgEvents, DsDevice device)
   : base(epgEvents, device)
 {
   _useDISEqCMotor = false;
   TvBusinessLayer layer = new TvBusinessLayer();
   Card card = layer.GetCardByDevicePath(device.DevicePath);
   if (card != null)
   {
     Setting setting = layer.GetSetting("dvbs" + card.IdCard + "motorEnabled", "no");
     if (setting.Value == "yes")
       _useDISEqCMotor = true;
   }
   _conditionalAccess = new ConditionalAccess(null, null, null, this);
   _ptrDisEqc = Marshal.AllocCoTaskMem(20);
   _disEqcMotor = new DiSEqCMotor(this);
   GetTunerCapabilities();
 }
예제 #9
0
    /// <summary>
    /// Build the graph.
    /// </summary>
    public override void BuildGraph()
    {
      try
      {
        if (_graphState != GraphState.Idle)
        {
          Log.Log.Info("DRI CC: device already initialised");
          return;
        }

        bool useKeepAlive = !_isCetonDevice;
        Log.Log.Info("DRI CC: connect to device, keep-alive = {0}", useKeepAlive);
        _deviceConnection = _controlPoint.Connect(_descriptor.RootDescriptor, _descriptor.DeviceUUID, ResolveDataType, useKeepAlive);

        // services
        Log.Log.Debug("DRI CC: setup services");
        _tunerService = new TunerService(_deviceConnection.Device);
        _fdcService = new FdcService(_deviceConnection.Device);
        _auxService = new AuxService(_deviceConnection.Device);
        _encoderService = new EncoderService(_deviceConnection.Device);
        _casService = new CasService(_deviceConnection.Device);
        _muxService = new MuxService(_deviceConnection.Device);
        _securityService = new SecurityService(_deviceConnection.Device);
        _diagService = new DiagService(_deviceConnection.Device);
        _avTransportService = new AvTransportService(_deviceConnection.Device);
        _connectionManagerService = new ConnectionManagerService(_deviceConnection.Device);

        Log.Log.Debug("DRI CC: subscribe services");
        _stateVariableDelegate = new StateVariableChangedDlgt(OnStateVariableChanged);
        _tunerService.SubscribeStateVariables(_stateVariableDelegate);
        _auxService.SubscribeStateVariables(_stateVariableDelegate);
        _encoderService.SubscribeStateVariables(_stateVariableDelegate);
        _casService.SubscribeStateVariables(_stateVariableDelegate);
        _securityService.SubscribeStateVariables(_stateVariableDelegate);
        _avTransportService.SubscribeStateVariables(_stateVariableDelegate);
        _connectionManagerService.SubscribeStateVariables(_stateVariableDelegate);

        // Give time for the device to notify us about initial state variable values.
        // Attempting to continue with other actions now can overload the puny device
        // processors.
        Thread.Sleep(2000);

        int rcsId = -1;
        _connectionManagerService.PrepareForConnection(string.Empty, string.Empty, -1, UpnpConnectionDirection.Output, out _connectionId, out _avTransportId, out rcsId);
        Log.Log.Debug("DRI CC: PrepareForConnection, connection ID = {0}, AV transport ID = {1}", _connectionId, _avTransportId);

        // Check that the device is not already in use.
        if (IsTunerInUse())
        {
          throw new TvExceptionGraphBuildingFailed("DRI CC: tuner appears to be in use");
        }

        ReadDeviceInfo();

        Log.Log.Info("DRI CC: build graph");
        _graphBuilder = (IFilterGraph2)new FilterGraph();
        _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
        _capBuilder.SetFiltergraph(_graphBuilder);
        _rotEntry = new DsROTEntry(_graphBuilder);
        AddTsWriterFilterToGraph();
        AddStreamSourceFilter();

        // This shouldn't be required, but it enables us to reuse TvCardDvbBase
        // and use CI menus for delivering messages from the CableCARD to the
        // user.
        _conditionalAccess = new ConditionalAccess(null, null, null, this);

        _graphState = GraphState.Created;
      }
      catch (Exception)
      {
        Dispose();
        throw;
      }
    }
예제 #10
0
    /// <summary>
    /// Finds the correct bda tuner/capture filters and adds them to the graph
    /// Creates a graph like
    /// [NetworkProvider]->[Tuner]->[Capture]->[TsWriter]
    /// or if no capture filter is present:
    /// [NetworkProvider]->[Tuner]->[TsWriter]
    /// When a wintv ci module is found the graph will look like:
    /// [NetworkProvider]->[Tuner]->[Capture]->[WinTvCiUSB]->[TsWriter]
    /// or if no capture filter is present:
    /// [NetworkProvider]->[Tuner]->[WinTvCiUSB]->[TsWriter]
    /// </summary>
    /// <param name="device">Tuner device</param>
    protected void AddAndConnectBDABoardFilters(DsDevice device)
    {
      if (!CheckThreadId())
        return;
      Log.Log.WriteFile("dvb:AddAndConnectBDABoardFilters");
      _rotEntry = new DsROTEntry(_graphBuilder);
      Log.Log.WriteFile("dvb: find bda tuner");
      // Enumerate BDA Source filters category and found one that can connect to the network provider
      DsDevice[] devices = DsDevice.GetDevicesOfCat(FilterCategory.BDASourceFiltersCategory);
      for (int i = 0; i < devices.Length; i++)
      {
        IBaseFilter tmp;
        if (device.DevicePath != devices[i].DevicePath)
          continue;
        if (DevicesInUse.Instance.IsUsed(devices[i]))
        {
          Log.Log.Info("dvb:  [Tuner]: {0} is being used by TVServer already or another application!", devices[i].Name);
          continue;
        }
        int hr;
        try
        {
          hr = _graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
        }
        catch (Exception)
        {
          continue;
        }
        if (hr != 0)
        {
          if (tmp != null)
          {
            _graphBuilder.RemoveFilter(tmp);
            Release.ComObject("bda tuner", tmp);
          }
          continue;
        }
        //render [Network provider]->[Tuner]
        hr = _capBuilder.RenderStream(null, null, _filterNetworkProvider, null, tmp);
        if (hr == 0)
        {
          // Got it !
          _filterTuner = tmp;
          Log.Log.WriteFile("dvb:  using [Tuner]: {0}", devices[i].Name);
          _tunerDevice = devices[i];
          DevicesInUse.Instance.Add(devices[i]);
          Log.Log.WriteFile("dvb:  Render [Network provider]->[Tuner] OK");
          break;
        }
        // Try another...
        _graphBuilder.RemoveFilter(tmp);
        Release.ComObject("bda tuner", tmp);
      }
      // Assume we found a tuner filter...
      if (_filterTuner == null)
      {
        Log.Log.Info(
          "dvb:  A useable TV Tuner cannot be found! Either the device no longer exists or it's in use by another application!");
        Log.Log.Error("dvb:  No TVTuner installed");
        throw new TvException("No TVTuner installed");
      }

      Log.Log.WriteFile("dvb:  Setting lastFilter to Tuner filter");
      IBaseFilter lastFilter = _filterTuner;

      // Attempt to connect [Tuner]->[Capture]
      if (UseCaptureFilter())
      {
        Log.Log.WriteFile("dvb:  Find BDA receiver");
        Log.Log.WriteFile("dvb:  match Capture by Tuner device path");
        AddBDARendererToGraph(device, ref lastFilter);
        if (_filterCapture == null)
        {
          Log.Log.WriteFile("dvb:  Match by device path failed - trying alternative method");
          matchDevicePath = false;
          Log.Log.WriteFile("dvb:  match Capture filter by Tuner device connection");
          AddBDARendererToGraph(device, ref lastFilter);
        }
      }
      // Add additional filters after the capture/tuner device
      AddWinTvCIModule(ref lastFilter);
      AddDigitalDevicesCIModule(ref lastFilter);
      AddMdPlugs(ref lastFilter);
      // Now connect the required filters if not using the internal network provider
      if (!useInternalNetworkProvider)
      {
        // Connect the inf tee and demux to the last filter (saves one inf tee)
        ConnectMpeg2DemuxToInfTee(ref lastFilter);
        // Connect and add the filters to the demux
        AddBdaTransportFiltersToGraph();
      }
      // Render the last filter with the tswriter
      if (!ConnectTsWriter(lastFilter))
      {
        throw new TvExceptionGraphBuildingFailed("Graph building of DVB card failed");
      }
      Log.Log.WriteFile("dvb: Checking for hardware specific extensions");
      _conditionalAccess = new ConditionalAccess(_filterTuner, _filterTsWriter, _filterWinTvUsb, this);
    }