webradio/shoutcast.c File Reference


Detailed Description

SHOUTcast communication routines.

 *
 * $Log$
 *
 * 

Definition in file shoutcast.c.

Go to the source code of this file.

Defines

#define SHOUTCAST_THREAD_STACK   2048
#define SHOUTCAST_QLIST   "www.shoutcast.com/sbin/newxml.phtml"
#define SHOUTCAST_QTUNE   "www.shoutcast.com/sbin/tunein-station.pls"
#define ENCTYP_MPEG   1
#define ENCTYP_AAC   2
#define ENCTYP_AACP   3
#define ENCTYP_OGG   4
#define ENCTYP_WMA   5

Functions

static FILE * OpenTcpStream (TCPSOCKET *sock, CONST char *host, u_short port)
static int SendHttpRequest (FILE *stream, HTTP_SCHEME *schm)
static int ShoutCastGetGenreList (void)
 Retrieve a genre list from the SHOUTcast server.
int station_cmp (CONST void *ip1, CONST void *ip2)
static int ShoutCastGetStationList (CONST char *genre)
 Retrieve station list of a specified genre from SHOUTcast.
char * ShoutCastGetGenre (int idx)
char * ShoutCastGetStationName (char *genre, int idx)
int ShoutCastAddStation (int idx, int pos)
 Query streams of a specified station and create a favorites list entry.
int ShoutCastGetPlayList (int id)
static int ProcessMetaData (TCPSOCKET *sock, SHOUTCASTINFO *sci, u_int *status)
 Process embedded meta data.
void ShoutCastThread (void *arg)
 SHOUTcast receiver thread.
int ShoutCastCreate (RECEIVERINFO *rip)
 Create a SHOUTcast receiver instance.
int ShoutCastSetup (RECEIVERINFO *rip, STATIONINFO *sip)
 Setup SHOUTcast receiver.

Variables

static char station_genre [32]
static UXML_NODE * genre_tree
static int station_cnt
static STATION_INFO * station_list
RECEIVERPLUGIN rpiShoutcast
 Receiver plug-in reference structure.


Define Documentation

#define SHOUTCAST_THREAD_STACK   2048

Definition at line 89 of file shoutcast.c.

Referenced by ShoutCastCreate().

#define SHOUTCAST_QLIST   "www.shoutcast.com/sbin/newxml.phtml"

Definition at line 93 of file shoutcast.c.

Referenced by ShoutCastGetGenreList(), and ShoutCastGetStationList().

#define SHOUTCAST_QTUNE   "www.shoutcast.com/sbin/tunein-station.pls"

Definition at line 94 of file shoutcast.c.

Referenced by ShoutCastAddStation(), and ShoutCastGetPlayList().

#define ENCTYP_MPEG   1

Definition at line 99 of file shoutcast.c.

#define ENCTYP_AAC   2

Definition at line 100 of file shoutcast.c.

#define ENCTYP_AACP   3

Definition at line 101 of file shoutcast.c.

#define ENCTYP_OGG   4

Definition at line 102 of file shoutcast.c.

#define ENCTYP_WMA   5

Definition at line 103 of file shoutcast.c.


Function Documentation

static FILE* OpenTcpStream ( TCPSOCKET *  sock,
CONST char *  host,
u_short  port 
) [static]

Definition at line 116 of file shoutcast.c.

References LOG_SHOUTCAST, LOG_STATION, LogMsg(), MAX_TCPRCV_WAIT, and TcpHostConnect().

Referenced by ShoutCastAddStation(), ShoutCastGetGenreList(), and ShoutCastGetStationList().

Here is the call graph for this function:

LogMsgTcpHostConnect

static int SendHttpRequest ( FILE *  stream,
HTTP_SCHEME schm 
) [static]

Definition at line 133 of file shoutcast.c.

References proxy, HTTP_PROXY::proxy_port, HTTP_SCHEME::schm_host, HTTP_SCHEME::schm_path, and HTTP_SCHEME::schm_uri.

Referenced by ShoutCastAddStation(), ShoutCastGetGenreList(), and ShoutCastGetStationList().

static int ShoutCastGetGenreList ( void   )  [static]

Retrieve a genre list from the SHOUTcast server.

Definition at line 152 of file shoutcast.c.

References genre_tree, HttpSchemeParse(), HttpSchemeRelease(), OpenTcpStream(), HTTP_SCHEME::schm_host, HTTP_SCHEME::schm_portnum, SendHttpRequest(), and SHOUTCAST_QLIST.

Referenced by ShoutCastGetGenre().

Here is the call graph for this function:

HttpSchemeParseHttpSchemeReleaseOpenTcpStreamSendHttpRequestLogMsgTcpHostConnect

int station_cmp ( CONST void *  ip1,
CONST void *  ip2 
)

Definition at line 183 of file shoutcast.c.

Referenced by ShoutCastGetStationList().

static int ShoutCastGetStationList ( CONST char *  genre  )  [static]

Retrieve station list of a specified genre from SHOUTcast.

Definition at line 192 of file shoutcast.c.

References HttpSchemeParse(), HttpSchemeRelease(), LOG_SHOUTCAST, LogMsg(), OpenTcpStream(), HTTP_SCHEME::schm_host, HTTP_SCHEME::schm_portnum, SendHttpRequest(), SHOUTCAST_QLIST, station_cmp(), station_cnt, station_genre, and station_list.

Referenced by ShoutCastGetStationName().

Here is the call graph for this function:

HttpSchemeParseHttpSchemeReleaseLogMsgOpenTcpStreamSendHttpRequeststation_cmpTcpHostConnect

