/*****************************************************************************
* Includes
*****************************************************************************/
+#define _GNU_SOURCE
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
/* playlist node */
playlist_item_t *p_node_cat;
playlist_item_t *p_node_one;
- playlist_t *p_playlist;
/* Table of announces */
int i_announces;
#endif
static void FreeSDP( sdp_t *p_sdp );
-
-#define FREE( p ) \
- if( p ) { free( p ); (p) = NULL; }
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
? VLC_TRUE : VLC_FALSE;
/* Create our playlist node */
- p_sys->p_playlist = (playlist_t *)vlc_object_find( p_sd,
- VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_sys->p_playlist )
- {
- msg_Warn( p_sd, "unable to find playlist, cancelling SAP listening");
- return VLC_EGENERIC;
- }
+ pl_Yield( p_sd );
- playlist_NodesCreateForSD( p_sys->p_playlist, _("SAP sessions"),
- &p_sys->p_node_cat, &p_sys->p_node_one );
+ playlist_NodesPairCreate( pl_Get( p_sd ), _("SAP sessions"),
+ &p_sys->p_node_cat, &p_sys->p_node_one,
+ VLC_TRUE );
p_sys->i_announces = 0;
p_sys->pp_announces = NULL;
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
- FREE( psz_sdp );
+ FREENULL( psz_sdp );
return VLC_SUCCESS;
error:
- FREE( psz_sdp );
+ FREENULL( psz_sdp );
if( p_sdp ) FreeSDP( p_sdp ); p_sdp = NULL;
stream_Seek( p_demux->s, 0 );
return VLC_EGENERIC;
{
net_Close( p_sys->pi_fd[i] );
}
- FREE( p_sys->pi_fd );
+ FREENULL( p_sys->pi_fd );
#if 0
if( config_GetInt( p_sd, "sap-cache" ) )
{
RemoveAnnounce( p_sd, p_sys->pp_announces[i] );
}
- FREE( p_sys->pp_announces );
-
- if( p_sys->p_playlist )
- {
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_cat, VLC_TRUE,
- VLC_TRUE );
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_one, VLC_TRUE,
- VLC_TRUE );
- vlc_object_release( p_sys->p_playlist );
- }
+ FREENULL( p_sys->pp_announces );
+ playlist_NodeDelete( pl_Get(p_sd), p_sys->p_node_cat, VLC_TRUE,
+ VLC_TRUE );
+ playlist_NodeDelete( pl_Get(p_sd), p_sys->p_node_one, VLC_TRUE,
+ VLC_TRUE );
+ pl_Release( p_sd );
free( p_sys );
}
static int Demux( demux_t *p_demux )
{
sdp_t *p_sdp = p_demux->p_sys->p_sdp;
- playlist_t *p_playlist;
input_thread_t *p_input;
input_item_t *p_parent_input;
- p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_playlist )
- {
- msg_Err( p_demux, "playlist could not be found" );
- return VLC_EGENERIC;
- }
-
+ playlist_t *p_playlist = pl_Yield( p_demux );
p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT,
- FIND_PARENT );
+ FIND_PARENT );
+ assert( p_input );
if( !p_input )
{
msg_Err( p_demux, "parent input could not be found" );
p_parent_input = p_input->input.p_item;
vlc_mutex_lock( &p_parent_input->lock );
- FREE( p_parent_input->psz_uri );
+ FREENULL( p_parent_input->psz_uri );
p_parent_input->psz_uri = strdup( p_sdp->psz_uri );
- FREE( p_parent_input->psz_name );
+ FREENULL( p_parent_input->psz_name );
p_parent_input->psz_name = strdup( EnsureUTF8( p_sdp->psz_sessionname ) );
p_parent_input->i_type = ITEM_TYPE_NET;
CreateAnnounce( p_sd, i_hash, p_sdp );
- FREE( p_decompressed_buffer );
+ FREENULL( p_decompressed_buffer );
return VLC_SUCCESS;
}
}
if( p_sys->b_timeshift )
- vlc_input_item_AddOption( p_input, ":access-filter=timeshift" );
+ input_ItemAddOption( p_input, ":access-filter=timeshift" );
psz_value = GetAttribute( p_sap->p_sdp, "tool" );
if( psz_value != NULL )
{
- vlc_input_item_AddInfo( p_input, _("Session"),_("Tool"), psz_value );
+ input_ItemAddInfo( p_input, _("Session"),_("Tool"), psz_value );
}
if( strcmp( p_sdp->psz_username, "-" ) )
{
- vlc_input_item_AddInfo( p_input, _("Session"),
+ input_ItemAddInfo( p_input, _("Session"),
_("User"), p_sdp->psz_username );
}
if( p_child == NULL )
{
- p_child = playlist_NodeCreate( p_sys->p_playlist, psz_value,
+ p_child = playlist_NodeCreate( pl_Get( p_sd ), psz_value,
p_sys->p_node_cat );
p_child->i_flags &= ~PLAYLIST_SKIP_FLAG;
}
p_child = p_sys->p_node_cat;
}
- p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input, p_child,
+ p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input, p_child,
PLAYLIST_APPEND, PLAYLIST_END );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
p_sap->i_item_id_cat = p_item->i_id;
- p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
+ p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input,
p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
strncmp( psz_parse, "video", 5 ) )
{
msg_Warn( p_obj, "unhandled media type -%s-", psz_parse );
- FREE( psz_uri );
+ FREENULL( psz_uri );
return VLC_EGENERIC;
}
else
{
msg_Warn( p_obj, "unable to parse m field (1)");
- FREE( psz_uri );
+ FREENULL( psz_uri );
return VLC_EGENERIC;
}
else
{
msg_Warn( p_obj, "unable to parse m field (2)");
- FREE( psz_uri );
+ FREENULL( psz_uri );
return VLC_EGENERIC;
}
asprintf( &p_sdp->psz_uri, "%s://%s@%s:%i", psz_proto, psz_source,
psz_uri, i_port );
- FREE( psz_uri );
- FREE( psz_proto );
+ FREENULL( psz_uri );
+ FREENULL( psz_proto );
return VLC_SUCCESS;
}
p_sdp->i_session_id = atoll( psz_sess_id );
- FREE( psz_sess_id );
+ FREENULL( psz_sess_id );
GET_FIELD( psz_sess_id );
- FREE( psz_sess_id );
+ FREENULL( psz_sess_id );
GET_FIELD( p_sdp->psz_network_type );
GET_FIELD( p_sdp->psz_address_type );
static void FreeSDP( sdp_t *p_sdp )
{
int i;
- FREE( p_sdp->psz_sdp );
- FREE( p_sdp->psz_sessionname );
- FREE( p_sdp->psz_connection );
- FREE( p_sdp->psz_media );
- FREE( p_sdp->psz_uri );
- FREE( p_sdp->psz_username );
- FREE( p_sdp->psz_network_type );
+ FREENULL( p_sdp->psz_sdp );
+ FREENULL( p_sdp->psz_sessionname );
+ FREENULL( p_sdp->psz_connection );
+ FREENULL( p_sdp->psz_media );
+ FREENULL( p_sdp->psz_uri );
+ FREENULL( p_sdp->psz_username );
+ FREENULL( p_sdp->psz_network_type );
- FREE( p_sdp->psz_address );
- FREE( p_sdp->psz_address_type );
+ FREENULL( p_sdp->psz_address );
+ FREENULL( p_sdp->psz_address_type );
for( i= p_sdp->i_attributes - 1; i >= 0 ; i-- )
{
struct attribute_t *p_attr = p_sdp->pp_attributes[i];
- FREE( p_sdp->pp_attributes[i]->psz_field );
- FREE( p_sdp->pp_attributes[i]->psz_value );
+ FREENULL( p_sdp->pp_attributes[i]->psz_field );
+ FREENULL( p_sdp->pp_attributes[i]->psz_value );
REMOVE_ELEM( p_sdp->pp_attributes, p_sdp->i_attributes, i);
- FREE( p_attr );
+ FREENULL( p_attr );
}
- FREE( p_sdp );
+ FREENULL( p_sdp );
}
static int RemoveAnnounce( services_discovery_t *p_sd,
}
if( p_announce->i_input_id > -1 )
- {
- playlist_LockDeleteAllFromInput(
- p_sd->p_sys->p_playlist, p_announce->i_input_id );
- }
+ playlist_LockDeleteAllFromInput( pl_Get(p_sd), p_announce->i_input_id );
for( i = 0; i< p_sd->p_sys->i_announces; i++)
{