Exemple #1
0
        //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);
            }
        }