Changeset 923da58842e70c77aacd956274381eb30447b744

Show
Ignore:
Timestamp:
04/12/02 00:36:41 (6 years ago)
Author:
Arnaud Schauly <gitan@videolan.org>
git-committer:
Arnaud Schauly <gitan@videolan.org> 1038958601 +0000
git-parent:

[9125323fed7ff85b95393bf206b5f8b32ff01e14]

git-author:
Arnaud Schauly <gitan@videolan.org> 1038958601 +0000
Message:

* 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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_playlist.h

    r35b6968 r923da58  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN 
    5  * $Id: vlc_playlist.h,v 1.5 2002/11/12 21:20:36 gbazin Exp $ 
     5 * $Id: vlc_playlist.h,v 1.6 2002/12/03 23:36:41 gitan Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    2828{ 
    2929    char *     psz_name; 
     30    char *     psz_uri;  
    3031    int        i_type;   /* unused yet */ 
    3132    int        i_status; /* unused yet */ 
     
    7071 
    7172VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, int, int ) ); 
     73VLC_EXPORT( int,  playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) ); 
    7274VLC_EXPORT( int,  playlist_Delete, ( playlist_t *, int ) ); 
    7375 
  • modules/misc/sap.c

    re5daac6 r923da58  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: sap.c,v 1.1 2002/12/03 16:29:04 gitan Exp $ 
     5 * $Id: sap.c,v 1.2 2002/12/03 23:36:41 gitan Exp $ 
    66 * 
    77 * Authors: Arnaud Schauly <gitan@via.ecp.fr> 
     
    6363#define MAX_LINE_LENGTH 256 
    6464 
    65 #define HELLO_PORT 9875  // SAP is aloways on that port 
    66 #define HELLO_GROUP "239.255.255.255"   // FIX ME !!!!!!!!!!!!!!! 
     65#define HELLO_PORT 9875  /* SAP is always on that port */ 
     66#define HELLO_GROUP "239.255.255.255"    
    6767#define ADD_SESSION 1; 
    6868 
     
    8080 
    8181typedef struct  sess_descr_s { 
    82 /*    char *psz_version; // v field (protocol version) */ 
    8382    char *psz_origin; /* o field (username sess-id sess-version  
    8483                         nettype addrtype addr*/ 
     
    9897static int packet_handle ( char **, intf_thread_t * ); 
    9998 
    100 static sess_descr_t *  parse_sdp(char *  psz_pct) ; 
    101  
    102  
     99static sess_descr_t *  parse_sdp( char *,intf_thread_t * ) ; 
     100static playlist_item_t * sess_toitem( sess_descr_t * ); 
    103101 
    104102 
     
    138136    char *psz_network = NULL; 
    139137    struct sockaddr_in addr; 
    140     struct ip_mreq mreq; 
    141138    int fd,addrlen; 
    142139    char *psz_buf; 
     
    186183        if( i_read < 0 ) 
    187184        { 
    188             msg_Err( p_intf, "argggg" ); 
     185            msg_Err( p_intf, "Cannot read in the socket" ); 
    189186        } 
    190187        if( i_read == 0 ) 
     
    194191 
    195192 
    196         msg_Dbg( p_intf, "New packet arrived" ); 
    197193        packet_handle( &psz_buf, p_intf  ); 
    198194                                    
     
    215211} 
    216212 
    217   
     213/******************************************************************* 
     214 * sess_toitem : changes a sess_descr_t into a playlist_item_t 
     215 *******************************************************************/ 
     216 
     217static playlist_item_t *  sess_toitem( sess_descr_t * p_sd ) 
     218
     219    playlist_item_t * p_item; 
     220     
     221    p_item = malloc( sizeof( playlist_item_t ) ); 
     222    p_item->psz_name = p_sd->psz_sessionname; 
     223    p_item->psz_uri = p_sd->psz_uri;  
     224    p_item->i_type = 0; 
     225    p_item->i_status = 0; 
     226    p_item->b_autodeletion = VLC_FALSE;  
     227 
     228    return p_item; 
     229 
     230
     231 
    218232/******************************************************************** 
    219233 * parse_sap : Takes care of the SAP headers 
     
    239253static int packet_handle( char **  ppsz_packet, intf_thread_t * p_intf )  { 
    240254    int j=0; 
    241     sess_descr_t * sd; 
    242     playlist_t *p_playlist;  
     255    sess_descr_t * p_sd; 
     256    playlist_t *p_playlist; 
     257    playlist_item_t *p_item; 
    243258    char *  psz_enqueue; 
    244     char *  psz_udp = "udp://@\0"; 
    245259    int i; 
    246260     
     
    248262     
    249263    if(j != 0) { 
    250         msg_Dbg( p_intf, "SAP packet parsed"); 
    251         sd = parse_sdp( * ppsz_packet );  
    252          
    253         i = strlen( psz_udp ) + strlen( sd->psz_uri )+1 ; 
     264        p_sd = parse_sdp( *ppsz_packet, p_intf );  
     265         
     266        i = strlen( "udp://@\0" ) + strlen( p_sd->psz_uri )+1 ; 
    254267        psz_enqueue = malloc ( i * sizeof (char) ); 
    255268        memset( psz_enqueue, '\0',i ); 
    256         strcat ( psz_enqueue,psz_udp ); 
    257         strcat ( psz_enqueue,sd->psz_uri ); 
    258          
     269        strcat ( psz_enqueue,"udp://@\0" ); 
     270        strcat ( psz_enqueue,p_sd->psz_uri ); 
     271        free( p_sd->psz_uri ); 
     272        p_sd->psz_uri = psz_enqueue; 
     273         
     274        p_item = sess_toitem ( p_sd ); 
    259275        p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 
    260         playlist_Add ( p_playlist, psz_enqueue, PLAYLIST_CHECK_INSERT, PLAYLIST_END);  
    261         msg_Dbg(p_intf,"SAP packet : End of treatment"); 
     276 
     277        playlist_AddItem ( p_playlist, p_item, PLAYLIST_CHECK_INSERT, PLAYLIST_END); 
    262278        vlc_object_release( p_playlist ); 
    263279         
     280        free ( p_sd ); 
    264281        return 1; 
    265282    } 
    266     free ( sd ); 
    267283    return 0; // Invalid Packet  
    268284} 
     
    277293 ******************************************************/ 
    278294 
    279 static sess_descr_t *  parse_sdp(char *  psz_pct)  
     295static sess_descr_t *  parse_sdp( char *  psz_pct, intf_thread_t * p_intf )  
    280296{ 
    281297    int j,k; 
     
    290306           switch(psz_pct[(j-1)]) { 
    291307/*               case ('v') : { 
    292 //               ppsz_fill = & sd->psz_version; 
    293 //               break; 
     308                 ppsz_fill = & sd->psz_version; 
     309                 break; 
    294310            } */ 
    295311            case ('o') : { 
     
    335351 
    336352            default : {  
    337                fprintf( stderr,"Warning : Ignored field \"%c\" \n",psz_pct[j-1] ); 
     353/*               msg_Dbg( p_intf, "Warning : Ignored field \"%c\" \n",psz_pct[j-1] ); */ 
    338354               ppsz_fill = NULL; 
    339355            } 
  • src/input/input.c

    rbc061e8 r923da58  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.215 2002/11/11 14:39:12 sam Exp $ 
     7 * $Id: input.c,v 1.216 2002/12/03 23:36:41 gitan Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    8383 
    8484    /* Set target */ 
    85     p_input->psz_source = strdup( p_item->psz_name ); 
     85    p_input->psz_source = strdup( p_item->psz_uri ); 
    8686 
    8787    /* Demux */ 
  • src/playlist/playlist.c

    re5daac6 r923da58  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: playlist.c,v 1.24 2002/12/03 16:29:04 gitan Exp $ 
     5 * $Id: playlist.c,v 1.25 2002/12/03 23:36:41 gitan Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    104104                                          int i_mode, int i_pos ) 
    105105{ 
    106     playlist_item_t *p_item; 
    107  
     106    playlist_item_t * p_item;  
     107     
     108    p_item = malloc( sizeof( playlist_item_t ) ); 
     109    if( p_item == NULL ) 
     110    { 
     111        msg_Err( p_playlist, "out of memory" ); 
     112    } 
     113 
     114    p_item->psz_name = strdup( psz_target ); 
     115    p_item->psz_uri  = strdup( psz_target ); 
     116    p_item->i_type = 0; 
     117    p_item->i_status = 0; 
     118    p_item->b_autodeletion = VLC_FALSE; 
     119 
     120    return playlist_AddItem( p_playlist, p_item, i_mode, i_pos ); 
     121
     122 
     123 
     124int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, 
     125                int i_mode, int i_pos) 
     126
    108127 
    109128    vlc_mutex_lock( &p_playlist->object_lock ); 
     
    121140             for ( j = 0; j < p_playlist->i_size; j++ ) 
    122141             { 
    123                  if ( !strcmp( p_playlist->pp_items[j]->psz_name, psz_target ) ) 
     142                 if ( !strcmp( p_playlist->pp_items[j]->psz_uri, p_item->psz_uri ) ) 
    124143                 { 
    125                       msg_Dbg( p_playlist, "item � %s � already enqued",  
    126                                         psz_target ); 
     144                      if( p_item->psz_name )  
     145                      { 
     146                          free( p_item->psz_name ); 
     147                      } 
     148                      if( p_item->psz_uri ) 
     149                      { 
     150                          free( p_item->psz_uri ); 
     151                      } 
     152                      free( p_item ); 
    127153                      vlc_mutex_unlock( &p_playlist->object_lock ); 
    128154                      return 0;    
     
    135161 
    136162     
    137     msg_Dbg( p_playlist, "adding playlist item � %s �", psz_target ); 
     163    msg_Dbg( p_playlist, "adding playlist item � %s �", p_item->psz_name ); 
    138164     
    139165    /* Create the new playlist item */ 
    140     p_item = malloc( sizeof( playlist_item_t ) ); 
    141     if( p_item == NULL ) 
    142     { 
    143         msg_Err( p_playlist, "out of memory" ); 
    144     } 
    145  
    146     p_item->psz_name = strdup( psz_target ); 
    147     p_item->i_type = 0; 
    148     p_item->i_status = 0; 
    149     p_item->b_autodeletion = VLC_FALSE; 
    150166 
    151167