mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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;
|
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;
|
||||||
|
|
@ -139,12 +138,24 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
|
||||||
Log.d(TAG, "audioDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
|
Log.d(TAG, "audioDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAudioFormatChanged(Format format) {
|
||||||
|
Log.d(TAG, "audioFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
|
||||||
|
+ "]");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
||||||
|
public void onVideoFormatChanged(Format format) {
|
||||||
|
Log.d(TAG, "videoFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
|
||||||
|
+ "]");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
||||||
@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
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
@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 {
|
||||||
|
|
||||||
@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 {
|
||||||
@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 {
|
||||||
|
|
||||||
@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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue