📄 bdagraph.cpp
字号:
} while( hr != S_OK ); return VLC_SUCCESS;}/****************************************************************************** Submit a DVB-C Tune Request******************************************************************************/int BDAGraph::SubmitDVBCTuneRequest(){ HRESULT hr = S_OK; class localComPtr { public: IDVBTuneRequest* p_dvbc_tune_request; IDVBCLocator* p_dvbc_locator; localComPtr(): p_dvbc_tune_request(NULL), p_dvbc_locator(NULL) {}; ~localComPtr() { if( p_dvbc_tune_request ) p_dvbc_tune_request->Release(); if( p_dvbc_locator ) p_dvbc_locator->Release(); } } l; long l_frequency, l_symbolrate; int i_qam; ModulationType i_qam_mod; l_frequency = l_symbolrate = i_qam = -1; l_frequency = var_GetInteger( p_access, "dvb-frequency" ); l_symbolrate = var_GetInteger( p_access, "dvb-srate" ); i_qam = var_GetInteger( p_access, "dvb-modulation" ); i_qam_mod = BDA_MOD_NOT_SET; if( i_qam == 16 ) i_qam_mod = BDA_MOD_16QAM; if( i_qam == 32 ) i_qam_mod = BDA_MOD_32QAM; if( i_qam == 64 ) i_qam_mod = BDA_MOD_64QAM; if( i_qam == 128 ) i_qam_mod = BDA_MOD_128QAM; if( i_qam == 256 ) i_qam_mod = BDA_MOD_256QAM; guid_network_type = CLSID_DVBCNetworkProvider; hr = CreateTuneRequest(); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBCTuneRequest: "\ "Cannot create Tune Request: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = p_tune_request->QueryInterface( IID_IDVBTuneRequest, (void**)&l.p_dvbc_tune_request ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBCTuneRequest: "\ "Cannot QI for IDVBTuneRequest: hr=0x%8lx", hr ); return VLC_EGENERIC; } l.p_dvbc_tune_request->put_ONID( -1 ); l.p_dvbc_tune_request->put_SID( -1 ); l.p_dvbc_tune_request->put_TSID( -1 ); hr = ::CoCreateInstance( CLSID_DVBCLocator, 0, CLSCTX_INPROC, IID_IDVBCLocator, (void**)&l.p_dvbc_locator ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBCTuneRequest: "\ "Cannot create the DVB-C Locator: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = S_OK; if( l_frequency > 0 ) hr = l.p_dvbc_locator->put_CarrierFrequency( l_frequency ); if( SUCCEEDED( hr ) && l_symbolrate > 0 ) hr = l.p_dvbc_locator->put_SymbolRate( l_symbolrate ); if( SUCCEEDED( hr ) && i_qam_mod != BDA_MOD_NOT_SET ) hr = l.p_dvbc_locator->put_Modulation( i_qam_mod ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBCTuneRequest: "\ "Cannot set tuning parameters on Locator: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = p_tune_request->put_Locator( l.p_dvbc_locator ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBCTuneRequest: "\ "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, "SubmitDVBCTuneRequest: "\ "Cannot Build the Graph: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = Start(); } while( hr != S_OK ); return VLC_SUCCESS;}/****************************************************************************** Submit a DVB-S Tune Request******************************************************************************/int BDAGraph::SubmitDVBSTuneRequest(){ HRESULT hr = S_OK; class localComPtr { public: IDVBTuneRequest* p_dvbs_tune_request; IDVBSLocator* p_dvbs_locator; IDVBSTuningSpace* p_dvbs_tuning_space; localComPtr(): p_dvbs_tune_request(NULL), p_dvbs_locator(NULL), p_dvbs_tuning_space(NULL) {}; ~localComPtr() { if( p_dvbs_tuning_space ) p_dvbs_tuning_space->Release(); if( p_dvbs_tune_request ) p_dvbs_tune_request->Release(); if( p_dvbs_locator ) p_dvbs_locator->Release(); } } l; long l_frequency, l_symbolrate, l_azimuth, l_elevation, l_longitude; long l_lnb_lof1, l_lnb_lof2, l_lnb_slof, l_inversion, l_network_id; char* psz_polarisation; Polarisation i_polar; SpectralInversion i_inversion; VARIANT_BOOL b_west; l_frequency = l_symbolrate = l_azimuth = l_elevation = l_longitude = -1; l_lnb_lof1 = l_lnb_lof2 = l_lnb_slof = l_inversion = l_network_id = -1; l_frequency = var_GetInteger( p_access, "dvb-frequency" ); l_symbolrate = var_GetInteger( p_access, "dvb-srate" ); l_azimuth = var_GetInteger( p_access, "dvb-azimuth" ); l_elevation = var_GetInteger( p_access, "dvb-elevation" ); l_longitude = var_GetInteger( p_access, "dvb-longitude" ); l_lnb_lof1 = var_GetInteger( p_access, "dvb-lnb-lof1" ); l_lnb_lof2 = var_GetInteger( p_access, "dvb-lnb-lof2" ); l_lnb_slof = var_GetInteger( p_access, "dvb-lnb-slof" ); psz_polarisation = var_GetNonEmptyString( p_access, "dvb-polarisation" ); l_inversion = var_GetInteger( p_access, "dvb-inversion" ); l_network_id = var_GetInteger( p_access, "dvb-network_id" ); b_west = ( l_longitude < 0 ) ? TRUE : FALSE; i_polar = BDA_POLARISATION_NOT_SET; if( psz_polarisation != NULL ) switch( toupper( psz_polarisation[0] ) ) { case 'H': i_polar = BDA_POLARISATION_LINEAR_H; break; case 'V': i_polar = BDA_POLARISATION_LINEAR_V; break; case 'L': i_polar = BDA_POLARISATION_CIRCULAR_L; break; case 'R': i_polar = BDA_POLARISATION_CIRCULAR_R; break; } i_inversion = BDA_SPECTRAL_INVERSION_NOT_SET; if( l_inversion == 0 ) i_inversion = BDA_SPECTRAL_INVERSION_NORMAL; if( l_inversion == 1 ) i_inversion = BDA_SPECTRAL_INVERSION_INVERTED; if( l_inversion == 2 ) i_inversion = BDA_SPECTRAL_INVERSION_AUTOMATIC; guid_network_type = CLSID_DVBSNetworkProvider; hr = CreateTuneRequest(); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "Cannot create Tune Request: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = p_tune_request->QueryInterface( IID_IDVBTuneRequest, (void**)&l.p_dvbs_tune_request ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "Cannot QI for IDVBTuneRequest: hr=0x%8lx", hr ); return VLC_EGENERIC; } l.p_dvbs_tune_request->put_ONID( -1 ); l.p_dvbs_tune_request->put_SID( -1 ); l.p_dvbs_tune_request->put_TSID( -1 ); hr = ::CoCreateInstance( CLSID_DVBSLocator, 0, CLSCTX_INPROC, IID_IDVBSLocator, (void**)&l.p_dvbs_locator ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "Cannot create the DVBS Locator: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = p_tuning_space->QueryInterface( IID_IDVBSTuningSpace, (void**)&l.p_dvbs_tuning_space ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "Cannot QI for IDVBSTuningSpace: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = S_OK; if( l_frequency > 0 ) hr = l.p_dvbs_locator->put_CarrierFrequency( l_frequency ); if( SUCCEEDED( hr ) && l_symbolrate > 0 ) hr = l.p_dvbs_locator->put_SymbolRate( l_symbolrate ); if( SUCCEEDED( hr ) && l_azimuth > 0 ) hr = l.p_dvbs_locator->put_Azimuth( l_azimuth ); if( SUCCEEDED( hr ) && l_elevation > 0 ) hr = l.p_dvbs_locator->put_Elevation( l_elevation ); if( SUCCEEDED( hr ) ) hr = l.p_dvbs_locator->put_OrbitalPosition( labs( l_longitude ) ); if( SUCCEEDED( hr ) ) hr = l.p_dvbs_locator->put_WestPosition( b_west ); if( SUCCEEDED( hr ) && i_polar != BDA_POLARISATION_NOT_SET ) hr = l.p_dvbs_locator->put_SignalPolarisation( i_polar ); if( SUCCEEDED( hr ) && l_lnb_lof1 > 0 ) hr = l.p_dvbs_tuning_space->put_LowOscillator( l_lnb_lof1 ); if( SUCCEEDED( hr ) && l_lnb_lof2 > 0 ) hr = l.p_dvbs_tuning_space->put_HighOscillator( l_lnb_lof2 ); if( SUCCEEDED( hr ) && l_lnb_slof > 0 ) hr = l.p_dvbs_tuning_space->put_LNBSwitch( l_lnb_slof ); if( SUCCEEDED( hr ) && i_inversion != BDA_SPECTRAL_INVERSION_NOT_SET ) hr = l.p_dvbs_tuning_space->put_SpectralInversion( i_inversion ); if( SUCCEEDED( hr ) && l_network_id > 0 ) hr = l.p_dvbs_tuning_space->put_NetworkID( l_network_id ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "Cannot set tuning parameters on Locator: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = p_tune_request->put_Locator( l.p_dvbs_locator ); if( FAILED( hr ) ) { msg_Warn( p_access, "SubmitDVBSTuneRequest: "\ "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, "SubmitDVBSTuneRequest: "\ "Cannot Build the Graph: hr=0x%8lx", hr ); return VLC_EGENERIC; } hr = Start(); } while( hr != S_OK ); return VLC_SUCCESS;}/****************************************************************************** Load the Tuning Space from System Tuning Spaces according to the* Network Type requested******************************************************************************/HRESULT BDAGraph::CreateTuneRequest(){ HRESULT hr = S_OK; GUID guid_this_network_type; class localComPtr { public: ITuningSpaceContainer* p_tuning_space_container; IEnumTuningSpaces* p_tuning_space_enum; ITuningSpace* p_this_tuning_space; localComPtr(): p_tuning_space_container(NULL), p_tuning_space_enum(NULL), p_this_tuning_space(NULL) {}; ~localComPtr() { if( p_tuning_space_container ) p_tuning_space_container->Release(); if( p_tuning_space_enum ) p_tuning_space_enum->Release(); if( p_this_tuning_space ) p_this_tuning_space->Release(); } } l; /* A Tuning Space may already have been set up. If it is for the same * network type then all is well. Otherwise, reset the Tuning Space and get * a new one */ if( p_tuning_space ) { hr = p_tuning_space->get__NetworkType( &guid_this_network_type ); if( FAILED( hr ) ) guid_this_network_type = GUID_NULL; if( guid_this_network_type == guid_network_type ) { return S_OK; } else { p_tuning_space->Release(); p_tuning_space = NULL; } } /* Force use of the first available Tuner Device during Build */ l_tuner_used = -1; /* Get the SystemTuningSpaces container to enumerate through all the * defined tuning spaces */ hr = ::CoCreateInstance( CLSID_SystemTuningSpaces, 0, CLSCTX_INPROC, IID_ITuningSpaceContainer, (void**)&l.p_tuning_space_container ); if( FAILED( hr ) ) { msg_Warn( p_access, "CreateTuneRequest: "\ "Cannot CoCreate SystemTuningSpaces: hr=0x%8lx", hr ); return hr; } hr = l.p_tuning_space_container->get_EnumTuningSpaces( &l.p_tuning_space_enum ); if( FAILED( hr ) ) { msg_Warn( p_access, "CreateTuneRequest: "\ "Cannot create SystemTuningSpaces Enumerator: hr=0x%8lx", hr ); return hr; } while( l.p_tuning_space_enum->Next( 1, &l.p_this_tuning_space, NULL ) == S_OK ) { hr = l.p_this_tuning_space->get__NetworkType( &guid_this_network_type ); /* GUID_NULL means a non-BDA network was found e.g analog * Ignore failures and non-BDA networks and keep looking */ if( FAILED( hr ) ) guid_this_network_type == GUID_NULL; if( guid_this_network_type == guid_network_type ) { hr = l.p_this_tuning_space->QueryInterface( IID_ITuningSpace, (void**)&p_tuning_space ); if( FAILED( hr ) ) { msg_Warn( p_access, "CreateTuneRequest: "\ "Cannot QI Tuning Space: hr=0x%8lx", hr );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -