summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-08-18 22:44:50 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-08-18 22:44:50 +0000
commit53d13d5551ce5e228e3f389de141e0d945aac8f1 (patch)
tree6d867c609c0f3a1434958d3920e71c641492d0a0 /src
parent487a38e36bb276818313a6b59760671d8818f7eb (diff)
downloadxine-lib-53d13d5551ce5e228e3f389de141e0d945aac8f1.tar.gz
xine-lib-53d13d5551ce5e228e3f389de141e0d945aac8f1.tar.bz2
icecast support
CVS patchset: 2475 CVS date: 2002/08/18 22:44:50
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_mpgaudio.c69
-rw-r--r--src/input/input_http.c32
2 files changed, 81 insertions, 20 deletions
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index adea67862..30da03745 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpgaudio.c,v 1.53 2002/08/10 21:39:53 miguelfreitas Exp $
+ * $Id: demux_mpgaudio.c,v 1.54 2002/08/18 22:44:50 guenter Exp $
*
* demultiplexer for mpeg audio (i.e. mp3) streams
*
@@ -40,6 +40,10 @@
#include "demux.h"
#include "bswap.h"
+/*
+#define LOG
+*/
+
#define DEMUX_MPGAUDIO_IFACE_VERSION 3
#define VALID_ENDS "mp3,mp2,mpa,mpega"
@@ -152,8 +156,10 @@ static void mpg123_decode_header(demux_mpgaudio_t *this,unsigned long newhead)
if( !this->bitrate ) /* bitrate can't be zero, default to 128 */
this->bitrate = 128;
+#ifdef LOG
xine_log (this->xine, XINE_LOG_FORMAT,
_("demux_mpgaudio: MPEG %s Layer %d %ldkbps\n"), ver, lay, this->bitrate );
+#endif
this->stream_length = (int)(this->input->get_length(this->input) / (this->bitrate * 1000 / 8));
}
@@ -212,8 +218,13 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this) {
/*buf->pts = 0;*/
buf->input_pos = this->input->get_current_pos(this->input);
- buf->input_time = buf->input_pos * this->stream_length /
- this->input->get_length(this->input);
+ {
+ int len = this->input->get_length(this->input);
+ if (len>0)
+ buf->input_time = buf->input_pos * this->stream_length / len;
+ else
+ buf->input_time = 0;
+ }
buf->pts = pts;
buf->type = BUF_AUDIO_MPEG;
buf->decoder_info[0] = 1;
@@ -296,8 +307,8 @@ static int demux_mpgaudio_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static uint32_t demux_mpgaudio_read_head(input_plugin_t *input)
-{
+static uint32_t demux_mpgaudio_read_head(input_plugin_t *input) {
+
uint8_t buf[4096];
uint32_t head=0;
int bs = 0;
@@ -316,7 +327,23 @@ static uint32_t demux_mpgaudio_read_head(input_plugin_t *input)
if(input->read(input, buf, bs))
head = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
+
+#ifdef LOG
+ printf ("demux_mpgaudio: stream is seekable\n");
+#endif
+
+ } else if (input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW)) {
+ head = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
+#ifdef LOG
+ printf ("demux_mpgaudio: got preview\n");
+#endif
+ } else {
+#ifdef LOG
+ printf ("demux_mpgaudio: not seekable, no preview\n");
+#endif
+ return 0;
}
+
return head;
}
@@ -361,6 +388,10 @@ static int demux_mpgaudio_start (demux_plugin_t *this_gen,
this->input->seek (this->input, start_pos, SEEK_SET);
+ } else if( !this->thread_running ) {
+
+
+
}
this->status = DEMUX_OK;
@@ -397,8 +428,8 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
- return demux_mpgaudio_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_mpgaudio_start (this_gen, this->video_fifo, this->audio_fifo,
+ start_pos, start_time);
}
static int demux_mpgaudio_open(demux_plugin_t *this_gen,
@@ -417,8 +448,14 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
head = demux_mpgaudio_read_head(input);
+#ifdef LOG
+ printf ("demux_mpgaudio: head is %x\n", head);
+#endif
+
if (head == RIFF_TAG) {
-//printf (" **** found RIFF tag\n");
+#ifdef LOG
+ printf (" **** found RIFF tag\n");
+#endif
/* skip the remaining 12 bytes of the RIFF tag */
input->seek(input, 12, SEEK_CUR);
@@ -438,7 +475,9 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
for (i = 0; i < RIFF_CHECK_BYTES - 4; i++) {
head = be2me_32(*(unsigned int *)&riff_check[i]);
-//printf (" **** mpg123: checking %08X\n", head);
+#ifdef LOG
+ printf ("demux_mpgaudio: **** mpg123: checking %08X\n", head);
+#endif
if (mpg123_head_check(head)) {
this->input = input;
return DEMUX_CAN_HANDLE;
@@ -460,6 +499,15 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
char *m, *valid_ends;
MRL = input->get_mrl (input);
+
+#ifdef LOG
+ printf ("demux_mpgaudio: stage by extension %s\n", MRL);
+#endif
+
+ if (!strncmp (MRL, "ice ://", 7)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
suffix = strrchr(MRL, '.');
@@ -510,8 +558,7 @@ static void demux_mpgaudio_close (demux_plugin_t *this) {
static int demux_mpgaudio_get_stream_length (demux_plugin_t *this_gen) {
demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
- if( this->stream_length > 0 )
- {
+ if( this->stream_length > 0 ) {
return this->stream_length;
}
else
diff --git a/src/input/input_http.c b/src/input/input_http.c
index a481c8430..80561f7b0 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -43,10 +43,14 @@
extern int errno;
+/*
+#define LOG
+*/
+
#define PREVIEW_SIZE 2200
-#define BUFSIZE 1024
+#define BUFSIZE 1024
-#define DEFAULT_HTTP_PORT 80
+#define DEFAULT_HTTP_PORT 80
typedef struct {
input_plugin_t input_plugin;
@@ -64,6 +68,7 @@ typedef struct {
char buf[BUFSIZE];
char mrlbuf[BUFSIZE];
+ char mrlbuf2[BUFSIZE]; /* icecast */
char proxybuf[BUFSIZE];
char auth[BUFSIZE];
@@ -292,7 +297,8 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) {
int done,len,linenum;
strncpy (this->mrlbuf, mrl, BUFSIZE);
- this->mrl = mrl;
+ strncpy (this->mrlbuf2, mrl, BUFSIZE);
+ this->mrl = this->mrlbuf2;
if (strncasecmp (this->mrlbuf, "http://", 7))
return 0;
@@ -440,10 +446,18 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) {
char httpstatus[BUFSIZE];
if (sscanf(this->buf, "HTTP/%d.%d %d %[^\015\012]", &httpver, &httpsub,
- &httpcode, httpstatus) != 4)
- {
- xine_log (this->xine, XINE_LOG_MSG, _("input_http: invalid http answer\n"));
- return 0;
+ &httpcode, httpstatus) != 4) {
+
+ /* icecast ? */
+ if (sscanf(this->buf, "ICY %d OK", &httpcode) != 1) {
+ xine_log (this->xine, XINE_LOG_MSG, _("input_http: invalid http answer\n"));
+ return 0;
+ } else {
+ this->mrlbuf2[0] = 'i';
+ this->mrlbuf2[1] = 'c';
+ this->mrlbuf2[2] = 'e';
+ this->mrlbuf2[3] = ' ';
+ }
}
if (httpcode >= 300 && httpcode < 400) {
@@ -516,7 +530,7 @@ static off_t http_plugin_read (input_plugin_t *this_gen,
n = nlen - num_bytes;
#ifdef LOG
- printf ("stdin: %lld bytes from preview (which has %lld bytes)\n",
+ printf ("input_http: %lld bytes from preview (which has %lld bytes)\n",
n, this->preview_size);
#endif
@@ -647,7 +661,7 @@ static char *http_plugin_get_identifier (input_plugin_t *this_gen) {
static char* http_plugin_get_mrl (input_plugin_t *this_gen) {
http_input_plugin_t *this = (http_input_plugin_t *) this_gen;
- return this->mrl;
+ return this->mrlbuf2;
}
static int http_plugin_get_optional_data (input_plugin_t *this_gen,