summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-08-11 20:34:45 +0200
committerAnton Khirnov <anton@khirnov.net>2011-08-16 20:24:20 +0200
commit48f9e457ea0143e14b04f7ae9cc5358904f9475a (patch)
treebc39e61a4f1e3241c698221fcfbefcd2752e504a /libavformat
parentbca06e77e1b07f1dab04c3b9fef6fdcb62b4a401 (diff)
lavf: add avformat_query_codec().
It allows to check if a given codec can be written into a container.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h18
-rw-r--r--libavformat/utils.c14
2 files changed, 32 insertions, 0 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 957039f64e..2a00a9fea4 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -322,6 +322,14 @@ typedef struct AVOutputFormat {
const AVClass *priv_class; ///< AVClass for the private context
+ /**
+ * Test if the given codec can be stored in this container.
+ *
+ * @return 1 if the codec is supported, 0 if it is not.
+ * A negative number if unknown.
+ */
+ int (*query_codec)(enum CodecID id, int std_compliance);
+
/* private fields */
struct AVOutputFormat *next;
} AVOutputFormat;
@@ -1595,4 +1603,14 @@ attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char
*/
int av_match_ext(const char *filename, const char *extensions);
+/**
+ * Test if the given container can store a codec.
+ *
+ * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
+ *
+ * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
+ * A negative number if this information is not available.
+ */
+int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance);
+
#endif /* AVFORMAT_AVFORMAT_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b848ebb827..6e3cb2fa54 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3904,3 +3904,17 @@ int64_t ff_iso8601_to_unix_time(const char *datestr)
return 0;
#endif
}
+
+int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance)
+{
+ if (ofmt) {
+ if (ofmt->query_codec)
+ return ofmt->query_codec(codec_id, std_compliance);
+ else if (ofmt->codec_tag)
+ return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
+ else if (codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec ||
+ codec_id == ofmt->subtitle_codec)
+ return 1;
+ }
+ return AVERROR_PATCHWELCOME;
+}