]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/gvp.c
Force to specify options flags in input_item_New*.
[vlc] / modules / demux / playlist / gvp.c
index 05e472456ba06c59c5b5f5586932c49f927b1c27..bd4537bba252f02613edecee28c2a0dd2b628929 100644 (file)
@@ -52,7 +52,7 @@ description:The now infamous Apple Macintosh commercial aired during the 1984 Su
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_demux.h>
 
 #include "playlist.h"
@@ -61,7 +61,6 @@ description:The now infamous Apple Macintosh commercial aired during the 1984 Su
 
 struct demux_sys_t
 {
-    playlist_t *p_playlist;
     input_item_t *p_current_input;
 };
 
@@ -74,11 +73,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
 /*****************************************************************************
  * Import_GVP: main import function
  *****************************************************************************/
-int E_(Import_GVP)( vlc_object_t *p_this )
+int Import_GVP( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
-    int i_peek, i, b_found = VLC_FALSE;
-    const byte_t *p_peek;
+    int i_peek, i, b_found = false;
+    const uint8_t *p_peek;
 
     i_peek = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
 
@@ -87,7 +86,7 @@ int E_(Import_GVP)( vlc_object_t *p_this )
         if( p_peek[i] == 'g' && p_peek[i+1] == 'v' && p_peek[i+2] == 'p' &&
             !memcmp( p_peek+i, "gvp_version:", sizeof("gvp_version:") - 1 ) )
         {
-            b_found = VLC_TRUE;
+            b_found = true;
             break;
         }
     }
@@ -97,8 +96,9 @@ int E_(Import_GVP)( vlc_object_t *p_this )
     STANDARD_DEMUX_INIT_MSG(  "using Google Video Playlist (gvp) import" );
     p_demux->pf_control = Control;
     p_demux->pf_demux = Demux;
-    MALLOC_ERR( p_demux->p_sys, demux_sys_t );
-    p_demux->p_sys->p_playlist = NULL;
+    p_demux->p_sys = malloc( sizeof( demux_sys_t ) );
+    if( !p_demux->p_sys )
+        return VLC_ENOMEM;
 
     return VLC_SUCCESS;
 }
@@ -106,13 +106,11 @@ int E_(Import_GVP)( vlc_object_t *p_this )
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/
-void E_(Close_GVP)( vlc_object_t *p_this )
+void Close_GVP( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( p_sys->p_playlist )
-        vlc_object_release( p_sys->p_playlist );
     free( p_sys );
 }
 
@@ -133,7 +131,6 @@ static int Demux( demux_t *p_demux )
 
     INIT_PLAYLIST_STUFF;
 
-    p_sys->p_playlist = p_playlist;
     p_sys->p_current_input = p_current_input;
 
     while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
@@ -183,9 +180,8 @@ static int Demux( demux_t *p_demux )
             else
             {
                 /* handle multi-line descriptions */
-                buf = malloc( strlen( psz_description )
-                            + strlen( psz_attrvalue ) + 2 );
-                sprintf( buf, "%s\n%s", psz_description, psz_attrvalue );
+                if( asprintf( &buf, "%s\n%s", psz_description, psz_attrvalue ) == -1 )
+                    buf = NULL;
                 free( psz_description );
                 psz_description = buf;
             }
@@ -206,14 +202,14 @@ static int Demux( demux_t *p_demux )
     }
     else
     {
-        p_input = input_ItemNewExt( p_sys->p_playlist,
-                                    psz_url, psz_title, 0, NULL, -1 );
-#define SADD_INFO( type, field ) if( field ) { input_ItemAddInfo( \
+        p_input = input_item_NewExt( p_demux,
+                                    psz_url, psz_title, 0, NULL, 0, -1 );
+#define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \
                     p_input, _("Google Video"), _(type), "%s", field ) ; }
         SADD_INFO( "gvp_version", psz_version );
         SADD_INFO( "docid", psz_docid );
         SADD_INFO( "description", psz_description );
-        input_ItemAddSubItem( p_current_input, p_input );
+        input_item_AddSubItem( p_current_input, p_input );
         vlc_gc_decref( p_input );
     }
 
@@ -225,8 +221,6 @@ static int Demux( demux_t *p_demux )
     free( psz_title );
     free( psz_description );
 
-    p_sys->p_playlist = NULL;
-
     return 0; /* Needed for correct operation of go back */
 }