summaryrefslogtreecommitdiffstats
path: root/libavcodec/mediacodec.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-07-31 18:34:15 -0700
committerAman Gupta <aman@tmm1.net>2018-10-11 20:51:14 -0700
commitf6d48b618aadb7acea6539e3973c91e14164f531 (patch)
tree4c2bdc25c9dce6cf76c29b8054c296bd26824d32 /libavcodec/mediacodec.c
parente265832c378c3f4dc372f1c0f477810f63dd60fd (diff)
downloadffmpeg-streaming-f6d48b618aadb7acea6539e3973c91e14164f531.zip
ffmpeg-streaming-f6d48b618aadb7acea6539e3973c91e14164f531.tar.gz
avcodec/mediacodec: add av_mediacodec_render_buffer_at_time()
The existing av_mediacodec_release_buffer allows the user to render or discard the Surface-backed frame. This new method allows the user to control exactly when the frame will be rendered to its SurfaceView. Available since Android API 21. Signed-off-by: Aman Gupta <aman@tmm1.net>
Diffstat (limited to 'libavcodec/mediacodec.c')
-rw-r--r--libavcodec/mediacodec.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c
index b0aae43..aa14624 100644
--- a/libavcodec/mediacodec.c
+++ b/libavcodec/mediacodec.c
@@ -102,6 +102,22 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
return 0;
}
+int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time)
+{
+ MediaCodecDecContext *ctx = buffer->ctx;
+ int released = atomic_fetch_add(&buffer->released, 1);
+
+ if (!released && (ctx->delay_flush || buffer->serial == atomic_load(&ctx->serial))) {
+ atomic_fetch_sub(&ctx->hw_buffer_count, 1);
+ av_log(ctx->avctx, AV_LOG_DEBUG,
+ "Rendering output buffer %zd (%p) ts=%"PRId64" with time=%"PRId64" [%d pending]\n",
+ buffer->index, buffer, buffer->pts, time, atomic_load(&ctx->hw_buffer_count));
+ return ff_AMediaCodec_releaseOutputBufferAtTime(ctx->codec, buffer->index, time);
+ }
+
+ return 0;
+}
+
#else
#include <stdlib.h>
@@ -125,4 +141,9 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
return AVERROR(ENOSYS);
}
+int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time)
+{
+ return AVERROR(ENOSYS);
+}
+
#endif
OpenPOWER on IntegriCloud