summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_playlist.c')
-rw-r--r--src/demuxers/demux_playlist.c172
1 files changed, 86 insertions, 86 deletions
diff --git a/src/demuxers/demux_playlist.c b/src/demuxers/demux_playlist.c
index 3dd689657..a273f0242 100644
--- a/src/demuxers/demux_playlist.c
+++ b/src/demuxers/demux_playlist.c
@@ -1,18 +1,18 @@
/*
* Copyright (C) 2007 the xine project
- *
+ *
* This file is part of xine, a free video player.
- *
+ *
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
@@ -22,7 +22,7 @@
* Claudio Ciccani (klan@users.sourceforge.net)
*
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -60,13 +60,13 @@ typedef enum {
typedef struct {
demux_plugin_t demux_plugin;
-
+
xine_t *xine;
xine_stream_t *stream;
input_plugin_t *input;
-
+
playlist_t playlist;
-
+
int status;
} demux_playlist_t;
@@ -76,12 +76,12 @@ typedef struct {
static playlist_t detect_by_extension (input_plugin_t *input) {
- char *ext;
-
+ char *ext;
+
ext = strrchr (input->get_mrl (input), '.');
if (!ext)
- return XINE_PLT_NONE;
-
+ return XINE_PLT_NONE;
+
if (!strcasecmp (ext, ".m3u"))
return XINE_PLT_M3U;
if (!strcasecmp (ext, ".ram"))
@@ -108,24 +108,24 @@ static playlist_t detect_by_extension (input_plugin_t *input) {
static playlist_t detect_by_content (input_plugin_t *input) {
char buf[256], *tmp;
int len;
-
+
len = _x_demux_read_header (input, buf, sizeof(buf)-1);
if (len <= 0)
return XINE_PLT_NONE;
buf[len] = '\0';
-
+
tmp = buf;
while (*tmp && isspace(*tmp))
tmp++;
-
+
if (!strncmp (tmp, "[Reference]", 11) ||
!strncmp (tmp, "Ref1=", 5))
return XINE_PLT_REF;
if (!strncmp (tmp, "#EXTM3U", 7))
return XINE_PLT_M3U;
if (!strncmp (tmp, "file://", 7) ||
- !strncmp (tmp, "http://", 7) ||
- !strncmp (tmp, "rtsp://", 7) ||
+ !strncmp (tmp, "http://", 7) ||
+ !strncmp (tmp, "rtsp://", 7) ||
!strncmp (tmp, "pnm://", 6))
return XINE_PLT_RAM;
if (!strncmp (tmp, "[Playlist]", 10 ))
@@ -140,7 +140,7 @@ static playlist_t detect_by_content (input_plugin_t *input) {
return XINE_PLT_XSPF;
if (!strncmp (tmp, "<rss", 4))
return XINE_PLT_RSS;
-
+
if (!strncmp (tmp, "<?xml", 5)) {
tmp += 5;
while ((tmp = strchr (tmp, '<'))) {
@@ -157,27 +157,27 @@ static playlist_t detect_by_content (input_plugin_t *input) {
tmp++;
}
}
-
+
return XINE_PLT_NONE;
}
static char* trim (char *s) {
char *e;
-
+
while (*s && isspace(*s))
s++;
-
+
e = s + strlen(s) - 1;
while (e > s && isspace(*e))
*e-- = '\0';
-
+
return s;
}
static int parse_time (const char *s) {
int t = 0;
int i;
-
+
if (!s)
return 0;
@@ -185,7 +185,7 @@ static int parse_time (const char *s) {
s += 4;
else if (!strncmp (s, "smpte=", 6))
s += 6;
-
+
for (i = 0; i < 3; i++) {
t *= 60;
t += atoi(s);
@@ -202,12 +202,12 @@ static void parse_ref (demux_playlist_t *this, char *data, int length) {
char *src = data;
char *end;
int alt = 0;
-
+
while (src && *src) {
end = strchr (src, '\n');
if (end)
*end = '\0';
-
+
src = trim (src);
if (!strncmp (src, "Ref", 3)) {
src = strchr (src, '=');
@@ -216,7 +216,7 @@ static void parse_ref (demux_playlist_t *this, char *data, int length) {
_x_demux_send_mrl_reference (this->stream, alt++, src+1, NULL, 0, 0);
}
}
-
+
src = end;
if (src)
src++;
@@ -227,12 +227,12 @@ static void parse_m3u (demux_playlist_t *this, char *data, int length) {
char *src = data;
char *end;
char *title = NULL;
-
+
while (src && *src) {
end = strchr (src, '\n');
if (end)
*end = '\0';
-
+
src = trim (src);
if (*src == '#') {
if (!strncmp (src+1, "EXTINF:", 7)) {
@@ -245,7 +245,7 @@ static void parse_m3u (demux_playlist_t *this, char *data, int length) {
lprintf ("mrl:'%s'\n", src);
_x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
}
-
+
src = end;
if (src)
src++;
@@ -255,19 +255,19 @@ static void parse_m3u (demux_playlist_t *this, char *data, int length) {
static void parse_ram (demux_playlist_t *this, char *data, int length) {
char *src = data;
char *end;
-
+
while (src && *src) {
end = strchr (src, '\n');
if (end)
*end = '\0';
-
- src = trim (src);
+
+ src = trim (src);
if (!strcmp (src, "--stop--"))
break;
-
+
if (*src && *src != '#') {
char *title = NULL;
-
+
if (!strncmp (src, "rtsp://", 7) || !strncmp (src, "pnm://", 7)) {
char *tmp = strrchr (src, '?');
if (tmp) {
@@ -281,11 +281,11 @@ static void parse_ram (demux_playlist_t *this, char *data, int length) {
}
}
}
-
+
lprintf ("mrl:'%s'\n", src);
_x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
}
-
+
src = end;
if (src)
src++;
@@ -295,12 +295,12 @@ static void parse_ram (demux_playlist_t *this, char *data, int length) {
static void parse_pls (demux_playlist_t *this, char *data, int length) {
char *src = data;
char *end;
-
+
while (src && *src) {
end = strchr (src, '\n');
if (end)
*end = '\0';
-
+
src = trim (src);
if (!strncmp (src, "File", 4)) {
src = strchr (src+4, '=');
@@ -309,7 +309,7 @@ static void parse_pls (demux_playlist_t *this, char *data, int length) {
_x_demux_send_mrl_reference (this->stream, 0, src+1, NULL, 0, 0);
}
}
-
+
src = end;
if (src)
src++;
@@ -319,20 +319,20 @@ static void parse_pls (demux_playlist_t *this, char *data, int length) {
static void parse_asx (demux_playlist_t *this, char *data, int length) {
xml_node_t *root, *node, *tmp;
int is_asx = 0;
-
+
xml_parser_init (data, length, XML_PARSER_CASE_INSENSITIVE);
-
+
if (xml_parser_build_tree (&root) >= 0) {
if (!strcasecmp (root->name, "asx")) {
is_asx = 1;
-
+
for (node = root->child; node; node = node->next) {
if (!strcasecmp (node->name, "entry")) {
const char *title = NULL;
const char *src = NULL;
const char *start = NULL;
const char *duration = NULL;
-
+
for (tmp = node->child; tmp; tmp = tmp->next) {
if (!strcasecmp (tmp->name, "title")) {
title = tmp->data;
@@ -347,7 +347,7 @@ static void parse_asx (demux_playlist_t *this, char *data, int length) {
duration = xml_parser_get_property (tmp, "value");
}
}
-
+
if (src) {
lprintf ("mrl:'%s'\n", src);
_x_demux_send_mrl_reference (this->stream, 0, src, title,
@@ -359,45 +359,45 @@ static void parse_asx (demux_playlist_t *this, char *data, int length) {
xml_parser_free_tree (root);
}
-
+
if (!is_asx) {
/* No tags found? Might be a references list. */
parse_ref (this, data, length);
- }
+ }
}
static void parse_smi (demux_playlist_t *this, char *data, int length) {
xml_node_t *root, *node, *tmp;
int is_smi = 0;
-
+
xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
-
+
if (xml_parser_build_tree (&root) >= 0) {
for (node = root; node; node = node->next) {
if (!strcmp (node->name, "smil"))
break;
}
-
+
if (node) {
is_smi = 1;
-
+
for (node = node->child; node; node = node->next) {
if (!strcmp (node->name, "body")) {
for (tmp = node->child; tmp; tmp = tmp->next) {
if (!strcmp (tmp->name, "audio") || !strcmp (tmp->name, "video")) {
const char *src, *title;
int start, end;
-
+
src = xml_parser_get_property (tmp, "src");
title = xml_parser_get_property (tmp, "title");
start = parse_time (xml_parser_get_property (tmp, "clipBegin") ? :
xml_parser_get_property (tmp, "clip-begin"));
end = parse_time (xml_parser_get_property (tmp, "clipEnd") ? :
xml_parser_get_property (tmp, "clip-end"));
-
+
if (src) {
lprintf ("mrl:'%s'\n", src);
- _x_demux_send_mrl_reference (this->stream, 0, src, title,
+ _x_demux_send_mrl_reference (this->stream, 0, src, title,
start, end ? (end-start) : 0);
}
}
@@ -405,10 +405,10 @@ static void parse_smi (demux_playlist_t *this, char *data, int length) {
}
}
}
-
+
xml_parser_free_tree (root);
}
-
+
if (!is_smi) {
/* No tags found? Might be a RAM playlist. */
parse_ram (this, data, length);
@@ -417,14 +417,14 @@ static void parse_smi (demux_playlist_t *this, char *data, int length) {
static void parse_qtl (demux_playlist_t *this, char *data, int length) {
xml_node_t *root, *node;
-
+
xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
-
+
if (xml_parser_build_tree (&root) >= 0) {
for (node = root; node; node = node->next) {
if (!strcmp (node->name, "embed")) {
const char *src;
-
+
src = xml_parser_get_property (node, "src");
if (src) {
lprintf ("mrl:'%s'\n", src);
@@ -432,7 +432,7 @@ static void parse_qtl (demux_playlist_t *this, char *data, int length) {
}
}
}
-
+
xml_parser_free_tree (root);
}
}
@@ -441,7 +441,7 @@ static void parse_xspf (demux_playlist_t *this, char *data, int length) {
xml_node_t *root, *node, *tmp;
xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
-
+
if (xml_parser_build_tree (&root) >= 0) {
for (node = root; node; node = node->next) {
if (!strcmp (node->name, "playlist"))
@@ -453,12 +453,12 @@ static void parse_xspf (demux_playlist_t *this, char *data, int length) {
break;
}
}
- if (node) {
+ if (node) {
for (node = node->child; node; node = node->next) {
if (!strcmp (node->name, "track")) {
char *src = NULL;
char *title = NULL;
-
+
for (tmp = node->child; tmp; tmp = tmp->next) {
if (!strcmp (tmp->name, "location")) {
src = trim((char*)tmp->data);
@@ -467,7 +467,7 @@ static void parse_xspf (demux_playlist_t *this, char *data, int length) {
title = trim((char*)tmp->data);
}
}
-
+
if (src) {
lprintf ("mrl:'%s'\n", src);
_x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
@@ -475,7 +475,7 @@ static void parse_xspf (demux_playlist_t *this, char *data, int length) {
}
}
}
-
+
xml_parser_free_tree (root);
}
}
@@ -484,7 +484,7 @@ static void parse_rss (demux_playlist_t *this, char *data, int length) {
xml_node_t *root, *node, *item, *tmp;
xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
-
+
if (xml_parser_build_tree (&root) >= 0) {
for (node = root; node; node = node->next) {
if (!strcmp (node->name, "rss"))
@@ -509,7 +509,7 @@ static void parse_rss (demux_playlist_t *this, char *data, int length) {
src = xml_parser_get_property (tmp, "url");
}
}
-
+
if (src) {
lprintf ("mrl:'%s'\n", src);
_x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
@@ -518,7 +518,7 @@ static void parse_rss (demux_playlist_t *this, char *data, int length) {
}
}
}
-
+
xml_parser_free_tree (root);
}
}
@@ -526,20 +526,20 @@ static void parse_rss (demux_playlist_t *this, char *data, int length) {
static void demux_playlist_send_headers (demux_plugin_t *this_gen) {
demux_playlist_t *this = (demux_playlist_t *) this_gen;
-
+
this->status = DEMUX_OK;
-
+
_x_demux_control_start (this->stream);
-
+
this->input->seek (this->input, 0, SEEK_SET);
}
-
+
static int demux_playlist_send_chunk (demux_plugin_t *this_gen) {
demux_playlist_t *this = (demux_playlist_t *) this_gen;
char *data = NULL;
int length;
-
+
length = this->input->get_length (this->input);
if (length > 0) {
data = xine_xmalloc (length+1);
@@ -549,21 +549,21 @@ static int demux_playlist_send_chunk (demux_plugin_t *this_gen) {
else {
char buf[1024];
int len;
-
+
length = 0;
while ((len = this->input->read (this->input, buf, sizeof(buf))) > 0) {
data = realloc (data, length+len+1);
if (!data)
break;
-
+
memcpy (data+length, buf, len);
length += len;
data[length] = '\0';
}
}
-
+
lprintf ("data:%p length:%d\n", data, length);
-
+
if (data) {
switch (this->playlist) {
case XINE_PLT_REF:
@@ -597,12 +597,12 @@ static int demux_playlist_send_chunk (demux_plugin_t *this_gen) {
lprintf ("unexpected playlist type 0x%08x\n", this->playlist);
break;
}
-
+
free (data);
}
this->status = DEMUX_FINISHED;
-
+
return DEMUX_FINISHED;
}
@@ -613,7 +613,7 @@ static int demux_playlist_seek (demux_plugin_t *this_gen,
static int demux_playlist_get_status (demux_plugin_t *this_gen) {
demux_playlist_t *this = (demux_playlist_t *) this_gen;
-
+
return this->status;
}
@@ -631,7 +631,7 @@ static int demux_playlist_get_optional_data (demux_plugin_t *this_gen,
}
-static demux_plugin_t *open_plugin (demux_class_t *class_gen,
+static demux_plugin_t *open_plugin (demux_class_t *class_gen,
xine_stream_t *stream, input_plugin_t *input) {
demux_playlist_t *this;
@@ -649,7 +649,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
this->demux_plugin.get_capabilities = demux_playlist_get_capabilities;
this->demux_plugin.get_optional_data = demux_playlist_get_optional_data;
this->demux_plugin.demux_class = class_gen;
-
+
switch (stream->content_detection_method) {
case METHOD_BY_MRL:
lprintf ("detect by extension\n");
@@ -659,7 +659,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
return NULL;
}
break;
-
+
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
lprintf ("detect by content\n");
@@ -674,9 +674,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
free (this);
return NULL;
}
-
+
lprintf ("playlist:0x%08x (%s)\n", this->playlist, (char*)&this->playlist);
-
+
return &this->demux_plugin;
}
@@ -688,7 +688,7 @@ static void *init_plugin (xine_t *xine, void *data) {
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Playlist demux plugin");
this->demux_class.identifier = "playlist";
- this->demux_class.mimetypes =
+ this->demux_class.mimetypes =
"audio/mpegurl: m3u: M3U playlist;"
"audio/x-mpegurl: m3u: M3U playlist;"
//"audio/x-pn-realaudio: ram: RAM playlist;"