avformat/mux: Add flag for "only default codecs allowed"
AVOutputFormat has default codecs for audio, video and subtitle and often these are the only codecs of this type allowed. So add a flag to AVOutputFormat so that this can be checked generically. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -268,7 +268,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (of->flags_internal & FF_OFMT_FLAG_MAX_ONE_OF_EACH) {
|
||||
if (of->flags_internal & (FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS)) {
|
||||
enum AVCodecID default_codec_id = AV_CODEC_ID_NONE;
|
||||
unsigned nb;
|
||||
if ((unsigned)par->codec_type < FF_ARRAY_ELEMS(default_codec_offsets)) {
|
||||
@@ -276,7 +276,14 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
|
||||
if (default_codec_offsets[par->codec_type])
|
||||
default_codec_id = *(const enum AVCodecID*)((const char*)of + default_codec_offsets[par->codec_type]);
|
||||
}
|
||||
if (default_codec_id == AV_CODEC_ID_NONE || nb > 1) {
|
||||
if (of->flags_internal & FF_OFMT_FLAG_ONLY_DEFAULT_CODECS &&
|
||||
default_codec_id != AV_CODEC_ID_NONE && par->codec_id != default_codec_id) {
|
||||
av_log(s, AV_LOG_ERROR, "%s muxer supports only codec %s for type %s\n",
|
||||
of->p.name, avcodec_get_name(default_codec_id), av_get_media_type_string(par->codec_type));
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
} else if (default_codec_id == AV_CODEC_ID_NONE ||
|
||||
(of->flags_internal & FF_OFMT_FLAG_MAX_ONE_OF_EACH && nb > 1)) {
|
||||
const char *type = av_get_media_type_string(par->codec_type);
|
||||
av_log(s, AV_LOG_ERROR, "%s muxer does not support %s stream of type %s\n",
|
||||
of->p.name, default_codec_id == AV_CODEC_ID_NONE ? "any" : "more than one",
|
||||
|
||||
Reference in New Issue
Block a user