[vlc-devel] Add frequency and video standard options in dshow - rev2

Rémi Denis-Courmont remi at remlab.net
Thu Aug 5 22:00:21 CEST 2010


	Hello,

Le jeudi 5 août 2010 19:04:26 Manol Manolov, vous avez écrit :
> Here is the patch for dshow (applies to windows analog tv). I tested it
> with two tuners, but will be always nice to be tested with more. Note,
> from command line dshow-tuner-standard accepts integer. This might need
> to be changed...
> (Revision 2)

Are the new definitions copied verbatim from a copyright header or are they 
rewritten from scratch? I am not sure we can include say, MSVC headers into 
VLC legally.

Did you try to get the necessary update to MingW folks?


Some comments inline...

@@ -260,6 +299,13 @@ vlc_module_begin ()
 
 vlc_module_end ()
 
+
+/*****************************************************************************
+ * DirectShow GUIDs.
+ * Easier to define them here as mingw doesn't provide them all.
+ 
*****************************************************************************/
+const GUID PROPSETID_TUNER = {0x6a2e0605, 0x28e4, 0x11d0, {0xa1, 0x8c, 0x00, 
0xa0, 0xc9, 0x11, 0x89, 0x56}};

How about adding a static qualifier?

+
 /*****************************************************************************
  * DirectShow elementary stream descriptor
  *****************************************************************************/
@@ -426,6 +472,10 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t 
*p_sys,
     var_Create( p_this, "dshow-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
     var_Create( p_this, "dshow-tuner-channel",
                 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_this, "dshow-tuner-frequency",
+                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_this, "dshow-tuner-standard",
+                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );

The old surrounding code calls var_Create() for historical reasons. You can 
probably avoid this completely, if you use var_Inherit instead of var_Get 
later.

     var_Create( p_this, "dshow-tuner-country",
                 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_this, "dshow-tuner-input",
@@ -2227,11 +2277,15 @@ static void ConfigTuner( vlc_object_t *p_this, 
ICaptureGraphBuilder2 *p_graph,
     i_country = var_GetInteger( p_this, "dshow-tuner-country" );
     i_input = var_GetInteger( p_this, "dshow-tuner-input" );
     i_amtuner_mode = var_GetInteger( p_this, "dshow-amtuner-mode" );
+    i_frequency = var_GetInteger( p_this, "dshow-tuner-frequency" );
+    i_standard =
+        i_standards_list[var_CreateGetInteger( p_this, "dshow-tuner-standard" 
)];

You should really not need to 'Create' the variable again here.

Also, for good measure, you should probably check that the value is within the 
boundary of the table. But I don't understand why you need that level of 
indirection at all??

+
+    if( !i_channel && !i_frequency && !i_country && !i_input ) return; /* 
Nothing to do */
 
-    if( !i_channel && !i_country && !i_input ) return; /* Nothing to do */
+    msg_Dbg( p_this, "tuner config: channel %i, frequency %i, country %i, 
input type %i, standard %s",
+             i_channel, i_frequency, i_country, i_input, 
ppsz_standards_list_text[i_standard] );
 
-    msg_Dbg( p_this, "tuner config: channel %i, country %i, input type %i",
-             i_channel, i_country, i_input );
 
     hr = p_graph->FindInterface( &PIN_CATEGORY_CAPTURE, 
&MEDIATYPE_Interleaved,
                                  p_device_filter, IID_IAMTVTuner,
@@ -2266,7 +2320,107 @@ static void ConfigTuner( vlc_object_t *p_this, 
ICaptureGraphBuilder2 *p_graph,
     else if( i_input == 2 ) p_TV->put_InputType( 0, TunerInputAntenna );
 
     p_TV->put_CountryCode( i_country );
-    p_TV->put_Channel( i_channel, AMTUNER_SUBCHAN_NO_TUNE,
+
+    if( i_frequency <= 0 ) p_TV->put_Channel( i_channel, 
AMTUNER_SUBCHAN_NO_TUNE,
                        AMTUNER_SUBCHAN_NO_TUNE );
+
+    if( i_frequency > 0 || i_standard > 0) {
+        IKsPropertySet *pKs = NULL;
+        DWORD dw_supported = 0;
+        KSPROPERTY_TUNER_MODE_CAPS_S ModeCaps;
+        KSPROPERTY_TUNER_FREQUENCY_S Frequency;
+        KSPROPERTY_TUNER_STANDARD_S Standard;
+
+        hr = p_TV->QueryInterface(IID_IKsPropertySet,(void **)&pKs);
+        if (FAILED(hr))
+        {
+            msg_Dbg( p_this, "Couldn't QI for IKsPropertySet" );
+            return;

I guess you are leaking p_TV here.

+        }
+
+        memset(&ModeCaps,0,sizeof(KSPROPERTY_TUNER_MODE_CAPS_S));
+        memset(&Frequency,0,sizeof(KSPROPERTY_TUNER_FREQUENCY_S));
+        memset(&Standard,0,sizeof(KSPROPERTY_TUNER_STANDARD_S));
+        ModeCaps.Mode = AMTUNER_MODE_TV;
+
+        hr = pKs->QuerySupported(PROPSETID_TUNER,
+                KSPROPERTY_TUNER_MODE_CAPS,&dw_supported);
+        if(SUCCEEDED(hr) && dw_supported&KSPROPERTY_SUPPORT_GET)
+        {
+            DWORD cbBytes=0;
+            hr = pKs->Get(PROPSETID_TUNER,KSPROPERTY_TUNER_MODE_CAPS,
+                INSTANCEDATA_OF_PROPERTY_PTR(&ModeCaps),
+                INSTANCEDATA_OF_PROPERTY_SIZE(ModeCaps),
+                &ModeCaps,
+                sizeof(ModeCaps),
+                &cbBytes);
+        }
+        else
+        {
+            msg_Dbg( p_this, "KSPROPERTY_TUNER_MODE_CAPS not supported!" );
+            return;

Also pKs and p_TV here. And in a bunch of other paths further.

Best regards,

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list