opus: Add CodecCounters support
Fixes Issue #1047 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111708934
This commit is contained in:
parent
ab9e3bac46
commit
bb55fd8e47
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer.ext.opus;
|
package com.google.android.exoplayer.ext.opus;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer.CodecCounters;
|
||||||
import com.google.android.exoplayer.ExoPlaybackException;
|
import com.google.android.exoplayer.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer.ExoPlayer;
|
import com.google.android.exoplayer.ExoPlayer;
|
||||||
import com.google.android.exoplayer.MediaClock;
|
import com.google.android.exoplayer.MediaClock;
|
||||||
@ -75,6 +76,8 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
|
|||||||
*/
|
*/
|
||||||
public static final int MSG_SET_VOLUME = 1;
|
public static final int MSG_SET_VOLUME = 1;
|
||||||
|
|
||||||
|
public final CodecCounters codecCounters = new CodecCounters();
|
||||||
|
|
||||||
private final Handler eventHandler;
|
private final Handler eventHandler;
|
||||||
private final EventListener eventListener;
|
private final EventListener eventListener;
|
||||||
private final MediaFormatHolder formatHolder;
|
private final MediaFormatHolder formatHolder;
|
||||||
@ -191,6 +194,7 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
|
|||||||
throw new ExoPlaybackException(e);
|
throw new ExoPlaybackException(e);
|
||||||
}
|
}
|
||||||
decoder.start();
|
decoder.start();
|
||||||
|
codecCounters.codecInitCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering loop.
|
// Rendering loop.
|
||||||
@ -207,6 +211,7 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
|
|||||||
notifyDecoderError(e);
|
notifyDecoderError(e);
|
||||||
throw new ExoPlaybackException(e);
|
throw new ExoPlaybackException(e);
|
||||||
}
|
}
|
||||||
|
codecCounters.ensureUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderBuffer() throws OpusDecoderException, AudioTrack.InitializationException,
|
private void renderBuffer() throws OpusDecoderException, AudioTrack.InitializationException,
|
||||||
@ -253,6 +258,7 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
|
|||||||
// Release the buffer if it was consumed.
|
// Release the buffer if it was consumed.
|
||||||
if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
|
if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
|
||||||
decoder.releaseOutputBuffer(outputBuffer);
|
decoder.releaseOutputBuffer(outputBuffer);
|
||||||
|
codecCounters.renderedOutputBufferCount++;
|
||||||
outputBuffer = null;
|
outputBuffer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,6 +378,7 @@ public final class LibopusAudioTrackRenderer extends SampleSourceTrackRenderer
|
|||||||
if (decoder != null) {
|
if (decoder != null) {
|
||||||
decoder.release();
|
decoder.release();
|
||||||
decoder = null;
|
decoder = null;
|
||||||
|
codecCounters.codecReleaseCount++;
|
||||||
}
|
}
|
||||||
audioTrack.release();
|
audioTrack.release();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -192,6 +192,7 @@ public final class LibvpxVideoTrackRenderer extends SampleSourceTrackRenderer {
|
|||||||
if (decoder == null) {
|
if (decoder == null) {
|
||||||
decoder = new VpxDecoderWrapper(outputMode);
|
decoder = new VpxDecoderWrapper(outputMode);
|
||||||
decoder.start();
|
decoder.start();
|
||||||
|
codecCounters.codecInitCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering loop.
|
// Rendering loop.
|
||||||
@ -202,6 +203,7 @@ public final class LibvpxVideoTrackRenderer extends SampleSourceTrackRenderer {
|
|||||||
notifyDecoderError(e);
|
notifyDecoderError(e);
|
||||||
throw new ExoPlaybackException(e);
|
throw new ExoPlaybackException(e);
|
||||||
}
|
}
|
||||||
|
codecCounters.ensureUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOutputBuffer(long positionUs, long elapsedRealtimeUs)
|
private void processOutputBuffer(long positionUs, long elapsedRealtimeUs)
|
||||||
@ -406,6 +408,7 @@ public final class LibvpxVideoTrackRenderer extends SampleSourceTrackRenderer {
|
|||||||
if (decoder != null) {
|
if (decoder != null) {
|
||||||
decoder.release();
|
decoder.release();
|
||||||
decoder = null;
|
decoder = null;
|
||||||
|
codecCounters.codecReleaseCount++;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
super.onDisabled();
|
super.onDisabled();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user