char* ShoutCastGetGenre ( int  idx  ) 

Definition at line 275 of file shoutcast.c.

Referenced by CgiShoutCastGenres().

char* ShoutCastGetStationName ( char *  genre,
int  idx 
)

Definition at line 298 of file shoutcast.c.

Referenced by CgiShoutCastStations().

int ShoutCastAddStation ( int  idx,
int  pos 
)

Query streams of a specified station and create a favorites list entry.

Parameters:
idx SHOUTcast station list index.
pos Favorites list index.
Returns:
0 on success, -1 otherwise.

Definition at line 317 of file shoutcast.c.

Referenced by CgiShoutCastControl().

int ShoutCastGetPlayList ( int  id  ) 

Definition at line 374 of file shoutcast.c.

References HttpSchemeParse(), HttpSchemeRelease(), LOG_SHOUTCAST, LOG_STATION, LogMsg(), MAX_TCPRCV_WAIT, proxy, HTTP_PROXY::proxy_port, HTTP_SCHEME::schm_host, HTTP_SCHEME::schm_path, HTTP_SCHEME::schm_portnum, HTTP_SCHEME::schm_uri, SHOUTCAST_QTUNE, TcpGetLine(), TcpHostConnect(), and TcpPutString().

Here is the call graph for this function:

HttpSchemeParseHttpSchemeReleaseLogMsgTcpGetLineTcpHostConnectTcpPutString

static int ProcessMetaData ( TCPSOCKET *  sock,
SHOUTCASTINFO sci,
u_int *  status 
) [static]

Process embedded meta data.

Definition at line 464 of file shoutcast.c.

References DIST_FORCE, LOG_SHOUTCAST, LogMsg(), SHOUTCASTINFO::sci_metatitle, SHOUTCASTINFO::sci_metaurl, strdup(), TcpGetBuffer(), and UserIfShowStatus().

Referenced by ShoutCastThread().

Here is the call graph for this function:

LogMsgstrdupTcpGetBufferUserIfShowStatus

void ShoutCastThread ( void *  arg  ) 

SHOUTcast receiver thread.

Reads audio data from a TCP socket and passes it to a ring buffer. Meta data is parsed and removed from the audio stream.

Parameters:
arg Pointer to the player info structure.

Definition at line 544 of file shoutcast.c.

References DIST_FORCE, LOG_ERROR, LOG_SHOUTCAST, LOG_WARN, LogMsg(), MAX_WAIT_MP3BUF_FILLED, ProcessMetaData(), RECEIVERINFO::ri_bcast, RECEIVERINFO::ri_cmdevt, RECEIVERINFO::ri_decoder, RECEIVERINFO::ri_sip, RECEIVERINFO::ri_status, RECEIVERINFO::ri_stsevt, RSTAT_BUFFERING, RSTAT_IDLE, RSTAT_RUNNING, RSTAT_START, RSTAT_STOP, SHOUTCASTINFO::sci_metaint, SHOUTCASTINFO::sci_metapos, and UserIfShowStatus().

Referenced by ShoutCastCreate().

Here is the call graph for this function:

LogMsgProcessMetaDataUserIfShowStatusstrdupTcpGetBuffer

int ShoutCastCreate ( RECEIVERINFO rip  ) 

Create a SHOUTcast receiver instance.

Parameters:
rip Pointer to the receiver information structure.
Returns:
0 on success, -1 otherwise.

Definition at line 699 of file shoutcast.c.

References RECEIVERINFO::ri_bcast, SHOUTCAST_THREAD_STACK, and ShoutCastThread().

Here is the call graph for this function:

ShoutCastThreadLogMsgProcessMetaDataUserIfShowStatusstrdupTcpGetBuffer

int ShoutCastSetup ( RECEIVERINFO rip,
STATIONINFO sip 
)

Setup SHOUTcast receiver.

Parses the header lines of the HTTP response.

Returns:
0 on success, or -1 if the server responded with an error code or doesn't seem to provide a SHOUTcast stream.

Definition at line 725 of file shoutcast.c.

References CONTENT_TYPE_AACP, CONTENT_TYPE_MP3, CONTENT_TYPE_OGG, CONTENT_TYPE_UNKNOWN, PROTOCOL_TYPE_ICECAST, PROTOCOL_TYPE_SHOUTCAST, RECEIVERINFO::ri_bcast, SHOUTCASTINFO::sci_metaint, STATIONINFO::si_bitrate, STATIONINFO::si_content, STATIONINFO::si_genre, STATIONINFO::si_header, STATIONINFO::si_name, and STATIONINFO::si_protocol.


Variable Documentation

char station_genre[32] [static]

Definition at line 96 of file shoutcast.c.

Referenced by ShoutCastGetStationList(), and ShoutCastGetStationName().

UXML_NODE* genre_tree [static]

Definition at line 97 of file shoutcast.c.

Referenced by ShoutCastGetGenre(), and ShoutCastGetGenreList().

int station_cnt [static]

Definition at line 113 of file shoutcast.c.

Referenced by ShoutCastAddStation(), ShoutCastGetStationList(), and ShoutCastGetStationName().

STATION_INFO* station_list [static]

Definition at line 114 of file shoutcast.c.

Referenced by ShoutCastAddStation(), ShoutCastGetStationList(), and ShoutCastGetStationName().

RECEIVERPLUGIN rpiShoutcast

Initial value:

Receiver plug-in reference structure.

Used by the application to create a SHOUTcast receiver instance.

Definition at line 796 of file shoutcast.c.

Referenced by main().


© 2008 by egnite GmbH - visit www.ethernut.de