Commit 923da588 authored by Arnaud Schauly's avatar Arnaud Schauly

* src/playlist/playlist.c : Added playlist_AddItem (enqueues

playlist_item_t instead of psz_target ). Now playlist_Add uses
playlist_AddItem to enqueue.
* include/vlc_playlist.h : Added a psz_uri field in the playlist_item_t
structure.
* src/input/input.c : takes item->psz_uri  argument to start playing an
item.
parent 9125323f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions * vlc_playlist.h : Playlist functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: vlc_playlist.h,v 1.5 2002/11/12 21:20:36 gbazin Exp $ * $Id: vlc_playlist.h,v 1.6 2002/12/03 23:36:41 gitan Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
struct playlist_item_t struct playlist_item_t
{ {
char * psz_name; char * psz_name;
char * psz_uri;
int i_type; /* unused yet */ int i_type; /* unused yet */
int i_status; /* unused yet */ int i_status; /* unused yet */
vlc_bool_t b_autodeletion; vlc_bool_t b_autodeletion;
...@@ -69,5 +70,6 @@ void playlist_Destroy ( playlist_t * ); ...@@ -69,5 +70,6 @@ void playlist_Destroy ( playlist_t * );
VLC_EXPORT( void, playlist_Command, ( playlist_t *, int, int ) ); VLC_EXPORT( void, playlist_Command, ( playlist_t *, int, int ) );
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, int, int ) ); VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, int, int ) );
VLC_EXPORT( int, playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) );
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sap.c : SAP interface module * sap.c : SAP interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: sap.c,v 1.1 2002/12/03 16:29:04 gitan Exp $ * $Id: sap.c,v 1.2 2002/12/03 23:36:41 gitan Exp $
* *
* Authors: Arnaud Schauly <gitan@via.ecp.fr> * Authors: Arnaud Schauly <gitan@via.ecp.fr>
* *
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
#define MAX_LINE_LENGTH 256 #define MAX_LINE_LENGTH 256
#define HELLO_PORT 9875 // SAP is aloways on that port #define HELLO_PORT 9875 /* SAP is always on that port */
#define HELLO_GROUP "239.255.255.255" // FIX ME !!!!!!!!!!!!!!! #define HELLO_GROUP "239.255.255.255"
#define ADD_SESSION 1; #define ADD_SESSION 1;
/***************************************************************************** /*****************************************************************************
...@@ -79,7 +79,6 @@ static int Kill ( intf_thread_t * ); ...@@ -79,7 +79,6 @@ static int Kill ( intf_thread_t * );
static ssize_t NetRead ( intf_thread_t*, int , byte_t *, size_t ); static ssize_t NetRead ( intf_thread_t*, int , byte_t *, size_t );
typedef struct sess_descr_s { typedef struct sess_descr_s {
/* char *psz_version; // v field (protocol version) */
char *psz_origin; /* o field (username sess-id sess-version char *psz_origin; /* o field (username sess-id sess-version
nettype addrtype addr*/ nettype addrtype addr*/
char *psz_sessionname; char *psz_sessionname;
...@@ -97,9 +96,8 @@ typedef struct sess_descr_s { ...@@ -97,9 +96,8 @@ typedef struct sess_descr_s {
static int parse_sap ( char ** ); static int parse_sap ( char ** );
static int packet_handle ( char **, intf_thread_t * ); static int packet_handle ( char **, intf_thread_t * );
static sess_descr_t * parse_sdp(char * psz_pct) ; static sess_descr_t * parse_sdp( char *,intf_thread_t * ) ;
static playlist_item_t * sess_toitem( sess_descr_t * );
/***************************************************************************** /*****************************************************************************
...@@ -137,7 +135,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -137,7 +135,6 @@ static void Run( intf_thread_t *p_intf )
char *psz_addr; char *psz_addr;
char *psz_network = NULL; char *psz_network = NULL;
struct sockaddr_in addr; struct sockaddr_in addr;
struct ip_mreq mreq;
int fd,addrlen; int fd,addrlen;
char *psz_buf; char *psz_buf;
...@@ -185,7 +182,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -185,7 +182,7 @@ static void Run( intf_thread_t *p_intf )
if( i_read < 0 ) if( i_read < 0 )
{ {
msg_Err( p_intf, "argggg" ); msg_Err( p_intf, "Cannot read in the socket" );
} }
if( i_read == 0 ) if( i_read == 0 )
{ {
...@@ -193,7 +190,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -193,7 +190,6 @@ static void Run( intf_thread_t *p_intf )
} }
msg_Dbg( p_intf, "New packet arrived" );
packet_handle( &psz_buf, p_intf ); packet_handle( &psz_buf, p_intf );
} }
...@@ -214,7 +210,25 @@ static int Kill( intf_thread_t *p_intf ) ...@@ -214,7 +210,25 @@ static int Kill( intf_thread_t *p_intf )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*******************************************************************
* sess_toitem : changes a sess_descr_t into a playlist_item_t
*******************************************************************/
static playlist_item_t * sess_toitem( sess_descr_t * p_sd )
{
playlist_item_t * p_item;
p_item = malloc( sizeof( playlist_item_t ) );
p_item->psz_name = p_sd->psz_sessionname;
p_item->psz_uri = p_sd->psz_uri;
p_item->i_type = 0;
p_item->i_status = 0;
p_item->b_autodeletion = VLC_FALSE;
return p_item;
}
/******************************************************************** /********************************************************************
* parse_sap : Takes care of the SAP headers * parse_sap : Takes care of the SAP headers
******************************************************************** ********************************************************************
...@@ -238,32 +252,34 @@ static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothin ...@@ -238,32 +252,34 @@ static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothin
static int packet_handle( char ** ppsz_packet, intf_thread_t * p_intf ) { static int packet_handle( char ** ppsz_packet, intf_thread_t * p_intf ) {
int j=0; int j=0;
sess_descr_t * sd; sess_descr_t * p_sd;
playlist_t *p_playlist; playlist_t *p_playlist;
playlist_item_t *p_item;
char * psz_enqueue; char * psz_enqueue;
char * psz_udp = "udp://@\0";
int i; int i;
j=parse_sap( ppsz_packet ); j=parse_sap( ppsz_packet );
if(j != 0) { if(j != 0) {
msg_Dbg( p_intf, "SAP packet parsed"); p_sd = parse_sdp( *ppsz_packet, p_intf );
sd = parse_sdp( * ppsz_packet );
i = strlen( psz_udp ) + strlen( sd->psz_uri )+1 ; i = strlen( "udp://@\0" ) + strlen( p_sd->psz_uri )+1 ;
psz_enqueue = malloc ( i * sizeof (char) ); psz_enqueue = malloc ( i * sizeof (char) );
memset( psz_enqueue, '\0',i ); memset( psz_enqueue, '\0',i );
strcat ( psz_enqueue,psz_udp ); strcat ( psz_enqueue,"udp://@\0" );
strcat ( psz_enqueue,sd->psz_uri ); strcat ( psz_enqueue,p_sd->psz_uri );
free( p_sd->psz_uri );
p_sd->psz_uri = psz_enqueue;
p_item = sess_toitem ( p_sd );
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_Add ( p_playlist, psz_enqueue, PLAYLIST_CHECK_INSERT, PLAYLIST_END);
msg_Dbg(p_intf,"SAP packet : End of treatment"); playlist_AddItem ( p_playlist, p_item, PLAYLIST_CHECK_INSERT, PLAYLIST_END);
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
free ( p_sd );
return 1; return 1;
} }
free ( sd );
return 0; // Invalid Packet return 0; // Invalid Packet
} }
...@@ -276,7 +292,7 @@ static int packet_handle( char ** ppsz_packet, intf_thread_t * p_intf ) { ...@@ -276,7 +292,7 @@ static int packet_handle( char ** ppsz_packet, intf_thread_t * p_intf ) {
* Make a sess_descr_t with a psz * Make a sess_descr_t with a psz
******************************************************/ ******************************************************/
static sess_descr_t * parse_sdp(char * psz_pct) static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
{ {
int j,k; int j,k;
char ** ppsz_fill; char ** ppsz_fill;
...@@ -289,8 +305,8 @@ static sess_descr_t * parse_sdp(char * psz_pct) ...@@ -289,8 +305,8 @@ static sess_descr_t * parse_sdp(char * psz_pct)
{ {
switch(psz_pct[(j-1)]) { switch(psz_pct[(j-1)]) {
/* case ('v') : { /* case ('v') : {
// ppsz_fill = & sd->psz_version; ppsz_fill = & sd->psz_version;
// break; break;
} */ } */
case ('o') : { case ('o') : {
ppsz_fill = & sd->psz_origin; ppsz_fill = & sd->psz_origin;
...@@ -334,7 +350,7 @@ static sess_descr_t * parse_sdp(char * psz_pct) ...@@ -334,7 +350,7 @@ static sess_descr_t * parse_sdp(char * psz_pct)
} }
default : { default : {
fprintf( stderr,"Warning : Ignored field \"%c\" \n",psz_pct[j-1] ); /* msg_Dbg( p_intf, "Warning : Ignored field \"%c\" \n",psz_pct[j-1] ); */
ppsz_fill = NULL; ppsz_fill = NULL;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.215 2002/11/11 14:39:12 sam Exp $ * $Id: input.c,v 1.216 2002/12/03 23:36:41 gitan Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -82,7 +82,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -82,7 +82,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
p_input->b_eof = 0; p_input->b_eof = 0;
/* Set target */ /* Set target */
p_input->psz_source = strdup( p_item->psz_name ); p_input->psz_source = strdup( p_item->psz_uri );
/* Demux */ /* Demux */
p_input->p_demux = NULL; p_input->p_demux = NULL;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions * playlist.c : Playlist management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: playlist.c,v 1.24 2002/12/03 16:29:04 gitan Exp $ * $Id: playlist.c,v 1.25 2002/12/03 23:36:41 gitan Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -103,9 +103,28 @@ void playlist_Destroy( playlist_t * p_playlist ) ...@@ -103,9 +103,28 @@ void playlist_Destroy( playlist_t * p_playlist )
int playlist_Add( playlist_t *p_playlist, const char * psz_target, int playlist_Add( playlist_t *p_playlist, const char * psz_target,
int i_mode, int i_pos ) int i_mode, int i_pos )
{ {
playlist_item_t *p_item; playlist_item_t * p_item;
p_item = malloc( sizeof( playlist_item_t ) );
if( p_item == NULL )
{
msg_Err( p_playlist, "out of memory" );
}
p_item->psz_name = strdup( psz_target );
p_item->psz_uri = strdup( psz_target );
p_item->i_type = 0;
p_item->i_status = 0;
p_item->b_autodeletion = VLC_FALSE;
return playlist_AddItem( p_playlist, p_item, i_mode, i_pos );
}
int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item,
int i_mode, int i_pos)
{
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
/* /*
...@@ -120,10 +139,17 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target, ...@@ -120,10 +139,17 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target,
{ {
for ( j = 0; j < p_playlist->i_size; j++ ) for ( j = 0; j < p_playlist->i_size; j++ )
{ {
if ( !strcmp( p_playlist->pp_items[j]->psz_name, psz_target ) ) if ( !strcmp( p_playlist->pp_items[j]->psz_uri, p_item->psz_uri ) )
{ {
msg_Dbg( p_playlist, "item %s already enqued", if( p_item->psz_name )
psz_target ); {
free( p_item->psz_name );
}
if( p_item->psz_uri )
{
free( p_item->psz_uri );
}
free( p_item );
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
return 0; return 0;
} }
...@@ -134,19 +160,9 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target, ...@@ -134,19 +160,9 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target,
} }
msg_Dbg( p_playlist, "adding playlist item %s ", psz_target ); msg_Dbg( p_playlist, "adding playlist item %s ", p_item->psz_name );
/* Create the new playlist item */ /* Create the new playlist item */
p_item = malloc( sizeof( playlist_item_t ) );
if( p_item == NULL )
{
msg_Err( p_playlist, "out of memory" );
}
p_item->psz_name = strdup( psz_target );
p_item->i_type = 0;
p_item->i_status = 0;
p_item->b_autodeletion = VLC_FALSE;
/* Do a few boundary checks and allocate space for the item */ /* Do a few boundary checks and allocate space for the item */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment