Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
api: add sxplayer_release_frame_mediacodec()
Browse files Browse the repository at this point in the history
  • Loading branch information
mbouron committed Nov 3, 2020
1 parent abc13b0 commit 98a5525
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sxplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,27 @@ void sxplayer_release_frame(struct sxplayer_frame *frame)
}
}

int sxplayer_release_frame_mediacodec(struct sxplayer_frame **framep)
{
#ifdef HAVE_MEDIACODEC_HWACCEL
if (!*framep)
return 0;
struct sxplayer_frame *frame = *framep;
av_assert0(frame->pix_fmt == SXPLAYER_PIXFMT_MEDIACODEC);
AVMediaCodecBuffer *buffer = (AVMediaCodecBuffer *)frame->data;
int ret = av_mediacodec_release_buffer(buffer, 1);
sxplayer_release_frame(frame);
*framep = NULL;
if (ret < 0) {
LOG(s, ERROR, "Failed to release MediaCodec buffer: %s", av_err2str(ret));
return -1;
}
return 0;
#else
av_assert0(0);
#endif
}

int sxplayer_set_drop_ref(struct sxplayer_ctx *s, int drop)
{
return -1; // TODO
Expand Down
15 changes: 15 additions & 0 deletions sxplayer.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,21 @@ int sxplayer_set_drop_ref(struct sxplayer_ctx *s, int drop);
/* Release a frame obtained with sxplayer_get_frame() */
void sxplayer_release_frame(struct sxplayer_frame *frame);

/**
* Render to surface and release a MediaCodec frame obtained with
* sxplayer_get_frame().
*
* @param framep the address of a sxplayer_frame pointer to be rendered
* and released
*
* Note: the sxplayer_frame is released even if the underlying MediaCodec
* failed to be rendered.
*
* Return 0 on success, a negative value on error
*
*/
int sxplayer_release_frame_mediacodec(struct sxplayer_frame **framep);

/* Close and free everything */
void sxplayer_free(struct sxplayer_ctx **ss);

Expand Down

0 comments on commit 98a5525

Please sign in to comment.