Commit 8f81a57b authored by dionoea's avatar dionoea
Browse files

Support for Shoutcast TV. vp3 streams segfault, vp5 and 6 don't play :)

parent aa98ec01
......@@ -48,6 +48,7 @@ struct demux_sys_t
/* duplicate from modules/services_discovery/shout.c */
#define SHOUTCAST_BASE_URL "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml"
#define SHOUTCAST_TUNEIN_BASE_URL "http://www.shoutcast.com"
#define SHOUTCAST_TV_TUNEIN_URL "http://www.shoutcast.com/sbin/tunein-tvstation.pls?id="
/*****************************************************************************
* Local prototypes
......@@ -303,7 +304,8 @@ static int DemuxGenre( demux_t *p_demux )
return 0;
}
/* <stationlist>
/* radio stations:
* <stationlist>
* <tunein base="/sbin/tunein-station.pls"></tunein>
* <station name="the name"
* mt="mime type"
......@@ -313,6 +315,19 @@ static int DemuxGenre( demux_t *p_demux )
* ct="current track name/author/..."
* lc="listener count"></station>
* </stationlist>
*
* TV stations:
* <stationlist>
* <tunein base="/sbin/tunein-station.pls"></tunein>
* <station name="the name"
* id="the id"
* br="bit rate"
* rt="rating"
* load="server load ?"
* ct="current track name/author/..."
* genre="A big genre string"
* lc="listener count"></station>
* </stationlist>
**/
static int DemuxStation( demux_t *p_demux )
{
......@@ -328,6 +343,10 @@ static int DemuxStation( demux_t *p_demux )
char *psz_ct = NULL; /* current track */
char *psz_lc = NULL; /* listener count */
/* If these are set then it's *not* a radio but a TV */
char *psz_rt = NULL; /* rating for shoutcast TV */
char *psz_load = NULL; /* load for shoutcast TV */
char *psz_eltname = NULL; /* tag name */
while( xml_ReaderRead( p_sys->p_xml_reader ) == 1 )
......@@ -387,6 +406,8 @@ static int DemuxStation( demux_t *p_demux )
else GET_VALUE( genre )
else GET_VALUE( ct )
else GET_VALUE( lc )
else GET_VALUE( rt )
else GET_VALUE( load )
else
{
msg_Warn( p_demux,
......@@ -409,14 +430,29 @@ static int DemuxStation( demux_t *p_demux )
free( psz_eltname );
psz_eltname = xml_ReaderName( p_sys->p_xml_reader );
if( !psz_eltname ) return -1;
if( !strcmp( psz_eltname, "station" ) && psz_base )
if( !strcmp( psz_eltname, "station" ) &&
( psz_base || ( psz_rt && psz_load ) ) )
{
playlist_item_t *p_item;
char *psz_mrl = malloc( strlen( SHOUTCAST_TUNEIN_BASE_URL )
char *psz_mrl = NULL;
if( psz_rt || psz_load )
{
/* tv */
psz_mrl = malloc( strlen( SHOUTCAST_TV_TUNEIN_URL )
+ strlen( psz_id ) + 1 );
sprintf( psz_mrl, SHOUTCAST_TV_TUNEIN_URL "%s",
psz_id );
}
else
{
/* radio */
psz_mrl = malloc( strlen( SHOUTCAST_TUNEIN_BASE_URL )
+ strlen( psz_base ) + strlen( "?id=" )
+ strlen( psz_id ) + 1 );
sprintf( psz_mrl, SHOUTCAST_TUNEIN_BASE_URL "%s?id=%s",
sprintf( psz_mrl, SHOUTCAST_TUNEIN_BASE_URL "%s?id=%s",
psz_base, psz_id );
}
msg_Warn( p_demux, "%s", psz_mrl );
p_item = playlist_ItemNew( p_sys->p_playlist, psz_mrl,
psz_name );
free( psz_mrl );
......@@ -461,6 +497,22 @@ static int DemuxStation( demux_t *p_demux )
"%s",
psz_lc );
}
else if( psz_rt )
{
vlc_input_item_AddInfo( &p_item->input,
_( "Shoutcast" ),
_( "Rating" ),
"%s",
psz_rt );
}
else if( psz_load )
{
vlc_input_item_AddInfo( &p_item->input,
_( "Shoutcast" ),
_( "Load" ),
"%s",
psz_load );
}
playlist_NodeAddItem( p_sys->p_playlist, p_item,
p_sys->p_current->pp_parents[0]->i_view,
......@@ -482,6 +534,7 @@ static int DemuxStation( demux_t *p_demux )
FREE( psz_genre )
FREE( psz_ct )
FREE( psz_lc )
FREE( psz_rt )
#undef FREE
}
free( psz_eltname );
......
......@@ -50,13 +50,16 @@
#define MAX_LINE_LENGTH 256
#define SHOUTCAST_BASE_URL "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml"
#define SHOUTCAST_TV_BASE_URL "http/shout-winamp://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
/* Callbacks */
static int Open ( vlc_object_t * );
static int Open ( vlc_object_t *, int );
static int OpenRadio ( vlc_object_t * );
static int OpenTV ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin();
......@@ -68,7 +71,14 @@ vlc_module_begin();
add_suppressed_integer( "shoutcast-limit" );
set_capability( "services_discovery", 0 );
set_callbacks( Open, Close );
set_callbacks( OpenRadio, Close );
add_submodule();
set_shortname( "ShoutcastTV" );
set_description( _("Shoutcast TV listings") );
set_capability( "services_discovery", 0 );
set_callbacks( OpenTV, Close );
add_shortcut( "shoutcasttv" );
vlc_module_end();
......@@ -83,6 +93,9 @@ struct services_discovery_sys_t
vlc_bool_t b_dialog;
};
#define RADIO 0
#define TV 1
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -90,10 +103,20 @@ struct services_discovery_sys_t
/* Main functions */
static void Run ( services_discovery_t *p_intf );
static int OpenRadio( vlc_object_t *p_this )
{
return Open( p_this, RADIO );
}
static int OpenTV( vlc_object_t *p_this )
{
return Open( p_this, TV );
}
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
static int Open( vlc_object_t *p_this )
static int Open( vlc_object_t *p_this, int i_type )
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = malloc(
......@@ -118,8 +141,18 @@ static int Open( vlc_object_t *p_this )
p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
p_sys->p_item =
p_item = playlist_ItemNew( p_playlist, SHOUTCAST_BASE_URL, _("Shoutcast") );
switch( i_type )
{
case TV:
p_sys->p_item = p_item = playlist_ItemNew( p_playlist,
SHOUTCAST_TV_BASE_URL, _("Shoutcast TV") );
break;
case RADIO:
default:
p_sys->p_item = p_item = playlist_ItemNew( p_playlist,
SHOUTCAST_BASE_URL, _("Shoutcast") );
break;
}
playlist_NodeAddItem( p_playlist, p_item, p_view->i_id,
p_view->p_root, PLAYLIST_APPEND,
PLAYLIST_END );
......
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