From b7dd962b658dd71ac94dda89110140bfd3dd63d2 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 27 Oct 2002 01:52:15 +0000 Subject: return of ogg and vorbis, began implementing verbosity parameter CVS patchset: 3034 CVS date: 2002/10/27 01:52:15 --- src/Makefile.am | 3 +- src/demuxers/Makefile.am | 8 +- src/demuxers/demux_mpeg_block.c | 3 +- src/demuxers/demux_ogg.c | 316 +++++++++++++++++++++------------------ src/input/input_http.c | 2 +- src/libvorbis/xine_decoder.c | 108 +++++++------ src/xine-engine/load_plugins.c | 16 +- src/xine-engine/video_decoder.c | 8 +- src/xine-engine/xine.c | 13 +- src/xine-engine/xine_interface.c | 10 +- src/xine-engine/xine_internal.h | 4 +- 11 files changed, 280 insertions(+), 211 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 83e44da2c..b7f97f5fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,7 +40,8 @@ SUBDIRS = \ libw32dll \ liblpcm \ libxinevdec \ - libxineadec + libxineadec \ + libvorbis debug: @list='$(SUBDIRS)'; for subdir in $$list; do \ diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am index eedf2a462..2941f9dd3 100644 --- a/src/demuxers/Makefile.am +++ b/src/demuxers/Makefile.am @@ -47,10 +47,10 @@ lib_LTLIBRARIES = $(ogg_module) $(asf_module) xineplug_dmx_avi.la\ xineplug_dmx_fli.la \ xineplug_dmx_wav.la -#xineplug_dmx_ogg_la_SOURCES = demux_ogg.c -#xineplug_dmx_ogg_la_LIBADD = $(OGG_LIBS) $(VORBIS_LIBS)\ -# $(top_builddir)/src/xine-engine/libxine.la -#xineplug_dmx_ogg_la_LDFLAGS = -avoid-version -module +xineplug_dmx_ogg_la_SOURCES = demux_ogg.c +xineplug_dmx_ogg_la_LIBADD = $(OGG_LIBS) $(VORBIS_LIBS)\ + $(top_builddir)/src/xine-engine/libxine.la +xineplug_dmx_ogg_la_LDFLAGS = -avoid-version -module xineplug_dmx_avi_la_SOURCES = demux_avi.c xineplug_dmx_avi_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index c06e373ff..f94a04c20 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.131 2002/10/27 00:01:14 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.132 2002/10/27 01:52:15 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -939,7 +939,6 @@ static int demux_mpeg_block_start (demux_plugin_t *this_gen, off_t start_pos, int start_time) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; - buf_element_t *buf; int err; int status; diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 7a349f1d5..42a7bc03b 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.47 2002/10/26 22:00:53 guenter Exp $ + * $Id: demux_ogg.c,v 1.48 2002/10/27 01:52:15 guenter Exp $ * * demultiplexer for ogg streams * @@ -62,8 +62,6 @@ #define WRAP_THRESHOLD 220000 -#define VALID_ENDS "ogg,ogm" - typedef struct dsogg_video_header_s { int32_t width; int32_t height; @@ -100,10 +98,8 @@ typedef struct { typedef struct demux_ogg_s { demux_plugin_t demux_plugin; - xine_t *xine; + xine_stream_t *stream; - config_values_t *config; - fifo_buffer_t *audio_fifo; fifo_buffer_t *video_fifo; @@ -138,10 +134,21 @@ typedef struct demux_ogg_s { int send_newpts; int buf_flag_seek; int keyframe_needed; + int ignore_keyframes; } demux_ogg_t ; +typedef struct { + + demux_class_t demux_class; + + /* class-wide, global variables here */ + + xine_t *xine; + config_values_t *config; +} demux_ogg_class_t; + static void hex_dump (uint8_t *p, int length) { int i,j; unsigned char c; @@ -170,10 +177,10 @@ static void check_newpts (demux_ogg_t *this, int64_t pts, int video, int preview printf ("demux_ogg: diff=%lld\n", diff); if (this->buf_flag_seek) { - xine_demux_control_newpts(this->xine, pts, BUF_FLAG_SEEK); + xine_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK); this->buf_flag_seek = 0; } else { - xine_demux_control_newpts(this->xine, pts, 0); + xine_demux_control_newpts(this->stream, pts, 0); } this->send_newpts = 0; this->last_pts[1-video] = 0; @@ -312,7 +319,7 @@ static void send_ogg_buf (demux_ogg_t *this, } /* - * interpret strea start packages, send headers + * interpret stream start packages, send headers */ static void demux_ogg_send_header (demux_ogg_t *this) { @@ -327,9 +334,11 @@ static void demux_ogg_send_header (demux_ogg_t *this) { ogg_packet op; #ifdef LOG - printf ("demux_ogg: detecting stream types...\n"); + printf ("demux_ogg: detecting stream types...\n"); #endif + this->ignore_keyframes = 0; + while (!done) { int ret = ogg_sync_pageout(&this->oy,&this->og); @@ -395,9 +404,9 @@ static void demux_ogg_send_header (demux_ogg_t *this) { vorbis_comment_init(&vc); if (vorbis_synthesis_headerin(&vi, &vc, &op) >= 0) { - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] = vi.bitrate_nominal; - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = vi.rate; this->samplerate[stream_num] = vi.rate; @@ -410,7 +419,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_MSG, + xine_log (this->stream->xine, XINE_LOG_MSG, _("ogg: vorbis audio track indicated but no vorbis stream header found.\n")); } @@ -469,11 +478,11 @@ static void demux_ogg_send_header (demux_ogg_t *this) { * video metadata */ - this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] + this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = oggh->hubba.video.width; - this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] + this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = oggh->hubba.video.height; - this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] + this->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = this->frame_duration; this->avg_bitrate += 500000; /* FIXME */ @@ -549,13 +558,13 @@ static void demux_ogg_send_header (demux_ogg_t *this) { * audio metadata */ - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = oggh->hubba.audio.channels; - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITS] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = oggh->bits_per_sample; - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = oggh->samples_per_unit; - this->xine->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] = oggh->hubba.audio.avgbytespersec*8; } else /* no audio_fifo there */ @@ -624,15 +633,17 @@ static void demux_ogg_send_header (demux_ogg_t *this) { * video metadata */ - this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] + this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = bih.biWidth; - this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] + this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = bih.biHeight; - this->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] + this->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = this->frame_duration; this->avg_bitrate += 500000; /* FIXME */ + this->ignore_keyframes = 1; + } else if (*(int32_t*)op.packet+96 == 0x05589F81) { #if 0 @@ -781,16 +792,18 @@ static void demux_ogg_send_content (demux_ogg_t *this) { continue; } - if (this->keyframe_needed) { -// printf ("keyframe needed...\n"); + if (!this->ignore_keyframes && this->keyframe_needed) { +#ifdef LOG + printf ("demux_ogg: keyframe needed... buf_type=%08x\n", this->buf_types[stream_num]); +#endif if (((this->buf_types[stream_num] & 0xFF000000) == BUF_VIDEO_BASE) && (*op.packet == PACKET_IS_SYNCPOINT)) { -/* - printf("keyframe: l%ld b%ld e%ld g%ld p%ld str%d\n", + /* + printf("keyframe: l%ld b%ld e%ld g%ld p%ld str%d\n", op.bytes,op.b_o_s,op.e_o_s,(long) op.granulepos, (long) op.packetno,stream_num); - hex_dump (op.packet, op.bytes); -*/ + hex_dump (op.packet, op.bytes); + */ this->keyframe_needed = 0; } else continue; } @@ -845,7 +858,7 @@ static void *demux_ogg_loop (void *this_gen) { #ifdef LOG printf ("demux_ogg: sending end buffers\n"); #endif - xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM); + xine_demux_control_end(this->stream, BUF_FLAG_END_STREAM); } else { #ifdef LOG printf ("demux_ogg: not sending end buffers\n"); @@ -867,8 +880,10 @@ static void *demux_ogg_loop (void *this_gen) { static void demux_ogg_dispose (demux_plugin_t *this_gen) { demux_ogg_t *this = (demux_ogg_t *) this_gen; + + demux_ogg_stop (this_gen); + free (this); - } static void demux_ogg_stop (demux_plugin_t *this_gen) { @@ -892,9 +907,9 @@ static void demux_ogg_stop (demux_plugin_t *this_gen) { pthread_mutex_unlock( &this->mutex ); pthread_join (this->thread, &p); - xine_demux_flush_engine(this->xine); + xine_demux_flush_engine(this->stream); - xine_demux_control_end(this->xine, BUF_FLAG_END_USER); + xine_demux_control_end(this->stream, BUF_FLAG_END_USER); } static int demux_ogg_get_status (demux_plugin_t *this_gen) { @@ -903,12 +918,14 @@ static int demux_ogg_get_status (demux_plugin_t *this_gen) { return this->status; } -static int send_headers (demux_ogg_t *this) { +static void demux_ogg_send_headers (demux_plugin_t *this_gen) { + + demux_ogg_t *this = (demux_ogg_t *) this_gen; pthread_mutex_lock( &this->mutex ); - this->video_fifo = this->xine->video_fifo; - this->audio_fifo = this->xine->audio_fifo; + this->video_fifo = this->stream->video_fifo; + this->audio_fifo = this->stream->audio_fifo; this->status = DEMUX_OK; @@ -916,46 +933,38 @@ static int send_headers (demux_ogg_t *this) { * send start buffers */ - if( !this->thread_running ) { -` - this->last_pts[0] = 0; - this->last_pts[1] = 0; + this->last_pts[0] = 0; + this->last_pts[1] = 0; - /* - * initialize ogg engine - */ - ogg_sync_init(&this->oy); - - this->num_streams = 0; - this->num_audio_streams = 0; - this->num_video_streams = 0; - this->avg_bitrate = 1; - - this->input->seek (this->input, 0, SEEK_SET); - } - - if( !this->thread_running && (this->status == DEMUX_OK) ) { - xine_demux_control_start(this->xine); - } else { - xine_demux_flush_engine(this->xine); - } + /* + * initialize ogg engine + */ + ogg_sync_init(&this->oy); + + this->num_streams = 0; + this->num_audio_streams = 0; + this->num_video_streams = 0; + this->avg_bitrate = 1; + + this->input->seek (this->input, 0, SEEK_SET); if (this->status == DEMUX_OK) { + xine_demux_control_start(this->stream); /* send header */ demux_ogg_send_header (this); - xine_demux_control_headers_done (this->xine); - - +#ifdef LOG printf ("demux_ogg: headers sent, avg bitrate is %lld\n", this->avg_bitrate); - - pthread_mutex_unlock (&this->mutex); - return DEMUX_CAN_HANDLE; +#endif } + this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = this->num_video_streams>0; + this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = this->num_audio_streams>0; + + xine_demux_control_headers_done (this->stream); + pthread_mutex_unlock (&this->mutex); - return DEMUX_CANNOT_HANDLE; } static int demux_ogg_start (demux_plugin_t *this_gen, @@ -1010,7 +1019,7 @@ static int demux_ogg_start (demux_plugin_t *this_gen, } } else { this->buf_flag_seek = 1; - xine_demux_flush_engine(this->xine); + xine_demux_flush_engine(this->stream); err = 0; } @@ -1026,126 +1035,145 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, return demux_ogg_start (this_gen, start_pos, start_time); } -static int demux_ogg_open(demux_plugin_t *this_gen, - input_plugin_t *input, int stage) { +static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) { - demux_ogg_t *this = (demux_ogg_t *) this_gen; + demux_ogg_t *this = (demux_ogg_t *) this_gen; - switch(stage) { + if (this->avg_bitrate) + return this->input->get_length (this->input) * 8 / this->avg_bitrate; + else + return 0; +} - case STAGE_BY_CONTENT: +static demux_plugin_t *open_plugin (demux_class_t *class_gen, + xine_stream_t *stream, + input_plugin_t *input) { + + demux_ogg_t *this; + + switch (stream->content_detection_method) { + + case METHOD_BY_CONTENT: { uint8_t buf[4096]; - if((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) { + if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) { input->seek(input, 0, SEEK_SET); if (input->read(input, buf, 4)) { - if ((buf[0] == 'O') - && (buf[1] == 'g') - && (buf[2] == 'g') - && (buf[3] == 'S')) { - this->input = input; - return send_headers(this); - } - } - } - - if (input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW)) { - if ((buf[0] == 'O') - && (buf[1] == 'g') - && (buf[2] == 'g') - && (buf[3] == 'S')) { - this->input = input; - return send_headers(this); + if ((buf[0] != 'O') + || (buf[1] != 'g') + || (buf[2] != 'g') + || (buf[3] != 'S')) + return NULL; } - } + } else if (input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW)) { + if ((buf[0] != 'O') + || (buf[1] != 'g') + || (buf[2] != 'g') + || (buf[3] != 'S')) + return NULL; + } else + return NULL; } - return DEMUX_CANNOT_HANDLE; break; - case STAGE_BY_EXTENSION: { - char *ending; - char *MRL; - char *m, *valid_ends; + case METHOD_BY_EXTENSION: { + + char *ending, *mrl; - MRL = input->get_mrl (input); + mrl = input->get_mrl (input); /* - * check ending + * check extension */ - ending = strrchr(MRL, '.'); - - if(!ending) - return DEMUX_CANNOT_HANDLE; + ending = strrchr (mrl, '.'); - xine_strdupa(valid_ends, (this->config->register_string(this->config, - "mrl.ends_ogg", VALID_ENDS, - _("valid mrls ending for ogg demuxer"), - NULL, 20, NULL, NULL))); - while((m = xine_strsep(&valid_ends, ",")) != NULL) { + if (!ending) + return NULL; - while(*m == ' ' || *m == '\t') m++; - - if(!strcasecmp((ending + 1), m)) { - this->input = input; - return send_headers(this); - } + if (strncasecmp(ending, ".ogg", 4) && + strncasecmp(ending, ".ogm", 4)) { + return NULL; } + + } break; + default: + return NULL; } - return DEMUX_CANNOT_HANDLE; + /* + * if we reach this point, the input has been accepted. + */ + + this = xine_xmalloc (sizeof (demux_ogg_t)); + this->stream = stream; + this->input = input; + + this->demux_plugin.send_headers = demux_ogg_send_headers; + this->demux_plugin.start = demux_ogg_start; + this->demux_plugin.seek = demux_ogg_seek; + this->demux_plugin.stop = demux_ogg_stop; + this->demux_plugin.dispose = demux_ogg_dispose; + this->demux_plugin.get_status = demux_ogg_get_status; + this->demux_plugin.get_stream_length = demux_ogg_get_stream_length; + this->demux_plugin.demux_class = class_gen; + + this->status = DEMUX_FINISHED; + pthread_mutex_init( &this->mutex, NULL ); + + return &this->demux_plugin; } -static char *demux_ogg_get_id(void) { + + +/* + * ogg demuxer class + */ + +static char *get_description (demux_class_t *this_gen) { + return "OGG demux plugin"; +} + +static char *get_identifier (demux_class_t *this_gen) { return "OGG"; } -static char *demux_ogg_get_mimetypes(void) { +static char *get_extensions (demux_class_t *this_gen) { + return "ogg ogm"; +} + +static char *get_mimetypes (demux_class_t *this_gen) { return "audio/x-ogg: ogg: OggVorbis Audio;"; } -static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) { +static void class_dispose (demux_class_t *this_gen) { - demux_ogg_t *this = (demux_ogg_t *) this_gen; + demux_ogg_class_t *this = (demux_ogg_class_t *) this_gen; - if (this->avg_bitrate) - return this->input->get_length (this->input) * 8 / this->avg_bitrate; - else - return 0; + free (this); } -static void *init_demuxer_plugin (xine_t *xine, void *data) { - - demux_ogg_t *this; - - this = xine_xmalloc (sizeof (demux_ogg_t)); +static void *init_class (xine_t *xine, void *data) { + + demux_ogg_class_t *this; + + this = xine_xmalloc (sizeof (demux_ogg_class_t)); this->config = xine->config; this->xine = xine; - (void*) this->config->register_string(this->config, - "mrl.ends_ogg", VALID_ENDS, - _("valid mrls ending for ogg demuxer"), - NULL, 20, NULL, NULL); + this->demux_class.open_plugin = open_plugin; + this->demux_class.get_description = get_description; + this->demux_class.get_identifier = get_identifier; + this->demux_class.get_mimetypes = get_mimetypes; + this->demux_class.get_extensions = get_extensions; + this->demux_class.dispose = class_dispose; - this->demux_plugin.open = demux_ogg_open; - this->demux_plugin.start = demux_ogg_start; - this->demux_plugin.seek = demux_ogg_seek; - this->demux_plugin.stop = demux_ogg_stop; - 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; - this->demux_plugin.get_mimetypes = demux_ogg_get_mimetypes; - - this->status = DEMUX_FINISHED; - pthread_mutex_init( &this->mutex, NULL ); - return this; } @@ -1155,6 +1183,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, 11, "ogg", XINE_VERSION_CODE, NULL, init_demuxer_plugin }, + { PLUGIN_DEMUX, 14, "ogg", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_http.c b/src/input/input_http.c index c5fdb1aa4..2a9fc8993 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -331,7 +331,7 @@ static off_t http_plugin_read (input_plugin_t *this_gen, xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: EAGAIN\n")); continue; default: - xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error\n")); + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error %d\n"), errno); return 0; } } diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c index 28961844f..cceffc391 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.19 2002/09/18 00:51:34 guenter Exp $ + * $Id: xine_decoder.c,v 1.20 2002/10/27 01:52:15 guenter Exp $ * * (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine */ @@ -42,12 +42,15 @@ #define LOG */ +typedef struct { + audio_decoder_class_t decoder_class; +} vorbis_class_t; + typedef struct vorbis_decoder_s { audio_decoder_t audio_decoder; int64_t pts; - ao_instance_t *audio_out; int output_sampling_rate; int output_open; int output_mode; @@ -63,7 +66,7 @@ typedef struct vorbis_decoder_s { int header_count; - xine_t *xine; + xine_stream_t *stream; } vorbis_decoder_t; @@ -76,24 +79,6 @@ static void vorbis_reset (audio_decoder_t *this_gen) { vorbis_block_init(&this->vd,&this->vb); } -static void vorbis_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { - - vorbis_decoder_t *this = (vorbis_decoder_t *) this_gen; - - this->audio_out = audio_out; - this->output_open = 0; - this->header_count = 3; - this->convsize = 0; - - vorbis_info_init(&this->vi); - vorbis_comment_init(&this->vc); - -#ifdef LOG - printf ("libvorbis: init\n"); -#endif - -} - /* Known vorbis comment keys from ogg123 sources*/ static struct { char *key; /* includes the '=' for programming convenience */ @@ -130,7 +115,7 @@ static void get_metadata (vorbis_decoder_t *this) { i, vorbis_comment_keys[i].xine_metainfo_index); #endif - this->xine->meta_info[vorbis_comment_keys[i].xine_metainfo_index] + this->stream->meta_info[vorbis_comment_keys[i].xine_metainfo_index] = strdup (comment + strlen(vorbis_comment_keys[i].key)); } @@ -138,7 +123,7 @@ static void get_metadata (vorbis_decoder_t *this) { ++ptr; } - this->xine->meta_info[XINE_META_INFO_AUDIOCODEC] = strdup ("vorbis"); + this->stream->meta_info[XINE_META_INFO_AUDIOCODEC] = strdup ("vorbis"); } static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { @@ -153,7 +138,7 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (buf->decoder_flags & BUF_FLAG_PREVIEW) { #ifdef LOG - printf ("libvorbis: preview buffer\n"); + printf ("libvorbis: preview buffer, %d headers to go\n", this->header_count); #endif if (this->header_count) { @@ -197,10 +182,13 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->convsize=MAX_NUM_SAMPLES/this->vi.channels; if (!this->output_open) { - this->output_open = this->audio_out->open(this->audio_out, + this->output_open = this->stream->audio_out->open(this->stream->audio_out, 16, this->vi.rate, mode) ; + + this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE]=this->vi.bitrate_nominal; + } vorbis_synthesis_init(&this->vd,&this->vi); @@ -223,7 +211,7 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { int bout=(samplesconvsize?samples:this->convsize); audio_buffer_t *audio_buffer; - audio_buffer = this->audio_out->get_buffer (this->audio_out); + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); /* convert floats to 16 bit signed ints (host order) and interleave */ @@ -249,15 +237,20 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { audio_buffer->vpts = buf->pts; audio_buffer->num_frames = bout; - this->audio_out->put_buffer (this->audio_out, audio_buffer); + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer); buf->pts=0; vorbis_synthesis_read(&this->vd,bout); } - } + } +#ifdef LOG + else + printf ("libvorbis: output not open\n"); + +#endif } -static void vorbis_close (audio_decoder_t *this_gen) { +static void vorbis_dispose (audio_decoder_t *this_gen) { vorbis_decoder_t *this = (vorbis_decoder_t *) this_gen; @@ -267,34 +260,63 @@ static void vorbis_close (audio_decoder_t *this_gen) { vorbis_info_clear(&this->vi); /* must be called last */ if (this->output_open) - this->audio_out->close (this->audio_out); -} - -static char *vorbis_get_id(void) { - return "vorbis"; -} + this->stream->audio_out->close (this->stream->audio_out); -static void vorbis_dispose (audio_decoder_t *this_gen) { free (this_gen); } -static void *init_audio_decoder_plugin (xine_t *xine, void *data) { +static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, + xine_stream_t *stream) { vorbis_decoder_t *this ; this = (vorbis_decoder_t *) malloc (sizeof (vorbis_decoder_t)); - this->audio_decoder.init = vorbis_init; this->audio_decoder.decode_data = vorbis_decode_data; this->audio_decoder.reset = vorbis_reset; - this->audio_decoder.close = vorbis_close; - this->audio_decoder.get_identifier = vorbis_get_id; this->audio_decoder.dispose = vorbis_dispose; - this->xine = xine; - + this->stream = stream; + + this->output_open = 0; + this->header_count = 3; + this->convsize = 0; + + vorbis_info_init(&this->vi); + vorbis_comment_init(&this->vc); + return (audio_decoder_t *) this; } +/* + * vorbis plugin class + */ + +static char *get_identifier (audio_decoder_class_t *this) { + return "vorbis"; +} + +static char *get_description (audio_decoder_class_t *this) { + return "vorbis audio decoder plugin"; +} + +static void dispose_class (audio_decoder_class_t *this) { + free (this); +} + +static void *init_plugin (xine_t *xine, void *data) { + + vorbis_class_t *this; + + this = (vorbis_class_t *) malloc (sizeof (vorbis_class_t)); + + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; + + return this; +} + static uint32_t audio_types[] = { BUF_AUDIO_VORBIS, 0 }; @@ -306,6 +328,6 @@ static decoder_info_t dec_info_audio = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_DECODER, 9, "vorbis", XINE_VERSION_CODE, &dec_info_audio, init_audio_decoder_plugin }, + { PLUGIN_AUDIO_DECODER, 10, "vorbis", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 4b0e423b4..71d7a8750 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.106 2002/10/26 16:16:04 mroi Exp $ + * $Id: load_plugins.c,v 1.107 2002/10/27 01:52:15 guenter Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -129,8 +129,9 @@ static void _insert_plugin (xine_t *this, int i; if (info->API != api_version) { - printf ("load_plugins: ignoring plugin %s, wrong iface version %d (should be %d)\n", - info->id, info->API, api_version); + if (this->verbosity) + printf ("load_plugins: ignoring plugin %s, wrong iface version %d (should be %d)\n", + info->id, info->API, api_version); return; } @@ -246,14 +247,13 @@ static void collect_plugins(xine_t *this, char *path){ if(!(lib = dlopen (str, RTLD_LAZY | RTLD_GLOBAL))) { -/*#ifdef LOG*/ - { + + if (this->verbosity) { char *dl_error_msg = dlerror(); /* too noisy -- but good to catch unresolved references */ printf ("load_plugins: cannot open plugin lib %s:\n%s\n", str, dl_error_msg); } -/*#endif*/ } else { @@ -1109,7 +1109,9 @@ video_decoder_t *get_video_decoder (xine_stream_t *stream, uint8_t stream_type) if (!node->plugin_class) { /* remove non working plugin from catalog */ - printf("load_plugins: plugin %s failed to init its class.\n", node->info->id); + if (stream->xine->verbosity) + printf("load_plugins: plugin %s failed to init its class.\n", + node->info->id); for (j = i + 1; j < PLUGINS_PER_TYPE; j++) catalog->video_decoder_map[stream_type][j - 1] = catalog->video_decoder_map[stream_type][j]; diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index a7dcddfdf..90915ef3d 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.104 2002/10/26 02:12:27 jcdutton Exp $ + * $Id: video_decoder.c,v 1.105 2002/10/27 01:52:15 guenter Exp $ * */ @@ -183,8 +183,10 @@ void *video_decoder_loop (void *stream_gen) { stream->finished_count_video++; +#ifdef LOG printf ("video_decoder: reached end marker # %d\n", stream->finished_count_video); +#endif pthread_cond_broadcast (&stream->counter_changed); @@ -229,7 +231,9 @@ void *video_decoder_loop (void *stream_gen) { break; case BUF_CONTROL_DISCONTINUITY: +#ifdef LOG printf ("video_decoder: discontinuity ahead\n"); +#endif stream->video_in_discontinuity = 1; @@ -239,7 +243,9 @@ void *video_decoder_loop (void *stream_gen) { break; case BUF_CONTROL_NEWPTS: +#ifdef LOG printf ("video_decoder: new pts %lld\n", buf->disc_off); +#endif stream->video_in_discontinuity = 1; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 90afd3f0a..a4560e658 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.176 2002/10/26 22:08:08 guenter Exp $ + * $Id: xine.c,v 1.177 2002/10/27 01:52:15 guenter Exp $ * * top-level xine functions * @@ -606,7 +606,8 @@ xine_t *xine_new (void) { printf ("xine: failed to malloc xine_t\n"); abort(); } - + + this->verbosity = 0; #ifdef ENABLE_NLS /* @@ -875,11 +876,13 @@ void xine_log (xine_t *this, int buf, const char *format, ...) { this->log_buffers[buf]->scratch_printf (this->log_buffers[buf], format, argp); va_end (argp); - va_start (argp, format); + if (this->verbosity) { + va_start (argp, format); - vprintf (format, argp); + vprintf (format, argp); - va_end (argp); + va_end (argp); + } } const char *const *xine_get_log (xine_t *this, int buf) { diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 3f6017947..534674990 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.25 2002/10/24 19:37:29 guenter Exp $ + * $Id: xine_interface.c,v 1.26 2002/10/27 01:52:15 guenter Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -357,6 +357,9 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { stream->audio_out->set_property (stream->audio_out, AO_PROP_COMPRESSOR, value); break; + case XINE_PARAM_VERBOSITY: + stream->xine->verbosity = value; + case XINE_PARAM_VO_DEINTERLACE: case XINE_PARAM_VO_ASPECT_RATIO: case XINE_PARAM_VO_HUE: @@ -408,6 +411,9 @@ int xine_get_param (xine_stream_t *stream, int param) { return -1; return stream->audio_out->get_property (stream->audio_out, AO_PROP_COMPRESSOR); + case XINE_PARAM_VERBOSITY: + return stream->xine->verbosity; + case XINE_PARAM_VO_DEINTERLACE: case XINE_PARAM_VO_ASPECT_RATIO: case XINE_PARAM_VO_HUE: @@ -420,7 +426,7 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_VO_TVMODE: return stream->video_driver->get_property(stream->video_driver, param & 0xffffff); break; - + default: printf ("xine_interface: unknown param %d\n", param); } diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index bf5ffe6d3..74f0a1db2 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.106 2002/10/23 21:52:16 guenter Exp $ + * $Id: xine_internal.h,v 1.107 2002/10/27 01:52:15 guenter Exp $ * */ @@ -104,6 +104,8 @@ struct xine_s { /* log output that may be presented to the user */ scratch_buffer_t *log_buffers[XINE_LOG_NUM]; + int verbosity; + xine_list_t *streams; pthread_mutex_t streams_lock; }; -- cgit v1.2.3