VideoFrameReleaseControl
@UnstableApi
public final class VideoFrameReleaseControl
Controls the releasing of video frames.
Summary
Nested types |
|---|
@DocumentedThe frame release action returned by |
public class VideoFrameReleaseControl.FrameReleaseInfoPer |
public interface VideoFrameReleaseControl.FrameTimingEvaluatorDecides whether a frame should be forced to be released, or dropped. |
Constants |
|
|---|---|
static final int |
Signals a frame should be dropped. |
static final int |
Signals that a frame should be ignored. |
static final int |
Signals a frame should be released immediately. |
static final int |
Signals a frame should be scheduled for release. |
static final int |
Signals that a frame should be skipped. |
static final int |
Signals that a frame should not be released and the caller should try again later. |
Public constructors |
|---|
VideoFrameReleaseControl(Creates an instance. |
Public methods |
|
|---|---|
void |
Allows the frame control to indicate the first frame can be released before this instance is started. |
int |
@VideoFrameReleaseControl.FrameReleaseActionReturns a |
boolean |
isReady(boolean otherwiseReady)Whether the release control is ready to start playback. |
void |
join(boolean renderNextFrameImmediately)Joins the release control to a new stream. |
boolean |
Called when a frame has been released. |
void |
Called when rendering starts. |
void |
Called when rendering stops. |
void |
onStreamChanged(Called when the stream changes. |
void |
reset()Resets the release control. |
void |
setChangeFrameRateStrategy(Changes the |
void |
Sets the clock that will be used. |
void |
setFrameRate(float frameRate)Sets the frame rate. |
void |
setOutputSurface(@Nullable Surface outputSurface)Called when the display surface changed. |
void |
setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)Sets the playback speed. |
Constants
FRAME_RELEASE_DROP
public static final int FRAME_RELEASE_DROP = 2
Signals a frame should be dropped.
FRAME_RELEASE_IGNORE
public static final int FRAME_RELEASE_IGNORE = 4
Signals that a frame should be ignored.
FRAME_RELEASE_IMMEDIATELY
public static final int FRAME_RELEASE_IMMEDIATELY = 0
Signals a frame should be released immediately.
FRAME_RELEASE_SCHEDULED
public static final int FRAME_RELEASE_SCHEDULED = 1
Signals a frame should be scheduled for release. The release timestamp will be returned by getReleaseTimeNs.
FRAME_RELEASE_SKIP
public static final int FRAME_RELEASE_SKIP = 3
Signals that a frame should be skipped.
FRAME_RELEASE_TRY_AGAIN_LATER
public static final int FRAME_RELEASE_TRY_AGAIN_LATER = 5
Signals that a frame should not be released and the caller should try again later.
Public constructors
VideoFrameReleaseControl
public VideoFrameReleaseControl(
Context applicationContext,
VideoFrameReleaseControl.FrameTimingEvaluator frameTimingEvaluator,
long allowedJoiningTimeMs
)
Creates an instance.
| Parameters | |
|---|---|
Context applicationContext |
The application context. |
VideoFrameReleaseControl.FrameTimingEvaluator frameTimingEvaluator |
The |
long allowedJoiningTimeMs |
The maximum duration in milliseconds for which the caller can attempt to seamlessly join an ongoing playback. |
Public methods
allowReleaseFirstFrameBeforeStarted
public void allowReleaseFirstFrameBeforeStarted()
Allows the frame control to indicate the first frame can be released before this instance is started.
getFrameReleaseAction
@VideoFrameReleaseControl.FrameReleaseAction
public int getFrameReleaseAction(
long presentationTimeUs,
long positionUs,
long elapsedRealtimeUs,
long outputStreamStartPositionUs,
boolean isDecodeOnlyFrame,
boolean isLastFrame,
VideoFrameReleaseControl.FrameReleaseInfo frameReleaseInfo
)
Returns a FrameReleaseAction for a video frame which instructs the caller what to do with the frame.
| Parameters | |
|---|---|
long presentationTimeUs |
The presentation time of the video frame, in microseconds. |
long positionUs |
The current playback position, in microseconds. |
long elapsedRealtimeUs |
|
long outputStreamStartPositionUs |
The stream's start position, in microseconds. |
boolean isDecodeOnlyFrame |
Whether the frame is decode-only because its presentation time is before the intended start time. |
boolean isLastFrame |
Whether the frame is known to contain the last frame of the current stream. |
VideoFrameReleaseControl.FrameReleaseInfo frameReleaseInfo |
A |
| Returns | |
|---|---|
int |
A |
isReady
public boolean isReady(boolean otherwiseReady)
Whether the release control is ready to start playback.
| Parameters | |
|---|---|
boolean otherwiseReady |
Whether the caller is ready except for the release control. |
| Returns | |
|---|---|
boolean |
Whether the release control is ready. |
join
public void join(boolean renderNextFrameImmediately)
Joins the release control to a new stream.
The release control will pretend to be ready for a short time even if the first frame hasn't been rendered yet to avoid interrupting an ongoing playback.
| Parameters | |
|---|---|
boolean renderNextFrameImmediately |
Whether the next frame should be released as soon as possible or only at its preferred scheduled release time. |
onFrameReleasedIsFirstFrame
public boolean onFrameReleasedIsFirstFrame()
Called when a frame has been released.
| Returns | |
|---|---|
boolean |
Whether this is the first released frame. |
onStreamChanged
public void onStreamChanged(
@VideoSink.FirstFrameReleaseInstruction int firstFrameReleaseInstruction
)
Called when the stream changes.
Must also be called for the first stream.
setChangeFrameRateStrategy
public void setChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy int changeFrameRateStrategy
)
Changes the C.VideoChangeFrameRateStrategy used when calling setFrameRate.
The default value is VIDEO_CHANGE_FRAME_RATE_STRATEGY_ONLY_IF_SEAMLESS.
setOutputSurface
public void setOutputSurface(@Nullable Surface outputSurface)
Called when the display surface changed.
setPlaybackSpeed
public void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)
Sets the playback speed.