]> git.sesse.net Git - vlc/blobdiff - modules/access/dshow/dshow.cpp
Rewrite a useful tooltip for Windows DShow.
[vlc] / modules / access / dshow / dshow.cpp
index e15745d95ad8e4b181151a0aa888216b798466e8..128ed4963633b0292fc29d2eeb295ca90630b8e4 100644 (file)
@@ -33,7 +33,8 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_input.h>
 #include <vlc_access.h>
 #include <vlc_demux.h>
@@ -76,19 +77,19 @@ static void ConfigTuner( vlc_object_t *, ICaptureGraphBuilder2 *,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-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 const char *ppsz_tuner_input_text[] =
+static const char *const ppsz_vdev[] = { "", "none" };
+static const char *const ppsz_vdev_text[] = { N_("Default"), N_("None") };
+static const char *const ppsz_adev[] = { "", "none" };
+static const char *const ppsz_adev_text[] = { N_("Default"), N_("None") };
+static const int pi_tuner_input[] = { 0, 1, 2 };
+static const char *const 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"),
+static const char *const ppsz_amtuner_mode_text[] = { N_("Default"),
                                           N_("TV"),
                                           N_("FM radio"),
                                           N_("AM radio"),
@@ -157,7 +158,20 @@ static const char *ppsz_amtuner_mode_text[] = { N_("Default"),
 
 #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.")
+    "AM Tuner mode. Can be one of Default (0), TV (1)," \
+     "AM Radio (2), FM Radio (3) or DSS (4).")
+
+#define AUDIO_CHANNELS_TEXT N_("Number of audio channels")
+#define AUDIO_CHANNELS_LONGTEXT N_( \
+    "Select audio input format with the given number of audio channels (if non 0)" )
+
+#define AUDIO_SAMPLERATE_TEXT N_("Audio sample rate")
+#define AUDIO_SAMPLERATE_LONGTEXT N_( \
+    "Select audio input format with the given sample rate (if non 0)" )
+
+#define AUDIO_BITSPERSAMPLE_TEXT N_("Audio bits per sample")
+#define AUDIO_BITSPERSAMPLE_LONGTEXT N_( \
+    "Select audio input format with the given bits/sample (if non 0)" )
 
 static int  CommonOpen ( vlc_object_t *, access_sys_t *, bool );
 static void CommonClose( vlc_object_t *, access_sys_t * );
@@ -169,8 +183,8 @@ static int  DemuxOpen  ( vlc_object_t * );
 static void DemuxClose ( vlc_object_t * );
 
 vlc_module_begin();
-    set_shortname( _("DirectShow") );
-    set_description( _("DirectShow input") );
+    set_shortname( N_("DirectShow") );
+    set_description( N_("DirectShow input") );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_ACCESS );
     add_integer( "dshow-caching", (mtime_t)(0.2*CLOCK_FREQ) / 1000, NULL,
@@ -226,12 +240,19 @@ vlc_module_begin();
                 AMTUNER_MODE_TEXT, AMTUNER_MODE_LONGTEXT, false);
         change_integer_list( pi_amtuner_mode, ppsz_amtuner_mode_text, 0 );
 
+    add_integer( "dshow-audio-channels", 0, NULL, AUDIO_CHANNELS_TEXT,
+                 AUDIO_CHANNELS_LONGTEXT, true );
+    add_integer( "dshow-audio-samplerate", 0, NULL, AUDIO_SAMPLERATE_TEXT,
+                 AUDIO_SAMPLERATE_LONGTEXT, true );
+    add_integer( "dshow-audio-bitspersample", 0, NULL, AUDIO_BITSPERSAMPLE_TEXT,
+                 AUDIO_BITSPERSAMPLE_LONGTEXT, true );
+
     add_shortcut( "dshow" );
     set_capability( "access_demux", 0 );
     set_callbacks( DemuxOpen, DemuxClose );
 
     add_submodule();
-    set_description( _("DirectShow input") );
+    set_description( N_("DirectShow input") );
     set_capability( "access", 0 );
     set_callbacks( AccessOpen, AccessClose );
 
@@ -418,7 +439,7 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
     p_sys->p_capture_graph_builder2 = NULL;
     p_sys->p_control = NULL;
 
-    vlc_mutex_init( p_this, &p_sys->lock );
+    vlc_mutex_init( &p_sys->lock );
     vlc_cond_init( p_this, &p_sys->wait );
 
     /* Build directshow graph */
@@ -656,11 +677,13 @@ static int AccessOpen( vlc_object_t *p_this )
             p_stream->i_fourcc == VLC_FOURCC('d','v','s','d') ||
             p_stream->i_fourcc == VLC_FOURCC('d','v','h','d') )
         {
+            free( p_access->psz_demux );
             p_access->psz_demux = strdup( "rawdv" );
         }
         else if( p_stream->i_fourcc == VLC_FOURCC('m','p','2','v') )
         {
-            p_access->psz_demux = "mpgv";
+            free( p_access->psz_demux );
+            p_access->psz_demux = strdup( "mpgv" );
         }
     }
 
@@ -906,7 +929,10 @@ static int OpenDevice( vlc_object_t *p_this, access_sys_t *p_sys,
     size_t media_count =
         EnumDeviceCaps( p_this, p_device_filter, b_audio ? 0 : p_sys->i_chroma,
                         p_sys->i_width, p_sys->i_height,
-                        0, 0, 0, media_types, MAX_MEDIA_TYPES );
+      b_audio ? var_CreateGetInteger( p_this, "dshow-audio-channels" ) : 0,
+      b_audio ? var_CreateGetInteger( p_this, "dshow-audio-samplerate" ) : 0,
+      b_audio ? var_CreateGetInteger( p_this, "dshow-audio-bitspersample" ) : 0,
+      media_types, MAX_MEDIA_TYPES );
 
     AM_MEDIA_TYPE *mt = NULL;
 
@@ -1614,7 +1640,7 @@ static block_t *ReadCompressed( access_t *p_access )
 
     while( 1 )
     {
-        if( p_access->b_die || p_access->b_error ) return 0;
+        if( !vlc_object_alive (p_access) || p_access->b_error ) return 0;
 
         /* Get new sample/frame from the elementary stream (blocking). */
         vlc_mutex_lock( &p_sys->lock );
@@ -1644,7 +1670,7 @@ static block_t *ReadCompressed( access_t *p_access )
         }
 
         sample.p_sample->GetPointer( &p_data );
-        p_access->p_libvlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
+        vlc_memcpy( p_block->p_buffer, p_data, i_data_size );
         sample.p_sample->Release();
 
         /* The caller got what he wanted */
@@ -1728,12 +1754,12 @@ static int Demux( demux_t *p_demux )
     i_pts /= 10; /* Dshow works with 100 nano-seconds resolution */
 
 #if 0
-    msg_Dbg( p_demux, "Read() stream: %i, size: %i, PTS: "I64Fd,
+    msg_Dbg( p_demux, "Read() stream: %i, size: %i, PTS: %"PRId64,
              i_stream, i_data_size, i_pts );
 #endif
 
     p_block = block_New( p_demux, i_data_size );
-    p_demux->p_libvlc->pf_memcpy( p_block->p_buffer, p_data, i_data_size );
+    vlc_memcpy( p_block->p_buffer, p_data, i_data_size );
     p_block->i_pts = p_block->i_dts = i_pts;
     sample.p_sample->Release();