/*****************************************************************************
* gvp.c: Google Video Playlist demuxer
*****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006 VLC authors and VideoLAN
* $Id$
*
* Authors: Antoine Cellerier <dionoea @t videolan d.t org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
#include <vlc_demux.h>
-#include <errno.h> /* ENOMEM */
#include "playlist.h"
#define MAX_LINE 1024
struct demux_sys_t
{
- playlist_t *p_playlist;
- playlist_item_t *p_current;
- playlist_item_t *p_item_in_category;
+ input_item_t *p_current_input;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Demux( demux_t *p_demux);
-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;
- 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 );
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;
}
}
if( !b_found ) return VLC_EGENERIC;
- STANDARD_DEMUX_INIT_MSG( "using Google Video Playlist (gvp) import" )
+ 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;
}
/*****************************************************************************
* 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 );
}
char *psz_description = NULL;
input_item_t *p_input;
- INIT_PLAYLIST_STUFF;
+ input_item_t *p_current_input = GetCurrentItem(p_demux);
+
+ input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
- p_sys->p_playlist = p_playlist;
- p_sys->p_current = p_current;
- p_sys->p_item_in_category = p_item_in_category;
+ p_sys->p_current_input = p_current_input;
while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
{
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;
}
}
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, _("Google Video"), _(type), "%s", field ) ; }
+ p_input = input_item_New( psz_url, psz_title );
+#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 );
- playlist_BothAddInput( p_sys->p_playlist, p_input,
- p_sys->p_item_in_category,
- PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END, NULL, NULL, VLC_FALSE );
+ input_item_node_AppendItem( p_subitems, p_input );
+ vlc_gc_decref( p_input );
}
- HANDLE_PLAY_AND_RELEASE;
+ input_item_node_PostAndDelete( p_subitems );
+
+ vlc_gc_decref(p_current_input);
free( psz_version );
free( psz_url );
free( psz_title );
free( psz_description );
- p_sys->p_playlist = NULL;
-
- return -1; /* Needed for correct operation of go back */
-}
-
-static int Control( demux_t *p_demux, int i_query, va_list args )
-{
- return VLC_EGENERIC;
+ return 0; /* Needed for correct operation of go back */
}