Path: blob/master/dep/ffmpeg/include/libavcodec/mediacodec.h
4216 views
/*1* Android MediaCodec public API2*3* Copyright (c) 2016 Matthieu Bouron <matthieu.bouron stupeflix.com>4*5* This file is part of FFmpeg.6*7* FFmpeg is free software; you can redistribute it and/or8* modify it under the terms of the GNU Lesser General Public9* License as published by the Free Software Foundation; either10* version 2.1 of the License, or (at your option) any later version.11*12* FFmpeg is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15* Lesser General Public License for more details.16*17* You should have received a copy of the GNU Lesser General Public18* License along with FFmpeg; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20*/2122#ifndef AVCODEC_MEDIACODEC_H23#define AVCODEC_MEDIACODEC_H2425#include "libavcodec/avcodec.h"2627/**28* This structure holds a reference to a android/view/Surface object that will29* be used as output by the decoder.30*31*/32typedef struct AVMediaCodecContext {3334/**35* android/view/Surface object reference.36*/37void *surface;3839} AVMediaCodecContext;4041/**42* Allocate and initialize a MediaCodec context.43*44* When decoding with MediaCodec is finished, the caller must free the45* MediaCodec context with av_mediacodec_default_free.46*47* @return a pointer to a newly allocated AVMediaCodecContext on success, NULL otherwise48*/49AVMediaCodecContext *av_mediacodec_alloc_context(void);5051/**52* Convenience function that sets up the MediaCodec context.53*54* @param avctx codec context55* @param ctx MediaCodec context to initialize56* @param surface reference to an android/view/Surface57* @return 0 on success, < 0 otherwise58*/59int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx, void *surface);6061/**62* This function must be called to free the MediaCodec context initialized with63* av_mediacodec_default_init().64*65* @param avctx codec context66*/67void av_mediacodec_default_free(AVCodecContext *avctx);6869/**70* Opaque structure representing a MediaCodec buffer to render.71*/72typedef struct MediaCodecBuffer AVMediaCodecBuffer;7374/**75* Release a MediaCodec buffer and render it to the surface that is associated76* with the decoder. This function should only be called once on a given77* buffer, once released the underlying buffer returns to the codec, thus78* subsequent calls to this function will have no effect.79*80* @param buffer the buffer to render81* @param render 1 to release and render the buffer to the surface or 0 to82* discard the buffer83* @return 0 on success, < 0 otherwise84*/85int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);8687/**88* Release a MediaCodec buffer and render it at the given time to the surface89* that is associated with the decoder. The timestamp must be within one second90* of the current `java/lang/System#nanoTime()` (which is implemented using91* `CLOCK_MONOTONIC` on Android). See the Android MediaCodec documentation92* of [`android/media/MediaCodec#releaseOutputBuffer(int,long)`][0] for more details.93*94* @param buffer the buffer to render95* @param time timestamp in nanoseconds of when to render the buffer96* @return 0 on success, < 0 otherwise97*98* [0]: https://developer.android.com/reference/android/media/MediaCodec#releaseOutputBuffer(int,%20long)99*/100int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time);101102#endif /* AVCODEC_MEDIACODEC_H */103104105