⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 provider.cpp

📁 完整的基于Conxant平台的USB电视棒的WIN驱动程序。
💻 CPP
字号:
/*+++ *******************************************************************\ 
* 
*  Copyright and Disclaimer: 
*  
*     --------------------------------------------------------------- 
*     This software is provided "AS IS" without warranty of any kind, 
*     either expressed or implied, including but not limited to the 
*     implied warranties of noninfringement, merchantability and/or 
*     fitness for a particular purpose.
*     --------------------------------------------------------------- 
*   
*     Copyright (c) 2004 Conexant Systems, Inc. 
*     All rights reserved. 
*
\******************************************************************* ---*/ 

#include "Provider.h"
#include "..\inc\CxCopyProtect.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CProvider::CProvider() :
    _ref_count(0),
    _p_provider_filter(0),
    _properties(0)
{
}

CProvider::~CProvider()
{
    if(isInitialized())
    {
        unInitialize();    
    }
}

bool
CProvider::initialize(IBaseFilter* p_filter)
{
    // make sure we are not allocating on top of something already valid
    if (isInitialized() == true)
    {
        _ref_count++;
        return true;
    }

    // do our initialization here
    _p_provider_filter = p_filter; 
    p_filter->AddRef();

    if (_p_provider_filter == 0)
    {
        return false;
    }

    if(FAILED(_p_provider_filter->QueryInterface(
        IID_IKsPropertySet,
        (void**)&_properties)))
    {
        _properties = NULL;
    }

    _ref_count++;
    return true;
}

bool
CProvider::unInitialize()
{
    if (_ref_count > 0)
    {
        _ref_count--;
    }

    if ((_ref_count <= 0) &&
        (isInitialized() == true))
    {
        if(_properties)
        {
            _properties->Release();
            _properties = NULL;
        }

        // do our uninitialization here
        _p_provider_filter->Release();
        _p_provider_filter = 0;
    }

    return true;
}

bool
CProvider::isInitialized()
{
    return (_p_provider_filter != 0);
}

DWORD
CProvider::getStatus()
{
    DWORD ret_val = ~0;

    if (isInitialized() == false)
    {
        return ret_val;
    }

    PROPERTY_DWORD cmd;
    ZeroMemory(&cmd, sizeof(PROPERTY_DWORD));
    cmd.property.Flags = KSPROPERTY_TYPE_GET;
    cmd.property.Id = CX_COPY_PROTECT_STATUS ;
    cmd.property.Set= PROPSETID_CX_COPY_PROTECT;

    DWORD bytes_returned = 0;
    HRESULT hresult = _properties->Get(
        PROPSETID_CX_COPY_PROTECT, 
        CX_COPY_PROTECT_STATUS, 
        &cmd.data,
        sizeof(cmd.data),
        &cmd.data, 
        sizeof(cmd.data),
        &bytes_returned);

    //DbgLog((LOG_TRACE, 0, TEXT("bytes returned ... {%d}"), bytes_returned));
    //DbgLog((LOG_TRACE, 0, TEXT("data ... {%d}"), cmd.data));
    if (SUCCEEDED(hresult))
    {
        ret_val =  cmd.data;
    }

    return ret_val;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -