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 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer.demo; package com.google.android.exoplayer.demo;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.DefaultTrackSelector; import com.google.android.exoplayer.DefaultTrackSelector;
import com.google.android.exoplayer.DefaultTrackSelector.TrackInfo; import com.google.android.exoplayer.DefaultTrackSelector.TrackInfo;
import com.google.android.exoplayer.ExoPlaybackException; import com.google.android.exoplayer.ExoPlaybackException;
...@@ -140,12 +139,24 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -140,12 +139,24 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
} }
@Override @Override
public void onAudioFormatChanged(Format format) {
Log.d(TAG, "audioFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
+ "]");
}
@Override
public void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs, public void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs) { long initializationDurationMs) {
Log.d(TAG, "videoDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]"); Log.d(TAG, "videoDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
} }
@Override @Override
public void onVideoFormatChanged(Format format) {
Log.d(TAG, "videoFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
+ "]");
}
@Override
public void onDroppedFrames(int count, long elapsed) { public void onDroppedFrames(int count, long elapsed) {
Log.d(TAG, "droppedFrames [" + getSessionTimeString() + ", " + count + "]"); Log.d(TAG, "droppedFrames [" + getSessionTimeString() + ", " + count + "]");
} }
...@@ -200,9 +211,7 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -200,9 +211,7 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
@Override @Override
public void onDownstreamFormatChanged(int sourceId, Format format, int trigger, public void onDownstreamFormatChanged(int sourceId, Format format, int trigger,
long mediaTimeMs) { long mediaTimeMs) {
if (sourceId == C.TRACK_TYPE_VIDEO) { // Do nothing.
Log.d(TAG, "videoFormatChanged [" + getSessionTimeString() + ", " + format.id + "]");
}
} }
// Internal methods // Internal methods
...@@ -266,6 +275,9 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -266,6 +275,9 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
} }
private static String getFormatString(Format format) { private static String getFormatString(Format format) {
if (format == null) {
return "null";
}
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("id=").append(format.id).append(", mimeType=").append(format.sampleMimeType); builder.append("id=").append(format.id).append(", mimeType=").append(format.sampleMimeType);
if (format.bitrate != Format.NO_VALUE) { if (format.bitrate != Format.NO_VALUE) {
......
...@@ -63,8 +63,10 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -63,8 +63,10 @@ public final class SimpleExoPlayer implements ExoPlayer {
public interface DebugListener { public interface DebugListener {
void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs, void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs); long initializationDurationMs);
void onAudioFormatChanged(Format format);
void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs, void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs); long initializationDurationMs);
void onVideoFormatChanged(Format format);
void onDroppedFrames(int count, long elapsed); void onDroppedFrames(int count, long elapsed);
void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs); void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs);
} }
...@@ -481,6 +483,9 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -481,6 +483,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onVideoInputFormatChanged(Format format) { public void onVideoInputFormatChanged(Format format) {
videoFormat = format; videoFormat = format;
if (debugListener != null) {
debugListener.onVideoFormatChanged(format);
}
} }
@Override @Override
...@@ -508,8 +513,13 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -508,8 +513,13 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onVideoDisabled() { public void onVideoDisabled() {
videoFormat = null;
videoCodecCounters = null; videoCodecCounters = null;
if (videoFormat != null) {
videoFormat = null;
if (debugListener != null) {
debugListener.onVideoFormatChanged(null);
}
}
} }
// AudioTrackRendererEventListener implementation // AudioTrackRendererEventListener implementation
...@@ -531,6 +541,9 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -531,6 +541,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onAudioInputFormatChanged(Format format) { public void onAudioInputFormatChanged(Format format) {
audioFormat = format; audioFormat = format;
if (debugListener != null) {
debugListener.onAudioFormatChanged(format);
}
} }
@Override @Override
...@@ -543,8 +556,13 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -543,8 +556,13 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onAudioDisabled() { public void onAudioDisabled() {
audioFormat = null;
audioCodecCounters = null; audioCodecCounters = null;
if (audioFormat != null) {
audioFormat = null;
if (debugListener != null) {
debugListener.onAudioFormatChanged(null);
}
}
} }
// TextRenderer implementation // 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