mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Print when frame is rendered in EventLogger + tidying
This is the boring part of a larger change that fixes how video renderers behave when surfaces are attached and detached whilst they're enabled or started. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151563031
This commit is contained in:
parent
68b8a5e542
commit
9bc20d23a8
3 changed files with 35 additions and 35 deletions
|
|
@ -281,7 +281,7 @@ import java.util.Locale;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderedFirstFrame(Surface surface) {
|
public void onRenderedFirstFrame(Surface surface) {
|
||||||
// Do nothing.
|
Log.d(TAG, "renderedFirstFrame [" + surface + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultDrmSessionManager.EventListener
|
// DefaultDrmSessionManager.EventListener
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,8 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
|
|
||||||
private boolean inputStreamEnded;
|
private boolean inputStreamEnded;
|
||||||
private boolean outputStreamEnded;
|
private boolean outputStreamEnded;
|
||||||
private int lastReportedWidth;
|
private int reportedWidth;
|
||||||
private int lastReportedHeight;
|
private int reportedHeight;
|
||||||
|
|
||||||
private long droppedFrameAccumulationStartTimeMs;
|
private long droppedFrameAccumulationStartTimeMs;
|
||||||
private int droppedFrames;
|
private int droppedFrames;
|
||||||
|
|
@ -147,8 +147,8 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
|
this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
|
||||||
this.drmSessionManager = drmSessionManager;
|
this.drmSessionManager = drmSessionManager;
|
||||||
this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
|
this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
|
||||||
joiningDeadlineMs = -1;
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
clearLastReportedVideoSize();
|
clearReportedVideoSize();
|
||||||
formatHolder = new FormatHolder();
|
formatHolder = new FormatHolder();
|
||||||
flagsOnlyBuffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
|
flagsOnlyBuffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
|
||||||
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
||||||
|
|
@ -259,7 +259,7 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
|
|
||||||
// Drop the frame if we're joining and are more than 30ms late, or if we have the next frame
|
// 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.
|
// and that's also late. Else we'll render what we have.
|
||||||
if ((joiningDeadlineMs != -1 && outputBuffer.timeUs < positionUs - 30000)
|
if ((joiningDeadlineMs != C.TIME_UNSET && outputBuffer.timeUs < positionUs - 30000)
|
||||||
|| (nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream()
|
|| (nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream()
|
||||||
&& nextOutputBuffer.timeUs < positionUs)) {
|
&& nextOutputBuffer.timeUs < positionUs)) {
|
||||||
decoderCounters.droppedOutputBufferCount++;
|
decoderCounters.droppedOutputBufferCount++;
|
||||||
|
|
@ -408,9 +408,9 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
if (format != null && (isSourceReady() || outputBuffer != null)
|
if (format != null && (isSourceReady() || outputBuffer != null)
|
||||||
&& (renderedFirstFrame || !isRendererAvailable())) {
|
&& (renderedFirstFrame || !isRendererAvailable())) {
|
||||||
// Ready. If we were joining then we've now joined, so clear the joining deadline.
|
// Ready. If we were joining then we've now joined, so clear the joining deadline.
|
||||||
joiningDeadlineMs = -1;
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
return true;
|
return true;
|
||||||
} else if (joiningDeadlineMs == -1) {
|
} else if (joiningDeadlineMs == C.TIME_UNSET) {
|
||||||
// Not joining.
|
// Not joining.
|
||||||
return false;
|
return false;
|
||||||
} else if (SystemClock.elapsedRealtime() < joiningDeadlineMs) {
|
} else if (SystemClock.elapsedRealtime() < joiningDeadlineMs) {
|
||||||
|
|
@ -418,7 +418,7 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// The joining deadline has been exceeded. Give up and clear the deadline.
|
// The joining deadline has been exceeded. Give up and clear the deadline.
|
||||||
joiningDeadlineMs = -1;
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -439,18 +439,18 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
flushDecoder();
|
flushDecoder();
|
||||||
}
|
}
|
||||||
joiningDeadlineMs = joining && allowedJoiningTimeMs > 0
|
joiningDeadlineMs = joining && allowedJoiningTimeMs > 0
|
||||||
? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) : -1;
|
? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) : C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStarted() {
|
protected void onStarted() {
|
||||||
droppedFrames = 0;
|
droppedFrames = 0;
|
||||||
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
|
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
|
||||||
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStopped() {
|
protected void onStopped() {
|
||||||
joiningDeadlineMs = -1;
|
|
||||||
maybeNotifyDroppedFrames();
|
maybeNotifyDroppedFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,7 +460,7 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
outputBuffer = null;
|
outputBuffer = null;
|
||||||
format = null;
|
format = null;
|
||||||
waitingForKeys = false;
|
waitingForKeys = false;
|
||||||
clearLastReportedVideoSize();
|
clearReportedVideoSize();
|
||||||
try {
|
try {
|
||||||
releaseDecoder();
|
releaseDecoder();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -540,7 +540,7 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
// Clear state so that we always call the event listener with the video size and when a frame
|
// Clear state so that we always call the event listener with the video size and when a frame
|
||||||
// is rendered, even if the output hasn't changed.
|
// is rendered, even if the output hasn't changed.
|
||||||
renderedFirstFrame = false;
|
renderedFirstFrame = false;
|
||||||
clearLastReportedVideoSize();
|
clearReportedVideoSize();
|
||||||
// We only need to update the decoder if the output has changed.
|
// We only need to update the decoder if the output has changed.
|
||||||
if (this.surface != surface || this.outputBufferRenderer != outputBufferRenderer) {
|
if (this.surface != surface || this.outputBufferRenderer != outputBufferRenderer) {
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
|
|
@ -565,15 +565,15 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
|
||||||
return surface != null || outputBufferRenderer != null;
|
return surface != null || outputBufferRenderer != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearLastReportedVideoSize() {
|
private void clearReportedVideoSize() {
|
||||||
lastReportedWidth = Format.NO_VALUE;
|
reportedWidth = Format.NO_VALUE;
|
||||||
lastReportedHeight = Format.NO_VALUE;
|
reportedHeight = Format.NO_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeNotifyVideoSizeChanged(int width, int height) {
|
private void maybeNotifyVideoSizeChanged(int width, int height) {
|
||||||
if (lastReportedWidth != width || lastReportedHeight != height) {
|
if (reportedWidth != width || reportedHeight != height) {
|
||||||
lastReportedWidth = width;
|
reportedWidth = width;
|
||||||
lastReportedHeight = height;
|
reportedHeight = height;
|
||||||
eventDispatcher.videoSizeChanged(width, height, 0, 1);
|
eventDispatcher.videoSizeChanged(width, height, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
private int currentHeight;
|
private int currentHeight;
|
||||||
private int currentUnappliedRotationDegrees;
|
private int currentUnappliedRotationDegrees;
|
||||||
private float currentPixelWidthHeightRatio;
|
private float currentPixelWidthHeightRatio;
|
||||||
private int lastReportedWidth;
|
private int reportedWidth;
|
||||||
private int lastReportedHeight;
|
private int reportedHeight;
|
||||||
private int lastReportedUnappliedRotationDegrees;
|
private int reportedUnappliedRotationDegrees;
|
||||||
private float lastReportedPixelWidthHeightRatio;
|
private float reportedPixelWidthHeightRatio;
|
||||||
|
|
||||||
private boolean tunneling;
|
private boolean tunneling;
|
||||||
private int tunnelingAudioSessionId;
|
private int tunnelingAudioSessionId;
|
||||||
|
|
@ -257,11 +257,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
super.onStarted();
|
super.onStarted();
|
||||||
droppedFrames = 0;
|
droppedFrames = 0;
|
||||||
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
|
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
|
||||||
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStopped() {
|
protected void onStopped() {
|
||||||
joiningDeadlineMs = C.TIME_UNSET;
|
|
||||||
maybeNotifyDroppedFrames();
|
maybeNotifyDroppedFrames();
|
||||||
super.onStopped();
|
super.onStopped();
|
||||||
}
|
}
|
||||||
|
|
@ -544,22 +544,22 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearLastReportedVideoSize() {
|
private void clearLastReportedVideoSize() {
|
||||||
lastReportedWidth = Format.NO_VALUE;
|
reportedWidth = Format.NO_VALUE;
|
||||||
lastReportedHeight = Format.NO_VALUE;
|
reportedHeight = Format.NO_VALUE;
|
||||||
lastReportedPixelWidthHeightRatio = Format.NO_VALUE;
|
reportedPixelWidthHeightRatio = Format.NO_VALUE;
|
||||||
lastReportedUnappliedRotationDegrees = Format.NO_VALUE;
|
reportedUnappliedRotationDegrees = Format.NO_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeNotifyVideoSizeChanged() {
|
private void maybeNotifyVideoSizeChanged() {
|
||||||
if (lastReportedWidth != currentWidth || lastReportedHeight != currentHeight
|
if (reportedWidth != currentWidth || reportedHeight != currentHeight
|
||||||
|| lastReportedUnappliedRotationDegrees != currentUnappliedRotationDegrees
|
|| reportedUnappliedRotationDegrees != currentUnappliedRotationDegrees
|
||||||
|| lastReportedPixelWidthHeightRatio != currentPixelWidthHeightRatio) {
|
|| reportedPixelWidthHeightRatio != currentPixelWidthHeightRatio) {
|
||||||
eventDispatcher.videoSizeChanged(currentWidth, currentHeight, currentUnappliedRotationDegrees,
|
eventDispatcher.videoSizeChanged(currentWidth, currentHeight, currentUnappliedRotationDegrees,
|
||||||
currentPixelWidthHeightRatio);
|
currentPixelWidthHeightRatio);
|
||||||
lastReportedWidth = currentWidth;
|
reportedWidth = currentWidth;
|
||||||
lastReportedHeight = currentHeight;
|
reportedHeight = currentHeight;
|
||||||
lastReportedUnappliedRotationDegrees = currentUnappliedRotationDegrees;
|
reportedUnappliedRotationDegrees = currentUnappliedRotationDegrees;
|
||||||
lastReportedPixelWidthHeightRatio = currentPixelWidthHeightRatio;
|
reportedPixelWidthHeightRatio = currentPixelWidthHeightRatio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue