Add release callback and reference count to java EncodedImage class

Callback set by HardwareVideoEncoder, and wired to the codec's
releaseOutputBuffer. Intention is to move call of this method to the
destructor of a corresponding C++ class in a followup cl, and
eliminate an allocation and memcpy in the process.

Bug: webrtc:9378
Change-Id: I578480b63b68e6ac7a96cdde36379b3c50f05c3f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/142160
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29283}
This commit is contained in:
Niels Möller
2019-09-23 12:47:16 +02:00
committed by Commit Bot
parent 1b575417b3
commit 67309ef93c
4 changed files with 117 additions and 10 deletions

View File

@ -238,8 +238,14 @@ public interface VideoEncoder {
public interface Callback {
/**
* Call to return an encoded frame. It is safe to assume the byte buffer held by |frame| is not
* accessed after the call to this method returns.
* Old encoders assume that the byte buffer held by |frame| is not accessed after the call to
* this method returns. If the pipeline downstream needs to hold on to the buffer, it then has
* to make its own copy. We want to move to a model where no copying is needed, and instead use
* retain()/release() to signal to the encoder when it is safe to reuse the buffer.
*
* Over the transition, implementations of this class should use the maybeRetain() method if
* they want to keep a reference to the buffer, and fall back to copying if that method returns
* false.
*/
void onEncodedFrame(EncodedImage frame, CodecSpecificInfo info);
}