diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-09-18 00:51:33 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-09-18 00:51:33 +0000 |
commit | db4a9292eb386fe91bbb4059c1b172e45bd32ce7 (patch) | |
tree | 85a58e93c69fa06b6304bb936c77131b957d3c5f | |
parent | 1ad10f5795d76ee8d66c642cc4165593ce6a9e39 (diff) | |
download | xine-lib-db4a9292eb386fe91bbb4059c1b172e45bd32ce7.tar.gz xine-lib-db4a9292eb386fe91bbb4059c1b172e45bd32ce7.tar.bz2 |
first steps towards implementing stream/meta info
CVS patchset: 2680
CVS date: 2002/09/18 00:51:33
-rw-r--r-- | include/xine.h.in | 69 | ||||
-rw-r--r-- | src/demuxers/Makefile.am | 124 | ||||
-rw-r--r-- | src/demuxers/demux.h | 18 | ||||
-rw-r--r-- | src/demuxers/demux_asf.c | 196 | ||||
-rw-r--r-- | src/demuxers/demux_avi.c | 105 | ||||
-rw-r--r-- | src/demuxers/demux_elem.c | 114 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg.c | 106 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 207 | ||||
-rw-r--r-- | src/demuxers/demux_mpgaudio.c | 118 | ||||
-rw-r--r-- | src/demuxers/demux_ogg.c | 122 | ||||
-rw-r--r-- | src/libffmpeg/xine_decoder.c | 39 | ||||
-rw-r--r-- | src/libmpeg2/decode.c | 77 | ||||
-rw-r--r-- | src/libvorbis/xine_decoder.c | 64 | ||||
-rw-r--r-- | src/xine-engine/audio_decoder.c | 8 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 28 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 6 | ||||
-rw-r--r-- | src/xine-engine/demux.c | 15 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 4 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 18 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 121 | ||||
-rw-r--r-- | src/xine-engine/xine_interface.c | 13 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 13 |
22 files changed, 919 insertions, 666 deletions
diff --git a/include/xine.h.in b/include/xine.h.in index 091ca3f2d..a9fb0aaf5 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -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: xine.h.in,v 1.15 2002/09/17 11:54:55 f1rmb Exp $ + * $Id: xine.h.in,v 1.16 2002/09/18 00:51:33 guenter Exp $ * * public xine-lib (libxine) interface and documentation * @@ -296,16 +296,16 @@ int xine_register_report_codec_cb(xine_p self, * xine engine parameters */ -#define XINE_PARAM_SPEED 1 -#define XINE_PARAM_AV_OFFSET 2 -#define XINE_PARAM_AUDIO_CHANNEL_LOGICAL 3 -#define XINE_PARAM_SPU_CHANNEL 4 +#define XINE_PARAM_SPEED 1 /* see below */ +#define XINE_PARAM_AV_OFFSET 2 /* unit: 1/90000 sec */ +#define XINE_PARAM_AUDIO_CHANNEL_LOGICAL 3 /* -1 => auto, -2 => off */ +#define XINE_PARAM_SPU_CHANNEL 4 #define XINE_PARAM_VIDEO_CHANNEL 5 -#define XINE_PARAM_AUDIO_VOLUME 6 -#define XINE_PARAM_AUDIO_MUTE 7 -#define XINE_PARAM_AUDIO_COMPR_LEVEL 8 -#define XINE_PARAM_AUDIO_AMP_LEVEL 9 -#define XINE_PARAM_AUDIO_REPORT_LEVEL 10 +#define XINE_PARAM_AUDIO_VOLUME 6 /* 0..255 */ +#define XINE_PARAM_AUDIO_MUTE 7 /* 1=>mute, 0=>unmute */ +#define XINE_PARAM_AUDIO_COMPR_LEVEL 8 /* 0..255 */ +#define XINE_PARAM_AUDIO_AMP_LEVEL 9 /* 0..200, 100=>100% (default) */ +#define XINE_PARAM_AUDIO_REPORT_LEVEL 10 /* 1=>send events, 0=> don't */ /* stream format detection strategies */ @@ -346,17 +346,20 @@ int xine_register_report_codec_cb(xine_p self, /* xine_get_stream_info */ -#define XINE_STREAM_INFO_WIDTH 0 -#define XINE_STREAM_INFO_HEIGHT 1 -#define XINE_STREAM_INFO_SEEKABLE 2 -#define XINE_STREAM_INFO_VIDEO_FOURCC 3 -#define XINE_STREAM_INFO_VIDEO_CHANNELS 4 -#define XINE_STREAM_INFO_VIDEO_STREAMS 5 -#define XINE_STREAM_INFO_AUDIO_FOURCC 6 -#define XINE_STREAM_INFO_AUDIO_CHANNELS 7 -#define XINE_STREAM_INFO_AUDIO_BITS 8 -#define XINE_STREAM_INFO_AUDIO_SAMPLERATE 9 -#define XINE_STREAM_INFO_HAS_CHAPTERS 10 +#define XINE_STREAM_INFO_BITRATE 0 +#define XINE_STREAM_INFO_SEEKABLE 1 +#define XINE_STREAM_INFO_VIDEO_WIDTH 2 +#define XINE_STREAM_INFO_VIDEO_HEIGHT 3 +#define XINE_STREAM_INFO_VIDEO_RATIO 4 /* *10000 */ +#define XINE_STREAM_INFO_VIDEO_CHANNELS 5 +#define XINE_STREAM_INFO_VIDEO_STREAMS 6 +#define XINE_STREAM_INFO_VIDEO_BITRATE 7 +#define XINE_STREAM_INFO_FRAME_DURATION 8 /* 1/90000 sec */ +#define XINE_STREAM_INFO_AUDIO_CHANNELS 9 +#define XINE_STREAM_INFO_AUDIO_BITS 10 +#define XINE_STREAM_INFO_AUDIO_SAMPLERATE 11 +#define XINE_STREAM_INFO_AUDIO_BITRATE 12 +#define XINE_STREAM_INFO_HAS_CHAPTERS 13 /* xine_get_meta_info */ @@ -366,6 +369,10 @@ int xine_register_report_codec_cb(xine_p self, #define XINE_META_INFO_GENRE 3 #define XINE_META_INFO_ALBUM 4 #define XINE_META_INFO_YEAR 5 +#define XINE_META_INFO_VIDEOCODEC 6 +#define XINE_META_INFO_AUDIOCODEC 7 +#define XINE_META_INFO_SYSTEMLAYER 8 +#define XINE_META_INFO_INPUT_PLUGIN 9 /* * video stuff @@ -380,16 +387,16 @@ int xine_register_report_codec_cb(xine_p self, #define XINE_VISUAL_TYPE_DFB 5 /* video parameters */ -#define XINE_PARAM_VO_DEINTERLACE 0x01000000 -#define XINE_PARAM_VO_ASPECT_RATIO 0x01000001 -#define XINE_PARAM_VO_HUE 0x01000002 -#define XINE_PARAM_VO_SATURATION 0x01000003 -#define XINE_PARAM_VO_CONTRAST 0x01000004 -#define XINE_PARAM_VO_BRIGHTNESS 0x01000005 -#define XINE_PARAM_VO_ZOOM_X 0x01000008 -#define XINE_PARAM_VO_ZOOM_Y 0x0100000d -#define XINE_PARAM_VO_PAN_SCAN 0x01000009 -#define XINE_PARAM_VO_TVMODE 0x0100000a +#define XINE_PARAM_VO_DEINTERLACE 0x01000000 /* bool */ +#define XINE_PARAM_VO_ASPECT_RATIO 0x01000001 /* see below */ +#define XINE_PARAM_VO_HUE 0x01000002 /* 0..65535 */ +#define XINE_PARAM_VO_SATURATION 0x01000003 /* 0..65535 */ +#define XINE_PARAM_VO_CONTRAST 0x01000004 /* 0..65535 */ +#define XINE_PARAM_VO_BRIGHTNESS 0x01000005 /* 0..65535 */ +#define XINE_PARAM_VO_ZOOM_X 0x01000008 /* percent */ +#define XINE_PARAM_VO_ZOOM_Y 0x0100000d /* percent */ +#define XINE_PARAM_VO_PAN_SCAN 0x01000009 /* bool */ +#define XINE_PARAM_VO_TVMODE 0x0100000a /* ??? */ #define XINE_VO_ZOOM_STEP 100 #define XINE_VO_ZOOM_MAX 400 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; diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c index 7d008c7b8..cd6a05aeb 100644 --- a/src/libffmpeg/xine_decoder.c +++ b/src/libffmpeg/xine_decoder.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: xine_decoder.c,v 1.54 2002/09/05 22:18:56 mroi Exp $ + * $Id: xine_decoder.c,v 1.55 2002/09/18 00:51:33 guenter Exp $ * * xine decoder plugin using ffmpeg * @@ -191,10 +191,6 @@ static void find_sequence_header (ff_decoder_t *this, width = ((height >> 12) + 15) & ~15; height = ((height & 0xfff) + 15) & ~15; - xine_log (this->xine, XINE_LOG_FORMAT, - "ffmpeg: frame size is %d x %d\n", - width, height); - this->bih.biWidth = width; this->bih.biHeight = height; @@ -231,6 +227,13 @@ static void find_sequence_header (ff_decoder_t *this, this->video_step = 3000; } + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = width; + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = height; + this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = this->video_step; + + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("mpeg-1 (ffmpeg)"); + /* * init codec */ @@ -288,6 +291,10 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { memcpy ( &this->bih, buf->content, sizeof (xine_bmiheader)); this->video_step = buf->decoder_info[1]; + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->bih.biWidth; + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = this->bih.biHeight; + this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = this->video_step; + /* init codec */ codec_type = buf->type & 0xFFFF0000; @@ -295,40 +302,62 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { switch (codec_type) { case BUF_VIDEO_MSMPEG4_V1: codec = avcodec_find_decoder (CODEC_ID_MSMPEG4V1); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("ms mpeg-4 v1 (ffmpeg)"); break; case BUF_VIDEO_MSMPEG4_V2: codec = avcodec_find_decoder (CODEC_ID_MSMPEG4V2); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("ms mpeg-4 v2 (ffmpeg)"); break; case BUF_VIDEO_MSMPEG4_V3: codec = avcodec_find_decoder (CODEC_ID_MSMPEG4); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("ms mpeg-4 v3 (ffmpeg)"); break; case BUF_VIDEO_WMV7: codec = avcodec_find_decoder (CODEC_ID_WMV1); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("ms wmv 7 (ffmpeg)"); break; case BUF_VIDEO_MPEG4 : case BUF_VIDEO_XVID : case BUF_VIDEO_DIVX5 : codec = avcodec_find_decoder (CODEC_ID_MPEG4); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("mpeg-4 (ffmpeg)"); break; case BUF_VIDEO_JPEG: case BUF_VIDEO_MJPEG: codec = avcodec_find_decoder (CODEC_ID_MJPEG); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("mjpeg (ffmpeg)"); break; case BUF_VIDEO_I263: codec = avcodec_find_decoder (CODEC_ID_H263I); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("i263 (ffmpeg)"); break; case BUF_VIDEO_H263: codec = avcodec_find_decoder (CODEC_ID_H263); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("h263 (ffmpeg)"); break; case BUF_VIDEO_RV10: codec = avcodec_find_decoder (CODEC_ID_RV10); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("real video 1.0 (ffmpeg)"); break; case BUF_VIDEO_SORENSON_V1: codec = avcodec_find_decoder (CODEC_ID_SVQ1); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("sorenson svq 1 (ffmpeg)"); break; default: printf ("ffmpeg: unknown video format (buftype: 0x%08X)\n", buf->type & 0xFFFF0000); + this->xine->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup ("unknown (ffmpeg)"); } if (!codec) { diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c index 09863e682..fe022dd48 100644 --- a/src/libmpeg2/decode.c +++ b/src/libmpeg2/decode.c @@ -150,6 +150,61 @@ static inline void get_frame_duration (mpeg2dec_t * mpeg2dec, vo_frame_t *frame) /*printf("mpeg2dec: rff=%u\n",frame->repeat_first_field);*/ } +static void remember_metainfo (mpeg2dec_t *mpeg2dec) { + + picture_t * picture = mpeg2dec->picture; + + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = picture->frame_width; + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = picture->frame_height; + + switch (picture->aspect_ratio_information) { + case 3: /* anamorphic */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 16.0 /9.0; + break; + case 4: /* 2.11:1 */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 2.11/1.0; + break; + case 1: /* square pels */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000; + break; + default: + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 4.0 / 3.0; + break; + } + + switch (mpeg2dec->picture->frame_rate_code) { + case 1: /* 23.976 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3913; + break; + case 2: /* 24 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3750; + break; + case 3: /* 25 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3600; + break; + case 4: /* 29.97 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3003; + break; + case 5: /* 30 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000; + break; + case 6: /* 50 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1800; + break; + case 7: /* 59.94 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1525; + break; + case 8: /* 60 fps */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1509; + break; + default: + /* printf ("invalid/unknown frame rate code : %d \n", + frame->frame_rate_code); */ + mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000; + } +} + + static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, uint8_t * buffer) { @@ -295,15 +350,8 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, || (picture->frame_height != picture->coded_picture_height)) { xine_frame_change_event_t notify_event; - xine_log (mpeg2dec->xine, XINE_LOG_FORMAT, - "libmpeg2: frame size is %d x %d, ratio is %d\n", - picture->frame_width, picture->frame_height, - picture->frame_rate_code); - - printf ("libmpeg2: frame size has changed to from %d x %d to %d x %d\n", - picture->frame_width, picture->frame_height, - picture->coded_picture_width, picture->coded_picture_height); - + remember_metainfo (mpeg2dec); + notify_event.event.type = XINE_EVENT_FRAME_CHANGE; notify_event.width = picture->coded_picture_width; notify_event.height = picture->coded_picture_height; @@ -316,8 +364,6 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, if (picture->backward_reference_frame) picture->backward_reference_frame->free (picture->backward_reference_frame); - printf ("libmpeg2: old frames freed.\n"); - mpeg2dec->is_sequence_needed = 0; picture->forward_reference_frame = NULL; picture->backward_reference_frame = NULL; @@ -639,13 +685,8 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec, picture->frame_width = picture->coded_picture_width; picture->frame_height = picture->coded_picture_height; - xine_log (mpeg2dec->xine, XINE_LOG_FORMAT, - "libmpeg2: frame size is %d x %d\n", - picture->frame_width, picture->frame_height); - - printf ("libmpeg2: frame size %d x %d\n", - picture->frame_width, picture->frame_height); - + remember_metainfo (mpeg2dec); + notify_event.event.type = XINE_EVENT_FRAME_CHANGE; notify_event.width = picture->coded_picture_width; notify_event.height = picture->coded_picture_height; diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c index a540382c1..28961844f 100644 --- a/src/libvorbis/xine_decoder.c +++ b/src/libvorbis/xine_decoder.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: xine_decoder.c,v 1.18 2002/09/05 22:19:00 mroi Exp $ + * $Id: xine_decoder.c,v 1.19 2002/09/18 00:51:34 guenter Exp $ * * (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine */ @@ -63,6 +63,8 @@ typedef struct vorbis_decoder_s { int header_count; + xine_t *xine; + } vorbis_decoder_t; @@ -92,6 +94,53 @@ static void vorbis_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { } +/* Known vorbis comment keys from ogg123 sources*/ +static struct { + char *key; /* includes the '=' for programming convenience */ + int xine_metainfo_index; +} vorbis_comment_keys[] = { + {"ARTIST=", XINE_META_INFO_ARTIST}, + {"ALBUM=", XINE_META_INFO_ALBUM}, + {"TITLE=", XINE_META_INFO_TITLE}, + {"GENRE=", XINE_META_INFO_GENRE}, + {"DESCRIPTION=", XINE_META_INFO_COMMENT}, + {"DATE=", XINE_META_INFO_YEAR}, + {NULL, 0} +}; + +static void get_metadata (vorbis_decoder_t *this) { + + char **ptr=this->vc.user_comments; + while(*ptr){ + + char *comment = *ptr; + int i; + +#ifdef LOG + printf("libvorbis: %s\n", comment); +#endif + + for (i = 0; vorbis_comment_keys[i].key != NULL; i++) { + + if ( !strncasecmp (vorbis_comment_keys[i].key, comment, + strlen(vorbis_comment_keys[i].key)) ) { + +#ifdef LOG + printf ("libvorbis: known metadata %d %d\n", + i, vorbis_comment_keys[i].xine_metainfo_index); +#endif + + this->xine->meta_info[vorbis_comment_keys[i].xine_metainfo_index] + = strdup (comment + strlen(vorbis_comment_keys[i].key)); + + } + } + ++ptr; + } + + this->xine->meta_info[XINE_META_INFO_AUDIOCODEC] = strdup ("vorbis"); +} + static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { vorbis_decoder_t *this = (vorbis_decoder_t *) this_gen; @@ -120,16 +169,8 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { int mode = AO_CAP_MODE_MONO; - { - char **ptr=this->vc.user_comments; - while(*ptr){ - printf("libvorbis: %s\n",*ptr); - ++ptr; - } - printf ("\nlibvorbis: bitstream is %d channel(s), %ldHz\n", - this->vi.channels, this->vi.rate); - printf("libvorbis: encoded by: %s\n\n",this->vc.vendor); - } + get_metadata (this); + switch (this->vi.channels) { case 1: @@ -249,6 +290,7 @@ static void *init_audio_decoder_plugin (xine_t *xine, void *data) { this->audio_decoder.close = vorbis_close; this->audio_decoder.get_identifier = vorbis_get_id; this->audio_decoder.dispose = vorbis_dispose; + this->xine = xine; return (audio_decoder_t *) this; } diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index cabd18b03..9ad8ddfdc 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.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: audio_decoder.c,v 1.83 2002/09/04 23:31:13 guenter Exp $ + * $Id: audio_decoder.c,v 1.84 2002/09/18 00:51:34 guenter Exp $ * * * functions that implement audio decoding @@ -247,9 +247,9 @@ void *audio_decoder_loop (void *this_gen) { if (decoder) { xine_event_t event; - xine_log (this, XINE_LOG_FORMAT, - "audio_decoder: using audio decoder plugin '%s'\n", - decoder->get_identifier()); + + this->meta_info[XINE_META_INFO_AUDIOCODEC] + = strdup (decoder->get_identifier()); xine_report_codec( this, XINE_CODEC_AUDIO, 0, buf->type, 1); this->cur_audio_decoder_plugin = decoder; diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 89ac7afde..a890b5e41 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.64 2002/09/04 23:31:13 guenter Exp $ + * $Id: audio_out.c,v 1.65 2002/09/18 00:51:34 guenter Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -531,9 +531,29 @@ static int ao_open(ao_instance_t *this, int output_sample_rate, err; - xine_log (this->xine, XINE_LOG_FORMAT, - "audio_out: stream audio format is %d kHz sampling rate, %d bits. mode is %d.\n", - rate, bits, mode); + /* + * set metainfo + */ + + switch (mode) { + case AO_CAP_MODE_MONO: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 1; + case AO_CAP_MODE_STEREO: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 2; + case AO_CAP_MODE_4CHANNEL: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 4; + case AO_CAP_MODE_5CHANNEL: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 5; + case AO_CAP_MODE_5_1CHANNEL: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 6; + case AO_CAP_MODE_A52: + case AO_CAP_MODE_AC5: + default: + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 255; /* unknown */ + } + + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = bits; + this->xine->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = rate; this->input.mode = mode; this->input.rate = rate; diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index a83e37f6b..e43d5f3a4 100644 --- a/src/xine-engine/audio_out.h +++ b/src/xine-engine/audio_out.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: audio_out.h,v 1.33 2002/09/04 23:31:13 guenter Exp $ + * $Id: audio_out.h,v 1.34 2002/09/18 00:51:34 guenter Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index d8b4ed225..008f6ca1d 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -75,6 +75,21 @@ void xine_demux_control_newpts( xine_t *this, int64_t pts, uint32_t flags ) { } } +void xine_demux_control_headers_done (xine_t *this) { + + buf_element_t *buf; + + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_HEADERS_DONE; + this->video_fifo->put (this->video_fifo, buf); + + if (this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_HEADERS_DONE; + this->audio_fifo->put (this->audio_fifo, buf); + } +} + void xine_demux_control_start( xine_t *this ) { buf_element_t *buf; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 639b900f9..83f96158c 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.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: load_plugins.c,v 1.93 2002/09/16 21:49:35 miguelfreitas Exp $ + * $Id: load_plugins.c,v 1.94 2002/09/18 00:51:34 guenter Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -929,7 +929,7 @@ void dispose_plugins (xine_t *this) { demux_plugin_t *dp = node->plugin; if (dp) - dp->close (dp); + dp->dispose (dp); node = xine_list_next_content (this->plugin_catalog->demux); } diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index af6fa4b93..0ebbe223c 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.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: video_decoder.c,v 1.96 2002/09/04 23:31:13 guenter Exp $ + * $Id: video_decoder.c,v 1.97 2002/09/18 00:51:34 guenter Exp $ * */ @@ -97,6 +97,10 @@ void *video_decoder_loop (void *this_gen) { #endif switch (buf->type & 0xffff0000) { + case BUF_CONTROL_HEADERS_DONE: + this->header_sent_counter++; + break; + case BUF_CONTROL_START: if (this->cur_video_decoder_plugin) { @@ -279,12 +283,9 @@ void *video_decoder_loop (void *this_gen) { this->cur_video_decoder_plugin = decoder; this->cur_video_decoder_plugin->init (this->cur_video_decoder_plugin, this->video_out); - printf ("video_decoder: using decoder >%s< \n", - decoder->get_identifier()); + this->meta_info[XINE_META_INFO_VIDEOCODEC] + = strdup (decoder->get_identifier()); - xine_log (this, XINE_LOG_FORMAT, "using video decoder plugin '%s'\n", - decoder->get_identifier()); - xine_report_codec( this, XINE_CODEC_VIDEO, 0, buf->type, 1); ui_event.event.type = XINE_EVENT_OUTPUT_VIDEO; @@ -355,12 +356,17 @@ void video_decoder_shutdown (xine_t *this) { buf_element_t *buf; void *p; + printf ("video_decoder: shutdown...\n"); + /* this->video_fifo->clear(this->video_fifo); */ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + printf ("video_decoder: shutdown...2\n"); buf->type = BUF_CONTROL_QUIT; this->video_fifo->put (this->video_fifo, buf); + printf ("video_decoder: shutdown...3\n"); pthread_join (this->video_thread, &p); + printf ("video_decoder: shutdown...4\n"); } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index f00ce7a18..246c7bccb 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.158 2002/09/15 11:35:09 jcdutton Exp $ + * $Id: xine.c,v 1.159 2002/09/18 00:51:34 guenter Exp $ * * top-level xine functions * @@ -365,11 +365,23 @@ static int find_demuxer(xine_t *this) { int xine_open_internal (xine_t *this, const char *mrl) { - printf ("xine_open: mrl '%s'\n", mrl); + printf ("xine: open mrl '%s'\n", mrl); - if (this->speed != XINE_SPEED_NORMAL) { - xine_set_speed_internal (this, XINE_SPEED_NORMAL); + /* + * is this an 'opt:' mrlstyle ? + */ + if (xine_config_change_opt(this->config, mrl)) { + xine_event_t event; + + this->status = XINE_STATUS_STOP; + + event.type = XINE_EVENT_PLAYBACK_FINISHED; + pthread_mutex_unlock (&this->xine_lock); + xine_send_event (this, &event); + pthread_mutex_lock (&this->xine_lock); + return 1; } + /* * stop engine only for different mrl */ @@ -377,6 +389,11 @@ int xine_open_internal (xine_t *this, const char *mrl) { if ((this->status == XINE_STATUS_PLAY && strcmp (mrl, this->cur_mrl)) || (this->status == XINE_STATUS_LOGO)) { + printf ("xine: stopping engine\n"); + + if (this->speed != XINE_SPEED_NORMAL) + xine_set_speed_internal (this, XINE_SPEED_NORMAL); + if(this->cur_demuxer_plugin) { this->playing_logo = 0; this->cur_demuxer_plugin->stop (this->cur_demuxer_plugin); @@ -394,38 +411,31 @@ int xine_open_internal (xine_t *this, const char *mrl) { this->audio_out->control(this->audio_out, AO_CTRL_FLUSH_BUFFERS); this->status = XINE_STATUS_STOP; - } else { } - if (strcmp (mrl, this->cur_mrl)) { - /* Is it an 'opt:' mrlstyle ? */ - if (xine_config_change_opt(this->config, mrl)) { - xine_event_t event; - - this->status = XINE_STATUS_STOP; - - event.type = XINE_EVENT_PLAYBACK_FINISHED; - pthread_mutex_unlock (&this->xine_lock); - xine_send_event (this, &event); - pthread_mutex_lock (&this->xine_lock); - return 1; - } - } - - if (this->status == XINE_STATUS_STOP ) { + if (this->status == XINE_STATUS_STOP) { plugin_node_t *node; - int i; + int i, header_count; /* - * reset metainfo + * (1/3) reset metainfo */ for (i=0; i<XINE_STREAM_INFO_MAX; i++) { this->stream_info[i] = 0; - this->meta_info [i] = NULL; + if (this->meta_info[i]) { + free (this->meta_info[i]); + this->meta_info[i] = NULL; + } } + /* + * (2/3) start engine for new mrl' + */ + + printf ("xine: starting engine for new mrl\n"); + /* * find input plugin */ @@ -444,7 +454,7 @@ int xine_open_internal (xine_t *this, const char *mrl) { } if (!this->cur_input_plugin) { - xine_log (this, XINE_LOG_FORMAT, + xine_log (this, XINE_LOG_MSG, _("xine: cannot find input plugin for this MRL\n")); this->cur_demuxer_plugin = NULL; this->err = XINE_ERROR_NO_INPUT_PLUGIN; @@ -452,37 +462,46 @@ int xine_open_internal (xine_t *this, const char *mrl) { return 0; } - printf ("xine: using input plugin >%s< for this MRL (%s).\n", - this->cur_input_plugin->get_identifier(this->cur_input_plugin), mrl); - - xine_log (this, XINE_LOG_FORMAT, - _("using input plugin '%s' for MRL '%s'\n"), - this->cur_input_plugin->get_identifier(this->cur_input_plugin), - mrl); + this->meta_info[XINE_META_INFO_INPUT_PLUGIN] + = strdup (this->cur_input_plugin->get_identifier(this->cur_input_plugin)); /* * find demuxer plugin */ + header_count = this->header_sent_counter+1; if (!find_demuxer(this)) { - xine_log (this, XINE_LOG_FORMAT, + xine_log (this, XINE_LOG_MSG, _("xine: couldn't find demuxer for >%s<\n"), mrl); this->cur_input_plugin->close(this->cur_input_plugin); this->err = XINE_ERROR_NO_DEMUXER_PLUGIN; return 0; } - xine_log (this, XINE_LOG_FORMAT, - _("system layer format '%s' detected.\n"), - this->cur_demuxer_plugin->get_identifier()); - } + this->meta_info[XINE_META_INFO_SYSTEMLAYER] + = strdup (this->cur_demuxer_plugin->get_identifier()); - /* FIXME: ?? limited length ??? */ - strncpy (this->cur_mrl, mrl, 1024); + /* FIXME: ?? limited length ??? */ + strncpy (this->cur_mrl, mrl, 1024); - printf ("xine: xine_open done.\n"); + printf ("xine: engine start successful - waiting for headers to be sent\n"); - return 1; + /* + * (3/3) wait for headers to be sent and decoded + */ + + while (header_count>this->header_sent_counter) { + printf ("xine: waiting for headers.\n"); + xine_usec_sleep (20000); + } + + printf ("xine: xine_open done.\n"); + + return 1; + } + + printf ("xine: xine_open ignored (same mrl, already playing)\n"); + return 0; } int xine_play_internal (xine_t *this, int start_pos, int start_time) { @@ -493,8 +512,11 @@ int xine_play_internal (xine_t *this, int start_pos, int start_time) { printf ("xine: xine_play_internal\n"); + if (this->speed != XINE_SPEED_NORMAL) + xine_set_speed_internal (this, XINE_SPEED_NORMAL); + /* - * start demuxer + * start/seek demuxer */ if (start_pos) { /* FIXME: do we need to protect concurrent access to input plugin here? */ @@ -507,8 +529,6 @@ int xine_play_internal (xine_t *this, int start_pos, int start_time) { if (this->status == XINE_STATUS_STOP) { demux_status = this->cur_demuxer_plugin->start (this->cur_demuxer_plugin, - this->video_fifo, - this->audio_fifo, pos, start_time); } else { demux_status = this->cur_demuxer_plugin->seek (this->cur_demuxer_plugin, @@ -535,6 +555,8 @@ int xine_play_internal (xine_t *this, int start_pos, int start_time) { this->curtime_needed_for_osd = 5; } + printf ("xine: xine_play_internal ...done\n"); + return 1; } @@ -693,6 +715,16 @@ xine_p xine_new (void) { this->cur_input_plugin = NULL; this->cur_spu_decoder_plugin = NULL; this->report_codec_cb = NULL; + this->header_sent_counter = 0; + + /* + * meta info + */ + + for (i=0; i<XINE_STREAM_INFO_MAX; i++) { + this->stream_info[i] = 0; + this->meta_info [i] = NULL; + } /* * plugins @@ -1052,7 +1084,6 @@ int xine_get_log_section_count (xine_p this_ro) { const char *const *xine_get_log_names (xine_p this_ro) { static const char *log_sections[XINE_LOG_NUM + 1]; - log_sections[XINE_LOG_FORMAT] = _("stream format"); log_sections[XINE_LOG_MSG] = _("messages"); log_sections[XINE_LOG_PLUGIN] = _("plugin"); log_sections[XINE_LOG_NUM] = NULL; diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 99c9b4dfe..9f902209c 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.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: xine_interface.c,v 1.13 2002/09/16 15:09:36 jcdutton Exp $ + * $Id: xine_interface.c,v 1.14 2002/09/18 00:51:34 guenter Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -419,15 +419,18 @@ uint32_t xine_get_stream_info (xine_p this, int info) { return this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_CHAPTERS; return 0; - case XINE_STREAM_INFO_WIDTH: - case XINE_STREAM_INFO_HEIGHT: - case XINE_STREAM_INFO_VIDEO_FOURCC: + case XINE_STREAM_INFO_BITRATE: + case XINE_STREAM_INFO_VIDEO_WIDTH: + case XINE_STREAM_INFO_VIDEO_HEIGHT: + case XINE_STREAM_INFO_VIDEO_RATIO: case XINE_STREAM_INFO_VIDEO_CHANNELS: case XINE_STREAM_INFO_VIDEO_STREAMS: - case XINE_STREAM_INFO_AUDIO_FOURCC: + case XINE_STREAM_INFO_VIDEO_BITRATE: + case XINE_STREAM_INFO_FRAME_DURATION: case XINE_STREAM_INFO_AUDIO_CHANNELS: case XINE_STREAM_INFO_AUDIO_BITS: case XINE_STREAM_INFO_AUDIO_SAMPLERATE: + case XINE_STREAM_INFO_AUDIO_BITRATE: return this->stream_info[info]; default: diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index cfa9d684a..1e8fed0bf 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.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: xine_internal.h,v 1.99 2002/09/13 18:25:23 guenter Exp $ + * $Id: xine_internal.h,v 1.100 2002/09/18 00:51:34 guenter Exp $ * */ @@ -131,10 +131,9 @@ struct audio_decoder_s { * log constants */ -#define XINE_LOG_FORMAT 0 /* stream format, decoders, video size... */ -#define XINE_LOG_MSG 1 /* warnings, errors, ... */ -#define XINE_LOG_PLUGIN 2 -#define XINE_LOG_NUM 3 /* # of log buffers defined */ +#define XINE_LOG_MSG 0 /* warnings, errors, ... */ +#define XINE_LOG_PLUGIN 1 +#define XINE_LOG_NUM 2 /* # of log buffers defined */ #define XINE_STREAM_INFO_MAX 99 @@ -246,6 +245,8 @@ struct xine_s { /* stream meta information */ int stream_info[XINE_STREAM_INFO_MAX]; char *meta_info [XINE_STREAM_INFO_MAX]; + + int header_sent_counter; /* wait for headers sent */ }; /* @@ -275,6 +276,8 @@ void xine_demux_flush_engine (xine_t *this); void xine_demux_control_newpts (xine_t *this, int64_t pts, uint32_t flags ); +void xine_demux_control_headers_done (xine_t *this ); + void xine_demux_control_start (xine_t *this ); void xine_demux_control_end (xine_t *this, uint32_t flags ); |