private static String getDecoderCountersBufferCountString(DecoderCounters counters) { if (counters == null) { return ""; } counters.ensureUpdated(); return " sib:" + counters.skippedInputBufferCount + " sb:" + counters.skippedOutputBufferCount + " rb:" + counters.renderedOutputBufferCount + " db:" + counters.droppedBufferCount + " mcdb:" + counters.maxConsecutiveDroppedBufferCount + " dk:" + counters.droppedToKeyframeCount; }
public static void assertSkippedOutputBufferCount(String name, DecoderCounters counters, int expected) { counters.ensureUpdated(); int actual = counters.skippedOutputBufferCount; TestCase.assertEquals("Codec(" + name + ") skipped " + actual + " buffers. Expected " + expected + ".", expected, actual); }
public static void assertTotalOutputBufferCount(String name, DecoderCounters counters, int minCount, int maxCount) { counters.ensureUpdated(); int actual = getTotalOutputBuffers(counters); TestCase.assertTrue("Codec(" + name + ") output " + actual + " buffers. Expected in range [" + minCount + ", " + maxCount + "].", minCount <= actual && actual <= maxCount); }
public static void assertDroppedOutputBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.droppedOutputBufferCount; TestCase.assertTrue("Codec(" + name + ") was late decoding: " + actual + " buffers. " + "Limit: " + limit + ".", actual <= limit); }
public static void assertConsecutiveDroppedOutputBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.maxConsecutiveDroppedOutputBufferCount; TestCase.assertTrue("Codec(" + name + ") was late decoding: " + actual + " buffers consecutively. " + "Limit: " + limit + ".", actual <= limit); }
@Override protected void logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters) { metricsLogger.logMetric(MetricsLogger.KEY_TEST_NAME, streamName); metricsLogger.logMetric(MetricsLogger.KEY_IS_CDD_LIMITED_RETRY, isCddLimitedRetry); metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_DROPPED_COUNT, videoCounters.droppedOutputBufferCount); metricsLogger.logMetric(MetricsLogger.KEY_MAX_CONSECUTIVE_FRAMES_DROPPED_COUNT, videoCounters.maxConsecutiveDroppedOutputBufferCount); metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_SKIPPED_COUNT, videoCounters.skippedOutputBufferCount); metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_RENDERED_COUNT, videoCounters.renderedOutputBufferCount); metricsLogger.close(); }
@Override protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) { if (fullPlaybackNoSeeking) { // We shouldn't have skipped any output buffers. DecoderCountersUtil.assertSkippedOutputBufferCount(AUDIO_TAG, audioCounters, 0); DecoderCountersUtil.assertSkippedOutputBufferCount(VIDEO_TAG, videoCounters, 0); // We allow one fewer output buffer due to the way that MediaCodecRenderer and the // underlying decoders handle the end of stream. This should be tightened up in the future. DecoderCountersUtil.assertTotalOutputBufferCount(AUDIO_TAG, audioCounters, audioCounters.inputBufferCount - 1, audioCounters.inputBufferCount); DecoderCountersUtil.assertTotalOutputBufferCount(VIDEO_TAG, videoCounters, videoCounters.inputBufferCount - 1, videoCounters.inputBufferCount); } try { int droppedFrameLimit = (int) Math.ceil(MAX_DROPPED_VIDEO_FRAME_FRACTION * DecoderCountersUtil.getTotalOutputBuffers(videoCounters)); // Assert that performance is acceptable. // Assert that total dropped frames were within limit. DecoderCountersUtil.assertDroppedOutputBufferLimit(VIDEO_TAG, videoCounters, droppedFrameLimit); // Assert that consecutive dropped frames were within limit. DecoderCountersUtil.assertConsecutiveDroppedOutputBufferLimit(VIDEO_TAG, videoCounters, MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES); } catch (AssertionFailedError e) { if (trackSelector.includedAdditionalVideoFormats) { // Retry limiting to CDD mandated formats (b/28220076). Log.e(TAG, "Too many dropped or consecutive dropped frames.", e); needsCddLimitedRetry = true; } else { throw e; } } }
@Override public void onVideoEnabled(DecoderCounters counters) { videoDecoderCounters = counters; if (videoDebugListener != null) { videoDebugListener.onVideoEnabled(counters); } }
@Override public void onVideoDisabled(DecoderCounters counters) { if (videoDebugListener != null) { videoDebugListener.onVideoDisabled(counters); } videoFormat = null; videoDecoderCounters = null; }
@Override public void onAudioEnabled(DecoderCounters counters) { audioDecoderCounters = counters; if (audioDebugListener != null) { audioDebugListener.onAudioEnabled(counters); } }
@Override public void onAudioDisabled(DecoderCounters counters) { if (audioDebugListener != null) { audioDebugListener.onAudioDisabled(counters); } audioFormat = null; audioDecoderCounters = null; audioSessionId = C.AUDIO_SESSION_ID_UNSET; }
@Override protected void onEnabled(boolean joining) throws ExoPlaybackException { decoderCounters = new DecoderCounters(); eventDispatcher.enabled(decoderCounters); int tunnelingAudioSessionId = getConfiguration().tunnelingAudioSessionId; if (tunnelingAudioSessionId != C.AUDIO_SESSION_ID_UNSET) { audioTrack.enableTunnelingV21(tunnelingAudioSessionId); } else { audioTrack.disableTunneling(); } }
/** * Invokes {@link AudioRendererEventListener#onAudioEnabled(DecoderCounters)}. */ public void enabled(final DecoderCounters decoderCounters) { if (listener != null) { handler.post(new Runnable() { @Override public void run() { listener.onAudioEnabled(decoderCounters); } }); } }
/** * Invokes {@link AudioRendererEventListener#onAudioDisabled(DecoderCounters)}. */ public void disabled(final DecoderCounters counters) { if (listener != null) { handler.post(new Runnable() { @Override public void run() { counters.ensureUpdated(); listener.onAudioDisabled(counters); } }); } }
/** * Invokes {@link VideoRendererEventListener#onVideoEnabled(DecoderCounters)}. */ public void enabled(final DecoderCounters decoderCounters) { if (listener != null) { handler.post(new Runnable() { @Override public void run() { listener.onVideoEnabled(decoderCounters); } }); } }
/** * Invokes {@link VideoRendererEventListener#onVideoDisabled(DecoderCounters)}. */ public void disabled(final DecoderCounters counters) { if (listener != null) { handler.post(new Runnable() { @Override public void run() { counters.ensureUpdated(); listener.onVideoDisabled(counters); } }); } }
@Override public void onVideoEnabled(DecoderCounters counters) { HashMap<String, String> callingMethodParameters = new HashMap<>(); callingMethodParameters.put("counters", String.valueOf(counters)); infoListener.onNewInfo("onVideoEnabled", callingMethodParameters); }
@Override public void onVideoDisabled(DecoderCounters counters) { HashMap<String, String> callingMethodParameters = new HashMap<>(); callingMethodParameters.put("counters", String.valueOf(counters)); infoListener.onNewInfo("onVideoDisabled", callingMethodParameters); }
private static String getDecoderCountersBufferCountString(DecoderCounters counters) { if (counters == null) { return ""; } counters.ensureUpdated(); return " rb:" + counters.renderedOutputBufferCount + " sb:" + counters.skippedOutputBufferCount + " db:" + counters.droppedOutputBufferCount + " mcdb:" + counters.maxConsecutiveDroppedOutputBufferCount; }
@Override public void onAudioDisabled(DecoderCounters counters) { if (audioDebugListener != null) { audioDebugListener.onAudioDisabled(counters); } audioFormat = null; audioDecoderCounters = null; audioSessionId = AudioTrack.SESSION_ID_NOT_SET; }