* Includes
*****************************************************************************/
#include <vlc/vlc.h>
-#include <stdlib.h> /* malloc(), free() */
#include <assert.h>
#include <vlc_playlist.h>
sdp_t *p_sdp;
int i_input_id;
- int i_item_id_cat;
- int i_item_id_one;
};
struct services_discovery_sys_t
int i_fd;
int *pi_fd;
- /* playlist node */
- playlist_item_t *p_node_cat;
- playlist_item_t *p_node_one;
-
/* Table of announces */
int i_announces;
struct sap_announce_t **pp_announces;
#endif
/* Cache sap_timeshift value */
- p_sys->b_timeshift = var_CreateGetInteger( p_sd, "sap-timeshift" )
- ? VLC_TRUE : VLC_FALSE;
+ p_sys->b_timeshift = var_CreateGetInteger( p_sd, "sap-timeshift" );
- /* Create our playlist node */
- pl_Yield( p_sd );
+ /* Set our name */
+ services_discovery_SetLocalizedName( p_sd, _("SAP sessions") );
- playlist_NodesPairCreate( pl_Get( p_sd ), _("SAP sessions"),
- &p_sys->p_node_cat, &p_sys->p_node_one,
- VLC_TRUE );
- p_sys->p_node_cat->p_input->b_prefers_tree = VLC_TRUE;
p_sys->i_announces = 0;
p_sys->pp_announces = NULL;
char *psz_sdp = NULL;
sdp_t *p_sdp = NULL;
int errval = VLC_EGENERIC;
+ size_t i_len;
if( !var_CreateGetInteger( p_demux, "sap-parse" ) )
{
return VLC_EGENERIC;
/* Gather the complete sdp file */
- psz_sdp = NULL;
-
-#define SDP_MAX 65536
-#define OFFSET 1024
-
- for( size_t buflen = 0; buflen < SDP_MAX; buflen += OFFSET )
+ for( i_len = 0, psz_sdp = NULL; i_len < 65536; )
{
- char *psz_sdp_new = realloc( psz_sdp, buflen + 1 );
+ const int i_read_max = 1024;
+ char *psz_sdp_new = realloc( psz_sdp, i_len + i_read_max );
+ size_t i_read;
if( psz_sdp_new == NULL )
{
errval = VLC_ENOMEM;
}
psz_sdp = psz_sdp_new;
- ssize_t i_read = stream_Read( p_demux->s, psz_sdp + buflen, OFFSET );
+ i_read = stream_Read( p_demux->s, &psz_sdp[i_len], i_read_max );
if( i_read < 0 )
{
msg_Err( p_demux, "cannot read SDP" );
goto error;
}
+ i_len += i_read;
- psz_sdp[buflen + i_read] = '\0';
+ psz_sdp[i_len] = '\0';
- if( i_read < OFFSET )
+ if( i_read < i_read_max )
break; // EOF
}
-#undef OFFSET
p_sdp = ParseSDP( VLC_OBJECT(p_demux), psz_sdp );
}
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 );
}
return VLC_EGENERIC;
}
- p_parent_input = input_GetItem(p_input);
+ p_parent_input = input_GetItem( p_input );
+
+ input_item_SetURI( p_parent_input, p_sdp->psz_uri );
+ input_item_SetName( p_parent_input, p_sdp->psz_sessionname );
vlc_mutex_lock( &p_parent_input->lock );
- FREENULL( p_parent_input->psz_uri );
- p_parent_input->psz_uri = strdup( p_sdp->psz_uri );
- FREENULL( p_parent_input->psz_name );
- p_parent_input->psz_name = strdup( p_sdp->psz_sessionname );
+
p_parent_input->i_type = ITEM_TYPE_NET;
if( p_playlist->status.p_item &&
sdp_t *p_sdp )
{
input_item_t *p_input;
- playlist_item_t *p_item, *p_child;
const char *psz_value;
sap_announce_t *p_sap = (sap_announce_t *)malloc(
sizeof(sap_announce_t ) );
psz_value = GetAttribute( p_sap->p_sdp->pp_attributes, p_sap->p_sdp->i_attributes, "tool" );
if( psz_value != NULL )
{
- input_ItemAddInfo( p_input, _("Session"),_("Tool"), psz_value );
+ input_ItemAddInfo( p_input, _("Session"), _("Tool"), "%s",
+ psz_value );
}
if( strcmp( p_sdp->username, "-" ) )
{
- input_ItemAddInfo( p_input, _("Session"),
- _("User"), p_sdp->username );
+ input_ItemAddInfo( p_input, _("Session"), _("User"), "%s",
+ p_sdp->username );
}
/* Handle group */
else
psz_value = GetAttribute( p_sap->p_sdp->pp_attributes, p_sap->p_sdp->i_attributes, "x-plgroup" );
- if( psz_value != NULL )
- {
- p_child = playlist_ChildSearchName( p_sys->p_node_cat, psz_value );
-
- if( p_child == NULL )
- {
- p_child = playlist_NodeCreate( pl_Get( p_sd ), psz_value,
- p_sys->p_node_cat, 0 );
- p_child->i_flags &= ~PLAYLIST_SKIP_FLAG;
- }
- }
- else
- {
- p_child = p_sys->p_node_cat;
- }
-
- p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input, p_child,
- PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
- 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( pl_Get( p_sd ), p_input,
- p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END,
- VLC_FALSE );
- p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
- p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
- p_sap->i_item_id_one = p_item->i_id;
+ services_discovery_AddItem( p_sd, p_input, psz_value /* category name */ );
TAB_APPEND( p_sys->i_announces, p_sys->pp_announces, p_sap );