Commit e452abc5 authored by Matthieu Bouron's avatar Matthieu Bouron

lavc/mediacodec: refactor ff_AMediaCodecList_getCodecByType

Allows to select a codec (encoder or decoder) only if it supports a
specific profile.

Adds ff_AMediaCodecProfile_getProfileFromAVCodecContext to convert an
AVCodecContext profile to a MediaCodec profile. It only supports H264
for now.

The codepath using MediaCodecList.findDecoderForFormat() (Android >= 5.0)
has been dropped as this method does not allow to select a decoder
compatible with a specific profile.
parent 5b95b461
This diff is collapsed.
...@@ -52,7 +52,9 @@ ...@@ -52,7 +52,9 @@
* *
*/ */
char *ff_AMediaCodecList_getCodecNameByType(const char *mime, void *log_ctx); int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx);
char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int encoder, void *log_ctx);
struct FFAMediaFormat; struct FFAMediaFormat;
typedef struct FFAMediaFormat FFAMediaFormat; typedef struct FFAMediaFormat FFAMediaFormat;
......
...@@ -308,10 +308,16 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, ...@@ -308,10 +308,16 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s,
{ {
int ret = 0; int ret = 0;
int status; int status;
int profile;
s->first_buffer_at = av_gettime(); s->first_buffer_at = av_gettime();
s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, avctx); profile = ff_AMediaCodecProfile_getProfileFromAVCodecContext(avctx);
if (profile < 0) {
av_log(avctx, AV_LOG_WARNING, "Unsupported or unknown profile");
}
s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, profile, 0, avctx);
if (!s->codec_name) { if (!s->codec_name) {
ret = AVERROR_EXTERNAL; ret = AVERROR_EXTERNAL;
goto fail; goto fail;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment