mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Libvpx: configure a way in Medialib to drop frames instead of video lag.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=153858804
This commit is contained in:
parent
860eb26301
commit
e1c82fbb1a
1 changed files with 24 additions and 5 deletions
|
|
@ -262,11 +262,11 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the frame if we're joining and are more than 30ms late, or if we have the next frame
|
final long nextOutputBufferTimeUs =
|
||||||
// and that's also late. Else we'll render what we have.
|
nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream()
|
||||||
if ((joiningDeadlineMs != C.TIME_UNSET && outputBuffer.timeUs < positionUs - 30000)
|
? nextOutputBuffer.timeUs : C.TIME_UNSET;
|
||||||
|| (nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream()
|
if (shouldDropOutputBuffer(
|
||||||
&& nextOutputBuffer.timeUs < positionUs)) {
|
outputBuffer.timeUs, nextOutputBufferTimeUs, positionUs, joiningDeadlineMs)) {
|
||||||
dropBuffer();
|
dropBuffer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -280,6 +280,25 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the current frame should be dropped.
|
||||||
|
*
|
||||||
|
* @param outputBufferTimeUs The timestamp of the current output buffer.
|
||||||
|
* @param nextOutputBufferTimeUs The timestamp of the next output buffer or
|
||||||
|
* {@link TIME_UNSET} if the next output buffer is unavailable.
|
||||||
|
* @param positionUs The current playback position.
|
||||||
|
* @param joiningDeadlineMs The joining deadline.
|
||||||
|
* @return Returns whether to drop the current output buffer.
|
||||||
|
*/
|
||||||
|
protected boolean shouldDropOutputBuffer(long outputBufferTimeUs, long nextOutputBufferTimeUs,
|
||||||
|
long positionUs, long joiningDeadlineMs) {
|
||||||
|
// Drop the frame if we're joining and are more than 30ms late, or if we have the next frame
|
||||||
|
// and that's also late. Else we'll render what we have.
|
||||||
|
return (joiningDeadlineMs != C.TIME_UNSET && outputBufferTimeUs < positionUs - 30000)
|
||||||
|
|| (nextOutputBufferTimeUs != C.TIME_UNSET && nextOutputBufferTimeUs < positionUs);
|
||||||
|
}
|
||||||
|
|
||||||
private void renderBuffer() {
|
private void renderBuffer() {
|
||||||
int bufferMode = outputBuffer.mode;
|
int bufferMode = outputBuffer.mode;
|
||||||
boolean renderRgb = bufferMode == VpxDecoder.OUTPUT_MODE_RGB && surface != null;
|
boolean renderRgb = bufferMode == VpxDecoder.OUTPUT_MODE_RGB && surface != null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue