Propagate audioSessionId.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127300225
This commit is contained in:
parent
11e2e0e640
commit
e4a3483d6f
@ -149,6 +149,11 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
|
|||||||
Log.d(TAG, "audioEnabled [" + getSessionTimeString() + "]");
|
Log.d(TAG, "audioEnabled [" + getSessionTimeString() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAudioSessionId(int audioSessionId) {
|
||||||
|
Log.d(TAG, "audioSessionId [" + audioSessionId + "]");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||||
long initializationDurationMs) {
|
long initializationDurationMs) {
|
||||||
|
@ -34,6 +34,13 @@ public interface AudioRendererEventListener {
|
|||||||
*/
|
*/
|
||||||
void onAudioEnabled(CodecCounters counters);
|
void onAudioEnabled(CodecCounters counters);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked when the audio session is set.
|
||||||
|
*
|
||||||
|
* @param audioSessionId The audio session id.
|
||||||
|
*/
|
||||||
|
void onAudioSessionId(int audioSessionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a decoder is created.
|
* Invoked when a decoder is created.
|
||||||
*
|
*
|
||||||
@ -142,6 +149,17 @@ public interface AudioRendererEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void audioSessionId(final int audioSessionId) {
|
||||||
|
if (listener != null) {
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
listener.onAudioSessionId(audioSessionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
audioTrack.initialize(audioSessionId);
|
audioTrack.initialize(audioSessionId);
|
||||||
} else {
|
} else {
|
||||||
audioSessionId = audioTrack.initialize();
|
audioSessionId = audioTrack.initialize();
|
||||||
|
eventDispatcher.audioSessionId(audioSessionId);
|
||||||
onAudioSessionId(audioSessionId);
|
onAudioSessionId(audioSessionId);
|
||||||
}
|
}
|
||||||
audioTrackHasData = false;
|
audioTrackHasData = false;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.google.android.exoplayer2;
|
package com.google.android.exoplayer2;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.audio.AudioCapabilities;
|
import com.google.android.exoplayer2.audio.AudioCapabilities;
|
||||||
|
import com.google.android.exoplayer2.audio.AudioTrack;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
||||||
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
|
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
|
||||||
@ -62,6 +63,7 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
*/
|
*/
|
||||||
public interface DebugListener {
|
public interface DebugListener {
|
||||||
void onAudioEnabled(CodecCounters counters);
|
void onAudioEnabled(CodecCounters counters);
|
||||||
|
void onAudioSessionId(int audioSessionId);
|
||||||
void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||||
long initializationDurationMs);
|
long initializationDurationMs);
|
||||||
void onAudioFormatChanged(Format format);
|
void onAudioFormatChanged(Format format);
|
||||||
@ -109,6 +111,7 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
private DebugListener debugListener;
|
private DebugListener debugListener;
|
||||||
private CodecCounters videoCodecCounters;
|
private CodecCounters videoCodecCounters;
|
||||||
private CodecCounters audioCodecCounters;
|
private CodecCounters audioCodecCounters;
|
||||||
|
private int audioSessionId;
|
||||||
|
|
||||||
/* package */ SimpleExoPlayer(Context context, TrackSelector trackSelector,
|
/* package */ SimpleExoPlayer(Context context, TrackSelector trackSelector,
|
||||||
LoadControl loadControl, DrmSessionManager drmSessionManager,
|
LoadControl loadControl, DrmSessionManager drmSessionManager,
|
||||||
@ -143,6 +146,7 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
this.videoRendererCount = videoRendererCount;
|
this.videoRendererCount = videoRendererCount;
|
||||||
this.audioRendererCount = audioRendererCount;
|
this.audioRendererCount = audioRendererCount;
|
||||||
|
this.audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
||||||
|
|
||||||
// Build the player and associated objects.
|
// Build the player and associated objects.
|
||||||
player = new ExoPlayerImpl(renderers, trackSelector, loadControl);
|
player = new ExoPlayerImpl(renderers, trackSelector, loadControl);
|
||||||
@ -244,6 +248,14 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
return audioFormat;
|
return audioFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The audio session identifier. If not set {@code AudioTrack.SESSION_ID_NOT_SET} is
|
||||||
|
* returned.
|
||||||
|
*/
|
||||||
|
public int getAudioSessionId() {
|
||||||
|
return audioSessionId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The {@link CodecCounters} for video, or null if there is no video component to the
|
* @return The {@link CodecCounters} for video, or null if there is no video component to the
|
||||||
* current media.
|
* current media.
|
||||||
@ -547,6 +559,14 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAudioSessionId(int sessionId) {
|
||||||
|
audioSessionId = sessionId;
|
||||||
|
if (debugListener != null) {
|
||||||
|
debugListener.onAudioSessionId(sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs,
|
public void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs,
|
||||||
long initializationDurationMs) {
|
long initializationDurationMs) {
|
||||||
@ -579,6 +599,7 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
audioFormat = null;
|
audioFormat = null;
|
||||||
audioCodecCounters = null;
|
audioCodecCounters = null;
|
||||||
|
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextRendererOutput implementation
|
// TextRendererOutput implementation
|
||||||
|
@ -189,6 +189,7 @@ public abstract class AudioDecoderRenderer extends Renderer implements MediaCloc
|
|||||||
audioTrack.initialize(audioSessionId);
|
audioTrack.initialize(audioSessionId);
|
||||||
} else {
|
} else {
|
||||||
audioSessionId = audioTrack.initialize();
|
audioSessionId = audioTrack.initialize();
|
||||||
|
eventDispatcher.audioSessionId(audioSessionId);
|
||||||
onAudioSessionId(audioSessionId);
|
onAudioSessionId(audioSessionId);
|
||||||
}
|
}
|
||||||
audioTrackHasData = false;
|
audioTrackHasData = false;
|
||||||
|
@ -220,6 +220,11 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
|
|||||||
Log.d(tag, "audioEnabled");
|
Log.d(tag, "audioEnabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAudioSessionId(int audioSessionId) {
|
||||||
|
Log.d(tag, "audioSessionId [" + audioSessionId + "]");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||||
long initializationDurationMs) {
|
long initializationDurationMs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user