Commit b86c36e6 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

modules/services_discovery/podcast.c: Use the new API.

parent 3d041f13
......@@ -78,8 +78,6 @@ vlc_module_end();
struct services_discovery_sys_t
{
/* playlist node */
playlist_item_t *p_node_cat;
playlist_item_t *p_node_one;
input_thread_t **pp_input;
char **ppsz_urls;
......@@ -101,10 +99,49 @@ static int Open( vlc_object_t *p_this )
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = malloc(
sizeof( services_discovery_sys_t ) );
p_sys->i_urls = 0;
p_sys->ppsz_urls = NULL;
p_sys->pp_input = NULL;
p_sd->pf_run = Run;
p_sd->p_sys = p_sys;
/* Give us a name */
services_discovery_SetLocalizedName( p_sd, _("Podcasts") );
vlc_value_t val;
playlist_t *p_playlist;
playlist_item_t *p_item;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close:
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys;
int i;
for( i = 0; i < p_sys->i_urls; i++ )
{
if( p_sd->p_sys->pp_input[i] )
{
input_StopThread( p_sd->p_sys->pp_input[i] );
input_DestroyThread( p_sd->p_sys->pp_input[i] );
p_sd->p_sys->pp_input[i] = NULL;
}
}
free( p_sd->p_sys->pp_input );
for( i = 0; i < p_sys->i_urls; i++ ) free( p_sys->ppsz_urls[i] );
free( p_sys->ppsz_urls );
free( p_sys );
}
/*****************************************************************************
* Run: main thread
*****************************************************************************/
static void Run( services_discovery_t *p_sd )
{
services_discovery_sys_t *p_sys = p_sd->p_sys;
int i, j;
char *psz_buf;
......@@ -136,90 +173,18 @@ static int Open( vlc_object_t *p_this )
p_sys->ppsz_urls[j] = strdup( psz_tmp );
free( psz_buf );
p_sd->pf_run = Run;
p_sd->p_sys = p_sys;
/* Create our playlist node */
p_playlist = (playlist_t *)vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_sd, "unable to find playlist, cancelling");
return VLC_EGENERIC;
}
p_sys->p_node_cat = playlist_NodeCreate( p_playlist, _("Podcast"),
p_playlist->p_root_category, 0 );
p_sys->p_node_one = playlist_NodeCreate( p_playlist, _("Podcast"),
p_playlist->p_root_onelevel, 0 );
p_sys->p_node_one->p_input->i_id = p_sys->p_node_cat->p_input->i_id;
p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG;
p_sys->p_node_cat->i_flags |= PLAYLIST_RO_FLAG;
p_sys->p_node_one->i_flags |= PLAYLIST_SKIP_FLAG;
p_sys->p_node_cat->i_flags |= PLAYLIST_SKIP_FLAG;
p_sys->pp_input = malloc( p_sys->i_urls * sizeof( input_thread_t * ) );
for( i = 0; i < p_sys->i_urls; i++ )
{
input_item_t *p_input;
asprintf( &psz_buf, "%s", p_sys->ppsz_urls[i] );
p_input = input_ItemNewExt( p_playlist, psz_buf,
p_input = input_ItemNewExt( p_sd, psz_buf,
p_sys->ppsz_urls[i], 0, NULL, -1 );
input_ItemAddOption( p_input, "demux=podcast" );
p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_cat,
PLAYLIST_APPEND, PLAYLIST_END,
VLC_FALSE );
p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_one,
PLAYLIST_APPEND, PLAYLIST_END,
VLC_FALSE );
free( psz_buf );
p_sys->pp_input[i] = input_CreateThread( p_playlist, p_input );
}
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
vlc_object_release( p_playlist );
return VLC_SUCCESS;
}
/*****************************************************************************
* Close:
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys;
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_sd,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
int i;
for( i = 0; i < p_sys->i_urls; i++ )
{
if( p_sd->p_sys->pp_input[i] )
{
input_StopThread( p_sd->p_sys->pp_input[i] );
input_DestroyThread( p_sd->p_sys->pp_input[i] );
p_sd->p_sys->pp_input[i] = NULL;
}
}
free( p_sd->p_sys->pp_input );
if( p_playlist )
{
playlist_NodeDelete( p_playlist, p_sys->p_node_cat, VLC_TRUE, VLC_TRUE );
playlist_NodeDelete( p_playlist, p_sys->p_node_one, VLC_TRUE, VLC_TRUE );
vlc_object_release( p_playlist );
services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );
p_sys->pp_input[i] = input_CreateThread( p_sd, p_input );
}
for( i = 0; i < p_sys->i_urls; i++ ) free( p_sys->ppsz_urls[i] );
free( p_sys->ppsz_urls );
free( p_sys );
}
/*****************************************************************************
* Run: main thread
*****************************************************************************/
static void Run( services_discovery_t *p_sd )
{
while( !p_sd->b_die )
{
int i;
......
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