Postby Vayshya » 25 Jan 2007 12:22
Here is full code for VLC 0.8.1, later I will test it and compile for 0.8.6a.
...
static void ConfigTuner( vlc_object_t *, ICaptureGraphBuilder2 *,
IBaseFilter * );
...
#define CHANNEL_TEXT N_("TV Channel selection")
#define CHANNEL_LONGTEXT N_( \
"You can select the tv channel that will be used by the DirectShow plugin." )
#define COUNTRY_TEXT N_("Country selection")
#define COUNTRY_LONGTEXT N_( \
"You can select the country that will be used by the DirectShow plugin." )
#define INPUT_TEXT N_("Input selection (Cable/Antenna)")
#define INPUT_LONGTEXT N_( \
"You can select the input that will be used by the DirectShow plugin." )
#define TVSTANDARD_TEXT N_("TV standard selection")
#define TVSTANDARD_LONGTEXT N_( \
"You can select TV standard that will be used by the DirectShow plugin." )
...
add_integer( "dshow-channel", 1, NULL, CHANNEL_TEXT, CHANNEL_LONGTEXT,
VLC_TRUE );
add_integer( "dshow-country", 1, NULL, COUNTRY_TEXT, COUNTRY_LONGTEXT,
VLC_TRUE );
add_bool( "dshow-input", VLC_FALSE, NULL, INPUT_TEXT, INPUT_LONGTEXT,
VLC_TRUE );
add_integer( "dshow-tvstandard", 1, NULL, TVSTANDARD_TEXT, TVSTANDARD_LONGTEXT,
VLC_TRUE );
...
var_Create( p_this, "dshow-channel", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_this, "dshow-country", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_this, "dshow-input", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_this, "dshow-tvstandard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
...
ConfigTuner( p_this, p_sys->p_capture_graph_builder2,
p_device_filter );
...
static void ConfigTuner( vlc_object_t *p_this,
ICaptureGraphBuilder2 *p_capture_graph,
IBaseFilter *p_device_filter )
{
int i_channel, i_country;
long l_modes = 0;
bool b_input;
HRESULT hr;
int i_tvstandard;
i_channel = var_GetInteger( p_this, "dshow-channel" );
i_country = var_GetInteger( p_this, "dshow-country" );
b_input = var_GetBool( p_this, "dshow-input" );
i_tvstandard = var_GetInteger( p_this, "dshow-tvstandard" );
msg_Dbg( p_this, "Config channel: %i, country: %i",
i_channel, i_country );
msg_Dbg( p_this, "Config tvstandard: %i",
i_tvstandard );
if( p_capture_graph )
{
IAMTVTuner *p_TV = NULL;
hr = p_capture_graph->FindInterface( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved,
p_device_filter,
IID_IAMTVTuner, (void **)&p_TV );
if( FAILED(hr) )
{
hr = p_capture_graph->FindInterface( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
p_device_filter,
IID_IAMTVTuner,
(void **)&p_TV );
}
if( SUCCEEDED(hr) )
{
hr = p_TV->GetAvailableModes(&l_modes);
if (SUCCEEDED(hr) && (l_modes & AMTUNER_MODE_TV))
{
hr = p_TV->put_Mode(AMTUNER_MODE_TV);
}
if ( b_input )
p_TV->put_InputType( 0, TunerInputAntenna );
else
p_TV->put_InputType( 0, TunerInputCable );
p_TV->put_CountryCode( (long)i_country );
p_TV->put_Channel( (long)i_channel,
AMTUNER_SUBCHAN_NO_TUNE,
AMTUNER_SUBCHAN_NO_TUNE );
p_TV->Release();
}
IAMAnalogVideoDecoder *p_TV2 = NULL;
hr = p_capture_graph->FindInterface( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved,
p_device_filter,
IID_IAMAnalogVideoDecoder, (void **)&p_TV2 );
if( FAILED(hr) )
{
hr = p_capture_graph->FindInterface( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
p_device_filter,
IID_IAMAnalogVideoDecoder,
(void **)&p_TV2 );
}
if( SUCCEEDED(hr) )
{
hr = p_TV2->put_TVFormat( (long)i_tvformat);
p_TV->Release();
}
}
}