summaryrefslogtreecommitdiff
path: root/src/demuxers
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers')
-rw-r--r--src/demuxers/Makefile.am124
-rw-r--r--src/demuxers/demux.h18
-rw-r--r--src/demuxers/demux_asf.c196
-rw-r--r--src/demuxers/demux_avi.c105
-rw-r--r--src/demuxers/demux_elem.c114
-rw-r--r--src/demuxers/demux_mpeg.c106
-rw-r--r--src/demuxers/demux_mpeg_block.c207
-rw-r--r--src/demuxers/demux_mpgaudio.c118
-rw-r--r--src/demuxers/demux_ogg.c122
9 files changed, 583 insertions, 527 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am
index 45d6ab6bd..f083fb5fe 100644
--- a/src/demuxers/Makefile.am
+++ b/src/demuxers/Makefile.am
@@ -5,33 +5,37 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic
libdir = $(XINE_PLUGINDIR)
-if HAVE_VORBIS
+#if HAVE_VORBIS
ogg_module = xineplug_dmx_ogg.la
-endif
+#endif
-if HAVE_ZLIB
+#if HAVE_ZLIB
qt_modules = xineplug_dmx_qt.la
-endif
+#endif
-if BUILD_ASF
+#if BUILD_ASF
asf_module = xineplug_dmx_asf.la
-endif
+#endif
##
# IMPORTANT:
# ---------
# All of xine demuxer plugins should be named like the scheme "xineplug_dmx_"
#
-lib_LTLIBRARIES = $(ogg_module) $(qt_modules) $(asf_module) xineplug_dmx_avi.la \
+#lib_LTLIBRARIES = $(ogg_module) $(qt_modules) $(asf_module) xineplug_dmx_avi.la \
+# xineplug_dmx_mpeg_block.la xineplug_dmx_mpeg.la \
+# xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la \
+# xineplug_dmx_mpeg_pes.la xineplug_dmx_mpeg_ts.la \
+# xineplug_dmx_cda.la xineplug_dmx_film.la \
+# xineplug_dmx_roq.la xineplug_dmx_fli.la \
+# xineplug_dmx_smjpeg.la xineplug_dmx_wav.la \
+# xineplug_dmx_idcin.la xineplug_dmx_wc3movie.la \
+# xineplug_dmx_vqa.la xineplug_dmx_voc.la \
+# xineplug_dmx_aiff.la xineplug_dmx_snd.la
+
+lib_LTLIBRARIES = $(ogg_module) $(asf_module) xineplug_dmx_avi.la\
xineplug_dmx_mpeg_block.la xineplug_dmx_mpeg.la \
- xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la \
- xineplug_dmx_mpeg_pes.la xineplug_dmx_mpeg_ts.la \
- xineplug_dmx_cda.la xineplug_dmx_film.la \
- xineplug_dmx_roq.la xineplug_dmx_fli.la \
- xineplug_dmx_smjpeg.la xineplug_dmx_wav.la \
- xineplug_dmx_idcin.la xineplug_dmx_wc3movie.la \
- xineplug_dmx_vqa.la xineplug_dmx_voc.la \
- xineplug_dmx_aiff.la xineplug_dmx_snd.la
+ xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la
xineplug_dmx_ogg_la_SOURCES = demux_ogg.c
xineplug_dmx_ogg_la_LIBADD = $(OGG_LIBS) $(VORBIS_LIBS)\
@@ -58,69 +62,69 @@ xineplug_dmx_mpeg_elem_la_SOURCES = demux_elem.c
xineplug_dmx_mpeg_elem_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
xineplug_dmx_mpeg_elem_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_mpeg_pes_la_SOURCES = demux_pes.c
-xineplug_dmx_mpeg_pes_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_mpeg_pes_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_mpeg_pes_la_SOURCES = demux_pes.c
+#xineplug_dmx_mpeg_pes_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_mpeg_pes_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_mpeg_ts_la_SOURCES = demux_ts.c
-xineplug_dmx_mpeg_ts_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_mpeg_ts_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_mpeg_ts_la_SOURCES = demux_ts.c
+#xineplug_dmx_mpeg_ts_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_mpeg_ts_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_qt_la_SOURCES = demux_qt.c qtpalette.h
-xineplug_dmx_qt_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_qt_la_LIBADD = -lz $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_qt_la_SOURCES = demux_qt.c qtpalette.h
+#xineplug_dmx_qt_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_qt_la_LIBADD = -lz $(top_builddir)/src/xine-engine/libxine.la
xineplug_dmx_asf_la_SOURCES = demux_asf.c
xineplug_dmx_asf_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
xineplug_dmx_asf_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_cda_la_SOURCES = demux_cda.c
-xineplug_dmx_cda_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_cda_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_cda_la_SOURCES = demux_cda.c
+#xineplug_dmx_cda_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_cda_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_film_la_SOURCES = demux_film.c
-xineplug_dmx_film_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_film_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_film_la_SOURCES = demux_film.c
+#xineplug_dmx_film_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_film_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_roq_la_SOURCES = demux_roq.c
-xineplug_dmx_roq_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_roq_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_roq_la_SOURCES = demux_roq.c
+#xineplug_dmx_roq_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_roq_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_fli_la_SOURCES = demux_fli.c
-xineplug_dmx_fli_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_fli_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_fli_la_SOURCES = demux_fli.c
+#xineplug_dmx_fli_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_fli_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_smjpeg_la_SOURCES = demux_smjpeg.c
-xineplug_dmx_smjpeg_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_smjpeg_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_smjpeg_la_SOURCES = demux_smjpeg.c
+#xineplug_dmx_smjpeg_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_smjpeg_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_wav_la_SOURCES = demux_wav.c
-xineplug_dmx_wav_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_wav_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_wav_la_SOURCES = demux_wav.c
+#xineplug_dmx_wav_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_wav_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_idcin_la_SOURCES = demux_idcin.c
-xineplug_dmx_idcin_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_idcin_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_idcin_la_SOURCES = demux_idcin.c
+#xineplug_dmx_idcin_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_idcin_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_wc3movie_la_SOURCES = demux_wc3movie.c
-xineplug_dmx_wc3movie_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_wc3movie_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_wc3movie_la_SOURCES = demux_wc3movie.c
+#xineplug_dmx_wc3movie_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_wc3movie_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_vqa_la_SOURCES = demux_vqa.c
-xineplug_dmx_vqa_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_vqa_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_vqa_la_SOURCES = demux_vqa.c
+#xineplug_dmx_vqa_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_vqa_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_voc_la_SOURCES = demux_voc.c
-xineplug_dmx_voc_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_voc_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_voc_la_SOURCES = demux_voc.c
+#xineplug_dmx_voc_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_voc_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_aiff_la_SOURCES = demux_aiff.c
-xineplug_dmx_aiff_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_aiff_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_aiff_la_SOURCES = demux_aiff.c
+#xineplug_dmx_aiff_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_aiff_la_LDFLAGS = -avoid-version -module
-xineplug_dmx_snd_la_SOURCES = demux_snd.c
-xineplug_dmx_snd_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
-xineplug_dmx_snd_la_LDFLAGS = -avoid-version -module
+#xineplug_dmx_snd_la_SOURCES = demux_snd.c
+#xineplug_dmx_snd_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+#xineplug_dmx_snd_la_LDFLAGS = -avoid-version -module
include_HEADERS = demux.h qtpalette.h
diff --git a/src/demuxers/demux.h b/src/demuxers/demux.h
index e2d5b7391..41e23d211 100644
--- a/src/demuxers/demux.h
+++ b/src/demuxers/demux.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2000, 2001 the xine project
+ * Copyright (C) 2000-2002 the xine project
*
- * This file is part of xine, a unix video player.
+ * This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux.h,v 1.18 2002/09/05 22:18:50 mroi Exp $
+ * $Id: demux.h,v 1.19 2002/09/18 00:51:33 guenter Exp $
*/
#ifndef HAVE_DEMUX_H
@@ -35,7 +35,7 @@ extern "C" {
#include "input_plugin.h"
#endif
-#define DEMUXER_PLUGIN_IFACE_VERSION 10
+#define DEMUXER_PLUGIN_IFACE_VERSION 11
#define DEMUX_OK 0
#define DEMUX_FINISHED 1
@@ -63,6 +63,8 @@ struct demux_plugin_s
* ask demuxer to open the given stream (input-plugin)
* using the content-detection method specified in <stage>
*
+ * demuxer should send header/preview packages in this stage
+ *
* return values:
* DEMUX_CAN_HANDLE on success
* DEMUX_CANNOT_HANDLE on failure
@@ -86,9 +88,7 @@ struct demux_plugin_s
* starting the demuxer)
*/
- int (*start) (demux_plugin_t *this, fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time);
+ int (*start) (demux_plugin_t *this, off_t start_pos, int start_time);
/*
* ask running demux thread to seek
@@ -119,7 +119,7 @@ struct demux_plugin_s
* close demuxer, free all resources
*/
- void (*close) (demux_plugin_t *this) ;
+ void (*dispose) (demux_plugin_t *this) ;
/*
* returns DEMUX_OK or DEMUX_FINISHED
@@ -133,7 +133,7 @@ struct demux_plugin_s
char* (*get_identifier) (void);
- /*
+ /*
* return MIME types supported for this plugin
*/
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c
index a17e0adf4..4a3053dfb 100644
--- a/src/demuxers/demux_asf.c
+++ b/src/demuxers/demux_asf.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_asf.c,v 1.56 2002/09/05 22:18:51 mroi Exp $
+ * $Id: demux_asf.c,v 1.57 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for asf streams
*
@@ -349,11 +349,7 @@ static void asf_send_audio_header (demux_asf_t *this, int stream) {
printf ("demux_asf: unknown audio type 0x%x\n", wavex->wFormatTag);
xine_report_codec( this->xine, XINE_CODEC_AUDIO, wavex->wFormatTag, 0, 0);
this->streams[stream].buf_type = BUF_CONTROL_NOP;
- } else
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: audio format : %s (wFormatTag 0x%x)\n"),
- buf_audio_name(this->streams[stream].buf_type),
- wavex->wFormatTag);
+ }
buf->size = this->wavex_size;
buf->type = this->streams[stream].buf_type;
@@ -376,10 +372,7 @@ static void asf_send_video_header (demux_asf_t *this, int stream) {
if( !this->streams[stream].buf_type ) {
printf ("demux_asf: unknown video format %.4s\n",
- (char*)&bih->biCompression);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: video format : %s\n"),
- buf_video_name(this->streams[stream].buf_type));
+ (char*)&bih->biCompression);
xine_report_codec( this->xine, XINE_CODEC_VIDEO, bih->biCompression, 0, 0);
this->status = DEMUX_FINISHED;
@@ -437,9 +430,7 @@ static int asf_read_header (demux_asf_t *this) {
else
this->rate = 0;
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: stream length is %d sec, rate is %d bytes/sec\n"),
- this->length, this->rate);
+ this->xine->stream_info[XINE_STREAM_INFO_BITRATE] = this->rate*8;
start_time = get_le32(this); /* start timestamp in 1/1000 s*/
@@ -1159,7 +1150,7 @@ static void *demux_asf_loop (void *this_gen) {
return NULL;
}
-static void demux_asf_close (demux_plugin_t *this_gen) {
+static void demux_asf_dispose (demux_plugin_t *this_gen) {
demux_asf_t *this = (demux_asf_t *) this_gen;
free (this);
@@ -1204,98 +1195,110 @@ static int demux_asf_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static int demux_asf_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
+static int demux_asf_send_headers (demux_asf_t *this) {
- demux_asf_t *this = (demux_asf_t *) this_gen;
- int err;
- int status;
- int i;
- int stream_id;
+ int i;
+ int stream_id;
uint32_t buf_type, bitrate, max_vrate, max_arate;
- pthread_mutex_lock( &this->mutex );
+ pthread_mutex_lock (&this->mutex);
+
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
this->status = DEMUX_OK;
- if( !this->thread_running ) {
- this->audio_fifo = audio_fifo;
- this->video_fifo = video_fifo;
+ /*
+ * send start buffer
+ */
+ xine_demux_control_start(this->xine);
+
+ /*
+ * initialize asf engine
+ */
+
+ this->num_streams = 0;
+ this->num_audio_streams = 0;
+ this->num_video_streams = 0;
+ this->audio_stream = 0;
+ this->video_stream = 0;
+ this->audio_stream_id = 0;
+ this->video_stream_id = 0;
+ this->packet_size = 0;
+ this->seqno = 0;
+ this->frame_duration = 3000;
+
+ if (this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE)
+ this->input->seek (this->input, 0, SEEK_SET);
+
+ if (!asf_read_header (this)) {
+ return DEMUX_CANNOT_HANDLE;
+ } else {
+ this->header_size = this->input->get_current_pos (this->input);
- /*
- * send start buffer
- */
- xine_demux_control_start(this->xine);
+ this->xine->meta_info[XINE_META_INFO_TITLE] =
+ strdup (this->title);
+ this->xine->meta_info[XINE_META_INFO_ARTIST] =
+ strdup (this->author);
+ this->xine->meta_info[XINE_META_INFO_COMMENT] =
+ strdup (this->comment);
- /*
- * initialize asf engine
+
+ /* Choose the best audio and the best video stream.
+ * Use the bitrate to do the choice.
*/
+ max_vrate = 0;
+ max_arate = 0;
+ for(i = 0; i < this->num_streams; i++) {
+ buf_type = (this->streams[i].buf_type & BUF_MAJOR_MASK);
+ stream_id = this->streams[i].stream_id;
+ bitrate = this->bitrates[stream_id];
+
+ printf("demux_asf: stream: %d, bitrate %d bps, ", stream_id, bitrate);
+ if ((buf_type == BUF_VIDEO_BASE) &&
+ (bitrate > max_vrate || this->video_stream_id == 0)) {
- this->num_streams = 0;
- this->num_audio_streams = 0;
- this->num_video_streams = 0;
- this->audio_stream = 0;
- this->video_stream = 0;
- this->audio_stream_id = 0;
- this->video_stream_id = 0;
- this->packet_size = 0;
- this->seqno = 0;
- this->frame_duration = 3000;
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] = bitrate;
- if (this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE)
- this->input->seek (this->input, 0, SEEK_SET);
+ max_vrate = bitrate;
+ this->video_stream = i;
+ this->video_stream_id = stream_id;
+ } else if ((buf_type == BUF_AUDIO_BASE) &&
+ (bitrate > max_arate || this->audio_stream_id == 0)) {
- if (!asf_read_header (this)) {
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] = bitrate;
- this->status = DEMUX_FINISHED;
- } else {
- this->header_size = this->input->get_current_pos (this->input);
-
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: title : %s\n"), this->title);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: author : %s\n"), this->author);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: copyright : %s\n"), this->copyright);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_asf: comment : %s\n"), this->comment);
-
-
- /* Choose the best audio and the best video stream.
- * Use the bitrate to do the choice.
- */
- max_vrate = 0;
- max_arate = 0;
- for(i = 0; i < this->num_streams; i++) {
- buf_type = (this->streams[i].buf_type & BUF_MAJOR_MASK);
- stream_id = this->streams[i].stream_id;
- bitrate = this->bitrates[stream_id];
-
- printf("demux_asf: stream: %d, bitrate %d bps, ", stream_id, bitrate);
- if ((buf_type == BUF_VIDEO_BASE) &&
- (bitrate > max_vrate || this->video_stream_id == 0)) {
- printf("video\n");
- max_vrate = bitrate;
- this->video_stream = i;
- this->video_stream_id = stream_id;
- } else if ((buf_type == BUF_AUDIO_BASE) &&
- (bitrate > max_arate || this->audio_stream_id == 0)) {
- printf("audio\n");
- max_arate = bitrate;
- this->audio_stream = i;
- this->audio_stream_id = stream_id;
- }
+ max_arate = bitrate;
+ this->audio_stream = i;
+ this->audio_stream_id = stream_id;
}
- printf("demux_asf: video stream_id: %d, audio stream_id: %d\n",
- this->video_stream_id, this->audio_stream_id);
-
- asf_send_audio_header(this, this->audio_stream);
- asf_send_video_header(this, this->video_stream);
}
+ printf("demux_asf: video stream_id: %d, audio stream_id: %d\n",
+ this->video_stream_id, this->audio_stream_id);
+
+ asf_send_audio_header(this, this->audio_stream);
+ asf_send_video_header(this, this->video_stream);
}
- else {
+
+ xine_demux_control_headers_done (this->xine);
+
+ pthread_mutex_unlock (&this->mutex);
+
+ return DEMUX_CAN_HANDLE;
+}
+
+static int demux_asf_start (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ demux_asf_t *this = (demux_asf_t *) this_gen;
+ int err;
+ int status;
+
+ pthread_mutex_lock( &this->mutex );
+
+ this->status = DEMUX_OK;
+
+ if (!this->thread_running) {
xine_demux_flush_engine(this->xine);
}
@@ -1354,11 +1357,10 @@ static int demux_asf_start (demux_plugin_t *this_gen,
}
static int demux_asf_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
- demux_asf_t *this = (demux_asf_t *) this_gen;
+ off_t start_pos, int start_time) {
+ /* demux_asf_t *this = (demux_asf_t *) this_gen; */
- return demux_asf_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_asf_start (this_gen, start_pos, start_time);
}
@@ -1382,7 +1384,7 @@ static int demux_asf_open(demux_plugin_t *this_gen,
if (!memcmp(buf, &asf_header, sizeof(GUID))) {
printf ("demux_asf: file starts with an asf header\n");
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_asf_send_headers (this);
}
return DEMUX_CANNOT_HANDLE;
@@ -1413,7 +1415,7 @@ static int demux_asf_open(demux_plugin_t *this_gen,
if(!strcasecmp((ending + 1), m)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_asf_send_headers (this);
}
}
}
@@ -1456,7 +1458,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_asf_start;
this->demux_plugin.seek = demux_asf_seek;
this->demux_plugin.stop = demux_asf_stop;
- this->demux_plugin.close = demux_asf_close;
+ this->demux_plugin.dispose = demux_asf_dispose;
this->demux_plugin.get_status = demux_asf_get_status;
this->demux_plugin.get_identifier = demux_asf_get_id;
this->demux_plugin.get_stream_length = demux_asf_get_stream_length;
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 587ec2279..3689fa05b 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_avi.c,v 1.109 2002/09/05 22:18:51 mroi Exp $
+ * $Id: demux_avi.c,v 1.110 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for avi streams
*
@@ -647,9 +647,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
if (AVI->idx==0)
ERR_EXIT(AVI_ERR_NO_MEM);
- if (this->input->read(this->input, (char *)AVI->idx, n) != n )
- {
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: avi index is broken\n"));
+ if (this->input->read(this->input, (char *)AVI->idx, n) != n ) {
+ xine_log (this->xine, XINE_LOG_MSG, _("demux_avi: avi index is broken\n"));
free (AVI->idx); /* Index is broken, reconstruct */
AVI->idx = NULL;
AVI->n_idx = AVI->max_idx = 0;
@@ -1192,7 +1191,7 @@ static void demux_avi_stop (demux_plugin_t *this_gen) {
xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
}
-static void demux_avi_close (demux_plugin_t *this_gen) {
+static void demux_avi_dispose (demux_plugin_t *this_gen) {
demux_avi_t *this = (demux_avi_t *) this_gen;
if (this->avi)
@@ -1207,9 +1206,48 @@ static int demux_avi_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
+static int demux_avi_send_headers (demux_avi_t *this) {
+
+ int i;
+
+ pthread_mutex_lock (&this->mutex);
+
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
+
+ this->status = DEMUX_OK;
+
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->avi->width;
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = this->avi->height;
+
+ for (i=0; i < this->avi->n_audio; i++)
+ printf ("demux_avi: audio format[%d] = 0x%x\n",
+ i, this->avi->audio[i]->wavex->wFormatTag);
+ this->no_audio = 0;
+
+ for(i=0; i < this->avi->n_audio; i++) {
+ 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);
+ xine_report_codec( this->xine, XINE_CODEC_AUDIO, this->avi->audio[i]->wavex->wFormatTag, 0, 0);
+ this->no_audio = 1;
+ this->avi->audio[i]->audio_type = BUF_CONTROL_NOP;
+ } else
+ 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);
+ }
+
+ xine_demux_control_headers_done (this->xine);
+
+ pthread_mutex_unlock (&this->mutex);
+
+ return DEMUX_CAN_HANDLE;
+}
+
static int demux_avi_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
off_t start_pos, int start_time) {
demux_avi_t *this = (demux_avi_t *) this_gen;
@@ -1223,38 +1261,6 @@ static int demux_avi_start (demux_plugin_t *this_gen,
pthread_mutex_lock( &this->mutex );
- this->status = DEMUX_OK;
-
- if( !this->thread_running ) {
- this->audio_fifo = audio_fifo;
- this->video_fifo = video_fifo;
-
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: video format = %s\n"),
- this->avi->compressor);
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: video frame size %ld x %ld\n"),
- this->avi->width, this->avi->height);
- for(i=0; i < this->avi->n_audio; i++)
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: audio format[%d] = 0x%lx\n"),
- i, this->avi->audio[i]->wavex->wFormatTag);
- this->no_audio = 0;
-
- for(i=0; i < this->avi->n_audio; i++) {
- this->avi->audio[i]->audio_type = formattag_to_buf_audio (this->avi->audio[i]->wavex->wFormatTag);
-
- if( !this->avi->audio[i]->audio_type ) {
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: unknown audio type 0x%lx\n"),
- this->avi->audio[i]->wavex->wFormatTag);
- xine_report_codec( this->xine, XINE_CODEC_AUDIO, this->avi->audio[i]->wavex->wFormatTag, 0, 0);
- this->no_audio = 1;
- this->avi->audio[i]->audio_type = BUF_CONTROL_NOP;
- }
- else
- xine_log (this->xine, XINE_LOG_FORMAT, _("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);
- }
- }
-
AVI_seek_start (this->avi);
/*
@@ -1385,8 +1391,8 @@ static int demux_avi_start (demux_plugin_t *this_gen,
this->avi->video_type = fourcc_to_buf_video(*(uint32_t *)this->avi->compressor);
if ( !this->avi->video_type ) {
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: unknown video codec '%.4s'\n"),
- (char*)&this->avi->bih.biCompression);
+ printf ("demux_avi: unknown video codec '%.4s'\n",
+ (char*)&this->avi->bih.biCompression);
buf->free_buffer (buf);
xine_report_codec( this->xine, XINE_CODEC_VIDEO, this->avi->bih.biCompression, 0, 0);
@@ -1394,8 +1400,8 @@ static int demux_avi_start (demux_plugin_t *this_gen,
this->status = DEMUX_FINISHED;
} else {
buf->type = this->avi->video_type;
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_avi: video codec is '%s'\n"),
- buf_video_name(buf->type));
+ printf ("demux_avi: video codec is '%s'\n",
+ buf_video_name(buf->type));
this->video_fifo->put (this->video_fifo, buf);
@@ -1472,11 +1478,10 @@ static int demux_avi_start (demux_plugin_t *this_gen,
static int demux_avi_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
- demux_avi_t *this = (demux_avi_t *) this_gen;
+ off_t start_pos, int start_time) {
+ /* demux_avi_t *this = (demux_avi_t *) this_gen; */
- return demux_avi_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_avi_start (this_gen, start_pos, start_time);
}
static int demux_avi_open(demux_plugin_t *this_gen,
@@ -1512,7 +1517,7 @@ static int demux_avi_open(demux_plugin_t *this_gen,
strncpy(this->last_mrl, input->get_mrl (input), 1024);
- return DEMUX_CAN_HANDLE;
+ return demux_avi_send_headers (this);
}
/* printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n", this->AVI_errno); */
@@ -1550,7 +1555,7 @@ static int demux_avi_open(demux_plugin_t *this_gen,
if (this->avi) {
strncpy(this->last_mrl, input->get_mrl (input), 1024);
- return DEMUX_CAN_HANDLE;
+ return demux_avi_send_headers (this);
} else {
printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
this->AVI_errno);
@@ -1608,7 +1613,7 @@ static void *init_demuxer_plugin(xine_t *xine, void *data) {
this->demux_plugin.start = demux_avi_start;
this->demux_plugin.seek = demux_avi_seek;
this->demux_plugin.stop = demux_avi_stop;
- this->demux_plugin.close = demux_avi_close;
+ this->demux_plugin.dispose = demux_avi_dispose;
this->demux_plugin.get_status = demux_avi_get_status;
this->demux_plugin.get_identifier = demux_avi_get_id;
this->demux_plugin.get_stream_length = demux_avi_get_stream_length;
diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c
index e879a38a8..7f421dc99 100644
--- a/src/demuxers/demux_elem.c
+++ b/src/demuxers/demux_elem.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_elem.c,v 1.51 2002/09/05 22:18:51 mroi Exp $
+ * $Id: demux_elem.c,v 1.52 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for elementary mpeg streams
*
@@ -71,9 +71,6 @@ typedef struct {
} demux_mpeg_elem_t ;
-/*
- *
- */
static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) {
buf_element_t *buf;
@@ -98,9 +95,6 @@ static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) {
return (buf->size == this->blocksize);
}
-/*
- *
- */
static void *demux_mpeg_elem_loop (void *this_gen) {
demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen;
@@ -135,17 +129,13 @@ static void *demux_mpeg_elem_loop (void *this_gen) {
xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM);
}
- printf ("demux_elem: demux loop finished.\n");
-
this->thread_running = 0;
pthread_mutex_unlock( &this->mutex );
pthread_exit(NULL);
}
-/*
- *
- */
+
static void demux_mpeg_elem_stop (demux_plugin_t *this_gen) {
demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen;
@@ -170,69 +160,80 @@ static void demux_mpeg_elem_stop (demux_plugin_t *this_gen) {
xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
}
-/*
- *
- */
static int demux_mpeg_elem_get_status (demux_plugin_t *this_gen) {
demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen;
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-/*
- *
- */
+
+static int demux_elem_send_headers (demux_mpeg_elem_t *this) {
+
+ pthread_mutex_lock (&this->mutex);
+
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
+
+ this->blocksize = this->input->get_blocksize(this->input);
+ if (!this->blocksize)
+ this->blocksize = 2048;
+
+ xine_demux_control_start(this->xine);
+
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+ int num_buffers = NUM_PREVIEW_BUFFERS;
+
+ this->input->seek (this->input, 0, SEEK_SET);
+
+ this->status = DEMUX_OK ;
+ while ((num_buffers > 0) && (this->status == DEMUX_OK)) {
+ demux_mpeg_elem_next(this, 1);
+ num_buffers--;
+ }
+ }
+
+ xine_demux_control_headers_done (this->xine);
+
+ pthread_mutex_unlock (&this->mutex);
+
+ return DEMUX_CAN_HANDLE;
+}
+
static int demux_mpeg_elem_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
+ off_t start_pos, int start_time) {
demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen;
int err;
int status;
pthread_mutex_lock( &this->mutex );
+
+ printf ("demux_elem: start\n");
this->status = DEMUX_OK;
- if( !this->thread_running ) {
- this->video_fifo = video_fifo;
- this->audio_fifo = audio_fifo;
-
- this->blocksize = this->input->get_blocksize(this->input);
- if (!this->blocksize)
- this->blocksize = 2048;
-
- xine_demux_control_start(this->xine);
-
- if((this->input->get_capabilities(this->input) & INPUT_CAP_PREVIEW) != 0) {
- int num_buffers = NUM_PREVIEW_BUFFERS;
-
- this->input->seek (this->input, 0, SEEK_SET);
-
- this->status = DEMUX_OK ;
- while ((num_buffers > 0) && (this->status == DEMUX_OK)) {
- demux_mpeg_elem_next(this, 1);
- num_buffers--;
- }
- }
- } else {
+ if (this->thread_running)
xine_demux_flush_engine(this->xine);
- }
+
- if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
/* FIXME: implement time seek */
this->input->seek (this->input, start_pos, SEEK_SET);
}
+ printf ("demux_elem: seek done\n");
+
/*
* now start demuxing
*/
this->status = DEMUX_OK;
if( !this->thread_running ) {
+
+ printf ("demux_elem: start thread\n");
+
this->send_end_buffers = 1;
this->thread_running = 1;
if ((err = pthread_create (&this->thread,
@@ -251,17 +252,11 @@ static int demux_mpeg_elem_start (demux_plugin_t *this_gen,
}
static int demux_mpeg_elem_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
- demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen;
-
- return demux_mpeg_elem_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ off_t start_pos, int start_time) {
+ return demux_mpeg_elem_start (this_gen, start_pos, start_time);
}
-/*
- *
- */
static int demux_mpeg_elem_open(demux_plugin_t *this_gen,
input_plugin_t *input, int stage) {
@@ -295,7 +290,7 @@ static int demux_mpeg_elem_open(demux_plugin_t *this_gen,
return DEMUX_CANNOT_HANDLE;
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_elem_send_headers(this);
}
}
return DEMUX_CANNOT_HANDLE;
@@ -322,7 +317,7 @@ static int demux_mpeg_elem_open(demux_plugin_t *this_gen,
if(!strcasecmp((suffix + 1), m)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_elem_send_headers(this);
}
}
}
@@ -339,9 +334,6 @@ static int demux_mpeg_elem_open(demux_plugin_t *this_gen,
return DEMUX_CANNOT_HANDLE;
}
-/*
- *
- */
static char *demux_mpeg_elem_get_id(void) {
return "MPEG_ELEM";
}
@@ -350,7 +342,7 @@ static char *demux_mpeg_elem_get_mimetypes(void) {
return "";
}
-static void demux_mpeg_elem_close (demux_plugin_t *this) {
+static void demux_mpeg_elem_dispose (demux_plugin_t *this) {
free (this);
}
@@ -375,7 +367,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_mpeg_elem_start;
this->demux_plugin.seek = demux_mpeg_elem_seek;
this->demux_plugin.stop = demux_mpeg_elem_stop;
- this->demux_plugin.close = demux_mpeg_elem_close;
+ this->demux_plugin.dispose = demux_mpeg_elem_dispose;
this->demux_plugin.get_status = demux_mpeg_elem_get_status;
this->demux_plugin.get_identifier = demux_mpeg_elem_get_id;
this->demux_plugin.get_stream_length = demux_mpeg_elem_get_stream_length;
@@ -393,6 +385,6 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 10, "elem", XINE_VERSION_CODE, NULL, init_demuxer_plugin },
+ { PLUGIN_DEMUX, 11, "elem", XINE_VERSION_CODE, NULL, init_demuxer_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 1e4649701..5242af47b 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg.c,v 1.75 2002/09/05 22:18:52 mroi Exp $
+ * $Id: demux_mpeg.c,v 1.76 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -834,53 +834,58 @@ static int demux_mpeg_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static int demux_mpeg_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
-
- demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
- int err;
- int status;
-
+static int demux_mpeg_send_headers (demux_mpeg_t *this) {
pthread_mutex_lock( &this->mutex );
- if( !this->thread_running ) {
-
- this->video_fifo = video_fifo;
- this->audio_fifo = audio_fifo;
-
- this->rate = 0; /* fixme */
- this->last_pts[0] = 0;
- this->last_pts[1] = 0;
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
- xine_demux_control_start(this->xine);
-
- if ((this->input->get_capabilities (this->input) & INPUT_CAP_PREVIEW) != 0 ) {
-
- uint32_t w;
- int num_buffers = NUM_PREVIEW_BUFFERS;
-
- this->preview_mode = 1;
-
- this->input->seek (this->input, 4, SEEK_SET);
-
- this->status = DEMUX_OK ;
+ this->rate = 0; /* fixme */
+ this->last_pts[0] = 0;
+ this->last_pts[1] = 0;
+
+ xine_demux_control_start(this->xine);
+
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_PREVIEW) != 0 ) {
+
+ uint32_t w;
+ int num_buffers = NUM_PREVIEW_BUFFERS;
+
+ this->preview_mode = 1;
+
+ this->input->seek (this->input, 4, SEEK_SET);
+
+ this->status = DEMUX_OK ;
+
+ do {
+
+ w = parse_pack_preview (this, &num_buffers);
+
+ if (w != 0x000001ba)
+ demux_mpeg_resync (this, w);
+
+ num_buffers --;
+
+ } while ( (this->status == DEMUX_OK) && (num_buffers>0)) ;
+
+ /* printf ("demux_mpeg: rate %d\n", this->rate); */
+ }
- do {
+ xine_demux_control_headers_done (this->xine);
- w = parse_pack_preview (this, &num_buffers);
+ pthread_mutex_unlock (&this->mutex);
- if (w != 0x000001ba)
- demux_mpeg_resync (this, w);
+ return DEMUX_CAN_HANDLE;
+}
- num_buffers --;
+static int demux_mpeg_start (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
- } while ( (this->status == DEMUX_OK) && (num_buffers>0)) ;
+ demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
+ int err;
+ int status;
- /* printf ("demux_mpeg: rate %d\n", this->rate); */
- }
- }
+ pthread_mutex_lock( &this->mutex );
if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) {
@@ -926,10 +931,9 @@ static int demux_mpeg_start (demux_plugin_t *this_gen,
static int demux_mpeg_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
- demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
+ /* demux_mpeg_t *this = (demux_mpeg_t *) this_gen; */
- return demux_mpeg_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_mpeg_start (this_gen, start_pos, start_time);
}
static int demux_mpeg_open(demux_plugin_t *this_gen,
@@ -966,7 +970,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
pckbuf = read_bytes (this, 1);
if ((pckbuf>>4) != 4) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
}
break;
@@ -978,7 +982,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
pckbuf = read_bytes (this, 1);
if ((pckbuf>>4) != 4) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
}
break;
@@ -1010,7 +1014,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
pckbuf = read_bytes (this, 1);
if ((pckbuf>>4) != 4) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
}
break;
@@ -1041,7 +1045,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
for (j = 0; j < 1024 - 4; j++) {
if (BE_32(&buf[j]) == MPEG_MARKER) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
}
}
@@ -1074,7 +1078,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
if(!strncmp((media + 3), "mpeg1", 5)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
else if(!strncasecmp((media + 3), "mpeg2", 5)) {
return DEMUX_CANNOT_HANDLE;
@@ -1102,7 +1106,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen,
if(!strcasecmp((ending + 1), m)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_send_headers (this);
}
}
}
@@ -1125,7 +1129,7 @@ static char *demux_mpeg_get_mimetypes(void) {
"video/x-mpeg: mpeg, mpg, mpe: MPEG animation;";
}
-static void demux_mpeg_close (demux_plugin_t *this) {
+static void demux_mpeg_dispose (demux_plugin_t *this) {
free (this);
}
@@ -1161,13 +1165,15 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_mpeg_start;
this->demux_plugin.seek = demux_mpeg_seek;
this->demux_plugin.stop = demux_mpeg_stop;
- this->demux_plugin.close = demux_mpeg_close;
+ this->demux_plugin.dispose = demux_mpeg_dispose;
this->demux_plugin.get_status = demux_mpeg_get_status;
this->demux_plugin.get_identifier = demux_mpeg_get_id;
this->demux_plugin.get_stream_length = demux_mpeg_get_stream_length;
this->demux_plugin.get_mimetypes = demux_mpeg_get_mimetypes;
this->status = DEMUX_FINISHED;
+ this->xine = xine;
+
pthread_mutex_init( &this->mutex, NULL );
return this;
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index dda24484e..802438270 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg_block.c,v 1.113 2002/09/07 20:09:28 mroi Exp $
+ * $Id: demux_mpeg_block.c,v 1.114 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -842,7 +842,7 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) {
}
-static void demux_mpeg_block_close (demux_plugin_t *this_gen) {
+static void demux_mpeg_block_dispose (demux_plugin_t *this_gen) {
demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen;
free (this->scratch_base);
@@ -902,10 +902,54 @@ static int demux_mpeg_detect_blocksize(demux_mpeg_block_t *this,
return 2048;
}
+static int demux_mpeg_block_send_headers (demux_mpeg_block_t *this) {
+
+ pthread_mutex_lock (&this->mutex);
+
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
+
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+ if (!this->blocksize)
+ this->blocksize = demux_mpeg_detect_blocksize( this, this->input );
+
+ if (!this->blocksize)
+ return DEMUX_CANNOT_HANDLE;
+ }
+
+ /*
+ * send start buffer
+ */
+
+ xine_demux_control_start(this->xine);
+
+ if (!this->rate)
+ this->rate = demux_mpeg_block_estimate_rate (this);
+
+ if((this->input->get_capabilities(this->input) & INPUT_CAP_PREVIEW) != 0) {
+
+ int num_buffers = NUM_PREVIEW_BUFFERS;
+
+ this->input->seek (this->input, 0, SEEK_SET);
+
+ this->status = DEMUX_OK ;
+ while ( (num_buffers>0) && (this->status == DEMUX_OK) ) {
+
+ demux_mpeg_block_parse_pack(this, 1);
+ num_buffers --;
+ }
+ }
+ this->status = DEMUX_FINISHED;
+
+ xine_demux_control_headers_done (this->xine);
+
+ pthread_mutex_unlock (&this->mutex);
+
+ return DEMUX_CAN_HANDLE;
+}
+
static int demux_mpeg_block_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
off_t start_pos, int start_time) {
demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen;
@@ -915,107 +959,65 @@ static int demux_mpeg_block_start (demux_plugin_t *this_gen,
pthread_mutex_lock( &this->mutex );
- this->video_fifo = video_fifo;
- this->audio_fifo = audio_fifo;
-
if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
- if (!this->blocksize)
- this->blocksize = demux_mpeg_detect_blocksize( this, this->input );
+
+ if (start_pos) {
+ start_pos /= (off_t) this->blocksize;
+ start_pos *= (off_t) this->blocksize;
+
+ this->input->seek (this->input, start_pos, SEEK_SET);
+ } else if (start_time) {
+ start_pos = start_time * this->rate * 50;
+ start_pos /= (off_t) this->blocksize;
+ start_pos *= (off_t) this->blocksize;
+
+ this->input->seek (this->input, start_pos, SEEK_SET);
+ } else
+ this->input->seek (this->input, 0, SEEK_SET);
}
- if( this->blocksize ) {
+ /*
+ * query CLUT from the input plugin
+ */
- if( !this->thread_running ) {
- /*
- * send start buffer
- */
-
- xine_demux_control_start(this->xine);
-
- if (!this->rate)
- this->rate = demux_mpeg_block_estimate_rate (this);
-
- if((this->input->get_capabilities(this->input) & INPUT_CAP_PREVIEW) != 0) {
-
- int num_buffers = NUM_PREVIEW_BUFFERS;
-
- this->input->seek (this->input, 0, SEEK_SET);
-
- this->status = DEMUX_OK ;
- while ( (num_buffers>0) && (this->status == DEMUX_OK) ) {
-
- demux_mpeg_block_parse_pack(this, 1);
- num_buffers --;
- }
- }
- this->status = DEMUX_FINISHED;
- }
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_CLUT) &&
+ ((this->input->get_optional_data(this->input, buf->mem, INPUT_OPTIONAL_DATA_CLUT)
+ == INPUT_OPTIONAL_SUCCESS))) {
+ buf->type = BUF_SPU_CLUT;
- if (start_pos) {
- start_pos /= (off_t) this->blocksize;
- start_pos *= (off_t) this->blocksize;
+ this->video_fifo->put(this->video_fifo, buf);
+ } else {
+ buf->free_buffer(buf);
+ }
- this->input->seek (this->input, start_pos, SEEK_SET);
- } else if (start_time) {
- start_pos = start_time * this->rate * 50;
- start_pos /= (off_t) this->blocksize;
- start_pos *= (off_t) this->blocksize;
-
- this->input->seek (this->input, start_pos, SEEK_SET);
- } else
- this->input->seek (this->input, 0, SEEK_SET);
- }
-
- /*
- * query CLUT from the input plugin
- */
-
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
-
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_CLUT) &&
- ((this->input->get_optional_data(this->input, buf->mem, INPUT_OPTIONAL_DATA_CLUT)
- == INPUT_OPTIONAL_SUCCESS))) {
- buf->type = BUF_SPU_CLUT;
-
- this->video_fifo->put(this->video_fifo, buf);
- } else {
- buf->free_buffer(buf);
- }
-
- /*
- * now start demuxing
- */
- this->send_newpts = 1;
- if( !this->thread_running ) {
+ /*
+ * now start demuxing
+ */
+ this->send_newpts = 1;
+ if( !this->thread_running ) {
+
+ this->buf_flag_seek = 0;
+ this->nav_last_end_pts = this->nav_last_start_pts = 0;
+ this->status = DEMUX_OK ;
+ this->last_pts[0] = 0;
+ this->last_pts[1] = 0;
- this->buf_flag_seek = 0;
- this->nav_last_end_pts = this->nav_last_start_pts = 0;
- this->status = DEMUX_OK ;
- this->last_pts[0] = 0;
- this->last_pts[1] = 0;
-
- this->send_end_buffers = 1;
- this->thread_running = 1;
- if ((err = pthread_create (&this->thread,
- NULL, demux_mpeg_block_loop, this)) != 0) {
- printf ("demux_mpeg_block: can't create new thread (%s)\n",
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
+ if ((err = pthread_create (&this->thread,
+ NULL, demux_mpeg_block_loop, this)) != 0) {
+ printf ("demux_mpeg_block: can't create new thread (%s)\n",
strerror(err));
- abort();
- }
- } else {
- this->buf_flag_seek = 1;
- this->nav_last_end_pts = this->nav_last_start_pts = 0;
- xine_demux_flush_engine(this->xine);
+ abort();
}
+ } else {
+ this->buf_flag_seek = 1;
+ this->nav_last_end_pts = this->nav_last_start_pts = 0;
+ xine_demux_flush_engine(this->xine);
}
- else {
- xine_log (this->xine, XINE_LOG_MSG,
- _("demux_mpeg_block: unknown block size. try using demux_mpeg.\n"));
- this->status = DEMUX_FINISHED ;
- }
-
+
/* this->status is saved because we can be interrupted between
* pthread_mutex_unlock and return
*/
@@ -1025,11 +1027,10 @@ static int demux_mpeg_block_start (demux_plugin_t *this_gen,
}
static int demux_mpeg_block_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
- demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen;
+ off_t start_pos, int start_time) {
+ /* demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; */
- return demux_mpeg_block_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_mpeg_block_start (this_gen, start_pos, start_time);
}
@@ -1085,7 +1086,7 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
return DEMUX_CANNOT_HANDLE;
demux_mpeg_block_accept_input (this, input);
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_block_send_headers (this);
}
}
return DEMUX_CANNOT_HANDLE;
@@ -1118,7 +1119,7 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
this->blocksize = 2048;
demux_mpeg_block_accept_input(this, input);
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_block_send_headers (this);
}
}
@@ -1126,7 +1127,7 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
if(!strncmp(MRL, "vcd", 3)) {
this->blocksize = 2324;
demux_mpeg_block_accept_input (this, input);
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_block_send_headers (this);
}
}
@@ -1150,7 +1151,7 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
if(!strcasecmp((ending + 1), m)) {
this->blocksize = 0;
demux_mpeg_block_accept_input (this, input);
- return DEMUX_CAN_HANDLE;
+ return demux_mpeg_block_send_headers (this);
}
}
}
@@ -1207,7 +1208,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_mpeg_block_start;
this->demux_plugin.seek = demux_mpeg_block_seek;
this->demux_plugin.stop = demux_mpeg_block_stop;
- this->demux_plugin.close = demux_mpeg_block_close;
+ this->demux_plugin.dispose = demux_mpeg_block_dispose;
this->demux_plugin.get_status = demux_mpeg_block_get_status;
this->demux_plugin.get_identifier = demux_mpeg_block_get_id;
this->demux_plugin.get_stream_length = demux_mpeg_block_get_stream_length;
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 67cdc7854..011e3f652 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpgaudio.c,v 1.60 2002/09/05 22:18:52 mroi Exp $
+ * $Id: demux_mpgaudio.c,v 1.61 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for mpeg audio (i.e. mp3) streams
*
@@ -162,9 +162,6 @@ static void read_id3_tags (demux_mpgaudio_t *this) {
if ( (tag.tag[0]=='T') && (tag.tag[1]=='A') && (tag.tag[2]=='G') ) {
- xine_ui_event_t uevent;
- char temp_str[100];
-
#ifdef LOG
printf ("demux_mpgaudio: id3 tag found\n");
#endif
@@ -176,20 +173,17 @@ static void read_id3_tags (demux_mpgaudio_t *this) {
chomp (tag.title);
chomp (tag.artist);
chomp (tag.album);
+ chomp (tag.comment);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("mp3: song title '%s'\n"), tag.title);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("mp3: artist '%s'\n"), tag.artist);
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("mp3: album '%s'\n"), tag.album);
-
- sprintf (temp_str, "%s: %s", tag.artist, tag.title);
-
- uevent.event.type = XINE_EVENT_UI_SET_TITLE;
- uevent.data = temp_str;
+ this->xine->meta_info [XINE_META_INFO_TITLE]
+ = strdup (tag.title);
+ this->xine->meta_info [XINE_META_INFO_ARTIST]
+ = strdup (tag.artist);
+ this->xine->meta_info [XINE_META_INFO_ALBUM]
+ = strdup (tag.album);
+ this->xine->meta_info [XINE_META_INFO_COMMENT]
+ = strdup (tag.comment);
- xine_send_event(this->xine, &uevent.event);
}
}
}
@@ -227,11 +221,17 @@ static void mpg123_decode_header(demux_mpgaudio_t *this,unsigned long newhead) {
if( !this->bitrate ) /* bitrate can't be zero, default to 128 */
this->bitrate = 128;
+
+ if (!this->xine->meta_info[XINE_META_INFO_AUDIOCODEC]) {
+
+ char *str = malloc (80);
+
+ sprintf (str, "mpeg %s audio layer %d", ver, lay);
+ this->xine->meta_info[XINE_META_INFO_AUDIOCODEC] = str;
+
+ this->xine->stream_info[XINE_STREAM_INFO_BITRATE] = this->bitrate*1000;
+ }
-#ifdef LOG
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("demux_mpgaudio: MPEG %s Layer %d %ldkbps\n"), ver, lay, this->bitrate );
-#endif
this->stream_length = (int)(this->input->get_length(this->input) / (this->bitrate * 1000 / 8));
}
@@ -430,33 +430,24 @@ static uint32_t demux_mpgaudio_read_head(input_plugin_t *input) {
return head;
}
-static int demux_mpgaudio_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
+static int demux_mpgaudio_send_headers (demux_mpgaudio_t *this) {
- demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
- int err;
- int status;
-
- pthread_mutex_lock( &this->mutex );
+ pthread_mutex_lock (&this->mutex);
- if( !this->thread_running ) {
- this->video_fifo = video_fifo;
- this->audio_fifo = audio_fifo;
-
- this->stream_length = 0;
- this->bitrate = 0;
- this->last_pts = 0;
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
- if( !audio_fifo ) {
- xine_log (this->xine, XINE_LOG_FORMAT, _("demux_mpgaudio: no audio driver!\n") );
- pthread_mutex_unlock( &this->mutex );
- return DEMUX_FINISHED;
- }
+ this->stream_length = 0;
+ this->bitrate = 0;
+ this->last_pts = 0;
+
+ if (!this->audio_fifo) {
+ xine_log (this->xine, XINE_LOG_MSG, _("demux_mpgaudio: no audio driver!\n") );
+ pthread_mutex_unlock( &this->mutex );
+ return DEMUX_CANNOT_HANDLE;
}
- if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
uint32_t head;
if( !this->thread_running ) {
@@ -467,17 +458,31 @@ static int demux_mpgaudio_start (demux_plugin_t *this_gen,
read_id3_tags (this);
}
-
+ }
+
+ xine_demux_control_headers_done (this->xine);
+
+ pthread_mutex_unlock (&this->mutex);
+
+ return DEMUX_CAN_HANDLE;
+}
+
+static int demux_mpgaudio_start (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
+ int err;
+ int status;
+
+ pthread_mutex_lock( &this->mutex );
+
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
+
if (!start_pos && start_time && this->stream_length > 0)
start_pos = start_time * this->input->get_length(this->input) /
this->stream_length;
this->input->seek (this->input, start_pos, SEEK_SET);
-
- } else if( !this->thread_running ) {
-
-
-
}
this->status = DEMUX_OK;
@@ -514,10 +519,9 @@ static int demux_mpgaudio_start (demux_plugin_t *this_gen,
static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
- demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
+ /* demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen; */
- return demux_mpgaudio_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_mpgaudio_start (this_gen, start_pos, start_time);
}
static int demux_mpgaudio_open(demux_plugin_t *this_gen,
@@ -568,13 +572,13 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
#endif
if (mpg123_head_check(head)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpgaudio_send_headers (this);
}
}
} else {
if (mpg123_head_check(head)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpgaudio_send_headers (this);
}
}
return DEMUX_CANNOT_HANDLE;
@@ -594,7 +598,7 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
if (!strncmp (MRL, "ice ://", 7)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpgaudio_send_headers (this);
}
suffix = strrchr(MRL, '.');
@@ -612,7 +616,7 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
if(!strcasecmp((suffix + 1), m)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return demux_mpgaudio_send_headers (this);
}
}
}
@@ -639,7 +643,7 @@ static char *demux_mpgaudio_get_mimetypes(void) {
"audio/x-mpeg: mpa,abs,mpega: MPEG audio;";
}
-static void demux_mpgaudio_close (demux_plugin_t *this) {
+static void demux_mpgaudio_dispose (demux_plugin_t *this) {
free (this);
}
@@ -670,7 +674,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_mpgaudio_start;
this->demux_plugin.seek = demux_mpgaudio_seek;
this->demux_plugin.stop = demux_mpgaudio_stop;
- this->demux_plugin.close = demux_mpgaudio_close;
+ this->demux_plugin.dispose = demux_mpgaudio_dispose;
this->demux_plugin.get_status = demux_mpgaudio_get_status;
this->demux_plugin.get_identifier = demux_mpgaudio_get_id;
this->demux_plugin.get_stream_length = demux_mpgaudio_get_stream_length;
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index 18529bd5b..434afadd0 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_ogg.c,v 1.41 2002/09/05 22:18:52 mroi Exp $
+ * $Id: demux_ogg.c,v 1.42 2002/09/18 00:51:33 guenter Exp $
*
* demultiplexer for ogg streams
*
@@ -181,8 +181,13 @@ static void check_newpts (demux_ogg_t *this, int64_t pts, int video, int preview
/* use pts for bitrate measurement */
- if (pts>180000)
+ if (pts>180000) {
this->avg_bitrate = this->input->get_current_pos (this->input) * 8 * 90000/ pts;
+
+ if (this->avg_bitrate<1)
+ this->avg_bitrate = 1;
+
+ }
}
/*
@@ -382,17 +387,15 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
+this->num_audio_streams++;
this->preview_buffers[stream_num] = 3;
-
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: vorbis audio stream detected\n"));
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
if (vorbis_synthesis_headerin(&vi, &vc, &op) >= 0) {
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: vorbis avg. bitrate %d, samplerate %d\n"),
- vi.bitrate_nominal, vi.rate);
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE]
+ = vi.bitrate_nominal;
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE]
+ = vi.rate;
this->samplerate[stream_num] = vi.rate;
@@ -404,7 +407,7 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
} else {
this->samplerate[stream_num] = 44100;
this->preview_buffers[stream_num] = 0;
- xine_log (this->xine, XINE_LOG_FORMAT,
+ xine_log (this->xine, XINE_LOG_MSG,
_("ogg: vorbis audio track indicated but no vorbis stream header found.\n"));
}
@@ -459,10 +462,16 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
buf->size = sizeof (xine_bmiheader);
buf->type = this->buf_types[stream_num];
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: video format %.4s, frame size %d x %d, %d fps\n"),
- &bih.biCompression, bih.biWidth, bih.biHeight,
- 90000/this->frame_duration);
+ /*
+ * video metadata
+ */
+
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH]
+ = oggh->hubba.video.width;
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT]
+ = oggh->hubba.video.height;
+ this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION]
+ = this->frame_duration;
this->avg_bitrate += 500000; /* FIXME */
@@ -532,6 +541,20 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->samplerate[stream_num] = oggh->samples_per_unit;
this->avg_bitrate += oggh->hubba.audio.avgbytespersec*8;
+
+ /*
+ * audio metadata
+ */
+
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS]
+ = oggh->hubba.audio.channels;
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITS]
+ = oggh->bits_per_sample;
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE]
+ = oggh->samples_per_unit;
+ this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE]
+ = oggh->hubba.audio.avgbytespersec*8;
+
} else /* no audio_fifo there */
this->buf_types[stream_num] = BUF_CONTROL_NOP;
@@ -594,10 +617,16 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
printf ("demux_ogg: frame duration %d\n", this->frame_duration);
#endif
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: video format %.4s, frame size %d x %d, %d fps\n"),
- &bih.biCompression, bih.biWidth, bih.biHeight,
- 90000/this->frame_duration);
+ /*
+ * video metadata
+ */
+
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH]
+ = bih.biWidth;
+ this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT]
+ = bih.biHeight;
+ this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION]
+ = this->frame_duration;
this->avg_bitrate += 500000; /* FIXME */
@@ -631,15 +660,13 @@ static void demux_ogg_send_header (demux_ogg_t *this) {
this->buf_types[stream_num] = BUF_CONTROL_NOP;
} else {
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: old header detected but stream type is unknown\n"));
+ printf ("demux_ogg: old header detected but stream type is unknown\n");
this->buf_types[stream_num] = BUF_CONTROL_NOP;
}
} else {
- xine_log (this->xine, XINE_LOG_FORMAT,
- _("ogg: unknown stream type (signature >%.8s<). hex dump of bos packet follows:\n"),
- op.packet);
+ printf ("demux_ogg: unknown stream type (signature >%.8s<). hex dump of bos packet follows:\n",
+ op.packet);
hex_dump (op.packet, op.bytes);
@@ -832,7 +859,7 @@ static void *demux_ogg_loop (void *this_gen) {
return NULL;
}
-static void demux_ogg_close (demux_plugin_t *this_gen) {
+static void demux_ogg_dispose (demux_plugin_t *this_gen) {
demux_ogg_t *this = (demux_ogg_t *) this_gen;
free (this);
@@ -871,16 +898,12 @@ static int demux_ogg_get_status (demux_plugin_t *this_gen) {
return (this->thread_running?DEMUX_OK:DEMUX_FINISHED);
}
-static int demux_ogg_start (demux_plugin_t *this_gen,
- fifo_buffer_t *video_fifo,
- fifo_buffer_t *audio_fifo,
- off_t start_pos, int start_time) {
-
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
- int err;
+static int send_headers (demux_ogg_t *this) {
pthread_mutex_lock( &this->mutex );
- err = 1;
+
+ this->video_fifo = this->xine->video_fifo;
+ this->audio_fifo = this->xine->audio_fifo;
this->status = DEMUX_OK;
@@ -889,8 +912,6 @@ static int demux_ogg_start (demux_plugin_t *this_gen,
*/
if( !this->thread_running ) {
- this->video_fifo = video_fifo;
- this->audio_fifo = audio_fifo;
this->last_pts[0] = 0;
this->last_pts[1] = 0;
@@ -917,8 +938,30 @@ static int demux_ogg_start (demux_plugin_t *this_gen,
if (this->status == DEMUX_OK) {
/* send header */
demux_ogg_send_header (this);
+
+ xine_demux_control_headers_done (this->xine);
+
+
+ printf ("demux_ogg: headers sent, avg bitrate is %lld\n",
+ this->avg_bitrate);
+
+ pthread_mutex_unlock (&this->mutex);
+ return DEMUX_CAN_HANDLE;
}
+ pthread_mutex_unlock (&this->mutex);
+ return DEMUX_CANNOT_HANDLE;
+}
+
+static int demux_ogg_start (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ demux_ogg_t *this = (demux_ogg_t *) this_gen;
+ int err;
+
+ pthread_mutex_lock( &this->mutex );
+ err = 1;
+
/*
* seek to start position
*/
@@ -973,10 +1016,9 @@ static int demux_ogg_start (demux_plugin_t *this_gen,
static int demux_ogg_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
+ /* demux_ogg_t *this = (demux_ogg_t *) this_gen; */
- return demux_ogg_start (this_gen, this->video_fifo, this->audio_fifo,
- start_pos, start_time);
+ return demux_ogg_start (this_gen, start_pos, start_time);
}
static int demux_ogg_open(demux_plugin_t *this_gen,
@@ -1001,7 +1043,7 @@ static int demux_ogg_open(demux_plugin_t *this_gen,
&& (buf[2] == 'g')
&& (buf[3] == 'S')) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return send_headers(this);
}
}
}
@@ -1012,7 +1054,7 @@ static int demux_ogg_open(demux_plugin_t *this_gen,
&& (buf[2] == 'g')
&& (buf[3] == 'S')) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return send_headers(this);
}
}
}
@@ -1045,7 +1087,7 @@ static int demux_ogg_open(demux_plugin_t *this_gen,
if(!strcasecmp((ending + 1), m)) {
this->input = input;
- return DEMUX_CAN_HANDLE;
+ return send_headers(this);
}
}
}
@@ -1090,7 +1132,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) {
this->demux_plugin.start = demux_ogg_start;
this->demux_plugin.seek = demux_ogg_seek;
this->demux_plugin.stop = demux_ogg_stop;
- this->demux_plugin.close = demux_ogg_close;
+ this->demux_plugin.dispose = demux_ogg_dispose;
this->demux_plugin.get_status = demux_ogg_get_status;
this->demux_plugin.get_identifier = demux_ogg_get_id;
this->demux_plugin.get_stream_length = demux_ogg_get_stream_length;