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

📄 bdagraph.cpp

📁 vlc源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/***************************************************************************** * bdagraph.cpp : DirectShow BDA graph for vlc ***************************************************************************** * Copyright( C ) 2007 the VideoLAN team * * Author: Ken Self <kens@campoz.fslife.co.uk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or *( at your option ) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include "bdagraph.h"#include <ctype.h>/**************************************************************************** * Interfaces for calls from C ****************************************************************************/extern "C" {    void dvb_newBDAGraph( access_t* p_access )    {        p_access->p_sys->p_bda_module = new BDAGraph( p_access );    };    void dvb_deleteBDAGraph( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            delete p_access->p_sys->p_bda_module;    };    int dvb_SubmitATSCTuneRequest( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->SubmitATSCTuneRequest();        return VLC_EGENERIC;    };    int dvb_SubmitDVBTTuneRequest( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->SubmitDVBTTuneRequest();        return VLC_EGENERIC;    };    int dvb_SubmitDVBCTuneRequest( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->SubmitDVBCTuneRequest();        return VLC_EGENERIC;    };    int dvb_SubmitDVBSTuneRequest( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->SubmitDVBSTuneRequest();        return VLC_EGENERIC;    };    long dvb_GetBufferSize( access_t* p_access )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->GetBufferSize();        return -1;    };    long dvb_ReadBuffer( access_t* p_access, long* l_buffer_len, BYTE* p_buff )    {        if( p_access->p_sys->p_bda_module )            return p_access->p_sys->p_bda_module->ReadBuffer( l_buffer_len,                p_buff );        return -1;    };};/****************************************************************************** Constructor*****************************************************************************/BDAGraph::BDAGraph( access_t* p_this ):    p_access( p_this ),    guid_network_type(GUID_NULL),    l_tuner_used(-1),    d_graph_register( 0 ){    b_ready = FALSE;    p_tuning_space = NULL;    p_tune_request = NULL;    p_media_control = NULL;    p_filter_graph = NULL;    p_system_dev_enum = NULL;    p_network_provider = p_tuner_device = p_capture_device = NULL;    p_sample_grabber = p_mpeg_demux = p_transport_info = NULL;    p_scanning_tuner = NULL;    p_grabber = NULL;    /* Initialize COM - MS says to use CoInitializeEx in preference to     * CoInitialize */    CoInitializeEx( 0, COINIT_APARTMENTTHREADED );}/****************************************************************************** Destructor*****************************************************************************/BDAGraph::~BDAGraph(){    Destroy();    CoUninitialize();}/****************************************************************************** Submit an ATSC Tune Request*****************************************************************************/int BDAGraph::SubmitATSCTuneRequest(){    HRESULT hr = S_OK;    class localComPtr    {        public:        IATSCChannelTuneRequest* p_atsc_tune_request;        IATSCLocator* p_atsc_locator;        localComPtr(): p_atsc_tune_request(NULL), p_atsc_locator(NULL) {};        ~localComPtr()        {            if( p_atsc_tune_request )                p_atsc_tune_request->Release();            if( p_atsc_locator )                p_atsc_locator->Release();        }    } l;    long l_major_channel, l_minor_channel, l_physical_channel;    l_major_channel = l_minor_channel = l_physical_channel = -1;/*    l_major_channel = var_GetInteger( p_access, "dvb-major-channel" );    l_minor_channel = var_GetInteger( p_access, "dvb-minor-channel" );    l_physical_channel = var_GetInteger( p_access, "dvb-physical-channel" );*/    guid_network_type = CLSID_ATSCNetworkProvider;    hr = CreateTuneRequest();    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitATSCTuneRequest: "\            "Cannot create Tuning Space: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = p_tune_request->QueryInterface( IID_IATSCChannelTuneRequest,        (void**)&l.p_atsc_tune_request );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitATSCTuneRequest: "\            "Cannot QI for IATSCChannelTuneRequest: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = ::CoCreateInstance( CLSID_ATSCLocator, 0, CLSCTX_INPROC,                             IID_IATSCLocator, (void**)&l.p_atsc_locator );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitATSCTuneRequest: "\            "Cannot create the ATSC locator: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = S_OK;    if( l_major_channel > 0 )        hr = l.p_atsc_tune_request->put_Channel( l_major_channel );    if( SUCCEEDED( hr ) && l_minor_channel > 0 )        hr = l.p_atsc_tune_request->put_MinorChannel( l_minor_channel );    if( SUCCEEDED( hr ) && l_physical_channel > 0 )        hr = l.p_atsc_locator->put_PhysicalChannel( l_physical_channel );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitATSCTuneRequest: "\            "Cannot set tuning parameters: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = p_tune_request->put_Locator( l.p_atsc_locator );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitATSCTuneRequest: "\            "Cannot put the locator: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    /* Build and Run the Graph. If a Tuner device is in use the graph will     * fail to run. Repeated calls to build will check successive tuner     * devices */    do    {        hr = Build();        if( FAILED( hr ) )        {            msg_Warn( p_access, "SubmitATSCTuneRequest: "\                "Cannot Build the Graph: hr=0x%8lx", hr );            return VLC_EGENERIC;        }        hr = Start();    }    while( hr != S_OK );    return VLC_SUCCESS;}/****************************************************************************** Submit a DVB-T Tune Request******************************************************************************/int BDAGraph::SubmitDVBTTuneRequest(){    HRESULT hr = S_OK;    class localComPtr    {        public:        IDVBTuneRequest* p_dvbt_tune_request;        IDVBTLocator* p_dvbt_locator;        localComPtr(): p_dvbt_tune_request(NULL), p_dvbt_locator(NULL) {};        ~localComPtr()        {            if( p_dvbt_tune_request )                p_dvbt_tune_request->Release();            if( p_dvbt_locator )                p_dvbt_locator->Release();        }    } l;    long l_frequency, l_bandwidth, l_hp_fec, l_lp_fec, l_guard;    long l_transmission, l_hierarchy;    BinaryConvolutionCodeRate i_hp_fec, i_lp_fec;    GuardInterval             i_guard;    TransmissionMode          i_transmission;    HierarchyAlpha            i_hierarchy;    l_frequency = l_bandwidth = l_hp_fec = l_lp_fec = l_guard = -1;    l_transmission = l_hierarchy = -1;    l_frequency = var_GetInteger( p_access, "dvb-frequency" );    l_bandwidth = var_GetInteger( p_access, "dvb-bandwidth" );    l_hp_fec = var_GetInteger( p_access, "dvb-code-rate-hp" );    l_lp_fec = var_GetInteger( p_access, "dvb-code-rate-lp" );    l_guard = var_GetInteger( p_access, "dvb-guard" );    l_transmission = var_GetInteger( p_access, "dvb-transmission" );    l_hierarchy = var_GetInteger( p_access, "dvb-hierarchy" );    i_hp_fec = BDA_BCC_RATE_NOT_SET;    if( l_hp_fec == 1 )        i_hp_fec = BDA_BCC_RATE_1_2;    if( l_hp_fec == 2 )        i_hp_fec = BDA_BCC_RATE_2_3;    if( l_hp_fec == 3 )        i_hp_fec = BDA_BCC_RATE_3_4;    if( l_hp_fec == 4 )        i_hp_fec = BDA_BCC_RATE_5_6;    if( l_hp_fec == 5 )        i_hp_fec = BDA_BCC_RATE_7_8;    i_lp_fec = BDA_BCC_RATE_NOT_SET;    if( l_lp_fec == 1 )        i_lp_fec = BDA_BCC_RATE_1_2;    if( l_lp_fec == 2 )        i_lp_fec = BDA_BCC_RATE_2_3;    if( l_lp_fec == 3 )        i_lp_fec = BDA_BCC_RATE_3_4;    if( l_lp_fec == 4 )        i_lp_fec = BDA_BCC_RATE_5_6;    if( l_lp_fec == 5 )        i_lp_fec = BDA_BCC_RATE_7_8;    i_guard = BDA_GUARD_NOT_SET;    if( l_guard == 32 )        i_guard = BDA_GUARD_1_32;    if( l_guard == 16 )        i_guard = BDA_GUARD_1_16;    if( l_guard == 8 )        i_guard = BDA_GUARD_1_8;    if( l_guard == 4 )        i_guard = BDA_GUARD_1_4;    i_transmission = BDA_XMIT_MODE_NOT_SET;    if( l_transmission == 2 )        i_transmission = BDA_XMIT_MODE_2K;    if( l_transmission == 8 )        i_transmission = BDA_XMIT_MODE_8K;    i_hierarchy = BDA_HALPHA_NOT_SET;    if( l_hierarchy == 1 )        i_hierarchy = BDA_HALPHA_1;    if( l_hierarchy == 2 )        i_hierarchy = BDA_HALPHA_2;    if( l_hierarchy == 4 )        i_hierarchy = BDA_HALPHA_4;    guid_network_type = CLSID_DVBTNetworkProvider;    hr = CreateTuneRequest();    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitDVBTTuneRequest: "\            "Cannot create Tune Request: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = p_tune_request->QueryInterface( IID_IDVBTuneRequest,        (void**)&l.p_dvbt_tune_request );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitDVBTTuneRequest: "\            "Cannot QI for IDVBTuneRequest: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    l.p_dvbt_tune_request->put_ONID( -1 );    l.p_dvbt_tune_request->put_SID( -1 );    l.p_dvbt_tune_request->put_TSID( -1 );    hr = ::CoCreateInstance( CLSID_DVBTLocator, 0, CLSCTX_INPROC,        IID_IDVBTLocator, (void**)&l.p_dvbt_locator );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitDVBTTuneRequest: "\            "Cannot create the DVBT Locator: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = S_OK;    if( l_frequency > 0 )        hr = l.p_dvbt_locator->put_CarrierFrequency( l_frequency );    if( SUCCEEDED( hr ) && l_bandwidth > 0 )        hr = l.p_dvbt_locator->put_Bandwidth( l_bandwidth );    if( SUCCEEDED( hr ) && i_hp_fec != BDA_BCC_RATE_NOT_SET )        hr = l.p_dvbt_locator->put_InnerFECRate( i_hp_fec );    if( SUCCEEDED( hr ) && i_lp_fec != BDA_BCC_RATE_NOT_SET )        hr = l.p_dvbt_locator->put_LPInnerFECRate( i_lp_fec );    if( SUCCEEDED( hr ) && i_guard != BDA_GUARD_NOT_SET )        hr = l.p_dvbt_locator->put_Guard( i_guard );    if( SUCCEEDED( hr ) && i_transmission != BDA_XMIT_MODE_NOT_SET )        hr = l.p_dvbt_locator->put_Mode( i_transmission );    if( SUCCEEDED( hr ) && i_hierarchy != BDA_HALPHA_NOT_SET )        hr = l.p_dvbt_locator->put_HAlpha( i_hierarchy );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitDVBTTuneRequest: "\            "Cannot set tuning parameters on Locator: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    hr = p_tune_request->put_Locator( l.p_dvbt_locator );    if( FAILED( hr ) )    {        msg_Warn( p_access, "SubmitDVBTTuneRequest: "\            "Cannot put the locator: hr=0x%8lx", hr );        return VLC_EGENERIC;    }    /* Build and Run the Graph. If a Tuner device is in use the graph will     * fail to run. Repeated calls to build will check successive tuner     * devices */    do    {        hr = Build();        if( FAILED( hr ) )        {            msg_Warn( p_access, "SubmitDVBTTuneRequest: "\                "Cannot Build the Graph: hr=0x%8lx", hr );            return VLC_EGENERIC;        }        hr = Start();

⌨️ 快捷键说明

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