]> git.sesse.net Git - vlc/commitdiff
Support subtitle description when comming from attachments (close #3241).
authorLaurent Aimar <fenrir@videolan.org>
Sat, 23 Jan 2010 20:16:39 +0000 (21:16 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 23 Jan 2010 20:31:57 +0000 (21:31 +0100)
src/input/input.c

index 049d54027b086f5f2f93376b50f8d7a6a036c20e..73b6e83aab65833668e1467dc58411f9027597f5 100644 (file)
@@ -1035,31 +1035,42 @@ static void LoadSubtitles( input_thread_t *p_input )
 
     /* Load subtitles from attachments */
     int i_attachment = 0;
-    char **ppsz_attachment = NULL;
+    input_attachment_t **pp_attachment = NULL;
 
     vlc_mutex_lock( &p_input->p->p_item->lock );
     for( int i = 0; i < p_input->p->i_attachment; i++ )
     {
         const input_attachment_t *a = p_input->p->attachment[i];
         if( !strcmp( a->psz_mime, "application/x-srt" ) )
-            TAB_APPEND( i_attachment, ppsz_attachment,
-                        strdup( a->psz_name ) );
+            TAB_APPEND( i_attachment, pp_attachment,
+                        vlc_input_attachment_New( a->psz_name, NULL,
+                                                  a->psz_description, NULL, 0 ) );
     }
     vlc_mutex_unlock( &p_input->p->p_item->lock );
 
+    if( i_attachment > 0 )
+        var_Create( p_input, "sub-description", VLC_VAR_STRING );
     for( int i = 0; i < i_attachment; i++ )
     {
+        input_attachment_t *a = pp_attachment[i];
+        if( !a )
+            continue;
         char *psz_mrl;
-        if( ppsz_attachment[i] &&
-            asprintf( &psz_mrl, "attachment://%s", ppsz_attachment[i] ) >= 0 )
+        if( a->psz_name[i] &&
+            asprintf( &psz_mrl, "attachment://%s", a->psz_name ) >= 0 )
         {
+            var_SetString( p_input, "sub-description", a->psz_description ? a->psz_description : "");
+
             SubtitleAdd( p_input, psz_mrl, b_forced );
+
             b_forced = false;
             free( psz_mrl );
         }
-        free( ppsz_attachment[i] );
+        vlc_input_attachment_Delete( a );
     }
-    free( ppsz_attachment );
+    free( pp_attachment );
+    if( i_attachment > 0 )
+        var_Destroy( p_input, "sub-description" );
 }
 
 static void LoadSlaves( input_thread_t *p_input )