Commit 4a3980c7 by olly Committed by Oliver Woodman

Add format change events to SimpleExoPlayer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124344637
parent 80b10b5f
......@@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer.demo;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.DefaultTrackSelector;
import com.google.android.exoplayer.DefaultTrackSelector.TrackInfo;
import com.google.android.exoplayer.ExoPlaybackException;
......@@ -140,12 +139,24 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
}
@Override
public void onAudioFormatChanged(Format format) {
Log.d(TAG, "audioFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
+ "]");
}
@Override
public void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs) {
Log.d(TAG, "videoDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
}
@Override
public void onVideoFormatChanged(Format format) {
Log.d(TAG, "videoFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
+ "]");
}
@Override
public void onDroppedFrames(int count, long elapsed) {
Log.d(TAG, "droppedFrames [" + getSessionTimeString() + ", " + count + "]");
}
......@@ -200,9 +211,7 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
@Override
public void onDownstreamFormatChanged(int sourceId, Format format, int trigger,
long mediaTimeMs) {
if (sourceId == C.TRACK_TYPE_VIDEO) {
Log.d(TAG, "videoFormatChanged [" + getSessionTimeString() + ", " + format.id + "]");
}
// Do nothing.
}
// Internal methods
......@@ -266,6 +275,9 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
}
private static String getFormatString(Format format) {
if (format == null) {
return "null";
}
StringBuilder builder = new StringBuilder();
builder.append("id=").append(format.id).append(", mimeType=").append(format.sampleMimeType);
if (format.bitrate != Format.NO_VALUE) {
......
......@@ -63,8 +63,10 @@ public final class SimpleExoPlayer implements ExoPlayer {
public interface DebugListener {
void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs);
void onAudioFormatChanged(Format format);
void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs);
void onVideoFormatChanged(Format format);
void onDroppedFrames(int count, long elapsed);
void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs);
}
......@@ -481,6 +483,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override
public void onVideoInputFormatChanged(Format format) {
videoFormat = format;
if (debugListener != null) {
debugListener.onVideoFormatChanged(format);
}
}
@Override
......@@ -508,8 +513,13 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override
public void onVideoDisabled() {
videoFormat = null;
videoCodecCounters = null;
if (videoFormat != null) {
videoFormat = null;
if (debugListener != null) {
debugListener.onVideoFormatChanged(null);
}
}
}
// AudioTrackRendererEventListener implementation
......@@ -531,6 +541,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override
public void onAudioInputFormatChanged(Format format) {
audioFormat = format;
if (debugListener != null) {
debugListener.onAudioFormatChanged(format);
}
}
@Override
......@@ -543,8 +556,13 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override
public void onAudioDisabled() {
audioFormat = null;
audioCodecCounters = null;
if (audioFormat != null) {
audioFormat = null;
if (debugListener != null) {
debugListener.onAudioFormatChanged(null);
}
}
}
// TextRenderer implementation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment