]> git.sesse.net Git - vlc/blobdiff - modules/access/dshow/dshow.cpp
Fix the strings.
[vlc] / modules / access / dshow / dshow.cpp
index 9e5113133e4e35a818f6bc4a74c0248a3906ca4d..5285686ccb5dc2e36a77b08a58bbf8e9965a66df 100644 (file)
 #include <string.h>
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/vout.h>
+#include <vlc_input.h>
+#include <vlc_access.h>
+#include <vlc_demux.h>
+#include <vlc_vout.h>
+#include <vlc_interface.h>
 
 #include "common.h"
 #include "filter.h"
@@ -69,13 +72,23 @@ static void ConfigTuner( vlc_object_t *, ICaptureGraphBuilder2 *,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static char *ppsz_vdev[] = { "", "none" };
-static char *ppsz_vdev_text[] = { N_("Default"), N_("None") };
-static char *ppsz_adev[] = { "", "none" };
-static char *ppsz_adev_text[] = { N_("Default"), N_("None") };
+static const char *ppsz_vdev[] = { "", "none" };
+static const char *ppsz_vdev_text[] = { N_("Default"), N_("None") };
+static const char *ppsz_adev[] = { "", "none" };
+static const char *ppsz_adev_text[] = { N_("Default"), N_("None") };
 static int  pi_tuner_input[] = { 0, 1, 2 };
-static char *ppsz_tuner_input_text[] =
+static const char *ppsz_tuner_input_text[] =
     {N_("Default"), N_("Cable"), N_("Antenna")};
+static const int pi_amtuner_mode[]  = { AMTUNER_MODE_DEFAULT,
+                                 AMTUNER_MODE_TV,
+                                 AMTUNER_MODE_FM_RADIO,
+                                 AMTUNER_MODE_AM_RADIO,
+                                 AMTUNER_MODE_DSS };
+static const char *ppsz_amtuner_mode_text[] = { N_("Default"),
+                                          N_("TV"),
+                                          N_("FM radio"),
+                                          N_("AM radio"),
+                                          N_("DSS") };
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
@@ -86,17 +99,16 @@ static char *ppsz_tuner_input_text[] =
     "Name of the video device that will be used by the " \
     "DirectShow plugin. If you don't specify anything, the default device " \
     "will be used.")
-/// \bug [String] size stuff should be on video !
 #define ADEV_TEXT N_("Audio device name")
 #define ADEV_LONGTEXT N_( \
     "Name of the audio device that will be used by the " \
     "DirectShow plugin. If you don't specify anything, the default device " \
-    "will be used. You can specify a standard size (cif, d1, ...) or <width>x<height>")
+    "will be used. ")
 #define SIZE_TEXT N_("Video size")
 #define SIZE_LONGTEXT N_( \
     "Size of the video that will be displayed by the " \
     "DirectShow plugin. If you don't specify anything the default size for " \
-    "your device will be used.")
+    "your device will be used. You can specify a standard size (cif, d1, ...) or <width>x<height>.")
 #define CHROMA_TEXT N_("Video input chroma format")
 #define CHROMA_LONGTEXT N_( \
     "Force the DirectShow video input to use a specific chroma format " \
@@ -126,7 +138,7 @@ static char *ppsz_tuner_input_text[] =
 #define VIDEO_IN_TEXT N_("Video input pin")
 #define VIDEO_IN_LONGTEXT N_( \
   "Select the video input source, such as composite, s-video, " \
-  "or tuner. Since these settings are hardware-specfic, you should find good " \
+  "or tuner. Since these settings are hardware-specific, you should find good " \
   "settings in the \"Device config\" area, and use those numbers here. -1 " \
   "means that settings will not be changed.")
 #define AUDIO_IN_TEXT N_("Audio input pin")
@@ -139,6 +151,10 @@ static char *ppsz_tuner_input_text[] =
 #define AUDIO_OUT_LONGTEXT N_( \
   "Select the audio output type. See the \"video input\" option." )
 
+#define AMTUNER_MODE_TEXT N_("AM Tuner mode")
+#define AMTUNER_MODE_LONGTEXT N_( \
+    "AM Tuner mode. Can be one of DEFAULT, TV, AM_RADIO, FM_RADIO or DSS.")
+
 static int  CommonOpen ( vlc_object_t *, access_sys_t *, vlc_bool_t );
 static void CommonClose( vlc_object_t *, access_sys_t * );
 
@@ -202,6 +218,10 @@ vlc_module_begin();
     add_integer( "dshow-audio-output", -1, NULL, AUDIO_OUT_TEXT,
                  AUDIO_OUT_LONGTEXT, VLC_TRUE );
 
+    add_integer( "dshow-amtuner-mode", AMTUNER_MODE_TV, NULL,
+                AMTUNER_MODE_TEXT, AMTUNER_MODE_LONGTEXT, VLC_FALSE);
+        change_integer_list( pi_amtuner_mode, ppsz_amtuner_mode_text, 0 );
+
     add_shortcut( "dshow" );
     set_capability( "access_demux", 0 );
     set_callbacks( DemuxOpen, DemuxClose );
@@ -371,6 +391,9 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
     var_Create( p_this, "dshow-tuner-input",
                 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
+    var_Create( p_this, "dshow-amtuner-mode",
+                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+
     var_Create( p_this, "dshow-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
     var_Create( p_this, "dshow-video-input", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
@@ -456,16 +479,16 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
     for( i = p_sys->i_crossbar_route_depth-1; i >= 0 ; --i )
     {
             var_Get( p_this, "dshow-video-input", &val );
-            if( val.i_int > 0 )
+            if( val.i_int >= 0 )
                     p_sys->crossbar_routes[i].VideoInputIndex=val.i_int;
             var_Get( p_this, "dshow-video-output", &val );
-            if( val.i_int > 0 )
+            if( val.i_int >= 0 )
                     p_sys->crossbar_routes[i].VideoOutputIndex=val.i_int;
             var_Get( p_this, "dshow-audio-input", &val );
-            if( val.i_int > 0 )
+            if( val.i_int >= 0 )
                     p_sys->crossbar_routes[i].AudioInputIndex=val.i_int;
             var_Get( p_this, "dshow-audio-output", &val );
-            if( val.i_int > 0 )
+            if( val.i_int >= 0 )
                     p_sys->crossbar_routes[i].AudioOutputIndex=val.i_int;
 
         IAMCrossbar *pXbar = p_sys->crossbar_routes[i].pXbar;
@@ -869,6 +892,9 @@ static int OpenDevice( vlc_object_t *p_this, access_sys_t *p_sys,
     {
         msg_Err( p_this, "can't use device: %s, unsupported device type",
                  devicename.c_str() );
+        intf_UserFatal( p_this, VLC_FALSE, _("Capturing failed"), 
+                        _("VLC cannot use the device \"%s\", because its device "
+                          "type is not supported.") );
         return VLC_EGENERIC;
     }
 
@@ -916,6 +942,9 @@ static int OpenDevice( vlc_object_t *p_this, access_sys_t *p_sys,
     else {
         /* capture device */
         msg_Err( p_this, "capture device '%s' does not support required parameters !", devicename.c_str() );
+        intf_UserFatal( p_this, VLC_FALSE, _("Capturing failed"), 
+                        _("The capture device \"%s\" does not support the "
+                          "required parameters."), devicename.c_str() );
         p_device_filter->Release();
         return VLC_EGENERIC;
     }
@@ -1586,7 +1615,7 @@ static block_t *ReadCompressed( access_t *p_access )
         }
 
         sample.p_sample->GetPointer( &p_data );
-        p_access->p_vlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
+        p_access->p_libvlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
         sample.p_sample->Release();
 
         /* The caller got what he wanted */
@@ -1675,7 +1704,7 @@ static int Demux( demux_t *p_demux )
 #endif
 
     p_block = block_New( p_demux, i_data_size );
-    p_demux->p_vlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
+    p_demux->p_libvlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
     p_block->i_pts = p_block->i_dts = i_pts;
     sample.p_sample->Release();
 
@@ -1789,8 +1818,8 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
         /* Keep the 2 first entries */
         for( i = 2; i < p_item->i_list; i++ )
         {
-            free( p_item->ppsz_list[i] );
-            free( p_item->ppsz_list_text[i] );
+            free( const_cast<char *>(p_item->ppsz_list[i]) );
+            free( const_cast<char *>(p_item->ppsz_list_text[i]) );
         }
         /* TODO: Remove when no more needed */
         p_item->ppsz_list[i] = NULL;
@@ -1812,10 +1841,10 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     if( !list_devices.size() ) return VLC_SUCCESS;
 
     p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+        (const char **)realloc( p_item->ppsz_list,
                           (list_devices.size()+3) * sizeof(char *) );
     p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+        (const char **)realloc( p_item->ppsz_list_text,
                           (list_devices.size()+3) * sizeof(char *) );
 
     list<string>::iterator iter;
@@ -1871,6 +1900,7 @@ static int ConfigDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     if( p_device_filter )
     {
         ShowPropertyPage( p_device_filter );
+        p_device_filter->Release();
     }
     else
     {
@@ -2031,7 +2061,7 @@ static void ShowTunerProperties( vlc_object_t *p_this,
 static void ConfigTuner( vlc_object_t *p_this, ICaptureGraphBuilder2 *p_graph,
                          IBaseFilter *p_device_filter )
 {
-    int i_channel, i_country, i_input;
+    int i_channel, i_country, i_input, i_amtuner_mode;
     long l_modes = 0;
     IAMTVTuner *p_TV;
     HRESULT hr;
@@ -2041,6 +2071,7 @@ static void ConfigTuner( vlc_object_t *p_this, ICaptureGraphBuilder2 *p_graph,
     i_channel = var_GetInteger( p_this, "dshow-tuner-channel" );
     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" );
 
     if( !i_channel && !i_country && !i_input ) return; /* Nothing to do */
 
@@ -2071,9 +2102,9 @@ static void ConfigTuner( vlc_object_t *p_this, ICaptureGraphBuilder2 *p_graph,
     }
 
     hr = p_TV->GetAvailableModes( &l_modes );
-    if( SUCCEEDED(hr) && (l_modes & AMTUNER_MODE_TV) )
+    if( SUCCEEDED(hr) && (l_modes & i_amtuner_mode) )
     {
-        hr = p_TV->put_Mode( AMTUNER_MODE_TV );
+        hr = p_TV->put_Mode( (AMTunerModeType)i_amtuner_mode );
     }
 
     if( i_input == 1 ) p_TV->put_InputType( 0, TunerInputCable );