]> git.sesse.net Git - vlc/blobdiff - modules/demux/subtitle.c
Qt: CaptureOpenPanel: check and prefill with usual devices
[vlc] / modules / demux / subtitle.c
index 8b77dd3ac4efd22f144132b13627da07a46ebbdb..b8021d883d0477e6b2d039bb6f651be16a32e606 100644 (file)
 #include <vlc_input.h>
 #include <vlc_memory.h>
 
-#include <errno.h>
-#ifdef HAVE_SYS_TYPES_H
-#   include <sys/types.h>
-#endif
 #include <ctype.h>
 
 #include <vlc_demux.h>
@@ -62,6 +58,8 @@ static void Close( vlc_object_t *p_this );
     "\"sami\", \"dvdsubtitle\", \"mpl2\", \"aqt\", \"pjs\", "\
     "\"mpsub\", \"jacosub\", \"psb\", \"realtext\", \"dks\", \"subviewer1\", " \
     " and \"auto\" (meaning autodetection, this should always work).")
+#define SUB_DESCRIPTION_LONGTEXT \
+    N_("Override the default track description.")
 
 static const char *const ppsz_sub_type[] =
 {
@@ -86,6 +84,8 @@ vlc_module_begin ()
     add_string( "sub-type", "auto", NULL, N_("Subtitles format"),
                 SUB_TYPE_LONGTEXT, true )
         change_string_list( ppsz_sub_type, NULL, NULL )
+    add_string( "sub-description", NULL, NULL, N_("Subtitles description"),
+                SUB_DESCRIPTION_LONGTEXT, true )
     set_callbacks( Open, Close )
 
     add_shortcut( "subtitle" )
@@ -226,7 +226,7 @@ static const struct
 static int Demux( demux_t * );
 static int Control( demux_t *, int, va_list );
 
-/*static void Fix( demux_t * );*/
+static void Fix( demux_t * );
 
 /*****************************************************************************
  * Module initializer
@@ -518,18 +518,25 @@ static int Open ( vlc_object_t *p_this )
              p_sys->i_type == SUB_TYPE_SSA2_4 ||
              p_sys->i_type == SUB_TYPE_ASS )
     {
+        Fix( p_demux );
         es_format_Init( &fmt, SPU_ES, VLC_CODEC_SSA );
     }
     else
     {
         es_format_Init( &fmt, SPU_ES, VLC_CODEC_SUBT );
     }
+    char *psz_description = var_InheritString( p_demux, "sub-description" );
+    if( psz_description && *psz_description )
+        fmt.psz_description = psz_description;
+    else
+        free( psz_description );
     if( p_sys->psz_header != NULL )
     {
         fmt.i_extra = strlen( p_sys->psz_header ) + 1;
         fmt.p_extra = strdup( p_sys->psz_header );
     }
     p_sys->es = es_out_Add( p_demux->out, &fmt );
+    es_format_Clean( &fmt );
 
     return VLC_SUCCESS;
 }
@@ -702,12 +709,10 @@ static int Demux( demux_t *p_demux )
 /*****************************************************************************
  * Fix: fix time stamp and order of subtitle
  *****************************************************************************/
-#ifdef USE_THIS_UNUSED_PIECE_OF_CODE
 static void Fix( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     bool b_done;
-    int     i_index;
 
     /* *** fix order (to be sure...) *** */
     /* We suppose that there are near in order and this durty bubble sort
@@ -716,10 +721,10 @@ static void Fix( demux_t *p_demux )
     do
     {
         b_done = true;
-        for( i_index = 1; i_index < p_sys->i_subtitles; i_index++ )
+        for( int i_index = 1; i_index < p_sys->i_subtitles; i_index++ )
         {
             if( p_sys->subtitle[i_index].i_start <
-                    p_sys->subtitle[i_index - 1].i_start )
+                p_sys->subtitle[i_index - 1].i_start )
             {
                 subtitle_t sub_xch;
                 memcpy( &sub_xch,
@@ -736,7 +741,6 @@ static void Fix( demux_t *p_demux )
         }
     } while( !b_done );
 }
-#endif
 
 static int TextLoad( text_t *txt, stream_t *s )
 {
@@ -1849,7 +1853,7 @@ static int ParsePSB( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
 
 static int64_t ParseRealTime( char *psz, int *h, int *m, int *s, int *f )
 {
-    if( strlen( psz ) == 0 ) return 0;
+    if( *psz == '\0' ) return 0;
     if( sscanf( psz, "%d:%d:%d.%d", h, m, s, f ) == 4 ||
             sscanf( psz, "%d:%d.%d", m, s, f ) == 3 ||
             sscanf( psz, "%d.%d", s, f ) == 2 ||