This allows reporting missing features and requesting samples from
all libraries in a standard way; with a simplified API.
---
 libavcodec/avcodec.h |    2 ++
 libavcodec/utils.c   |    3 +++
 libavcodec/version.h |    3 +++
 libavutil/internal.h |   20 ++++++++++++++++++++
 libavutil/log.c      |   39 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8e89e1f..1160ded 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4147,6 +4147,7 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, 
size_t min_size);
  */
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
 
+#if FF_API_MISSING_SAMPLE
 /**
  * Log a generic warning message about a missing feature. This function is
  * intended to be used internally by Libav (libavcodec, libavformat, etc.)
@@ -4170,6 +4171,7 @@ void av_log_missing_feature(void *avc, const char 
*feature, int want_sample);
  * @param[in] msg string containing an optional message, or NULL if no message
  */
 void av_log_ask_for_sample(void *avc, const char *msg, ...) 
av_printf_format(2, 3);
+#endif /* FF_API_MISSING_SAMPLE */
 
 /**
  * Register the hardware accelerator hwaccel.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 13efea4..8b2ee1b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -42,6 +42,7 @@
 #include "thread.h"
 #include "internal.h"
 #include "bytestream.h"
+#include "version.h"
 #include <stdlib.h>
 #include <stdarg.h>
 #include <limits.h>
@@ -2031,6 +2032,7 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, 
int a, int b)
     return i;
 }
 
+#if FF_API_MISSING_SAMPLE
 void av_log_missing_feature(void *avc, const char *feature, int want_sample)
 {
     av_log(avc, AV_LOG_WARNING, "%s is not implemented. Update your Libav "
@@ -2055,6 +2057,7 @@ void av_log_ask_for_sample(void *avc, const char *msg, 
...)
 
     va_end(argument_list);
 }
+#endif /* FF_API_MISSING_SAMPLE */
 
 static AVHWAccel *first_hwaccel = NULL;
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 20d30ef..78d6b3a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -64,6 +64,9 @@
 #ifndef FF_API_IDCT
 #define FF_API_IDCT              (LIBAVCODEC_VERSION_MAJOR < 55)
 #endif
+#ifndef FF_API_MISSING_SAMPLE
+#define FF_API_MISSING_SAMPLE    (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
 #ifndef FF_API_DEINTERLACE
 #define FF_API_DEINTERLACE       (LIBAVCODEC_VERSION_MAJOR < 56)
 #endif
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 3cf55f6..2481a01 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -162,4 +162,24 @@
 #   define ONLY_IF_THREADS_ENABLED(x) NULL
 #endif
 
+/**
+ * Log a generic warning message about a missing feature.
+ *
+ * @param[in] avc a pointer to an arbitrary struct of which the first
+ *                field is a pointer to an AVClass struct
+ * @param[in] msg string containing the name of the missing feature
+ */
+void avpriv_report_missing_feature(void *avc,
+                                   const char *msg, ...) av_printf_format(2, 
3);
+
+/**
+ * Log a generic warning message asking for a sample.
+ *
+ * @param[in] avc a pointer to an arbitrary struct of which the first field is
+ *                a pointer to an AVClass struct
+ * @param[in] msg string containing the name of the missing feature
+ */
+void avpriv_request_sample(void *avc,
+                           const char *msg, ...) av_printf_format(2, 3);
+
 #endif /* AVUTIL_INTERNAL_H */
diff --git a/libavutil/log.c b/libavutil/log.c
index 8012976..bd46b0c 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -32,10 +32,12 @@
 #if HAVE_IO_H
 #include <io.h>
 #endif
+#include <stdarg.h>
 #include <stdlib.h>
 #include "avstring.h"
 #include "avutil.h"
 #include "common.h"
+#include "internal.h"
 #include "log.h"
 
 static int av_log_level = AV_LOG_INFO;
@@ -179,3 +181,40 @@ void av_log_set_callback(void (*callback)(void*, int, 
const char*, va_list))
 {
     av_log_callback = callback;
 }
+
+static void missing_feature_sample(int sample, void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+
+    av_vlog(avc, AV_LOG_WARNING, msg, argument_list);
+    av_log(avc, AV_LOG_WARNING, " is not implemented. Update your Libav "
+           "version to the newest one from Git. If the problem still "
+           "occurs, it means that your file has a feature which has not "
+           "been implemented.\n");
+    if (sample)
+        av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
+               "of this file to ftp://upload.libav.org/incoming/ "
+               "and contact the libav-devel mailing list.\n");
+
+    va_end(argument_list);
+}
+
+void avpriv_request_sample(void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+    missing_feature_sample(1, avc, msg, argument_list);
+    va_end(argument_list);
+}
+
+void avpriv_report_missing_feature(void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+    missing_feature_sample(0, avc, msg, argument_list);
+    va_end(argument_list);
+}
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to