From 71f892d3de61366d6bac72b7c9b4f4b262b66af9 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 7 Jul 2004 15:12:02 +0000 Subject: [PATCH] hook up our debug system Original commit message from CVS: hook up our debug system --- ChangeLog | 10 +++++++++- common | 2 +- ext/ffmpeg/gstffmpeg.c | 33 +++++++++++++++++++++++++++++++++ ext/ffmpeg/gstffmpegcodecmap.h | 7 +++++++ ext/ffmpeg/gstffmpegdec.c | 3 +++ 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a931181f67..44dbf8e6e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,16 @@ +2004-07-07 Thomas Vander Stichele + + * ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_log_callback), (plugin_init): + * ext/ffmpeg/gstffmpegcodecmap.h: + * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_chain): + hook up our debug handler to FFmpeg's. + warn about getting negative have_data + 2004-07-04 Thomas Vander Stichele * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_base_init): * ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_base_init): - bring category order in line with others + bring category order in line with others 2004-06-13 Ronald Bultje diff --git a/common b/common index 1af22afdec..59a2885f01 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 1af22afdec71295108f882c828e08f10d8a3e94b +Subproject commit 59a2885f01e3092ffaefbed270f331c143b16d6b diff --git a/ext/ffmpeg/gstffmpeg.c b/ext/ffmpeg/gstffmpeg.c index a0fd86581f..545b2b31f6 100644 --- a/ext/ffmpeg/gstffmpeg.c +++ b/ext/ffmpeg/gstffmpeg.c @@ -33,6 +33,9 @@ #include #endif +GST_DEBUG_CATEGORY_STATIC (ffmpeg_debug); +#define GST_CAT_DEFAULT ffmpeg_debug + extern gboolean gst_ffmpegdemux_register (GstPlugin * plugin); extern gboolean gst_ffmpegdec_register (GstPlugin * plugin); extern gboolean gst_ffmpegenc_register (GstPlugin * plugin); @@ -41,12 +44,40 @@ extern gboolean gst_ffmpegcsp_register (GstPlugin * plugin); extern URLProtocol gstreamer_protocol; +static void +gst_ffmpeg_log_callback (void * ptr, int level, const char * fmt, va_list vl) +{ + GstDebugLevel gst_level; + + switch (level) { + case AV_LOG_QUIET: + gst_level = GST_LEVEL_NONE; + break; + case AV_LOG_ERROR: + gst_level = GST_LEVEL_ERROR; + break; + case AV_LOG_INFO: + gst_level = GST_LEVEL_INFO; + break; + case AV_LOG_DEBUG: + gst_level = GST_LEVEL_DEBUG; + break; + default: + gst_level = GST_LEVEL_INFO; + break; + } + + gst_debug_log_valist (ffmpeg_debug, gst_level, "", "", 0, NULL, fmt, vl); +} + static gboolean plugin_init (GstPlugin * plugin) { if (!gst_library_load ("gstbytestream")) return FALSE; + GST_DEBUG_CATEGORY_INIT (ffmpeg_debug, "ffmpeg", 0, "FFmpeg elements"); + av_log_set_callback (gst_ffmpeg_log_callback); av_register_all (); gst_ffmpegenc_register (plugin); @@ -67,3 +98,5 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, "All FFMPEG codecs", plugin_init, FFMPEG_VERSION, "LGPL", "FFMpeg", "http://ffmpeg.sourceforge.net/") + + diff --git a/ext/ffmpeg/gstffmpegcodecmap.h b/ext/ffmpeg/gstffmpegcodecmap.h index 49fc922160..473dfb2562 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.h +++ b/ext/ffmpeg/gstffmpegcodecmap.h @@ -87,4 +87,11 @@ gst_ffmpeg_caps_with_codectype (enum CodecType type, GstCaps * gst_ffmpeg_formatid_to_caps (const gchar *format_name); + +/* FFMPEG debugging function; maybe move to a different file */ +GST_DEBUG_CATEGORY_EXTERN (ffmpeg_debug); +static void +gst_ffmpeg_log_callback (void * ptr, int level, const char * fmt, va_list vl); + #endif /* __GST_FFMPEG_CODECMAP_H__ */ + diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index df86a38ebf..1ea0de4853 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -433,6 +433,9 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data) outbuf = gst_buffer_new_and_alloc (AVCODEC_MAX_AUDIO_FRAME_SIZE); len = avcodec_decode_audio (ffmpegdec->context, (int16_t *) GST_BUFFER_DATA (outbuf), &have_data, data, size); + if (have_data < 0) + GST_WARNING_OBJECT (ffmpegdec, "len %d, have_data: %d < 0 !", + len, have_data); if (have_data) { GST_BUFFER_SIZE (outbuf) = have_data;