//anysee _anysee = null; #endregion //ctor /// <summary> /// Initializes a new instance of the <see cref="ConditionalAccess"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> /// <param name="analyzerFilter">The capture filter.</param> /// <param name="winTvUsbCiFilter">The WinTV CI filter.</param> /// <param name="card">Determines the type of TV card</param> public ConditionalAccess(IBaseFilter tunerFilter, IBaseFilter analyzerFilter, IBaseFilter winTvUsbCiFilter, TvCardBase card) { try { //System.Diagnostics.Debugger.Launch(); if (card != null && card.DevicePath != null) { //fetch decrypt limit from DB and apply it. TvBusinessLayer layer = new TvBusinessLayer(); Card c = layer.GetCardByDevicePath(card.DevicePath); _decryptLimit = c.DecryptLimit; _useCam = c.CAM; _CamType = (CamType)c.CamType; Log.Log.WriteFile("CAM is {0} model", _CamType); } _mapSubChannels = new Dictionary <int, ConditionalAccessContext>(); TunerDri driTuner = card as TunerDri; if (driTuner != null) { _tunerDri = driTuner; _ciMenu = driTuner; } if (tunerFilter == null && analyzerFilter == null) { return; } //DVB checks. Conditional Access & DiSEqC etc. bool isDVBS = (card is TvCardDVBS); bool isDVBT = (card is TvCardDVBT); bool isDVBC = (card is TvCardDVBC); if (isDVBC || isDVBS || isDVBT) { Log.Log.WriteFile("Check for KNC"); // Lookup device index of current card. only counting KNC cards by device path int DeviceIndex = KNCDeviceLookup.GetDeviceIndex(card); _knc = new KNCAPI(tunerFilter, (uint)DeviceIndex); if (_knc.IsKNC) { //if (_knc.IsCamReady()) _ciMenu = _knc; // Register KNC CI Menu capabilities when CAM detected and ready Log.Log.WriteFile("KNC card detected"); return; } Release.DisposeToNull(ref _knc); Log.Log.WriteFile("Check for Digital Everywhere"); _digitalEveryWhere = new DigitalEverywhere(tunerFilter); if (_digitalEveryWhere.IsDigitalEverywhere) { Log.Log.WriteFile("Digital Everywhere card detected"); _diSEqCMotor = new DiSEqCMotor(_digitalEveryWhere); if (_digitalEveryWhere.IsCamReady()) { Log.Log.WriteFile("Digital Everywhere registering CI menu capabilities"); _ciMenu = _digitalEveryWhere; // Register FireDTV CI Menu capabilities when CAM detected and ready } //_digitalEveryWhere.ResetCAM(); return; } Release.DisposeToNull(ref _digitalEveryWhere); Log.Log.WriteFile("Check for Twinhan"); _twinhan = new Twinhan(tunerFilter); if (_twinhan.IsTwinhan) { Log.Log.WriteFile("Twinhan card detected"); _diSEqCMotor = new DiSEqCMotor(_twinhan); Log.Log.WriteFile("Twinhan registering CI menu capabilities"); _ciMenu = _twinhan; // Register Twinhan CI Menu capabilities when CAM detected and ready return; } Release.DisposeToNull(ref _twinhan); Log.Log.WriteFile("Check for TechnoTrend"); _technoTrend = new TechnoTrendAPI(tunerFilter); if (_technoTrend.IsTechnoTrend) { ////if (_technoTrend.IsCamPresent()) _ciMenu = _technoTrend; // Register Technotrend CI Menu capabilities Log.Log.WriteFile("TechnoTrend card detected"); return; } Release.DisposeToNull(ref _technoTrend); Log.Log.WriteFile("Check for Hauppauge"); _hauppauge = new Hauppauge(tunerFilter); if (_hauppauge.IsHauppauge) { Log.Log.WriteFile("Hauppauge card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); Log.Log.WriteFile("WinTV CI registering CI menu capabilities"); _ciMenu = _winTvCiModule; // WinTv CI Menu capabilities } _diSEqCMotor = new DiSEqCMotor(_hauppauge); return; } Release.DisposeToNull(ref _hauppauge); Release.DisposeToNull(ref _winTvCiModule); /*Log.Log.Info("Check for anysee"); * _anysee = new anysee(tunerFilter, analyzerFilter); * if (_anysee.Isanysee) * { * Log.Log.Info("anysee device detected"); * return; * }*/ Log.Log.WriteFile("Check for ProfRed"); _profred = new ProfRed(tunerFilter); if (_profred.IsProfRed) { Log.Log.WriteFile("ProfRed card detected"); _diSEqCMotor = new DiSEqCMotor(_profred); return; } Release.DisposeToNull(ref _profred); // TeVii support _TeVii = new TeVii(); _TeVii.Init(tunerFilter); _TeVii.DevicePath = card.DevicePath; Log.Log.WriteFile("Check for {0}", _TeVii.Provider); _TeVii.CheckAndOpen(); if (_TeVii.IsSupported) { _diSEqCMotor = new DiSEqCMotor(_TeVii); _HWProvider = _TeVii; Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _TeVii); // DigitalDevices support _DigitalDevices = new DigitalDevices(tunerFilter); if (_DigitalDevices.IsGenericBDAS) { _genericbdas = _DigitalDevices; if (_DigitalDevices.IsSupported) { _ciMenu = _DigitalDevices; } return; // detected } Release.DisposeToNull(ref _DigitalDevices); Log.Log.WriteFile("Check for Conexant based card"); _conexant = new ConexantBDA(tunerFilter); if (_conexant.IsConexant) { Log.Log.WriteFile("Conexant BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _conexant); Release.DisposeToNull(ref _winTvCiModule); Log.Log.WriteFile("Check for GenPix BDA based card"); _genpix = new GenPixBDA(tunerFilter); if (_genpix.IsGenPix) { Log.Log.WriteFile("GenPix BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _genpix); Release.DisposeToNull(ref _winTvCiModule); Log.Log.WriteFile("Check for Generic DVB-S card"); _genericbdas = new GenericBDAS(tunerFilter); if (_genericbdas.IsGenericBDAS) { Log.Log.WriteFile("Generic BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _genericbdas); //Final WinTV-CI check for DVB-T hybrid cards Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); return; } Release.DisposeToNull(ref _winTvCiModule); } //ATSC checks bool isATSC = (card is TvCardATSC); if (isATSC) { Log.Log.WriteFile("Check for ViXS ATSC QAM card"); _isvixsatsc = new ViXSATSC(tunerFilter); if (_isvixsatsc.IsViXSATSC) { Log.Log.WriteFile("ViXS ATSC QAM card detected"); return; } Release.DisposeToNull(ref _isvixsatsc); Log.Log.WriteFile("Check for Generic ATSC QAM card"); _isgenericatsc = new GenericATSC(tunerFilter); if (_isgenericatsc.IsGenericATSC) { Log.Log.WriteFile("Generic ATSC QAM card detected"); return; } Release.DisposeToNull(ref _isgenericatsc); } } catch (Exception ex) { Log.Log.Write(ex); } }
/// <summary> /// Checks if the WinTV USB CI module is installed /// if so it adds it to the directshow graph /// in the following way: /// [Network Provider]->[Tuner Filter]->[Capture Filter]->[WinTvCI Filter] /// alternaively like this: /// [Network Provider]->[Tuner Filter]->[WinTvCI Filter] /// </summary> /// <param name="lastFilter">A reference to the last filter.</param> protected void AddWinTvCIModule(ref IBaseFilter lastFilter) { //check if the hauppauge wintv usb CI module is installed DsDevice[] capDevices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSCapture); DsDevice usbWinTvDevice = null; int hr; //Log.Log.WriteFile("AddWinTvCIModule: capDevices {0}", capDevices.Length); for (int capIndex = 0; capIndex < capDevices.Length; capIndex++) { if (capDevices[capIndex].Name != null) { //Log.Log.WriteFile("AddWinTvCIModule: {0}", capDevices[capIndex].Name.ToLower()); if (capDevices[capIndex].Name.ToUpperInvariant() == "WINTVCIUSBBDA SOURCE") { if (false == DevicesInUse.Instance.IsUsed(capDevices[capIndex])) { usbWinTvDevice = capDevices[capIndex]; break; } } } } if (usbWinTvDevice == null) { Log.Log.Info("dvb: WinTv CI module not detected."); return; } //wintv ci usb module found Log.Log.Info("dvb: WinTv CI module detected"); //add logic to check if WinTV device should be built with this DVB graph. TvBusinessLayer layer = new TvBusinessLayer(); int winTvTunerCardId = Int32.Parse(layer.GetSetting("winTvCiTuner", "-1").Value); if (winTvTunerCardId != this._cardId) { Log.Log.Info("dvb: WinTv CI module not assigned to card: {0}", _tunerDevice.Name); return; } Log.Log.Info("dvb: Adding WinTv CI to graph"); //add filter to graph IBaseFilter tmpCiFilter; try { hr = _graphBuilder.AddSourceFilterForMoniker(usbWinTvDevice.Mon, null, usbWinTvDevice.Name, out tmpCiFilter); } catch (Exception) { Log.Log.Info("dvb: failed to add WinTv CI filter to graph"); return; } if (hr != 0) { //cannot add filter to graph... Log.Log.Info("dvb: failed to add WinTv CI filter to graph"); if (tmpCiFilter != null) { //release WinTV CI resources& remove filter & render graph without it. winTvCiHandler.Shutdown(); _graphBuilder.RemoveFilter(tmpCiFilter); Release.ComObject("WintvUsbCI module", tmpCiFilter); } return; } //Check if WinTV CI is plugged in to USB port if not remove filter from graph. winTvCiHandler = new WinTvCiModule(tmpCiFilter); int winTVCIStatus = winTvCiHandler.Init(); //Log.Log.Info("WinTVCI: Init() returned: {0}", winTVCIStatus); if (winTVCIStatus != (int)HResult.Serverity.Success) { //release WinTV CI resources& remove filter & render graph without it. winTvCiHandler.Shutdown(); _graphBuilder.RemoveFilter(tmpCiFilter); Release.ComObject("WintvUsbCI module", tmpCiFilter); Log.Log.Info("dvb: WinTv CI not plugged in or driver not installed correctly!"); return; } //WinTV-CI tray icon no longer required as it is now fully native supported //now render ..->[WinTv USB] Log.Log.Info("dvb: Render ...->[WinTvUSB]"); hr = _capBuilder.RenderStream(null, null, lastFilter, null, tmpCiFilter); if (hr != 0) { Log.Log.Error("dvb: Render ...->[WinTvUSB] failed"); winTvCiHandler.Shutdown(); _graphBuilder.RemoveFilter(tmpCiFilter); Release.ComObject("WintvUsbCI module", tmpCiFilter); return; } _filterWinTvUsb = tmpCiFilter; _deviceWinTvUsb = usbWinTvDevice; DevicesInUse.Instance.Add(usbWinTvDevice); Log.Log.WriteFile("dvb: Setting lastFilter to WinTV CI"); lastFilter = _filterWinTvUsb; return; }
//anysee _anysee = null; #endregion //ctor /// <summary> /// Initializes a new instance of the <see cref="ConditionalAccess"/> class. /// </summary> /// <param name="tunerFilter">The tuner filter.</param> /// <param name="analyzerFilter">The capture filter.</param> /// <param name="winTvUsbCiFilter">The WinTV CI filter.</param> /// <param name="card">Determines the type of TV card</param> public ConditionalAccess(IBaseFilter tunerFilter, IBaseFilter analyzerFilter, IBaseFilter winTvUsbCiFilter, TvCardBase card) { try { //System.Diagnostics.Debugger.Launch(); if (card != null && card.DevicePath != null) { //fetch decrypt limit from DB and apply it. TvBusinessLayer layer = new TvBusinessLayer(); Card c = layer.GetCardByDevicePath(card.DevicePath); _decryptLimit = c.DecryptLimit; _useCam = c.CAM; _CamType = (CamType)c.CamType; Log.Log.WriteFile("CAM is {0} model", _CamType); } _mapSubChannels = new Dictionary<int, ConditionalAccessContext>(); TunerDri driTuner = card as TunerDri; if (driTuner != null) { _tunerDri = driTuner; _ciMenu = driTuner; } if (tunerFilter == null && analyzerFilter == null) return; //DVB checks. Conditional Access & DiSEqC etc. bool isDVBS = (card is TvCardDVBS); bool isDVBT = (card is TvCardDVBT); bool isDVBC = (card is TvCardDVBC); if (isDVBC || isDVBS || isDVBT) { Log.Log.WriteFile("Check for KNC"); // Lookup device index of current card. only counting KNC cards by device path int DeviceIndex = KNCDeviceLookup.GetDeviceIndex(card); _knc = new KNCAPI(tunerFilter, (uint)DeviceIndex); if (_knc.IsKNC) { //if (_knc.IsCamReady()) _ciMenu = _knc; // Register KNC CI Menu capabilities when CAM detected and ready Log.Log.WriteFile("KNC card detected"); return; } Release.DisposeToNull(ref _knc); Log.Log.WriteFile("Check for Digital Everywhere"); _digitalEveryWhere = new DigitalEverywhere(tunerFilter); if (_digitalEveryWhere.IsDigitalEverywhere) { Log.Log.WriteFile("Digital Everywhere card detected"); _diSEqCMotor = new DiSEqCMotor(_digitalEveryWhere); if (_digitalEveryWhere.IsCamReady()) { Log.Log.WriteFile("Digital Everywhere registering CI menu capabilities"); _ciMenu = _digitalEveryWhere; // Register FireDTV CI Menu capabilities when CAM detected and ready } //_digitalEveryWhere.ResetCAM(); return; } Release.DisposeToNull(ref _digitalEveryWhere); Log.Log.WriteFile("Check for Twinhan"); _twinhan = new Twinhan(tunerFilter); if (_twinhan.IsTwinhan) { Log.Log.WriteFile("Twinhan card detected"); _diSEqCMotor = new DiSEqCMotor(_twinhan); Log.Log.WriteFile("Twinhan registering CI menu capabilities"); _ciMenu = _twinhan; // Register Twinhan CI Menu capabilities when CAM detected and ready return; } Release.DisposeToNull(ref _twinhan); Log.Log.WriteFile("Check for TechnoTrend"); _technoTrend = new TechnoTrendAPI(tunerFilter); if (_technoTrend.IsTechnoTrend) { ////if (_technoTrend.IsCamPresent()) _ciMenu = _technoTrend; // Register Technotrend CI Menu capabilities Log.Log.WriteFile("TechnoTrend card detected"); return; } Release.DisposeToNull(ref _technoTrend); Log.Log.WriteFile("Check for Hauppauge"); _hauppauge = new Hauppauge(tunerFilter); if (_hauppauge.IsHauppauge) { Log.Log.WriteFile("Hauppauge card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); Log.Log.WriteFile("WinTV CI registering CI menu capabilities"); _ciMenu = _winTvCiModule; // WinTv CI Menu capabilities } _diSEqCMotor = new DiSEqCMotor(_hauppauge); return; } Release.DisposeToNull(ref _hauppauge); Release.DisposeToNull(ref _winTvCiModule); /*Log.Log.Info("Check for anysee"); _anysee = new anysee(tunerFilter, analyzerFilter); if (_anysee.Isanysee) { Log.Log.Info("anysee device detected"); return; }*/ Log.Log.WriteFile("Check for ProfRed"); _profred = new ProfRed(tunerFilter); if (_profred.IsProfRed) { Log.Log.WriteFile("ProfRed card detected"); _diSEqCMotor = new DiSEqCMotor(_profred); return; } Release.DisposeToNull(ref _profred); // TeVii support _TeVii = new TeVii(); _TeVii.Init(tunerFilter); _TeVii.DevicePath = card.DevicePath; Log.Log.WriteFile("Check for {0}", _TeVii.Provider); _TeVii.CheckAndOpen(); if (_TeVii.IsSupported) { _diSEqCMotor = new DiSEqCMotor(_TeVii); _HWProvider = _TeVii; Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _TeVii); // DigitalDevices support _DigitalDevices = new DigitalDevices(tunerFilter); if (_DigitalDevices.IsGenericBDAS) { _genericbdas = _DigitalDevices; if (_DigitalDevices.IsSupported) { _ciMenu = _DigitalDevices; } return; // detected } Release.DisposeToNull(ref _DigitalDevices); Log.Log.WriteFile("Check for Conexant based card"); _conexant = new ConexantBDA(tunerFilter); if (_conexant.IsConexant) { Log.Log.WriteFile("Conexant BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _conexant); Release.DisposeToNull(ref _winTvCiModule); Log.Log.WriteFile("Check for GenPix BDA based card"); _genpix = new GenPixBDA(tunerFilter); if (_genpix.IsGenPix) { Log.Log.WriteFile("GenPix BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _genpix); Release.DisposeToNull(ref _winTvCiModule); Log.Log.WriteFile("Check for Generic DVB-S card"); _genericbdas = new GenericBDAS(tunerFilter); if (_genericbdas.IsGenericBDAS) { Log.Log.WriteFile("Generic BDA card detected"); Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); } return; } Release.DisposeToNull(ref _genericbdas); //Final WinTV-CI check for DVB-T hybrid cards Log.Log.WriteFile("Check for Hauppauge WinTV CI"); if (winTvUsbCiFilter != null) { Log.Log.WriteFile("WinTV CI detected in graph - using capabilities..."); _winTvCiModule = new WinTvCiModule(winTvUsbCiFilter); return; } Release.DisposeToNull(ref _winTvCiModule); } //ATSC checks bool isATSC = (card is TvCardATSC); if (isATSC) { Log.Log.WriteFile("Check for ViXS ATSC QAM card"); _isvixsatsc = new ViXSATSC(tunerFilter); if (_isvixsatsc.IsViXSATSC) { Log.Log.WriteFile("ViXS ATSC QAM card detected"); return; } Release.DisposeToNull(ref _isvixsatsc); Log.Log.WriteFile("Check for Generic ATSC QAM card"); _isgenericatsc = new GenericATSC(tunerFilter); if (_isgenericatsc.IsGenericATSC) { Log.Log.WriteFile("Generic ATSC QAM card detected"); return; } Release.DisposeToNull(ref _isgenericatsc); } } catch (Exception ex) { Log.Log.Write(ex); } }