[xiph-commits] r18544 - in icecast/trunk/ices: doc src
ph3-der-loewe at svn.xiph.org
ph3-der-loewe at svn.xiph.org
Sat Aug 18 19:37:45 PDT 2012
Author: ph3-der-loewe
Date: 2012-08-18 19:37:44 -0700 (Sat, 18 Aug 2012)
New Revision: 18544
Modified:
icecast/trunk/ices/doc/inputs.html
icecast/trunk/ices/src/im_playlist.c
icecast/trunk/ices/src/playlist_basic.c
icecast/trunk/ices/src/playlist_basic.h
Log:
Added support for more playlist formats: m3u and VCLT.
This is the first patch of my multi-playlist format series.
Modified: icecast/trunk/ices/doc/inputs.html
===================================================================
--- icecast/trunk/ices/doc/inputs.html 2012-08-18 20:34:11 UTC (rev 18543)
+++ icecast/trunk/ices/doc/inputs.html 2012-08-19 02:37:44 UTC (rev 18544)
@@ -160,7 +160,7 @@
type. The current types are basic and script.
</p>
- <h3>Basic</h3>
+ <h3>Basic / M3U / VCLT</h3>
<pre>
<param name="type">basic</param>
<param name="file">/path/to/playlist</param>
@@ -168,10 +168,18 @@
<param name="once">0</param>
<param name="restart-after-reread">1</param>
</pre>
+ <h4>type</h4>
+ <div class=indentedbox>
+ This is the file format of the playlist.
+ Currently "basic", "m3u" and "vclt" are supported.
+ </div>
<h4>file</h4>
<div class=indentedbox>
State a path to a file which will contain a list of Ogg Vorbis filenames
- to play. One per line with lines beginning with '#' being treated as
+ to play.
+ The format of this file depends on the setting of "type".
+ For type "basic" the format is
+ one filename per line with lines beginning with '#' being treated as
comments. If a line has a single '-' then standard input is read, which
provides a way of getting some external Ogg Vorbis stream into ices.
</div>
Modified: icecast/trunk/ices/src/im_playlist.c
===================================================================
--- icecast/trunk/ices/src/im_playlist.c 2012-08-18 20:34:11 UTC (rev 18543)
+++ icecast/trunk/ices/src/im_playlist.c 2012-08-19 02:37:44 UTC (rev 18544)
@@ -46,6 +46,8 @@
static module modules[] = {
{ "basic", playlist_basic_initialise},
+ { "m3u", playlist_basic_initialise},
+ { "vclt", playlist_basic_initialise},
{ "script", playlist_script_initialise},
{NULL,NULL}
};
Modified: icecast/trunk/ices/src/playlist_basic.c
===================================================================
--- icecast/trunk/ices/src/playlist_basic.c 2012-08-18 20:34:11 UTC (rev 18543)
+++ icecast/trunk/ices/src/playlist_basic.c 2012-08-19 02:37:44 UTC (rev 18544)
@@ -54,6 +54,8 @@
FILE *file;
char buf[1024];
int buflen;
+ char *ret;
+ int is_next_entry = 1;
file = fopen(data->file, "rb");
@@ -76,28 +78,45 @@
buflen = 0;
while (1)
{
- if(fgets(buf,1024, file) == NULL) break;
- if(buf[0]==0) break;
+ if((ret=fgets(buf, sizeof(buf), file)) == NULL) break;
+ if(ret[0]==0) break;
- if(buf[0]=='\n' || (buf[0]=='\r' && buf[1]=='\n'))
+ if(ret[0]=='\n' || (ret[0]=='\r' && ret[1]=='\n'))
continue;
- if(buf[0] == '#') /* Commented out entry */
+ if(ret[0] == '#') /* Commented out entry */
continue;
- buf[strlen(buf)-1] = 0;
+ ret[strlen(ret)-1] = 0;
/* De-fuck windows files. */
- if(strlen(buf) > 0 && buf[strlen(buf)-1] == '\r')
- buf[strlen(buf)-1] = 0;
+ if(strlen(ret) > 0 && ret[strlen(ret)-1] == '\r')
+ ret[strlen(ret)-1] = 0;
+ if (data->type == PLAYLIST_VCLT)
+ {
+ if (!strcmp(ret, "=="))
+ {
+ is_next_entry = 1;
+ continue;
+ }
+
+ if (!is_next_entry)
+ continue;
+
+ if (!!strncasecmp(ret, "FILENAME=", 9))
+ continue;
+ ret += 9;
+ is_next_entry = 0;
+ }
+
if(buflen < data->len+1)
{
buflen += 100;
data->pl = realloc(data->pl, buflen*sizeof(char *));
}
- data->pl[data->len++] = strdup(buf);
+ data->pl[data->len++] = strdup(ret);
}
if (!data->len)
@@ -186,6 +205,16 @@
free (fn);
}
+static basic_playlist_type _str2type(const char * type) {
+ if ( !strcmp(type, "basic") )
+ return PLAYLIST_BASIC;
+ if ( !strcmp(type, "m3u") )
+ return PLAYLIST_M3U;
+ if ( !strcmp(type, "vclt") )
+ return PLAYLIST_VCLT;
+ return PLAYLIST_INVALID;
+}
+
int playlist_basic_initialise(module_param_t *params, playlist_state_t *pl)
{
basic_playlist *data;
@@ -209,7 +238,7 @@
else if(!strcmp(params->name, "restart-after-reread"))
data->restartafterreread = atoi(params->value);
else if(!strcmp(params->name, "type"))
- ; /* We recognise this, but don't want to do anything with it */
+ data->type = _str2type(params->value);
else
{
LOG_WARN1("Unknown parameter to playlist input module: %s",
@@ -225,6 +254,13 @@
return -1;
}
+ if (data->type == PLAYLIST_INVALID)
+ {
+ LOG_ERROR0("Playlist type invalid for playlist module");
+ free(data);
+ return -1;
+ }
+
return 0;
}
Modified: icecast/trunk/ices/src/playlist_basic.h
===================================================================
--- icecast/trunk/ices/src/playlist_basic.h 2012-08-18 20:34:11 UTC (rev 18543)
+++ icecast/trunk/ices/src/playlist_basic.h 2012-08-19 02:37:44 UTC (rev 18544)
@@ -14,6 +14,14 @@
#ifndef __PLAYLIST_BASIC_H__
#define __PLAYLIST_BASIC_H__
+typedef enum
+{
+ PLAYLIST_INVALID,
+ PLAYLIST_BASIC,
+ PLAYLIST_M3U,
+ PLAYLIST_VCLT,
+} basic_playlist_type;
+
typedef struct
{
char **pl;
@@ -24,6 +32,7 @@
int random;
int once;
int restartafterreread;
+ basic_playlist_type type; /* Playlist type */
} basic_playlist;
More information about the commits
mailing list