mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Add format change events to SimpleExoPlayer.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124344637
This commit is contained in:
parent
80b10b5fc1
commit
4a3980c71e
2 changed files with 36 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
@ -139,12 +138,24 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
|
|||
Log.d(TAG, "audioDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
|
||||
}
|
||||
|
||||
@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
|
||||
|
|
|
|||
Loading…
Reference in a new issue