summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Zuehlke <andruil@users.sourceforge.net>2003-07-16 14:14:17 +0000
committerMarco Zuehlke <andruil@users.sourceforge.net>2003-07-16 14:14:17 +0000
commite2e5e35d881df42eb2ea9a6a288b4d0935444ec7 (patch)
tree1b9cb38abee90359f27ec49cf5013a47268d280d
parentc9451e4e24ba657e8d9ca0528f4a384847ec8063 (diff)
downloadxine-lib-e2e5e35d881df42eb2ea9a6a288b4d0935444ec7.tar.gz
xine-lib-e2e5e35d881df42eb2ea9a6a288b4d0935444ec7.tar.bz2
more cleanup; remove unused variables; use lprintf
CVS patchset: 5168 CVS date: 2003/07/16 14:14:17
-rw-r--r--src/demuxers/demux_avi.c411
-rw-r--r--src/demuxers/demux_mng.c4
-rw-r--r--src/demuxers/demux_mpeg.c150
-rw-r--r--src/demuxers/demux_ogg.c493
-rw-r--r--src/demuxers/demux_real.c453
-rw-r--r--src/xine-engine/demux.c2
-rw-r--r--src/xine-utils/utils.c39
-rw-r--r--src/xine-utils/xineutils.h4
8 files changed, 581 insertions, 975 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index e191683c5..52c231375 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -16,14 +16,15 @@
* 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
- *
- * $Id: demux_avi.c,v 1.163 2003/07/14 18:49:13 tmattern Exp $
+ */
+
+/*
+ * $Id: demux_avi.c,v 1.164 2003/07/16 14:14:17 andruil Exp $
*
* demultiplexer for avi streams
*
* part of the code is taken from
* avilib (C) 1999 Rainer Johanni <Rainer@Johanni.de>
- *
*/
/*
@@ -58,6 +59,11 @@
#include <string.h>
#include <stdlib.h>
+/********** logging **********/
+#define LOG_MODULE "demux_avi"
+#define LOG_VERBOSE
+/* #define LOG */
+
#include "xine_internal.h"
#include "xineutils.h"
#include "demux.h"
@@ -68,25 +74,19 @@
#define AVIIF_KEYFRAME 0x00000010L
-/*
-#define LOG
-*/
-
#define MAX_AUDIO_STREAMS 8
#define NUM_PREVIEW_BUFFERS 10
/* The following variable indicates the kind of error */
-typedef struct
-{
+typedef struct{
off_t pos;
long len;
long flags;
} video_index_entry_t;
-typedef struct
-{
+typedef struct{
off_t pos;
long len;
off_t tot;
@@ -95,29 +95,25 @@ typedef struct
/* These next three are the video and audio structures that can grow
* during the playback of a streaming file. */
-typedef struct
-{
+typedef struct{
long video_frames; /* Number of video frames */
long alloc_frames; /* Allocated number of frames */
video_index_entry_t *vindex;
} video_index_t;
-typedef struct
-{
+typedef struct{
long audio_chunks; /* Chunks of audio data in the file */
long alloc_chunks; /* Allocated number of chunks */
audio_index_entry_t *aindex;
} audio_index_t;
-typedef struct
-{
+typedef struct{
off_t nexttagoffset; /* The offset into the AVI file where we expect */
/* to find the next A/V frame */
} idx_grow_t;
-typedef struct
-{
+typedef struct{
long dwScale_audio, dwRate_audio;
long dwSampleSize;
@@ -137,8 +133,7 @@ typedef struct
} avi_audio_t;
-typedef struct
-{
+typedef struct{
long width; /* Width of a video frame */
long height; /* Height of a video frame */
long dwScale, dwRate;
@@ -172,23 +167,18 @@ typedef struct demux_avi_s {
demux_plugin_t demux_plugin;
xine_stream_t *stream;
-
fifo_buffer_t *audio_fifo;
fifo_buffer_t *video_fifo;
-
input_plugin_t *input;
+ int status;
avi_t *avi;
- int status;
-
int no_audio;
uint32_t video_step;
uint32_t AVI_errno;
- char last_mrl[1024];
-
idx_grow_t idx_grow;
int streaming;
@@ -197,13 +187,7 @@ typedef struct demux_avi_s {
} demux_avi_t ;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_avi_class_t;
#define AVI_ERR_SIZELIM 1 /* The write of the data would exceed
@@ -253,8 +237,7 @@ typedef struct {
/* Append an index entry for a newly-found video frame */
-static int video_index_append(avi_t *AVI, off_t pos, long len, long flags)
-{
+static int video_index_append(avi_t *AVI, off_t pos, long len, long flags) {
video_index_t *vit = &(AVI->video_idx);
/* Make sure there's room */
@@ -278,8 +261,7 @@ static int video_index_append(avi_t *AVI, off_t pos, long len, long flags)
/* Append an index entry for a newly-found audio frame */
static int audio_index_append(avi_t *AVI, int stream, off_t pos, long len,
- off_t tot)
-{
+ off_t tot) {
audio_index_t *ait = &(AVI->audio[stream]->audio_idx);
/* Make sure there's room */
@@ -301,18 +283,15 @@ static int audio_index_append(avi_t *AVI, int stream, off_t pos, long len,
return 0;
}
-static unsigned long str2ulong(unsigned char *str)
-{
+static unsigned long str2ulong(unsigned char *str) {
return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) );
}
-static unsigned long str2ushort(unsigned char *str)
-{
+static unsigned long str2ushort(unsigned char *str) {
return ( str[0] | (str[1]<<8) );
}
-static void long2str(unsigned char *dst, int n)
-{
+static void long2str(unsigned char *dst, int n) {
dst[0] = (n )&0xff;
dst[1] = (n>> 8)&0xff;
dst[2] = (n>>16)&0xff;
@@ -325,14 +304,12 @@ static int64_t get_audio_pts (demux_avi_t *this, int track, long posc,
off_t postot, long posb) {
avi_audio_t *at = this->avi->audio[track];
-
-#ifdef LOG
- printf("demux_avi: get_audio_pts: track=%d, posc=%ld, postot=%lld, posb=%ld\n",
- track, posc, postot, posb);
-#endif
+
+ lprintf("get_audio_pts: track=%d, posc=%ld, postot=%lld, posb=%ld\n", track, posc, postot, posb);
+
if (at->dwSampleSize==0) {
/* variable bitrate */
- return (int64_t)(90000.0 * (double)posc *
+ return (int64_t)(90000.0 * (double)posc *
(double)at->dwScale_audio / (double)at->dwRate_audio);
} else {
/* constant bitrate */
@@ -354,8 +331,7 @@ static int64_t get_video_pts (demux_avi_t *this, long pos) {
/* Some handy stopper tests for idx_grow, below. */
/* Use this one to ensure the current video frame is in the index. */
-static long video_pos_stopper(demux_avi_t *this, void *data)
-{
+static long video_pos_stopper(demux_avi_t *this, void *data){
if (this->avi->video_posf >= this->avi->video_idx.video_frames) {
return -1;
}
@@ -363,8 +339,7 @@ static long video_pos_stopper(demux_avi_t *this, void *data)
}
/* Use this one to ensure the current audio chunk is in the index. */
-static long audio_pos_stopper(demux_avi_t *this, void *data)
-{
+static long audio_pos_stopper(demux_avi_t *this, void *data) {
avi_audio_t *AVI_A = (avi_audio_t *)data;
if (AVI_A->audio_posc >= AVI_A->audio_idx.audio_chunks) {
@@ -375,8 +350,7 @@ static long audio_pos_stopper(demux_avi_t *this, void *data)
/* Use this one to ensure that a video frame with the given position
* is in the index. */
-static long start_pos_stopper(demux_avi_t *this, void *data)
-{
+static long start_pos_stopper(demux_avi_t *this, void *data) {
off_t start_pos = *(off_t *)data;
long maxframe = this->avi->video_idx.video_frames - 1;
@@ -390,8 +364,7 @@ static long start_pos_stopper(demux_avi_t *this, void *data)
/* Use this one to ensure that a video frame with the given timestamp
* is in the index. */
-static long start_time_stopper(demux_avi_t *this, void *data)
-{
+static long start_time_stopper(demux_avi_t *this, void *data) {
int64_t video_pts = *(int64_t *)data;
long maxframe = this->avi->video_idx.video_frames - 1;
@@ -450,7 +423,7 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *),
xine_event_send (this->stream, &event);
}
-
+
if (this->input->read(this->input, data, 8) != 8)
break;
@@ -464,7 +437,7 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *),
n = str2ulong(data+4);
this->idx_grow.nexttagoffset += PAD_EVEN(n + 8);
-
+
/* Check if we got a tag ##db, ##dc or ##wb */
if ((data[0] == this->avi->video_tag[0]) &&
@@ -473,7 +446,7 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *),
off_t pos = curtagoffset + ioff;
long len = n;
uint32_t tmp;
-
+
/* FIXME:
* UGLY hack to detect a keyframe parsing decoder data
* AVI chuncks doesn't provide this info and we need it during
@@ -500,7 +473,7 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *),
if (tmp == 0x000001B6) flags = 0;
break;
}
-
+
if (video_index_append(this->avi, pos, len, flags) == -1) {
/* If we're out of memory, we just don't grow the index, but
* nothing really bad happens. */
@@ -531,9 +504,9 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *),
}
/* Fetch the current video index entry, growing the index if necessary. */
-static video_index_entry_t *video_cur_index_entry(demux_avi_t *this)
-{
+static video_index_entry_t *video_cur_index_entry(demux_avi_t *this) {
avi_t *AVI = this->avi;
+
if (AVI->video_posf >= AVI->video_idx.video_frames) {
/* We don't have enough frames; see if the file's bigger yet. */
if (idx_grow(this, video_pos_stopper, NULL) < 0) {
@@ -546,8 +519,8 @@ static video_index_entry_t *video_cur_index_entry(demux_avi_t *this)
/* Fetch the current audio index entry, growing the index if necessary. */
static audio_index_entry_t *audio_cur_index_entry(demux_avi_t *this,
- avi_audio_t *AVI_A)
-{
+ avi_audio_t *AVI_A) {
+
if (AVI_A->audio_posc >= AVI_A->audio_idx.audio_chunks) {
/* We don't have enough chunks; see if the file's bigger yet. */
if (idx_grow(this, audio_pos_stopper, AVI_A) < 0) {
@@ -558,8 +531,7 @@ static audio_index_entry_t *audio_cur_index_entry(demux_avi_t *this,
return &(AVI_A->audio_idx.aindex[AVI_A->audio_posc]);
}
-static void AVI_close(avi_t *AVI)
-{
+static void AVI_close(avi_t *AVI){
int i;
if(AVI->idx) free(AVI->idx);
@@ -581,8 +553,7 @@ do { \
return 0; \
} while(0)
-static int avi_sampsize(avi_t *AVI, int track)
-{
+static int avi_sampsize(avi_t *AVI, int track) {
int s;
s = ((AVI->audio[track]->wavex->wBitsPerSample+7)/8)*
AVI->audio[track]->wavex->nChannels;
@@ -592,8 +563,7 @@ static int avi_sampsize(avi_t *AVI, int track)
}
static int avi_add_index_entry(demux_avi_t *this, avi_t *AVI, unsigned char *tag,
- long flags, long pos, long len)
-{
+ long flags, long pos, long len) {
void *ptr;
if(AVI->n_idx>=AVI->max_idx) {
@@ -620,7 +590,7 @@ static int avi_add_index_entry(demux_avi_t *this, avi_t *AVI, unsigned char *tag
return 0;
}
-static avi_t *AVI_init(demux_avi_t *this) {
+static avi_t *AVI_init(demux_avi_t *this) {
avi_t *AVI;
long i, j, n, idx_type;
@@ -636,10 +606,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
uint8_t data[256];
/* Create avi_t structure */
+ lprintf("start\n");
-#ifdef LOG
- printf("demux_avi: AVI_init\n");
-#endif
AVI = (avi_t *) xine_xmalloc(sizeof(avi_t));
if(AVI==NULL) {
this->AVI_errno = AVI_ERR_NO_MEM;
@@ -726,10 +694,9 @@ static avi_t *AVI_init(demux_avi_t *this) {
for (i=0;i<hdrl_len;) {
/* List tags are completly ignored */
-#ifdef LOG
- printf("demux_asf: AVI_INIT: tag: %c%c%c%c\n",
- hdrl_data[i], hdrl_data[i+1], hdrl_data[i+2], hdrl_data[i+3]);
-#endif
+ lprintf("tag: %c%c%c%c\n",
+ hdrl_data[i], hdrl_data[i+1], hdrl_data[i+2], hdrl_data[i+3]);
+
if (strncasecmp(hdrl_data+i,"LIST",4)==0) {
i+= 12;
@@ -743,10 +710,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
if(strncasecmp(hdrl_data+i,"strh",4)==0) {
i += 8;
-#ifdef LOG
- printf("demux_asf: AVI_INIT: tag: %c%c%c%c\n",
- hdrl_data[i], hdrl_data[i+1], hdrl_data[i+2], hdrl_data[i+3]);
-#endif
+ lprintf("tag: %c%c%c%c\n",
+ hdrl_data[i], hdrl_data[i+1], hdrl_data[i+2], hdrl_data[i+3]);
if(strncasecmp(hdrl_data+i,"vids",4) == 0 && !vids_strh_seen) {
AVI->compressor = *(uint32_t *) hdrl_data+i+4;
@@ -760,9 +725,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
AVI->video_strn = num_stream;
vids_strh_seen = 1;
-#ifdef LOG
- printf("demux_asf: AVI_INIT: video stream header\n");
-#endif
+ lprintf("video stream header\n");
lasttag = 1; /* vids */
} else if (strncasecmp (hdrl_data+i,"auds",4) ==0 /* && ! auds_strh_seen*/) {
if(AVI->n_audio < MAX_AUDIO_STREAMS) {
@@ -780,9 +743,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
a->dwSampleSize = str2ulong(hdrl_data+i+44);
a->audio_tot = 0;
auds_strh_seen = 1;
-#ifdef LOG
- printf("demux_asf: AVI_INIT: audio stream header\n");
-#endif
+ lprintf("audio stream header\n");
+
lasttag = 2; /* auds */
AVI->n_audio++;
}
@@ -792,7 +754,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
} else if(strncasecmp(hdrl_data+i,"strf",4)==0) {
i += 8;
if(lasttag == 1) {
- /* printf ("size : %d\n",sizeof(AVI->bih)); */
+ /* lprintf ("size : %d\n",sizeof(AVI->bih)); */
AVI->bih = (xine_bmiheader *)
xine_xmalloc((n < sizeof(xine_bmiheader)) ? sizeof(xine_bmiheader) : n);
if(AVI->bih == NULL) {
@@ -802,26 +764,24 @@ static avi_t *AVI_init(demux_avi_t *this) {
memcpy (AVI->bih, hdrl_data+i, n);
xine_bmiheader_le2me( AVI->bih );
-
+
/* stream_read(demuxer->stream,(char*) &avi_header.bih,MIN(size2,sizeof(avi_header.bih))); */
AVI->width = AVI->bih->biWidth;
AVI->height = AVI->bih->biHeight;
/*
- printf ("size : %d x %d (%d x %d)\n", AVI->width, AVI->height, AVI->bih.biWidth, AVI->bih.biHeight);
- printf(" biCompression %d='%.4s'\n", AVI->bih.biCompression,
+ lprintf ("size : %d x %d (%d x %d)\n", AVI->width, AVI->height, AVI->bih.biWidth, AVI->bih.biHeight);
+ lprintf (" biCompression %d='%.4s'\n", AVI->bih.biCompression,
&AVI->bih.biCompression);
*/
-#ifdef LOG
- printf("demux_asf: AVI_INIT: video stream format\n");
-#endif
+ lprintf("video stream format\n");
+
vids_strf_seen = 1;
/* load the palette, if there is one */
AVI->palette_count = AVI->bih->biClrUsed;
if (AVI->palette_count > 256) {
- printf ("demux_avi: number of colors exceeded 256 (%d)",
- AVI->palette_count);
+ lprintf ("number of colors exceeded 256 (%d)", AVI->palette_count);
AVI->palette_count = 256;
}
for (j = 0; j < AVI->palette_count; j++) {
@@ -837,9 +797,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
memcpy((void *)AVI->audio[AVI->n_audio-1]->wavex, hdrl_data+i, n);
xine_waveformatex_le2me( AVI->audio[AVI->n_audio-1]->wavex );
-#ifdef LOG
- printf("demux_asf: AVI_INIT: audio stream format\n");
-#endif
+ lprintf("audio stream format\n");
auds_strf_seen = 1;
}
lasttag = 0;
@@ -966,9 +924,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
}
} else {
/* We'll just dynamically grow the index as needed. */
-#ifdef LOG
- printf("demux_avi: AVI_init, no index\n");
-#endif
+ lprintf("no index\n");
this->idx_grow.nexttagoffset = AVI->movi_start;
this->has_index = 0;
}
@@ -979,14 +935,11 @@ static avi_t *AVI_init(demux_avi_t *this) {
AVI->video_posf = 0;
AVI->video_posb = 0;
-#ifdef LOG
- printf("demux_avi: AVI_init done, pos=%lld, AVI->movi_start=%lld\n", this->input->get_current_pos(this->input), AVI->movi_start);
-#endif
+ lprintf("done, pos=%lld, AVI->movi_start=%lld\n", this->input->get_current_pos(this->input), AVI->movi_start);
return AVI;
}
-static void AVI_seek_start(avi_t *AVI)
-{
+static void AVI_seek_start(avi_t *AVI) {
int i;
AVI->video_posf = 0;
@@ -1010,7 +963,7 @@ static long AVI_read_audio(demux_avi_t *this, avi_audio_t *AVI_A, char *audbuf,
nr = 0; /* total number of bytes read */
- /* printf ("avi audio package len: %d\n", AVI_A->audio_index[AVI_A->audio_posc].len); */
+ /* lprintf ("avi audio package len: %d\n", AVI_A->audio_index[AVI_A->audio_posc].len); */
while(bytes>0) {
@@ -1034,7 +987,7 @@ static long AVI_read_audio(demux_avi_t *this, avi_audio_t *AVI_A, char *audbuf,
else
todo = left;
pos = aie->pos + AVI_A->audio_posb;
- /* printf ("demux_avi: read audio from %lld\n", pos); */
+ /* lprintf ("read audio from %lld\n", pos); */
if (this->input->seek (this->input, pos, SEEK_SET)<0)
return -1;
if (this->input->read(this->input, audbuf+nr,todo) != todo) {
@@ -1092,7 +1045,7 @@ static long AVI_read_video(demux_avi_t *this, avi_t *AVI, char *vidbuf,
else
todo = left;
pos = vie->pos + AVI->video_posb;
- /* printf ("demux_avi: read video from %lld\n", pos); */
+ /* lprintf ("read video from %lld\n", pos); */
if (this->input->seek (this->input, pos, SEEK_SET)<0)
return -1;
if (this->input->read(this->input, vidbuf+nr,todo) != todo) {
@@ -1140,7 +1093,6 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) {
}
}
-
video_pts = get_video_pts (this, this->avi->video_posf);
for (i=0; i < this->avi->n_audio; i++) {
@@ -1156,10 +1108,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) {
audio_pts =
get_audio_pts (this, i, audio->audio_posc, aie->tot, audio->audio_posb);
-#ifdef LOG
- printf ("demux_avi: video_pts %lld audio_pts %lld\n",
- video_pts, audio_pts);
-#endif
+ lprintf ("video_pts %lld audio_pts %lld\n", video_pts, audio_pts);
if (!this->no_audio && (audio_pts < video_pts)) {
@@ -1207,7 +1156,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) {
buf->extra_info->input_time = video_pts / 90;
buf->extra_info->input_pos = this->input->get_current_pos(this->input);
-
+
if (this->has_index) {
/* use video_frames-2 instead of video_frames-1 to fix problems with weird
non-interleaved streams */
@@ -1223,7 +1172,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) {
}
/*
- printf ("demux_avi: adding buf %d to video fifo, decoder_info[0]: %d\n",
+ lprintf ("adding buf %d to video fifo, decoder_info[0]: %d\n",
buf, buf->decoder_info[0]);
*/
@@ -1242,7 +1191,6 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) {
* It's used in streaming mode
*/
static int get_chunk_header(demux_avi_t *this, uint32_t *len, int *audio_stream) {
-
long i;
char data[256];
@@ -1251,12 +1199,9 @@ static int get_chunk_header(demux_avi_t *this, uint32_t *len, int *audio_stream)
break;
*len = str2ulong(data+4);
-#ifdef LOG
- printf("demux_avi: get_chunk_header, %c%c%c%c, pos=%lld, len=%u\n",
- data[0], data[1], data[2], data[3],
- this->input->get_current_pos(this->input),
- *len);
-#endif
+ lprintf("header: %c%c%c%c, pos=%lld, len=%u\n",
+ data[0], data[1], data[2], data[3],
+ this->input->get_current_pos(this->input), *len);
/* Dive into RIFF and LIST entries */
if(strncasecmp(data, "LIST", 4) == 0 ||
@@ -1286,10 +1231,7 @@ static int get_chunk_header(demux_avi_t *this, uint32_t *len, int *audio_stream)
return AVI_HEADER_AUDIO;
}
}
-
-#ifdef LOG
- printf("demux_avi: unknown header: %c %c %c %c\n", data[0], data[1], data[2], data[3]);
-#endif
+ lprintf("unknown header: %c %c %c %c\n", data[0], data[1], data[2], data[3]);
return AVI_HEADER_UNKNOWN;
}
return AVI_HEADER_UNKNOWN;
@@ -1310,18 +1252,14 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) {
avi_audio_t *audio;
current_pos = this->input->get_current_pos(this->input);
-
-#ifdef LOG
- printf("demux_avi: demux_avi_next, input_pos=%lld\n", current_pos);
-#endif
+ lprintf("input_pos=%lld\n", current_pos);
header = get_chunk_header(this, &chunk_len, &audio_stream);
switch (header) {
case AVI_HEADER_AUDIO:
-#ifdef LOG
- printf("demux_avi: demux_avi_next_streaming, AVI_HEADER_AUDIO\n");
-#endif
+ lprintf("AVI_HEADER_AUDIO\n");
+
audio = this->avi->audio[audio_stream];
left = chunk_len;
@@ -1366,9 +1304,7 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) {
case AVI_HEADER_VIDEO:
-#ifdef LOG
- printf("demux_avi: demux_avi_next_streaming, AVI_HEADER_VIDEO\n");
-#endif
+ lprintf("AVI_HEADER_VIDEO\n");
left = chunk_len;
while (left > 0) {
@@ -1404,9 +1340,7 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) {
break;
case AVI_HEADER_UNKNOWN:
-#ifdef LOG
- printf("demux_avi: demux_avi_next_streaming, AVI_HEADER_UNKNOWN\n");
-#endif
+ lprintf("AVI_HEADER_UNKNOWN\n");
current_pos = this->input->get_current_pos(this->input);
if (this->input->seek(this->input, chunk_len, SEEK_CUR) != (current_pos + chunk_len)) {
return 0;
@@ -1418,14 +1352,11 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) {
this->input->seek (this->input,
this->input->get_current_pos(this->input) & 1, SEEK_CUR);
-#ifdef LOG
- printf("demux_avi: demux_avi_next done\n");
-#endif
+ lprintf("done\n");
return 1;
}
static int demux_avi_send_chunk (demux_plugin_t *this_gen) {
-
demux_avi_t *this = (demux_avi_t *) this_gen;
if (this->streaming) {
@@ -1457,13 +1388,10 @@ static int demux_avi_get_status (demux_plugin_t *this_gen) {
}
static void demux_avi_send_headers (demux_plugin_t *this_gen) {
-
demux_avi_t *this = (demux_avi_t *) this_gen;
int i;
-#ifdef LOG
- printf("demux_avi: demux_avi_send_headers\n");
-#endif
+ lprintf("start\n");
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
@@ -1483,14 +1411,16 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) {
this->avi->audio[i]->audio_type = formattag_to_buf_audio (this->avi->audio[i]->wavex->wFormatTag);
if( !this->avi->audio[i]->audio_type ) {
- printf ("demux_avi: unknown audio type 0x%x\n",
- this->avi->audio[i]->wavex->wFormatTag);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "unknown audio type 0x%x\n",
+ this->avi->audio[i]->wavex->wFormatTag);
this->no_audio = 1;
this->avi->audio[i]->audio_type = BUF_AUDIO_UNKNOWN;
- } else if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: audio type %s (wFormatTag 0x%x)\n",
- buf_audio_name(this->avi->audio[i]->audio_type),
- (int)this->avi->audio[i]->wavex->wFormatTag);
+ } else
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_avi: audio type %s (wFormatTag 0x%x)\n",
+ buf_audio_name(this->avi->audio[i]->audio_type),
+ (int)this->avi->audio[i]->wavex->wFormatTag);
}
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
@@ -1523,18 +1453,16 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) {
this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] = this->avi->compressor;
if (!this->avi->video_type) {
-
- printf ("demux_avi: unknown video codec '%.4s'\n",
- (char*)&this->avi->bih->biCompression);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_avi: unknown video codec '%.4s'\n",
+ (char*)&this->avi->bih->biCompression);
this->avi->video_type = BUF_VIDEO_UNKNOWN;
-
}
-
buf->type = this->avi->video_type;
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: video codec is '%s'\n",
- buf_video_name(buf->type));
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_avi: video codec is '%s'\n",
+ buf_video_name(buf->type));
this->video_fifo->put (this->video_fifo, buf);
@@ -1583,11 +1511,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) {
break;
}
}
-
-#ifdef LOG
- printf("demux_avi: demux_avi_send_headers done\n");
-#endif
-
+ lprintf("done\n");
}
}
@@ -1611,9 +1535,8 @@ static int demux_avi_seek (demux_plugin_t *this_gen,
* seek to start pos / time
*/
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: start pos is %lld, start time is %d\n",
- start_pos, start_time);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "start pos is %lld, start time is %d\n",start_pos, start_time);
/* Seek video. We do a single idx_grow at the beginning rather than
* incrementally growing the index in a loop, so that if the index
@@ -1670,9 +1593,7 @@ static int demux_avi_seek (demux_plugin_t *this_gen,
vie = video_cur_index_entry(this);
}
if (!vie || !(vie->flags & AVIIF_KEYFRAME)) {
-#ifdef LOG
- printf ("demux_avi: No previous keyframe found\n");
-#endif
+ lprintf ("No previous keyframe found\n");
}
video_pts = get_video_pts (this, cur_pos);
@@ -1681,8 +1602,8 @@ static int demux_avi_seek (demux_plugin_t *this_gen,
* position we've already found, so we won't be seeking though the
* file much at this point. */
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: video_pts = %lld\n", video_pts);
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ lprintf ("video_pts = %lld\n", video_pts);
/* FIXME ? */
audio_pts = 77777777;
@@ -1703,23 +1624,19 @@ static int demux_avi_seek (demux_plugin_t *this_gen,
} else {
min_pos = cur_pos;
}
-#ifdef LOG
- printf ("demux_avi: audio_pts = %lld %lld < %lld < %lld\n",
- audio_pts, min_pos, cur_pos, max_pos);
-#endif
+ lprintf ("audio_pts = %lld %lld < %lld < %lld\n",
+ audio_pts, min_pos, cur_pos, max_pos);
} else {
if (cur_pos > min_pos) {
max_pos = cur_pos;
} else {
this->status = DEMUX_FINISHED;
- printf ("demux_avi: audio seek to start failed\n");
+ lprintf ("audio seek to start failed\n");
break;
}
}
}
-#ifdef LOG
- printf ("demux_avi: audio_pts = %lld\n", audio_pts);
-#endif
+ lprintf ("audio_pts = %lld\n", audio_pts);
/*
* try to make audio pos more accurate for long index entries
@@ -1738,17 +1655,14 @@ static int demux_avi_seek (demux_plugin_t *this_gen,
}
}
}
+ lprintf ("video posc: %ld, audio posc: %lld\n", this->avi->video_posf, audio_pts);
-#ifdef LOG
- printf ("demux_avi:seek: video posc: %d, audio posc: %lld\n", this->avi->video_posf, audio_pts);
-#endif
xine_demux_control_newpts (this->stream, video_pts, BUF_FLAG_SEEK);
return this->status;
}
static int demux_avi_get_stream_length (demux_plugin_t *this_gen) {
-
demux_avi_t *this = (demux_avi_t *) this_gen;
if (this->avi) {
@@ -1772,108 +1686,79 @@ static int demux_avi_get_optional_data(demux_plugin_t *this_gen,
}
static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream,
- input_plugin_t *input_gen) {
+ input_plugin_t *input) {
- input_plugin_t *input = (input_plugin_t *) input_gen;
demux_avi_t *this;
- uint8_t buf[MAX_PREVIEW_SIZE];
-
- this = xine_xmalloc (sizeof (demux_avi_t));
- this->stream = stream;
- this->input = input;
- this->demux_plugin.send_headers = demux_avi_send_headers;
- this->demux_plugin.send_chunk = demux_avi_send_chunk;
- this->demux_plugin.seek = demux_avi_seek;
- this->demux_plugin.dispose = demux_avi_dispose;
- this->demux_plugin.get_status = demux_avi_get_status;
- this->demux_plugin.get_stream_length = demux_avi_get_stream_length;
- this->demux_plugin.get_video_frame = NULL;
- this->demux_plugin.got_video_frame_cb= NULL;
- this->demux_plugin.get_capabilities = demux_avi_get_capabilities;
- this->demux_plugin.get_optional_data = demux_avi_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
-
- this->status = DEMUX_FINISHED;
-
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf("demux_avi.c: streaming mode\n");
- this->streaming = 1;
- }
switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
+ case METHOD_BY_CONTENT: {
+ uint8_t buf[12];
- if (input->get_capabilities(input) & INPUT_CAP_BLOCK) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
- this->AVI_errno);
- free (this);
+ if (input->get_capabilities(input) & INPUT_CAP_BLOCK)
return NULL;
- }
- if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) {
- input->seek(input, 0, SEEK_SET);
- if (input->read(input, buf, 12) != 12) {
- free (this);
- return NULL;
- }
- input->seek(input, 0, SEEK_SET);
- } else if ((input->get_capabilities(input) & INPUT_CAP_PREVIEW) != 0) {
- input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
- } else {
- free (this);
+ if (xine_demux_read_header(input, buf, 12) != 12)
return NULL;
- }
if( strncasecmp(buf ,"RIFF",4) !=0 ||
- strncasecmp(buf+8,"AVI ",4) !=0 ) {
- free (this);
+ strncasecmp(buf+8,"AVI ",4) !=0 )
return NULL;
- }
- break;
+ }
+ break;
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
-
- if (!ending) {
- free (this);
+ if (!xine_demux_check_extension (mrl, extensions))
return NULL;
- }
-
- if (strncasecmp (ending, ".AVI", 4)) {
- free (this);
- return NULL;
- }
}
-
/* we want to fall through here */
- case METHOD_EXPLICIT: {
- }
+
+ case METHOD_EXPLICIT:
break;
default:
- free (this);
return NULL;
}
+ this = xine_xmalloc (sizeof (demux_avi_t));
+
+ this->stream = stream;
+ this->input = input;
+
+ this->demux_plugin.send_headers = demux_avi_send_headers;
+ this->demux_plugin.send_chunk = demux_avi_send_chunk;
+ this->demux_plugin.seek = demux_avi_seek;
+ this->demux_plugin.dispose = demux_avi_dispose;
+ this->demux_plugin.get_status = demux_avi_get_status;
+ this->demux_plugin.get_stream_length = demux_avi_get_stream_length;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb= NULL;
+ this->demux_plugin.get_capabilities = demux_avi_get_capabilities;
+ this->demux_plugin.get_optional_data = demux_avi_get_optional_data;
+ this->demux_plugin.demux_class = class_gen;
+
+ this->status = DEMUX_FINISHED;
+
+ if (!INPUT_IS_SEEKABLE(input)) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "streaming mode\n");
+ this->streaming = 1;
+ }
+
this->avi = AVI_init (this);
if (!this->avi) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
- this->AVI_errno);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "AVI_init failed (AVI_errno: %d)\n", this->AVI_errno);
free (this);
return NULL;
}
- strncpy (this->last_mrl, input->get_mrl (input), 1024);
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_avi: %ld frames\n", this->avi->video_idx.video_frames);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_avi: %ld frames\n", this->avi->video_idx.video_frames);
return &this->demux_plugin;
}
@@ -1900,19 +1785,15 @@ static char *get_mimetypes (demux_class_t *this_gen) {
}
static void class_dispose (demux_class_t *this_gen) {
-
demux_avi_class_t *this = (demux_avi_class_t *) this_gen;
free (this);
}
static void *init_class (xine_t *xine, void *data) {
-
demux_avi_class_t *this;
- this = xine_xmalloc (sizeof (demux_avi_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_avi_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c
index 34ee31401..1880cd1da 100644
--- a/src/demuxers/demux_mng.c
+++ b/src/demuxers/demux_mng.c
@@ -19,7 +19,7 @@
*/
/*
- * $Id: demux_mng.c,v 1.9 2003/07/16 00:52:45 andruil Exp $
+ * $Id: demux_mng.c,v 1.10 2003/07/16 14:14:17 andruil Exp $
*
* demux_mng.c, Demuxer plugin for Multiple-image Network Graphics format
*
@@ -79,7 +79,7 @@ mng_bool mymng_open_stream(mng_handle mngh){
demux_mng_t *this = (demux_mng_t*)mng_get_userdata(mngh);
if (this->input->get_current_pos(this->input) != 0) {
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ if (!INPUT_IS_SEEKABLE(this->input)) {
return MNG_FALSE;
}
this->input->seek(this->input, 0, SEEK_SET);
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 4a9674922..70d3cc5b8 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -16,13 +16,13 @@
* 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
- *
- * $Id: demux_mpeg.c,v 1.120 2003/06/18 13:03:44 mroi Exp $
+ */
+
+/*
+ * $Id: demux_mpeg.c,v 1.121 2003/07/16 14:14:17 andruil Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
- *
- *
*/
#ifdef HAVE_CONFIG_H
@@ -34,7 +34,11 @@
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
-#include <unistd.h>
+
+/********** logging **********/
+#define LOG_MODULE "demux_mpeg"
+/* #define LOG_VERBOSE */
+/* #define LOG */
#include "xine_internal.h"
#include "demux.h"
@@ -48,39 +52,30 @@
#define PTS_VIDEO 1
typedef struct demux_mpeg_s {
-
demux_plugin_t demux_plugin;
+ xine_stream_t *stream;
fifo_buffer_t *audio_fifo;
fifo_buffer_t *video_fifo;
-
- xine_stream_t *stream;
input_plugin_t *input;
+ int status;
unsigned char dummy_space[100000];
-
- int status;
int preview_mode;
-
int rate;
int64_t last_pts[2];
int send_newpts;
int buf_flag_seek;
int has_pts;
-
} demux_mpeg_t;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_mpeg_class_t;
+#if 0
+ /* code never reached, is it still usefull ?? */
/*
* borrow a little knowledge from the Quicktime demuxer
*/
@@ -183,6 +178,7 @@ static void find_mdat_atom(input_plugin_t *input, off_t *mdat_offset,
input->seek(input, atom_size, SEEK_CUR);
}
}
+#endif
static uint32_t read_bytes (demux_mpeg_t *this, uint32_t n) {
@@ -213,7 +209,7 @@ static uint32_t read_bytes (demux_mpeg_t *this, uint32_t n) {
res = (buf[2]<<8) | buf[3] | (buf[1]<<16) | (buf[0] << 24);
break;
default:
- printf ("demux_mpeg: how how - something wrong in wonderland demux:read_bytes (%d)\n", n);
+ lprintf ("how how - something wrong in wonderland demux:read_bytes (%d)\n", n);
abort();
}
@@ -224,8 +220,7 @@ static uint32_t read_bytes (demux_mpeg_t *this, uint32_t n) {
i guess llabs may not be available everywhere */
#define abs(x) ( ((x)<0) ? -(x) : (x) )
-static void check_newpts( demux_mpeg_t *this, int64_t pts, int video )
-{
+static void check_newpts( demux_mpeg_t *this, int64_t pts, int video ) {
int64_t diff;
diff = pts - this->last_pts[video];
@@ -297,9 +292,9 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
buf->decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE;
buf->decoder_info[2] = SPU_DVD_SUBTYPE_PACKAGE;
buf->pts = pts;
-
- this->video_fifo->put (this->video_fifo, buf);
-
+
+ this->video_fifo->put (this->video_fifo, buf);
+
return;
}
@@ -575,21 +570,17 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
/*
if (w != 0x0f)
- xprintf (VERBOSE|DEMUX, " ERROR w (%02x) != 0x0F ",w);
+ lprintf("ERROR w (%02x) != 0x0F ",w);
*/
}
}
if (pts && !this->has_pts) {
-#ifdef LOG
- printf("demux_mpeg: this stream has pts\n");
-#endif
+ lprintf("this stream has pts\n");
this->has_pts = 1;
} else if (scr && !this->has_pts) {
-#ifdef LOG
- printf("demux_mpeg: use scr\n");
-#endif
+ lprintf("use scr\n");
pts = scr;
}
@@ -738,7 +729,7 @@ static uint32_t parse_pack(demux_mpeg_t *this) {
buf = read_bytes (this,1);
this->rate |= (buf >> 1);
- /* printf ("demux_mpeg: mux_rate = %d\n",this->rate); */
+ lprintf ("mux_rate = %d\n",this->rate);
} else
buf = read_bytes (this, 3) ;
@@ -748,7 +739,7 @@ static uint32_t parse_pack(demux_mpeg_t *this) {
buf = read_bytes (this, 4) ;
- /* printf (" code = %08x\n",buf);*/
+ /* lprintf("code = %08x\n",buf);*/
if (buf == 0x000001bb) {
buf = read_bytes (this, 2);
@@ -758,7 +749,7 @@ static uint32_t parse_pack(demux_mpeg_t *this) {
buf = read_bytes (this, 4) ;
}
- /* printf (" code = %08x\n",buf); */
+ /* lprintf("code = %08x\n",buf); */
while ( ((buf & 0xFFFFFF00) == 0x00000100)
&& ((buf & 0xff) != 0xba) ) {
@@ -779,8 +770,7 @@ static uint32_t parse_pack(demux_mpeg_t *this) {
}
-static uint32_t parse_pack_preview (demux_mpeg_t *this, int *num_buffers)
-{
+static uint32_t parse_pack_preview (demux_mpeg_t *this, int *num_buffers) {
uint32_t buf ;
int mpeg_version;
@@ -814,7 +804,7 @@ static uint32_t parse_pack_preview (demux_mpeg_t *this, int *num_buffers)
buf = read_bytes (this,1);
this->rate |= (buf >> 1);
}
- /* printf ("demux_mpeg: mux_rate = %d\n",this->rate); */
+ /* lprintf("mux_rate = %d\n",this->rate); */
} else
buf = read_bytes (this, 3) ;
@@ -858,7 +848,6 @@ static void demux_mpeg_resync (demux_mpeg_t *this, uint32_t buf) {
}
static int demux_mpeg_send_chunk (demux_plugin_t *this_gen) {
-
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
uint32_t w=0;
@@ -925,7 +914,7 @@ static int demux_mpeg_seek (demux_plugin_t *this_gen,
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
- if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) {
+ if (INPUT_IS_SEEKABLE(this->input)) {
if ( (!start_pos) && (start_time)) {
start_pos = start_time;
@@ -947,8 +936,7 @@ static int demux_mpeg_seek (demux_plugin_t *this_gen,
if( !this->stream->demux_thread_running ) {
this->preview_mode = 0;
this->buf_flag_seek = 0;
- }
- else {
+ } else {
this->buf_flag_seek = 1;
xine_demux_flush_engine(this->stream);
}
@@ -962,11 +950,10 @@ static void demux_mpeg_dispose (demux_plugin_t *this_gen) {
}
static int demux_mpeg_get_stream_length (demux_plugin_t *this_gen) {
-
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
if (this->rate)
- return (int)((int64_t) 1000 * this->input->get_length (this->input) /
+ return (int)((int64_t) 1000 * this->input->get_length (this->input) /
(this->rate * 50));
else
return 0;
@@ -1008,12 +995,15 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_BY_CONTENT: {
+#if 0
uint8_t buf[MAX_PREVIEW_SIZE];
off_t mdat_atom_offset = -1;
int64_t mdat_atom_size = -1;
unsigned int fourcc_tag;
int i, j;
int ok = 0;
+#endif
+ uint8_t buf[4];
/* use demux_mpeg_block for block devices */
if (input->get_capabilities(input) & INPUT_CAP_BLOCK ) {
@@ -1021,49 +1011,19 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0) {
-
- /* try preview */
-
- if ((input->get_capabilities(input) & INPUT_CAP_PREVIEW) == 0) {
- free (this);
- return NULL;
- }
-
- input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
-
-#ifdef LOG
- printf ("demux_mpeg: %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3]);
-#endif
-
- /*
- * look for mpeg header
- */
-
-
- if (!buf[0] && !buf[1] && (buf[2] == 0x01)
- && (buf[3] == 0xba)) /* if so, take it */
- break;
-
- free (this);
- return NULL;
- }
-
- input->seek(input, 0, SEEK_SET);
- if (input->read(input, buf, 16) == 16) {
+ /* look for mpeg header */
+ if (xine_demux_read_header(input, buf, 4) == 4) {
+ lprintf ("%02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3]);
+ if (!buf[0] && !buf[1] && (buf[2] == 0x01)
+ && (buf[3] == 0xba)) /* if so, take it */
+ break;
+ }
+ free (this);
+ return NULL;
- /*
- * look for mpeg header
- */
-
- if (!buf[0] && !buf[1] && (buf[2] == 0x01)
- && (buf[3] == 0xba)) /* if so, take it */
- break;
- free (this);
- return NULL;
- }
+#if 0
+ /* code never reached, is it still usefull ?? */
/* special case for MPEG streams hidden inside QT files; check
* is there is an mdat atom */
@@ -1121,27 +1081,21 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
free (this);
return NULL;
+#endif
}
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
-
- if (!ending) {
- free (this);
- return NULL;
- }
-
- if (strncasecmp(ending, ".MPEG", 5)
- && strncasecmp (ending, ".mpg", 4)) {
+ if (!xine_demux_check_extension (mrl, extensions)) {
free (this);
return NULL;
}
}
- break;
+ break;
case METHOD_EXPLICIT:
break;
@@ -1172,19 +1126,15 @@ static char *get_mimetypes (demux_class_t *this_gen) {
}
static void class_dispose (demux_class_t *this_gen) {
-
demux_mpeg_class_t *this = (demux_mpeg_class_t *) this_gen;
free (this);
}
static void *init_plugin (xine_t *xine, void *data) {
-
demux_mpeg_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_mpeg_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index 6fdfbb1fb..a8fb00067 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.c
@@ -16,8 +16,10 @@
* 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
- *
- * $Id: demux_ogg.c,v 1.103 2003/07/08 14:39:24 heinchen Exp $
+ */
+
+/*
+ * $Id: demux_ogg.c,v 1.104 2003/07/16 14:14:17 andruil Exp $
*
* demultiplexer for ogg streams
*
@@ -49,14 +51,15 @@
#include <theora/theora.h>
#endif
+/********** logging **********/
+#define LOG_MODULE "demux_ogg"
+/* #define LOG_VERBOSE */
+/* #define LOG */
+
#include "xine_internal.h"
#include "xineutils.h"
#include "demux.h"
-/*
-#define LOG
-*/
-
#define CHUNKSIZE 8500
#define PACKET_TYPE_HEADER 0x01
#define PACKET_TYPE_COMMENT 0x03
@@ -79,23 +82,19 @@ typedef struct demux_ogg_s {
demux_plugin_t demux_plugin;
xine_stream_t *stream;
-
fifo_buffer_t *audio_fifo;
fifo_buffer_t *video_fifo;
-
input_plugin_t *input;
+ int status;
#ifdef HAVE_THEORA
theora_info t_info;
theora_comment t_comment;
#endif
- int status;
-
int frame_duration;
ogg_sync_state oy;
- ogg_stream_state os;
ogg_page og;
ogg_stream_state oss[MAX_STREAMS];
@@ -126,19 +125,14 @@ typedef struct demux_ogg_s {
} demux_ogg_t ;
-
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_ogg_class_t;
+
static int intlog(int num) {
int ret=0;
+
while(num>0){
num=num/2;
ret=ret+1;
@@ -146,9 +140,9 @@ static int intlog(int num) {
return(ret);
}
-static int get_stream (demux_ogg_t *this, int serno)
-{
+static int get_stream (demux_ogg_t *this, int serno){
int i;
+
for (i = 0; i<this->num_streams; i++) {
if (this->oss[i].serialno == serno) {
return i;
@@ -196,19 +190,6 @@ static int read_ogg_packet (demux_ogg_t *this) {
return 1;
}
-static void hex_dump (uint8_t *p, int length) {
- int i,j;
- unsigned char c;
- for (j=0;j<length;j=i) {
- printf ("%04X ",j);
- for (i=j;i<(j+16<length?j+16:length);i++)
- printf ("%02X ", c=p[i]);
- for (i=j;i<(j+16<length?j+16:length);i++)
- if ( ((c=p[i])>=20) && (c<128)) printf ("%c", c); else printf (".");
- printf("\n");
- }
-}
-
static void send_ogg_packet (demux_ogg_t *this,
fifo_buffer_t *fifo,
ogg_packet *op,
@@ -279,18 +260,15 @@ static void send_ogg_packet (demux_ogg_t *this,
static void check_newpts (demux_ogg_t *this, int64_t pts, int video, int preview) {
int64_t diff;
-#ifdef LOG
- printf ("demux_ogg: new pts %lld found in stream\n",pts);
-#endif
+ lprintf ("new pts %lld found in stream\n",pts);
diff = pts - this->last_pts[video];
if (!preview && (pts>=0) &&
(this->send_newpts || (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD) ) ) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_ogg: diff=%lld (pts=%lld, last_pts=%lld)\n",
- diff, pts, this->last_pts[video]);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "diff=%lld (pts=%lld, last_pts=%lld)\n", diff, pts, this->last_pts[video]);
if (this->buf_flag_seek) {
xine_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK);
@@ -384,25 +362,19 @@ static void send_ogg_buf (demux_ogg_t *this,
memcpy (buf->content, op->packet+1+hdrlen, op->bytes-1-hdrlen);
buf->size = op->bytes-1-hdrlen;
}
-
-#ifdef LOG
- printf ("demux_ogg: audio buf_size %d\n", buf->size);
-#endif
-
+ lprintf ("audio buf_size %d\n", buf->size);
if ((op->granulepos!=-1) || (this->header_granulepos[stream_num]!=-1)) {
buf->pts = get_pts(this, stream_num, op->granulepos );
check_newpts( this, buf->pts, PTS_AUDIO, decoder_flags );
} else
- buf->pts = 0;
+ buf->pts = 0;
-#ifdef LOG
- printf ("demux_ogg: audiostream %d op-gpos %lld hdr-gpos %lld pts %lld \n"
- ,stream_num
- ,op->granulepos
- ,this->header_granulepos[stream_num]
- ,buf->pts);
-#endif
+ lprintf ("audiostream %d op-gpos %lld hdr-gpos %lld pts %lld \n",
+ stream_num,
+ op->granulepos,
+ this->header_granulepos[stream_num],
+ buf->pts);
buf->extra_info->input_pos = this->input->get_current_pos (this->input);
buf->extra_info->input_time = buf->pts / 90;
@@ -410,7 +382,7 @@ static void send_ogg_buf (demux_ogg_t *this,
buf->decoder_flags = decoder_flags;
this->audio_fifo->put (this->audio_fifo, buf);
-
+
#ifdef HAVE_THEORA
} else if ((this->buf_types[stream_num] & 0xFFFF0000) == BUF_VIDEO_THEORA) {
@@ -424,24 +396,20 @@ static void send_ogg_buf (demux_ogg_t *this,
/*Lets see if this is an Header*/
if ((theora_decode_header(&t_info, &t_comment, op))>=0) {
decoder_flags=decoder_flags|BUF_FLAG_HEADER;
-#ifdef LOG
- printf ("demux_ogg: found an header\n");
-#endif
+ lprintf ("found an header\n");
}
if ((op->granulepos!=-1) || (this->header_granulepos[stream_num]!=-1)) {
pts = get_pts(this, stream_num, op->granulepos );
check_newpts( this, pts, PTS_VIDEO, decoder_flags );
} else
- pts = 0;
+ pts = 0;
-#ifdef LOG
- printf ("demuxogg: theorastream %d op-gpos %lld hdr-gpos %lld pts %lld \n"
- ,stream_num
- ,op->granulepos
- ,this->header_granulepos[stream_num]
- ,pts);
-#endif
+ lprintf ("theorastream %d op-gpos %lld hdr-gpos %lld pts %lld \n",
+ stream_num,
+ op->granulepos,
+ this->header_granulepos[stream_num],
+ pts);
send_ogg_packet (this, this->video_fifo, op, pts, decoder_flags, stream_num);
@@ -454,16 +422,14 @@ static void send_ogg_buf (demux_ogg_t *this,
buf_element_t *buf;
int todo, done;
-#ifdef LOG
- printf ("demux_ogg: video buffer, type=%08x\n", this->buf_types[stream_num]);
-#endif
+ lprintf ("video buffer, type=%08x\n", this->buf_types[stream_num]);
todo = op->bytes;
- done = 1+hdrlen;
+ done = 1+hdrlen;
while (done<todo) {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
-
+
if ( (todo-done)>(buf->max_size-1)) {
buf->size = buf->max_size-1;
buf->decoder_flags = decoder_flags;
@@ -471,9 +437,9 @@ static void send_ogg_buf (demux_ogg_t *this,
buf->size = todo-done;
buf->decoder_flags = BUF_FLAG_FRAME_END | decoder_flags;
}
-
+
/*
- printf ("demux_ogg: done %d todo %d doing %d\n", done, todo, buf->size);
+ lprintf ("done %d todo %d doing %d\n", done, todo, buf->size);
*/
memcpy (buf->content, op->packet+done, buf->size);
@@ -481,24 +447,22 @@ static void send_ogg_buf (demux_ogg_t *this,
buf->pts = get_pts(this, stream_num, op->granulepos );
check_newpts( this, buf->pts, PTS_VIDEO, decoder_flags );
} else
- buf->pts = 0;
+ buf->pts = 0;
buf->extra_info->input_pos = this->input->get_current_pos (this->input);
buf->extra_info->input_time = buf->pts / 90 ;
buf->type = this->buf_types[stream_num] ;
-
+
done += buf->size;
-#ifdef LOG
- printf ("demuxogg: videostream %d op-gpos %lld hdr-gpos %lld pts %lld \n"
- ,stream_num
- ,op->granulepos
- ,this->header_granulepos[stream_num]
- ,buf->pts);
-#endif
+ lprintf ("videostream %d op-gpos %lld hdr-gpos %lld pts %lld \n",
+ stream_num,
+ op->granulepos,
+ this->header_granulepos[stream_num],
+ buf->pts);
this->video_fifo->put (this->video_fifo, buf);
-
+
}
} else if ((this->buf_types[stream_num] & 0xFF000000) == BUF_SPU_BASE) {
@@ -515,19 +479,14 @@ static void send_ogg_buf (demux_ogg_t *this,
}
if (op->packet[0] == PACKET_TYPE_HEADER ) {
-#ifdef LOG
- printf ("demux_ogg: Textstream-header-packet\n");
-#endif
+ lprintf ("Textstream-header-packet\n");
} else if (op->packet[0] == PACKET_TYPE_COMMENT ) {
char *comment;
vorbis_comment vc;
vorbis_info vi;
-#ifdef LOG
- printf ("demux_ogg: Textstream-comment-packet\n");
-#endif
-
+ lprintf ("Textstream-comment-packet\n");
vorbis_comment_init(&vc);
vorbis_info_init(&vi);
@@ -550,14 +509,12 @@ static void send_ogg_buf (demux_ogg_t *this,
start = op->granulepos;
end = start+lenbytes;
-#ifdef LOG
- printf ("demux_ogg: subtitlestream %d: %d -> %d :%s\n",stream_num,start,end,subtitle);
-#endif
+ lprintf ("subtitlestream %d: %d -> %d :%s\n",stream_num,start,end,subtitle);
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = this->buf_types[stream_num];
buf->pts = 0;
-
+
val = (uint32_t * )buf->content;
*val++ = start;
@@ -577,20 +534,14 @@ static void send_ogg_buf (demux_ogg_t *this,
*/
static void demux_ogg_send_header (demux_ogg_t *this) {
- int stream_num = -1;
- int cur_serno;
-
- int done = 0;
-
- int filelength,position;
-
- ogg_packet op;
-
+ int stream_num = -1;
+ int cur_serno;
+ int done = 0;
+ int filelength,position;
+ ogg_packet op;
xine_event_t ui_event;
-#ifdef LOG
- printf ("demux_ogg: detecting stream types...\n");
-#endif
+ lprintf ("detecting stream types...\n");
this->ignore_keyframes = 0;
@@ -600,16 +551,13 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
return;
}
/* now we've got at least one new page */
-
+
cur_serno = ogg_page_serialno (&this->og);
-
+
if (ogg_page_bos(&this->og)) {
+ lprintf ("beginning of stream\n");
+ lprintf ("serial number %d\n", cur_serno);
-#ifdef LOG
- printf ("demux_ogg: beginning of stream\ndemux_ogg: serial number %d\n",
- cur_serno);
-#endif
-
ogg_stream_init(&this->oss[this->num_streams], cur_serno);
stream_num = this->num_streams;
this->buf_types[stream_num] = 0;
@@ -618,48 +566,49 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
} else {
stream_num = get_stream(this, cur_serno);
if (stream_num == -1) {
- printf ("demux_ogg: help, stream with no beginning!\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "help, stream with no beginning!\n");
abort();
}
}
-
+
ogg_stream_pagein(&this->oss[stream_num], &this->og);
-
+
while (ogg_stream_packetout(&this->oss[stream_num], &op) == 1) {
-
+
if (!this->buf_types[stream_num]) {
/* detect buftype */
if (!strncmp (&op.packet[1], "vorbis", 6)) {
-
+
vorbis_info vi;
vorbis_comment vc;
-
+
this->buf_types[stream_num] = BUF_AUDIO_VORBIS
+this->num_audio_streams++;
-
+
this->preview_buffers[stream_num] = 3;
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
if (vorbis_synthesis_headerin(&vi, &vc, &op) >= 0) {
-
+
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE]
= vi.bitrate_nominal;
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE]
= vi.rate;
-
+
this->factor[stream_num] = 90000;
this->quotient[stream_num] = vi.rate;
-
+
if (vi.bitrate_nominal<1)
this->avg_bitrate += 100000; /* assume 100 kbit */
else
this->avg_bitrate += vi.bitrate_nominal;
-
+
} else {
this->factor[stream_num] = 900;
this->quotient[stream_num] = 441;
-
+
this->preview_buffers[stream_num] = 0;
xine_log (this->stream->xine, XINE_LOG_MSG,
_("ogg: vorbis audio track indicated but no vorbis stream header found.\n"));
@@ -699,10 +648,8 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->avg_bitrate += bitrate;
-#ifdef LOG
- printf ("demux_ogg: detected Speex stream,\trate %d\tbitrate %d\n",
+ lprintf ("detected Speex stream,\trate %d\tbitrate %d\n",
header->rate, bitrate);
-#endif
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE]
= header->rate;
@@ -710,16 +657,17 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->preview_buffers[stream_num] += header->extra_headers;
}
#else
- printf ("demux_ogg: Speex stream detected, unable to play\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "Speex stream detected, unable to play\n");
this->buf_types[stream_num] = BUF_CONTROL_NOP;
#endif
} else if (!strncmp (&op.packet[1], "video", 5)) {
-
+
buf_element_t *buf;
xine_bmiheader bih;
int channel;
-
+
int16_t locbits_per_sample;
uint32_t locsubtype;
int32_t locsize, locdefault_len, locbuffersize, locwidth, locheight;
@@ -734,12 +682,12 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
memcpy(&locbits_per_sample, &op.packet[41], 2);
memcpy(&locwidth, &op.packet[45], 4);
memcpy(&locheight, &op.packet[49], 4);
-
+
+ lprintf ("direct show filter created stream detected, hexdump:\n");
#ifdef LOG
- printf ("demux_ogg: direct show filter created stream detected, hexdump:\n");
- hex_dump (op.packet, op.bytes);
+ xine_hexdump (op.packet, op.bytes);
#endif
-
+
channel = this->num_video_streams++;
this->buf_types[stream_num] = fourcc_to_buf_video (locsubtype);
@@ -748,17 +696,15 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->buf_types[stream_num] |= channel;
this->preview_buffers[stream_num] = 5; /* FIXME: don't know */
-#ifdef LOG
- printf ("demux_ogg: subtype %.4s\n", &locsubtype);
- printf ("demux_ogg: time_unit %lld\n", loctime_unit);
- printf ("demux_ogg: samples_per_unit %lld\n", locsamples_per_unit);
- printf ("demux_ogg: default_len %d\n", locdefault_len);
- printf ("demux_ogg: buffersize %d\n", locbuffersize);
- printf ("demux_ogg: bits_per_sample %d\n", locbits_per_sample);
- printf ("demux_ogg: width %d\n", locwidth);
- printf ("demux_ogg: height %d\n", locheight);
- printf ("demux_ogg: buf_type %08x\n",this->buf_types[stream_num]);
-#endif
+ lprintf ("subtype %.4s\n", &locsubtype);
+ lprintf ("time_unit %lld\n", loctime_unit);
+ lprintf ("samples_per_unit %lld\n", locsamples_per_unit);
+ lprintf ("default_len %d\n", locdefault_len);
+ lprintf ("buffersize %d\n", locbuffersize);
+ lprintf ("bits_per_sample %d\n", locbits_per_sample);
+ lprintf ("width %d\n", locwidth);
+ lprintf ("height %d\n", locheight);
+ lprintf ("buf_type %08x\n",this->buf_types[stream_num]);
bih.biSize=sizeof(xine_bmiheader);
bih.biWidth = locwidth;
@@ -821,11 +767,11 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
memcpy(&locblockalign, &op.packet[47], 2);
memcpy(&locavgbytespersec, &op.packet[49], 4);
-#ifdef LOG
- printf ("demux_ogg: direct show filter created audio stream detected, hexdump:\n");
- hex_dump (op.packet, op.bytes);
+ lprintf ("direct show filter created audio stream detected, hexdump:\n");
+#ifdef LOG
+ xine_hexdump (op.packet, op.bytes);
#endif
-
+
memcpy(str, &locsubtype, 4);
str[4] = 0;
codec = strtoul(str, NULL, 16);
@@ -844,25 +790,23 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->buf_types[stream_num] = BUF_AUDIO_A52 | channel;
break;
default:
- printf ("demux_ogg: unknown audio codec type 0x%x\n",
- codec);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_ogg: unknown audio codec type 0x%x\n", codec);
this->buf_types[stream_num] = BUF_CONTROL_NOP;
break;
}
-#ifdef LOG
- printf ("demux_ogg: subtype 0x%x\n", codec);
- printf ("demux_ogg: time_unit %lld\n", loctime_unit);
- printf ("demux_ogg: samples_per_unit %lld\n", locsamples_per_unit);
- printf ("demux_ogg: default_len %d\n", locdefault_len);
- printf ("demux_ogg: buffersize %d\n", locbuffersize);
- printf ("demux_ogg: bits_per_sample %d\n", locbits_per_sample);
- printf ("demux_ogg: channels %d\n", locchannels);
- printf ("demux_ogg: blockalign %d\n", locblockalign);
- printf ("demux_ogg: avgbytespersec %d\n", locavgbytespersec);
- printf ("demux_ogg: buf_type %08x\n",this->buf_types[stream_num]);
-#endif
-
+ lprintf ("subtype 0x%x\n", codec);
+ lprintf ("time_unit %lld\n", loctime_unit);
+ lprintf ("samples_per_unit %lld\n", locsamples_per_unit);
+ lprintf ("default_len %d\n", locdefault_len);
+ lprintf ("buffersize %d\n", locbuffersize);
+ lprintf ("bits_per_sample %d\n", locbits_per_sample);
+ lprintf ("channels %d\n", locchannels);
+ lprintf ("blockalign %d\n", locblockalign);
+ lprintf ("avgbytespersec %d\n", locavgbytespersec);
+ lprintf ("buf_type %08x\n",this->buf_types[stream_num]);
+
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = this->buf_types[stream_num];
buf->decoder_flags = BUF_FLAG_HEADER;
@@ -871,13 +815,13 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
buf->decoder_info[2] = locbits_per_sample;
buf->decoder_info[3] = locchannels;
this->audio_fifo->put (this->audio_fifo, buf);
-
+
this->preview_buffers[stream_num] = 5; /* FIXME: don't know */
this->factor[stream_num] = 90000;
this->quotient[stream_num] = locsamples_per_unit;
-
-
+
+
this->avg_bitrate += locavgbytespersec*8;
/*
@@ -896,12 +840,12 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
} else /* no audio_fifo there */
this->buf_types[stream_num] = BUF_CONTROL_NOP;
- } else if (op.bytes >= 142
+ } else if (op.bytes >= 142
&& !strncmp (&op.packet[1], "Direct Show Samples embedded in Ogg", 35) ) {
-#ifdef LOG
- printf ("demux_ogg: older direct show filter-generated stream header detected.\n");
- hex_dump (op.packet, op.bytes);
+ lprintf ("older Direct Show filter-generated stream header detected. Hexdump:\n");
+#ifdef LOG
+ xine_hexdump (op.packet, op.bytes);
#endif
this->preview_buffers[stream_num] = 5; /* FIXME: don't know */
@@ -912,17 +856,11 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
int channel;
uint32_t fcc;
-#ifdef LOG
- printf ("demux_ogg: seems to be a video stream.\n");
-#endif
+ lprintf ("seems to be a video stream.\n");
channel = this->num_video_streams++;
-
fcc = *(uint32_t*)(op.packet+68);
-
-#ifdef LOG
- printf ("demux_ogg: fourcc %08x\n", fcc);
-#endif
+ lprintf ("fourcc %08x\n", fcc);
this->buf_types[stream_num] = fourcc_to_buf_video (fcc);
if( !this->buf_types[stream_num] )
@@ -935,7 +873,7 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
bih.biPlanes = 0;
memcpy (&bih.biCompression, op.packet+68, 4);
bih.biBitCount = *(int16_t*)(op.packet+182);
- if (!bih.biBitCount)
+ if (!bih.biBitCount)
bih.biBitCount = 24; /* FIXME ? */
bih.biSizeImage = (bih.biBitCount>>3)*bih.biWidth*bih.biHeight;
bih.biXPelsPerMeter = 1;
@@ -951,16 +889,14 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
buf->decoder_info[1] = this->frame_duration;
memcpy (buf->content, &bih, sizeof (xine_bmiheader));
- buf->size = sizeof (xine_bmiheader);
+ buf->size = sizeof (xine_bmiheader);
buf->type = this->buf_types[stream_num];
this->video_fifo->put (this->video_fifo, buf);
-#ifdef LOG
- printf ("demux_ogg: subtype %.4s\n", &fcc);
- printf ("demux_ogg: buf_type %08x\n", this->buf_types[stream_num]);
- printf ("demux_ogg: video size %d x %d\n", bih.biWidth, bih.biHeight);
- printf ("demux_ogg: frame duration %d\n", this->frame_duration);
-#endif
+ lprintf ("subtype %.4s\n", &fcc);
+ lprintf ("buf_type %08x\n", this->buf_types[stream_num]);
+ lprintf ("video size %d x %d\n", bih.biWidth, bih.biHeight);
+ lprintf ("frame duration %d\n", this->frame_duration);
/*
* video metadata
@@ -1002,12 +938,14 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
#endif
- printf ("demux_ogg: FIXME, old audio format not handled\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "FIXME, old audio format not handled\n");
this->buf_types[stream_num] = BUF_CONTROL_NOP;
} else {
- printf ("demux_ogg: old header detected but stream type is unknown\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "old header detected but stream type is unknown\n");
this->buf_types[stream_num] = BUF_CONTROL_NOP;
}
} else if (!strncmp (&op.packet[1], "text", 4)) {
@@ -1015,9 +953,7 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
uint32_t *val;
buf_element_t *buf;
-#ifdef LOG
- printf ("demux_ogg: textstream detected.\n");
-#endif
+ lprintf ("textstream detected.\n");
this->preview_buffers[stream_num] = 2;
channel= this->num_spu_streams++;
this->buf_types[stream_num] = BUF_SPU_OGM | channel;
@@ -1071,8 +1007,9 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
#endif
} else {
/*Rejected stream*/
- printf ("demux_ogg: A theora header was rejected by libtheora\n");
- this->buf_types[stream_num] = BUF_CONTROL_NOP;
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ " A theora header was rejected by libtheora\n");
+ this->buf_types[stream_num] = BUF_CONTROL_NOP;
this->preview_buffers[stream_num] = 5; /* FIXME: don't know */
}
#else
@@ -1082,11 +1019,10 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
#endif
} else {
- printf ("demux_ogg: unknown stream type (signature >%.8s<). hex dump of bos packet follows:\n",
- op.packet);
-
- hex_dump (op.packet, op.bytes);
-
+ if(this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG){
+ printf ("demux_ogg: unknown stream type (signature >%.8s<). hex dump of bos packet follows:\n", op.packet);
+ xine_hexdump (op.packet, op.bytes);
+ }
this->buf_types[stream_num] = BUF_CONTROL_NOP;
}
}
@@ -1095,10 +1031,8 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
* send preview buffer
*/
-#ifdef LOG
- printf ("demux_ogg: sending preview buffer of stream type %08x\n",
- this->buf_types[stream_num]);
-#endif
+ lprintf ("sending preview buffer of stream type %08x\n",
+ this->buf_types[stream_num]);
send_ogg_buf (this, &op, stream_num, BUF_FLAG_PREVIEW);
@@ -1115,10 +1049,8 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
if (this->preview_buffers[i]>0)
done = 0;
-#ifdef LOG
- printf ("demux_ogg: %d preview buffers left to send from stream %d\n",
- this->preview_buffers[i], i);
-#endif
+ lprintf ("%d preview buffers left to send from stream %d\n",
+ this->preview_buffers[i], i);
}
}
}
@@ -1130,7 +1062,7 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->time_length=-1;
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ if (INPUT_IS_SEEKABLE(this->input)) {
position=this->input->get_current_pos(this->input);
filelength=this->input->get_length(this->input);
@@ -1156,52 +1088,45 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
}
static void demux_ogg_send_content (demux_ogg_t *this) {
-
int stream_num;
int cur_serno;
ogg_packet op;
-#ifdef LOG
- printf ("demux_ogg: send package...\n");
-#endif
+ lprintf ("send package...\n");
if (!read_ogg_packet(this)) {
this->status = DEMUX_FINISHED;
-#ifdef LOG
- printf ("demux_ogg: EOF\n");
-#endif
+ lprintf ("EOF\n");
return;
}
/* now we've got one new page */
-
+
cur_serno = ogg_page_serialno (&this->og);
stream_num=get_stream(this, cur_serno);
if (stream_num < 0) {
- printf ("demux_ogg: error: unknown stream, serialnumber %d\n", cur_serno);
-
+ lprintf ("error: unknown stream, serialnumber %d\n", cur_serno);
+
if (!ogg_page_bos(&this->og)) {
- printf ("demux_ogg: help, stream with no beginning!\n");
+ lprintf ("help, stream with no beginning!\n");
}
-
- printf ("demux_ogg: adding late stream with serial number %d (all content will be discarded)\n",
+
+ lprintf ("adding late stream with serial number %d (all content will be discarded)\n",
cur_serno);
ogg_stream_init(&this->oss[this->num_streams], cur_serno);
stream_num = this->num_streams;
- this->buf_types[stream_num] = 0;
+ this->buf_types[stream_num] = 0;
this->header_granulepos[stream_num]=-1;
this->num_streams++;
}
-
+
ogg_stream_pagein(&this->oss[stream_num], &this->og);
-
+
if (ogg_page_bos(&this->og)) {
-#ifdef LOG
- printf ("demux_ogg: beginning of stream\ndemux_ogg: serial number %d - discard\n",
+ lprintf ("beginning of stream\ndemux_ogg: serial number %d - discard\n",
ogg_page_serialno (&this->og));
-#endif
while (ogg_stream_packetout(&this->oss[stream_num], &op) == 1) ;
return;
}
@@ -1210,7 +1135,7 @@ static void demux_ogg_send_content (demux_ogg_t *this) {
if (!this->ignore_keyframes && this->keyframe_needed
&& ((this->buf_types[stream_num] & 0xFF000000) != BUF_VIDEO_BASE))
return;
-
+
while (ogg_stream_packetout(&this->oss[stream_num], &op) == 1) {
/* printf("demux_ogg: packet: %.8s\n", op.packet); */
/* printf("demux_ogg: got a packet\n"); */
@@ -1218,13 +1143,9 @@ static void demux_ogg_send_content (demux_ogg_t *this) {
if ((*op.packet & PACKET_TYPE_HEADER) && (this->buf_types[stream_num]!=BUF_VIDEO_THEORA) && (this->buf_types[stream_num]!=BUF_AUDIO_SPEEX)) {
if (op.granulepos!=-1) {
this->header_granulepos[stream_num]=op.granulepos;
-#ifdef LOG
- printf ("demux_ogg: header with granulepos, remembering granulepos\n");
-#endif
+ lprintf ("header with granulepos, remembering granulepos\n");
} else {
-#ifdef LOG
- printf ("demux_ogg: header => discard\n");
-#endif
+ lprintf ("demux_ogg: header => discard\n");
}
continue;
}
@@ -1247,9 +1168,7 @@ static void demux_ogg_send_content (demux_ogg_t *this) {
}
if (!this->ignore_keyframes && this->keyframe_needed) {
-#ifdef LOG
- printf ("demux_ogg: keyframe needed... buf_type=%08x\n", this->buf_types[stream_num]);
-#endif
+ lprintf ("keyframe needed... buf_type=%08x\n", this->buf_types[stream_num]);
if (this->buf_types[stream_num] == BUF_VIDEO_THEORA) {
#ifdef HAVE_THEORA
@@ -1261,8 +1180,8 @@ static void demux_ogg_send_content (demux_ogg_t *this) {
if(op.granulepos>=0){
iframe=op.granulepos>>keyframe_granule_shift;
pframe=op.granulepos-(iframe<<keyframe_granule_shift);
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("seeking keyframe i %lld p %lld\n",iframe,pframe);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "seeking keyframe i %lld p %lld\n",iframe,pframe);
if (pframe!=0)
continue;
} else
@@ -1296,7 +1215,6 @@ static void demux_ogg_send_content (demux_ogg_t *this) {
}
static int demux_ogg_send_chunk (demux_plugin_t *this_gen) {
-
demux_ogg_t *this = (demux_ogg_t *) this_gen;
demux_ogg_send_content (this);
@@ -1305,7 +1223,6 @@ static int demux_ogg_send_chunk (demux_plugin_t *this_gen) {
}
static void demux_ogg_dispose (demux_plugin_t *this_gen) {
-
demux_ogg_t *this = (demux_ogg_t *) this_gen;
int i;
@@ -1335,7 +1252,6 @@ static int demux_ogg_get_status (demux_plugin_t *this_gen) {
}
static void demux_ogg_send_headers (demux_plugin_t *this_gen) {
-
demux_ogg_t *this = (demux_ogg_t *) this_gen;
this->video_fifo = this->stream->video_fifo;
@@ -1354,13 +1270,13 @@ static void demux_ogg_send_headers (demux_plugin_t *this_gen) {
* initialize ogg engine
*/
ogg_sync_init(&this->oy);
-
+
this->num_streams = 0;
this->num_audio_streams = 0;
this->num_video_streams = 0;
this->num_spu_streams = 0;
this->avg_bitrate = 1;
-
+
this->input->seek (this->input, 0, SEEK_SET);
if (this->status == DEMUX_OK) {
@@ -1368,10 +1284,7 @@ static void demux_ogg_send_headers (demux_plugin_t *this_gen) {
/* send header */
demux_ogg_send_header (this);
-#ifdef LOG
- printf ("demux_ogg: headers sent, avg bitrate is %lld\n",
- this->avg_bitrate);
-#endif
+ lprintf ("headers sent, avg bitrate is %lld\n", this->avg_bitrate);
}
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = this->num_video_streams>0;
@@ -1388,7 +1301,7 @@ static int demux_ogg_seek (demux_plugin_t *this_gen,
* seek to start position
*/
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ if (INPUT_IS_SEEKABLE(this->input)) {
this->keyframe_needed = (this->num_video_streams>0);
@@ -1398,25 +1311,20 @@ static int demux_ogg_seek (demux_plugin_t *this_gen,
else
start_pos = start_time * this->avg_bitrate/8;
-#ifdef LOG
- printf ("demux_ogg: seeking to %d seconds => %lld bytes\n",
- start_time, start_pos);
-#endif
+ lprintf ("seeking to %d seconds => %lld bytes\n", start_time, start_pos);
}
ogg_sync_reset(&this->oy);
for (i=0; i<this->num_streams; i++) {
this->header_granulepos[i]=-1;
- }
-
+ }
+
/*some strange streams have no syncpoint flag set at the beginning*/
if (start_pos == 0)
this->keyframe_needed = 0;
-#ifdef LOF
- printf ("demux_ogg: seek to %lld called\n",start_pos);
-#endif
+ lprintf ("seek to %lld called\n",start_pos);
this->input->seek (this->input, start_pos, SEEK_SET);
@@ -1522,61 +1430,34 @@ static int demux_ogg_get_optional_data(demux_plugin_t *this_gen,
static demux_plugin_t *open_plugin (demux_class_t *class_gen,
xine_stream_t *stream,
input_plugin_t *input) {
-
+
demux_ogg_t *this;
switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
- {
- uint8_t buf[MAX_PREVIEW_SIZE];
-
- if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) {
+ case METHOD_BY_CONTENT: {
+ uint8_t buf[4];
- input->seek(input, 0, SEEK_SET);
-
- if (input->read(input, buf, 4)) {
+ if (xine_demux_read_header(input, buf, 4) != 4)
+ return NULL;
- if ((buf[0] != 'O')
- || (buf[1] != 'g')
- || (buf[2] != 'g')
- || (buf[3] != 'S'))
- return NULL;
- } else {
- return NULL;
- }
- } else if (input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW)) {
- if ((buf[0] != 'O')
- || (buf[1] != 'g')
- || (buf[2] != 'g')
- || (buf[3] != 'S'))
- return NULL;
- } else
- return NULL;
- }
- break;
+ if ((buf[0] != 'O')
+ || (buf[1] != 'g')
+ || (buf[2] != 'g')
+ || (buf[3] != 'S'))
+ return NULL;
+ }
+ break;
case METHOD_BY_EXTENSION: {
+ char *extensions, *mrl;
- char *ending, *mrl;
-
mrl = input->get_mrl (input);
-
- /*
- * check extension
- */
-
- ending = strrchr (mrl, '.');
-
- if (!ending)
- return NULL;
-
- if (strncasecmp(ending, ".ogg", 4) &&
- strncasecmp(ending, ".ogm", 4) &&
- strncasecmp(ending, ".spx", 4)) {
- return NULL;
- }
+ extensions = class_gen->get_extensions (class_gen);
+ if (!xine_demux_check_extension (mrl, extensions)) {
+ return NULL;
+ }
}
break;
@@ -1618,8 +1499,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
return &this->demux_plugin;
}
-
-
/*
* ogg demuxer class
*/
@@ -1643,19 +1522,15 @@ static char *get_mimetypes (demux_class_t *this_gen) {
}
static void class_dispose (demux_class_t *this_gen) {
-
demux_ogg_class_t *this = (demux_ogg_class_t *) this_gen;
free (this);
}
static void *init_class (xine_t *xine, void *data) {
-
demux_ogg_class_t *this;
-
- this = xine_xmalloc (sizeof (demux_ogg_class_t));
- this->config = xine->config;
- this->xine = xine;
+
+ this = xine_xmalloc (sizeof (demux_ogg_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index 0b2d69124..9c7c7e16a 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -16,7 +16,9 @@
* 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
- *
+ */
+
+/*
* Real Media File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the Real file format, visit:
* http://www.pcisys.net/~melanson/codecs/
@@ -28,7 +30,7 @@
*
* Based on FFmpeg's libav/rm.c.
*
- * $Id: demux_real.c,v 1.59 2003/06/22 19:42:31 komadori Exp $
+ * $Id: demux_real.c,v 1.60 2003/07/16 14:14:17 andruil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,16 +44,17 @@
#include <stdlib.h>
#include <ctype.h>
+/********** logging **********/
+#define LOG_MODULE "demux_real"
+/* #define LOG_VERBOSE */
+/* #define LOG */
+
#include "xine_internal.h"
#include "xineutils.h"
#include "compat.h"
#include "demux.h"
#include "bswap.h"
-/*
-#define LOG
-*/
-
#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
( (long)(unsigned char)(ch3) | \
( (long)(unsigned char)(ch2) << 8 ) | \
@@ -115,22 +118,17 @@ typedef struct {
} real_stream_t;
typedef struct {
-
demux_plugin_t demux_plugin;
xine_stream_t *stream;
-
- config_values_t *config;
-
fifo_buffer_t *video_fifo;
fifo_buffer_t *audio_fifo;
-
input_plugin_t *input;
+ int status;
off_t index_start;
off_t data_start;
off_t data_size;
- int status;
unsigned int duration;
unsigned int packet_count;
unsigned int current_packet;
@@ -138,7 +136,7 @@ typedef struct {
real_stream_t video_streams[MAX_VIDEO_STREAMS];
int num_video_streams;
real_stream_t *video_stream;
-
+
real_stream_t audio_streams[MAX_AUDIO_STREAMS];
int num_audio_streams;
real_stream_t *audio_stream;
@@ -147,8 +145,6 @@ typedef struct {
unsigned int current_data_chunk_packet_count;
unsigned int next_data_chunk_offset;
- char last_mrl[1024];
-
int old_seqnum;
int packet_size_cur;
@@ -164,49 +160,10 @@ typedef struct {
} demux_real_t ;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_real_class_t;
-#ifdef LOG
-static void hexdump (char *buf, int length) {
-
- int i;
-
- printf ("demux_real: ascii contents>");
- for (i = 0; i < length; i++) {
- unsigned char c = buf[i];
-
- if ((c >= 32) && (c <= 128))
- printf ("%c", c);
- else
- printf (".");
- }
- printf ("\n");
-
- printf ("demux_real: complete hexdump of package follows:\ndemux_real 0x0000: ");
- for (i = 0; i < length; i++) {
- unsigned char c = buf[i];
-
- printf ("%02x", c);
-
- if ((i % 16) == 15)
- printf ("\ndemux_real: 0x%04x: ", i);
-
- if ((i % 2) == 1)
- printf (" ");
-
- }
- printf ("\n");
-}
-#endif
-
static void real_parse_index(demux_real_t *this) {
off_t next_index_chunk = this->index_start;
@@ -217,63 +174,55 @@ static void real_parse_index(demux_real_t *this) {
real_index_entry_t **index;
while(next_index_chunk) {
-#ifdef LOG
- printf("demux_real: reading index chunk at %llX\n", next_index_chunk);
-#endif
-
- /* Seek to index chunk */
+ lprintf("reading index chunk at %llX\n", next_index_chunk);
+
+ /* Seek to index chunk */
this->input->seek(this->input, next_index_chunk, SEEK_SET);
-
+
/* Read index chunk header */
if(this->input->read(this->input, index_chunk_header, INDEX_CHUNK_HEADER_SIZE)
!= INDEX_CHUNK_HEADER_SIZE) {
- printf("demux_real: index chunk header not read\n");
+ lprintf("index chunk header not read\n");
break;
}
-
+
/* Check chunk is actually an index chunk */
if(BE_32(&index_chunk_header[0]) == INDX_TAG) {
-
+
/* Check version */
if(BE_16(&index_chunk_header[8]) != 0) {
- printf("demux_real: unknown index chunk version %d\n",
- BE_16(&index_chunk_header[8]));
+ lprintf("unknown index chunk version %d\n",
+ BE_16(&index_chunk_header[8]));
break;
}
-
+
/* Read data from header */
entries = BE_32(&index_chunk_header[10]);
stream_num = BE_16(&index_chunk_header[14]);
next_index_chunk = BE_32(&index_chunk_header[16]);
-
+
/* Find which stream this index is for */
index = NULL;
for(i = 0; i < this->num_video_streams; i++) {
if(stream_num == this->video_streams[i].mdpr->stream_number) {
index = &this->video_streams[i].index;
this->video_streams[i].index_entries = entries;
-#ifdef LOG
- printf("demux_real: found index chunk for video stream with num %d\n",
- stream_num);
-#endif
+ lprintf("found index chunk for video stream with num %d\n", stream_num);
break;
}
}
-
+
if(!index) {
for(i = 0; i < this->num_audio_streams; i++) {
if(stream_num == this->audio_streams[i].mdpr->stream_number) {
index = &this->audio_streams[i].index;
this->audio_streams[i].index_entries = entries;
-#ifdef LOG
- printf("demux_real: found index chunk for audio stream with num %d\n",
- stream_num);
-#endif
+ lprintf("found index chunk for audio stream with num %d\n", stream_num);
break;
}
}
}
-
+
if(index && entries) {
/* Allocate memory for index */
*index = xine_xmalloc(entries * sizeof(real_index_entry_t));
@@ -282,40 +231,38 @@ static void real_parse_index(demux_real_t *this) {
for(i = 0; i < entries; i++) {
if(this->input->read(this->input, index_record, INDEX_RECORD_SIZE)
!= INDEX_RECORD_SIZE) {
- printf("demux_real: index record not read\n");
+ lprintf("index record not read\n");
free(*index);
*index = NULL;
break;
}
-
+
(*index)[i].timestamp = BE_32(&index_record[2]);
(*index)[i].offset = BE_32(&index_record[6]);
(*index)[i].packetno = BE_32(&index_record[10]);
}
} else {
- printf("demux_real: unused index chunk with %d entries for stream num %d\n",
- entries, stream_num);
+ lprintf("unused index chunk with %d entries for stream num %d\n",
+ entries, stream_num);
}
} else {
- printf("demux_real: expected index chunk found chunk type: %.4s\n",
- &index_chunk_header[0]);
+ lprintf("expected index chunk found chunk type: %.4s\n", &index_chunk_header[0]);
break;
}
}
-
+
/* Seek back to position before index reading */
this->input->seek(this->input, original_pos, SEEK_SET);
}
static mdpr_t *real_parse_mdpr(const char *data) {
-
mdpr_t *mdpr=malloc(sizeof(mdpr_t));
mdpr->object_version=BE_16(&data[0]);
if (mdpr->object_version != 0) {
- printf("warning: unknown object version in MDPR: 0x%04x\n",
- mdpr->object_version);
+ lprintf("warning: unknown object version in MDPR: 0x%04x\n",
+ mdpr->object_version);
}
mdpr->stream_number=BE_16(&data[2]);
@@ -326,36 +273,35 @@ static mdpr_t *real_parse_mdpr(const char *data) {
mdpr->start_time=BE_32(&data[20]);
mdpr->preroll=BE_32(&data[24]);
mdpr->duration=BE_32(&data[28]);
-
+
mdpr->stream_name_size=data[32];
mdpr->stream_name=malloc(sizeof(char)*(mdpr->stream_name_size+1));
memcpy(mdpr->stream_name, &data[33], mdpr->stream_name_size);
mdpr->stream_name[(int)mdpr->stream_name_size]=0;
-
+
mdpr->mime_type_size=data[33+mdpr->stream_name_size];
mdpr->mime_type=malloc(sizeof(char)*(mdpr->mime_type_size+1));
memcpy(mdpr->mime_type, &data[34+mdpr->stream_name_size], mdpr->mime_type_size);
mdpr->mime_type[(int)mdpr->mime_type_size]=0;
-
+
mdpr->type_specific_len=BE_32(&data[34+mdpr->stream_name_size+mdpr->mime_type_size]);
mdpr->type_specific_data=malloc(sizeof(char)*(mdpr->type_specific_len));
- memcpy(mdpr->type_specific_data,
+ memcpy(mdpr->type_specific_data,
&data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
-
+
+ lprintf("MDPR: stream number: %i\n", mdpr->stream_number);
+ lprintf("MDPR: maximal bit rate: %i\n", mdpr->max_bit_rate);
+ lprintf("MDPR: average bit rate: %i\n", mdpr->avg_bit_rate);
+ lprintf("MDPR: largest packet size: %i bytes\n", mdpr->max_packet_size);
+ lprintf("MDPR: average packet size: %i bytes\n", mdpr->avg_packet_size);
+ lprintf("MDPR: start time: %i\n", mdpr->start_time);
+ lprintf("MDPR: pre-buffer: %i ms\n", mdpr->preroll);
+ lprintf("MDPR: duration of stream: %i ms\n", mdpr->duration);
+ lprintf("MDPR: stream name: %s\n", mdpr->stream_name);
+ lprintf("MDPR: mime type: %s\n", mdpr->mime_type);
+ lprintf("MDPR: type specific data:\n");
#ifdef LOG
- printf("demux_real: MDPR: stream number: %i\n", mdpr->stream_number);
- printf("demux_real: MDPR: maximal bit rate: %i\n", mdpr->max_bit_rate);
- printf("demux_real: MDPR: average bit rate: %i\n", mdpr->avg_bit_rate);
- printf("demux_real: MDPR: largest packet size: %i bytes\n", mdpr->max_packet_size);
- printf("demux_real: MDPR: average packet size: %i bytes\n", mdpr->avg_packet_size);
- printf("demux_real: MDPR: start time: %i\n", mdpr->start_time);
- printf("demux_real: MDPR: pre-buffer: %i ms\n", mdpr->preroll);
- printf("demux_real: MDPR: duration of stream: %i ms\n", mdpr->duration);
- printf("demux_real: MDPR: stream name: %s\n", mdpr->stream_name);
- printf("demux_real: MDPR: mime type: %s\n", mdpr->mime_type);
- printf("demux_real: MDPR: type specific data:\n");
- hexdump(mdpr->type_specific_data, mdpr->type_specific_len);
- printf("\n");
+ xine_hexdump(mdpr->type_specific_data, mdpr->type_specific_len);
#endif
return mdpr;
@@ -386,22 +332,20 @@ static void real_parse_headers (demux_real_t *this) {
this->num_video_streams = 0;
this->num_audio_streams = 0;
- if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0)
+ if (INPUT_IS_SEEKABLE(this->input))
this->input->seek (this->input, 0, SEEK_SET);
if (this->input->read(this->input, signature, REAL_SIGNATURE_SIZE) !=
REAL_SIGNATURE_SIZE) {
- printf ("demux_real: signature not read\n");
-
+ lprintf ("signature not read\n");
this->status = DEMUX_FINISHED;
return;
}
if (BE_32(signature) != RMF_TAG) {
this->status = DEMUX_FINISHED;
- printf ("demux_real: signature not found '%.4s'\n",
- signature);
+ lprintf ("signature not found '%.4s'\n", signature);
return;
}
@@ -413,7 +357,7 @@ static void real_parse_headers (demux_real_t *this) {
* chunk is located */
while (chunk_type != DATA_TAG) {
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
+ if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
PREAMBLE_SIZE) {
this->status = DEMUX_FINISHED;
return;
@@ -421,10 +365,7 @@ static void real_parse_headers (demux_real_t *this) {
chunk_type = BE_32(&preamble[0]);
chunk_size = BE_32(&preamble[4]);
-#ifdef LOG
- printf ("demux_real: chunktype %.4s len %d\n", (char *) &chunk_type, chunk_size);
-#endif
-
+ lprintf ("chunktype %.4s len %d\n", (char *) &chunk_type, chunk_size);
switch (chunk_type) {
case PROP_TAG:
@@ -433,7 +374,7 @@ static void real_parse_headers (demux_real_t *this) {
chunk_size -= PREAMBLE_SIZE;
chunk_buffer = xine_xmalloc(chunk_size);
- if (this->input->read(this->input, chunk_buffer, chunk_size) !=
+ if (this->input->read(this->input, chunk_buffer, chunk_size) !=
chunk_size) {
free (chunk_buffer);
this->status = DEMUX_FINISHED;
@@ -446,15 +387,13 @@ static void real_parse_headers (demux_real_t *this) {
this->duration = BE_32(&chunk_buffer[22]);
this->index_start = BE_32(&chunk_buffer[30]);
this->data_start = BE_32(&chunk_buffer[34]);
- this->avg_bitrate = BE_32(&chunk_buffer[6]);
-
-#ifdef LOG
- printf("demux_real: PROP: packet count: %d\n", this->packet_count);
- printf("demux_real: PROP: duration: %d ms\n", this->duration);
- printf("demux_real: PROP: index start: %llX\n", this->index_start);
- printf("demux_real: PROP: data start: %llX\n", this->data_start);
- printf("demux_real: PROP: average bit rate: %lld\n", this->avg_bitrate);
-#endif
+ this->avg_bitrate = BE_32(&chunk_buffer[6]);
+
+ lprintf("PROP: packet count: %d\n", this->packet_count);
+ lprintf("PROP: duration: %d ms\n", this->duration);
+ lprintf("PROP: index start: %llX\n", this->index_start);
+ lprintf("PROP: data start: %llX\n", this->data_start);
+ lprintf("PROP: average bit rate: %lld\n", this->avg_bitrate);
if (this->avg_bitrate<1)
this->avg_bitrate = 1;
@@ -468,17 +407,14 @@ static void real_parse_headers (demux_real_t *this) {
mdpr = real_parse_mdpr (chunk_buffer);
-#ifdef LOG
- printf ("demux_real: parsing type specific data...\n");
-#endif
+ lprintf ("parsing type specific data...\n");
if(BE_32(mdpr->type_specific_data) == RA_TAG) {
int version;
version = BE_16(mdpr->type_specific_data + 4);
-#ifdef LOG
- printf("demux_real: audio version %d detected\n", version);
-#endif
+
+ lprintf("audio version %d detected\n", version);
if(version == 4) {
int str_len;
@@ -488,14 +424,12 @@ static void real_parse_headers (demux_real_t *this) {
} else if(version == 5) {
fourcc = ME_32(mdpr->type_specific_data + 66);
} else {
- printf("demux_real: unsupported audio header version %d\n", version);
+ lprintf("unsupported audio header version %d\n", version);
goto unknown;
}
-#ifdef LOG
- printf("demux_real: fourcc = %.4s\n", (char *) &fourcc);
-#endif
+ lprintf("fourcc = %.4s\n", (char *) &fourcc);
this->audio_streams[this->num_audio_streams].fourcc = fourcc;
this->audio_streams[this->num_audio_streams].buf_type = formattag_to_buf_audio(fourcc);
@@ -505,14 +439,10 @@ static void real_parse_headers (demux_real_t *this) {
this->num_audio_streams++;
} else if(BE_32(mdpr->type_specific_data + 4) == VIDO_TAG) {
-#ifdef LOG
- printf ("demux_real: video detected\n");
-#endif
-
+
+ lprintf ("video detected\n");
fourcc = *(uint32_t *) (mdpr->type_specific_data + 8);
-#ifdef LOG
- printf("demux_real: fourcc = %.4s\n", (char *) &fourcc);
-#endif
+ lprintf("fourcc = %.4s\n", (char *) &fourcc);
this->video_streams[this->num_video_streams].fourcc = fourcc;
this->video_streams[this->num_video_streams].buf_type = fourcc_to_buf_video(fourcc);
@@ -522,9 +452,8 @@ static void real_parse_headers (demux_real_t *this) {
this->num_video_streams++;
} else {
-#ifdef LOG
- printf("demux_real: unrecognised type specific data\n");
-#endif
+ lprintf("unrecognised type specific data\n");
+
unknown:
real_free_mdpr(mdpr);
}
@@ -594,9 +523,7 @@ unknown:
default:
/* this should not occur, but in case it does, skip the chunk */
-#ifdef LOG
- printf("demux_real: skipping a chunk!\n");
-#endif
+ lprintf("skipping a chunk!\n");
this->input->seek(this->input, chunk_size - PREAMBLE_SIZE, SEEK_CUR);
break;
@@ -612,17 +539,19 @@ unknown:
this->video_stream = &this->video_streams[0];
else if(this->num_video_streams) {
/* FIXME: Determine which stream to play */
- printf("demux_real: multiple video streams not supported\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "multiple video streams not supported\n");
this->status = DEMUX_FINISHED;
return;
} else
this->video_stream = NULL;
-
+
if(this->num_audio_streams == 1)
this->audio_stream = &this->audio_streams[0];
else if(this->num_audio_streams) {
/* FIXME: Determine which stream to play */
- printf("demux_real: multiple audio streams not supported\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "multiple audio streams not supported\n");
this->status = DEMUX_FINISHED;
return;
} else
@@ -644,20 +573,16 @@ unknown:
bih.biCompression = BE_32(this->video_stream->mdpr->type_specific_data + 30);
bih.biSize = sizeof(bih);
-#ifdef LOG
- printf("demux_real: setting size to w:%u h:%u for RV10\n",
- bih.biWidth, bih.biHeight);
- printf("demux_real: setting sub-codec to %X for RV10\n",
- bih.biCompression);
-#endif
+ lprintf("setting size to w:%u h:%u for RV10\n", bih.biWidth, bih.biHeight);
+ lprintf("setting sub-codec to %X for RV10\n", bih.biCompression);
memcpy(buf->content, &bih, bih.biSize);
} else {
memcpy(buf->content, this->video_stream->mdpr->type_specific_data,
this->video_stream->mdpr->type_specific_len);
-
+
buf->size = this->video_stream->mdpr->type_specific_len;
}
-
+
buf->type = this->video_stream->buf_type;
buf->decoder_flags = BUF_FLAG_HEADER;
buf->extra_info->input_pos = 0;
@@ -669,19 +594,19 @@ unknown:
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] =
this->video_stream->fourcc;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] =
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] =
this->video_stream->mdpr->avg_bit_rate;
}
-
+
if(this->audio_stream) {
/* Send headers */
if(this->audio_fifo) {
buf_element_t *buf;
-
+
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->content = buf->mem;
- memcpy(buf->content,
+ memcpy(buf->content,
this->audio_stream->mdpr->type_specific_data + 4,
this->audio_stream->mdpr->type_specific_len - 4);
@@ -691,15 +616,15 @@ unknown:
buf->decoder_flags = BUF_FLAG_HEADER;
buf->extra_info->input_pos = 0;
buf->extra_info->input_time = 0;
-
- this->audio_fifo->put (this->audio_fifo, buf);
+
+ this->audio_fifo->put (this->audio_fifo, buf);
}
-
+
/* Set meta info */
this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] =
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] =
this->audio_stream->fourcc;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] =
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] =
this->audio_stream->mdpr->avg_bit_rate;
}
}
@@ -721,34 +646,34 @@ static int demux_real_parse_references( demux_real_t *this) {
xine_event_t uevent;
- /* read file to memory.
+ /* read file to memory.
* warning: dumb code, but hopefuly ok since reference file is small */
do {
buf_size += 1024;
buf = realloc(buf, buf_size+1);
-
+
len = this->input->read(this->input, &buf[buf_used], buf_size-buf_used);
if( len > 0 )
buf_used += len;
-
+
/* 50k of reference file? no way. something must be wrong */
if( buf_used > 50*1024 )
break;
} while( len > 0 );
-
+
if(buf_used)
buf[buf_used] = '\0';
for(i=0;i<buf_used;i++) {
-
- /* "--stop--" is used to have pnm alternative for old real clients
+
+ /* "--stop--" is used to have pnm alternative for old real clients
* new real clients will stop processing the file and thus use
* rtsp protocol.
*/
if( !strncmp(&buf[i],"--stop--",8) )
alternative++;
-
+
if( !strncmp(&buf[i],"pnm://",6) || !strncmp(&buf[i],"rtsp://",7) ) {
for(j=i; buf[j] && buf[j] != '"' && !isspace(buf[j]); j++ )
;
@@ -786,17 +711,12 @@ static void check_newpts (demux_real_t *this, int64_t pts, int video, int previe
int64_t diff;
diff = pts - this->last_pts[video];
-
-#ifdef LOG
- printf ("demux_real: check_newpts %lld\n", pts);
-#endif
+ lprintf ("check_newpts %lld\n", pts);
if (!preview && pts &&
(this->send_newpts || (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD) ) ) {
-#ifdef LOG
- printf ("demux_real: diff=%lld\n", diff);
-#endif
+ lprintf ("diff=%lld\n", diff);
if (this->buf_flag_seek) {
xine_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK);
@@ -840,8 +760,8 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
if ( (size=this->input->read(this->input, header, DATA_PACKET_HEADER_SIZE)) !=
DATA_PACKET_HEADER_SIZE) {
- printf ("demux_real: read failed. wanted %d bytes, but got only %d\n",
- DATA_PACKET_HEADER_SIZE, size);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "read failed. wanted %d bytes, but got only %d\n", DATA_PACKET_HEADER_SIZE, size);
this->status = DEMUX_FINISHED;
return this->status;
@@ -855,10 +775,8 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
pts = (int64_t) timestamp * 90;
keyframe = header[11] & PN_KEYFRAME_FLAG;
-#ifdef LOG
- printf ("demux_real: packet of stream %d, 0x%X bytes @ %llX, pts = %lld%s\n",
- stream, size, offset, pts, keyframe ? ", keyframe" : "");
-#endif
+ lprintf ("packet of stream %d, 0x%X bytes @ %llX, pts = %lld%s\n",
+ stream, size, offset, pts, keyframe ? ", keyframe" : "");
if (this->video_stream && (stream == this->video_stream->mdpr->stream_number)) {
@@ -868,9 +786,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
buf_element_t *buf;
int n, fragment_size;
-#ifdef LOG
- printf ("demux_real: video chunk detected.\n");
-#endif
+ lprintf ("video chunk detected.\n");
/* sub-demuxer */
@@ -883,9 +799,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
*/
vpkg_header = stream_read_char (this); size--;
-#ifdef LOG
- printf ("demux_real: vpkg_hdr: %02x (size=%d)\n", vpkg_header, size);
-#endif
+ lprintf ("vpkg_hdr: %02x (size=%d)\n", vpkg_header, size);
if (0x40==(vpkg_header&0xc0)) {
/*
@@ -895,9 +809,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
int bummer;
bummer = stream_read_char (this); size--;
-#ifdef LOG
- printf ("demux_real: bummer == %02X\n",bummer);
-#endif
+ lprintf ("bummer == %02X\n",bummer);
vpkg_offset = 0;
vpkg_length = size;
@@ -941,17 +853,12 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
vpkg_seqnum = stream_read_char (this); size--;
}
-#ifdef LOG
- printf ("demux_real: seq=%d, offset=%d, length=%d, size=%d, frag size=%d, flags=%02x\n",
- vpkg_seqnum, vpkg_offset, vpkg_length, size, this->fragment_size,
- vpkg_header);
-#endif
+ lprintf ("seq=%d, offset=%d, length=%d, size=%d, frag size=%d, flags=%02x\n",
+ vpkg_seqnum, vpkg_offset, vpkg_length, size, this->fragment_size,
+ vpkg_header);
if (vpkg_seqnum != this->old_seqnum) {
-
-#ifdef LOG
- printf ("demux_real: new seqnum\n");
-#endif
+ lprintf ("new seqnum\n");
this->fragment_size = 0;
this->old_seqnum = vpkg_seqnum;
@@ -963,22 +870,17 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
buf->pts = pts;
buf->extra_info->input_pos = this->input->get_current_pos (this->input);
- buf->extra_info->input_time = (int)((int64_t)buf->extra_info->input_pos
- * 8 * 1000 / this->avg_bitrate);
+ buf->extra_info->input_time = (int)((int64_t)buf->extra_info->input_pos
+ * 8 * 1000 / this->avg_bitrate);
buf->type = this->video_stream->buf_type;
-
+
check_newpts (this, pts, PTS_VIDEO, 0);
if (this->fragment_size == 0) {
-
-#ifdef LOG
- printf ("demux_real: new packet starting\n");
-#endif
+ lprintf ("new packet starting\n");
buf->decoder_flags = BUF_FLAG_FRAME_START;
} else {
-#ifdef LOG
- printf ("demux_real: continuing packet \n");
-#endif
+ lprintf ("continuing packet \n");
buf->decoder_flags = 0;
}
@@ -986,21 +888,18 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
* calc size of fragment
*/
- if ((vpkg_header & 0xc0) == 0x080)
+ if ((vpkg_header & 0xc0) == 0x080)
fragment_size = vpkg_offset;
else {
- if (0x00 == (vpkg_header&0xc0))
+ if (0x00 == (vpkg_header&0xc0))
fragment_size = size;
else
fragment_size = vpkg_length;
}
-
-#ifdef LOG
- printf ("demux_real: fragment size is %d\n", fragment_size);
-#endif
+ lprintf ("fragment size is %d\n", fragment_size);
/*
- * read fragment_size bytes of data
+ * read fragment_size bytes of data
*/
n = this->input->read (this->input, buf->content, fragment_size);
@@ -1008,30 +907,24 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
buf->size = fragment_size;
if (n<fragment_size) {
- printf ("demux_real: read error %d/%d\n", n, fragment_size);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "read error %d/%d\n", n, fragment_size);
buf->free_buffer(buf);
this->status = DEMUX_FINISHED;
return this->status;
}
- this->video_fifo->put (this->video_fifo, buf);
+ this->video_fifo->put (this->video_fifo, buf);
size -= fragment_size;
-
-#ifdef LOG
- printf ("demux_real: size left %d\n", size);
-#endif
+ lprintf ("demux_real: size left %d\n", size);
this->fragment_size += fragment_size;
if (this->fragment_size >= vpkg_length) {
-#ifdef LOG
- printf ("demux_real: fragment finished (%d/%d)\n",
- this->fragment_size, vpkg_length);
- this->fragment_size = 0;
-#endif
+ lprintf ("fragment finished (%d/%d)\n", this->fragment_size, vpkg_length);
+ this->fragment_size = 0;
}
-
+
} /* while(size>2) */
} else if (this->audio_fifo && this->audio_stream &&
@@ -1040,9 +933,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
buf_element_t *buf;
int n;
-#ifdef LOG
- printf ("demux_real: audio chunk detected.\n");
-#endif
+ lprintf ("audio chunk detected.\n");
if(this->audio_need_keyframe && !keyframe)
goto discard;
@@ -1065,7 +956,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
n = this->input->read (this->input, buf->content, size);
if (n<size || size < 0) {
- printf ("demux_real: read error 44\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "read error 44\n");
buf->free_buffer(buf);
this->status = DEMUX_FINISHED;
@@ -1079,18 +970,15 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
} else {
/* discard */
-#ifdef LOG
- printf ("demux_real: chunk not detected; discarding.\n");
-#endif
+ lprintf ("chunk not detected; discarding.\n");
+
discard:
this->input->seek(this->input, size, SEEK_CUR);
}
-
+
if(this->packet_count && (this->current_packet == (this->packet_count - 1))) {
-#ifdef LOG
- printf("demux_real: read all packets\n");
-#endif
+ lprintf("read all packets\n");
this->status = DEMUX_FINISHED;
} else
this->current_packet++;
@@ -1100,7 +988,7 @@ discard:
this->current_data_chunk_packet_count--;
/* check if it's time to reload */
- if (!this->current_data_chunk_packet_count &&
+ if (!this->current_data_chunk_packet_count &&
this->next_data_chunk_offset) {
char preamble[PREAMBLE_SIZE];
unsigned char data_chunk_header[DATA_CHUNK_HEADER_SIZE];
@@ -1116,14 +1004,12 @@ discard:
}
/* load the rest of the DATA chunk header */
- if (this->input->read(this->input, data_chunk_header,
+ if (this->input->read(this->input, data_chunk_header,
DATA_CHUNK_HEADER_SIZE) != DATA_CHUNK_HEADER_SIZE) {
this->status = DEMUX_FINISHED;
return this->status;
}
-#ifdef LOG
- printf ("demux_real: **** found next DATA tag\n");
-#endif
+ lprintf ("**** found next DATA tag\n");
this->current_data_chunk_packet_count = BE_32(&data_chunk_header[2]);
this->next_data_chunk_offset = BE_32(&data_chunk_header[6]);
}
@@ -1166,7 +1052,7 @@ static void demux_real_send_headers(demux_plugin_t *this_gen) {
if( !this->reference_mode ) {
real_parse_headers (this);
} else {
- if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0)
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0)
this->input->seek (this->input, 0, SEEK_SET);
}
}
@@ -1177,18 +1063,18 @@ static int demux_real_seek (demux_plugin_t *this_gen,
demux_real_t *this = (demux_real_t *) this_gen;
real_index_entry_t *index, *other_index = NULL;
int i = 0, entries;
-
+
if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) &&
- ((this->audio_stream && this->audio_stream->index) ||
+ ((this->audio_stream && this->audio_stream->index) ||
(this->video_stream && this->video_stream->index))) {
-
+
/* video index has priority over audio index */
if(this->video_stream && this->video_stream->index) {
index = this->video_stream->index;
entries = this->video_stream->index_entries;
if(this->audio_stream)
other_index = this->audio_stream->index;
-
+
/* when seeking by video index the first audio chunk won't necesserily
* be a keyframe which would upset the decoder */
this->audio_need_keyframe = 1;
@@ -1198,7 +1084,7 @@ static int demux_real_seek (demux_plugin_t *this_gen,
if(this->video_stream)
other_index = this->video_stream->index;
}
-
+
if(start_pos) {
while((index[i+1].offset < start_pos) && (i < entries - 1))
i++;
@@ -1207,16 +1093,16 @@ static int demux_real_seek (demux_plugin_t *this_gen,
while((index[i+1].timestamp < start_time) && (i < entries - 1))
i++;
}
-
+
/* make sure we don't skip past audio/video at start of file */
if((i == 0) && other_index && (other_index[0].offset < index[0].offset))
index = other_index;
-
+
this->input->seek(this->input, index[i].offset, SEEK_SET);
-
+
/* is packet number global or is it local to current data chunk? */
this->current_packet = index[i].packetno;
-
+
if(this->stream->demux_thread_running) {
this->buf_flag_seek = 1;
xine_demux_flush_engine(this->stream);
@@ -1232,11 +1118,9 @@ static int demux_real_seek (demux_plugin_t *this_gen,
}
static void demux_real_dispose (demux_plugin_t *this_gen) {
-
+ demux_real_t *this = (demux_real_t *) this_gen;
int i;
- demux_real_t *this = (demux_real_t *) this_gen;
-
for(i = 0; i < this->num_video_streams; i++) {
real_free_mdpr(this->video_streams[i].mdpr);
if(this->video_streams[i].index)
@@ -1259,7 +1143,6 @@ static int demux_real_get_status (demux_plugin_t *this_gen) {
}
static int demux_real_get_stream_length (demux_plugin_t *this_gen) {
-
demux_real_t *this = (demux_real_t *) this_gen;
/* duration is stored in the file as milliseconds */
@@ -1287,11 +1170,11 @@ static int real_check_stream_type(uint8_t *buf, int len)
&& (buf[2] == 'M')
&& (buf[3] == 'F'))
return 1;
-
+
buf[len] = '\0';
if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") )
return 2;
-
+
return 0;
}
@@ -1306,21 +1189,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
case METHOD_BY_CONTENT:{
- if (!(len = xine_demux_read_header(input, buf, 1024)))
+ if (! (len = xine_demux_read_header(input, buf, 1024)) )
return NULL;
-#ifdef LOG
- printf ("demux_real: read 4 bytes: %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3]);
-#endif
+ lprintf ("read 4 bytes: %02x %02x %02x %02x\n",
+ buf[0], buf[1], buf[2], buf[3]);
if (!(stream_type = real_check_stream_type(buf,len)))
return NULL;
}
-#ifdef LOG
- printf ("demux_real: by content accepted.\n");
-#endif
+ lprintf ("by content accepted.\n");
break;
case METHOD_BY_EXTENSION: {
@@ -1329,18 +1208,12 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
mrl = input->get_mrl (input);
extensions = class_gen->get_extensions (class_gen);
-#ifdef LOG
- printf ("demux_real: by extension '%s'\n", mrl);
-#endif
+ lprintf ("by extension '%s'\n", mrl);
if (!xine_demux_check_extension (mrl, extensions)) {
return NULL;
}
-
-#ifdef LOG
- printf ("demux_real: by extension accepted.\n");
-#endif
-
+ lprintf ("by extension accepted.\n");
}
break;
@@ -1360,14 +1233,12 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/* discover stream type */
if(!stream_type)
- if (len = xine_demux_read_header(this->input, buf, 1024))
+ if ( (len = xine_demux_read_header(this->input, buf, 1024)) )
stream_type = real_check_stream_type(buf,len);
if(stream_type == 2){
this->reference_mode = 1;
-#ifdef LOG
- printf("demux_real: reference stream detected\n");
-#endif
+ lprintf("reference stream detected\n");
}else
this->reference_mode = 0;
@@ -1384,8 +1255,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.get_optional_data = demux_real_get_optional_data;
this->demux_plugin.demux_class = class_gen;
- strncpy (this->last_mrl, input->get_mrl (input), 1024);
-
return &this->demux_plugin;
}
@@ -1409,19 +1278,15 @@ static char *get_mimetypes (demux_class_t *this_gen) {
}
static void class_dispose (demux_class_t *this_gen) {
-
demux_real_class_t *this = (demux_real_class_t *) this_gen;
free (this);
}
static void *init_class (xine_t *xine, void *data) {
-
demux_real_class_t *this;
- this = xine_xmalloc (sizeof (demux_real_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_real_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index b93b04370..33477cc0f 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -356,8 +356,6 @@ int xine_demux_read_header( input_plugin_t *input, unsigned char *buffer, off_t
if (input->get_capabilities(input) & INPUT_CAP_SEEKABLE) {
input->seek(input, 0, SEEK_SET);
read_size = input->read(input, buffer, size);
- if (read_size != size)
- return 0;
input->seek(input, 0, SEEK_SET);
} else if (input->get_capabilities(input) & INPUT_CAP_PREVIEW) {
buf = xine_xmalloc(MAX_PREVIEW_SIZE);
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index d79388cea..92161b5af 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2000-2002 the xine project
*
* This file is part of xine, a free video player.
@@ -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: utils.c,v 1.13 2003/04/20 21:13:28 guenter Exp $
+ * $Id: utils.c,v 1.14 2003/07/16 14:14:17 andruil Exp $
*
*/
#define _POSIX_PTHREAD_SEMANTICS 1 /* for 5-arg getpwuid_r on solaris */
@@ -171,3 +171,38 @@ void xine_print_trace (void) {
printf("stack backtrace not available.\n");
#endif
}
+
+/* print a hexdump of length bytes from the data given in buf */
+void xine_hexdump (char *buf, int length) {
+ int i,j;
+ unsigned char c;
+
+ /* printf ("Hexdump: %i Bytes\n", length);*/
+ for(j=0; j<69; j++)
+ printf ("-");
+ printf ("\n");
+
+ j=0;
+ while(j<length) {
+ printf ("%04X ",j);
+ for (i=j; i<j+16; i++) {
+ if( i<length )
+ printf ("%02X ", buf[i]);
+ else
+ printf(" ");
+ }
+ for (i=j;i<(j+16<length?j+16:length);i++) {
+ c=buf[i];
+ if ((c>=20) && (c<128))
+ printf ("%c", c);
+ else
+ printf (".");
+ }
+ j=i;
+ printf("\n");
+ }
+
+ for(j=0; j<69; j++)
+ printf("-");
+ printf("\n");
+}
diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h
index d80e00b07..031bb418c 100644
--- a/src/xine-utils/xineutils.h
+++ b/src/xine-utils/xineutils.h
@@ -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: xineutils.h,v 1.56 2003/07/12 12:31:13 mroi Exp $
+ * $Id: xineutils.h,v 1.57 2003/07/16 14:14:17 andruil Exp $
*
*/
#ifndef XINEUTILS_H
@@ -825,6 +825,8 @@ extern int v_r_table[256];
extern int v_g_table[256];
extern int v_b_table[256];
+/* print a hexdump of the given data */
+void xine_hexdump (char *buf, int length);
/* backtrace printout funtion for use in XINE_ASSERT() macro */
void xine_print_trace(void);