hook up our debug system
authorThomas Vander Stichele <thomas@apestaart.org>
Wed, 7 Jul 2004 15:12:02 +0000 (15:12 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Wed, 7 Jul 2004 15:12:02 +0000 (15:12 +0000)
Original commit message from CVS:
hook up our debug system

ChangeLog
common
ext/ffmpeg/gstffmpeg.c
ext/ffmpeg/gstffmpegcodecmap.h
ext/ffmpeg/gstffmpegdec.c

index a931181..44dbf8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,16 @@
+2004-07-07  Thomas Vander Stichele  <thomas (at) apestaart (dot) org>
+
+       * 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  <thomas at apestaart dot org>
 
        * 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  <rbultje@ronald.bitfreak.net>
 
diff --git a/common b/common
index 1af22af..59a2885 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1af22afdec71295108f882c828e08f10d8a3e94b
+Subproject commit 59a2885f01e3092ffaefbed270f331c143b16d6b
index a0fd865..545b2b3 100644 (file)
@@ -33,6 +33,9 @@
 #include <ffmpeg/avformat.h>
 #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/")
+
+
index 49fc922..473dfb2 100644 (file)
@@ -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__ */
+
index df86a38..1ea0de4 100644 (file)
@@ -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;