mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Report decoder initialization information out of track renderer.
This commit is contained in:
parent
a17123c49b
commit
6bf52dd69c
3 changed files with 46 additions and 0 deletions
|
|
@ -163,6 +163,12 @@ public class EventLogger implements DemoPlayer.Listener, DemoPlayer.InfoListener
|
|||
printInternalError("cryptoError", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||
long initializationDurationMs) {
|
||||
Log.d(TAG, "decoderInitialized [" + getSessionTimeString() + "]");
|
||||
}
|
||||
|
||||
private void printInternalError(String type, Exception e) {
|
||||
Log.e(TAG, "internalError [" + getSessionTimeString() + ", " + type + "]", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ public class DemoPlayer implements ExoPlayer.Listener, ChunkSampleSource.EventLi
|
|||
void onLoadStarted(int sourceId, String formatId, int trigger, boolean isInitialization,
|
||||
int mediaStartTimeMs, int mediaEndTimeMs, long length);
|
||||
void onLoadCompleted(int sourceId, long bytesLoaded);
|
||||
void onDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||
long initializationDurationMs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -477,6 +479,16 @@ public class DemoPlayer implements ExoPlayer.Listener, ChunkSampleSource.EventLi
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDecoderInitialized(
|
||||
String decoderName,
|
||||
long elapsedRealtimeMs,
|
||||
long initializationDurationMs) {
|
||||
if (infoListener != null) {
|
||||
infoListener.onDecoderInitialized(decoderName, elapsedRealtimeMs, initializationDurationMs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpstreamError(int sourceId, IOException e) {
|
||||
if (internalErrorListener != null) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,17 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
|||
*/
|
||||
void onCryptoError(CryptoException e);
|
||||
|
||||
/**
|
||||
* Invoked when a decoder is successfully created.
|
||||
*
|
||||
* @param decoderName The decoder that was configured and created.
|
||||
* @param elapsedRealtimeMs {@code elapsedRealtime} timestamp of when the initialization
|
||||
* finished.
|
||||
* @param initializationDurationMs Amount of time taken to initialize the decoder.
|
||||
*/
|
||||
void onDecoderInitialized(String decoderName, long elapsedRealtimeMs,
|
||||
long initializationDurationMs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -332,9 +343,13 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
|||
String decoderName = decoderInfo.name;
|
||||
codecIsAdaptive = decoderInfo.adaptive;
|
||||
try {
|
||||
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
|
||||
codec = MediaCodec.createByCodecName(decoderName);
|
||||
configureCodec(codec, format.getFrameworkMediaFormatV16(), mediaCrypto);
|
||||
codec.start();
|
||||
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
|
||||
notifyDecoderInitialized(decoderName, codecInitializedTimestamp,
|
||||
codecInitializedTimestamp - codecInitializingTimestamp);
|
||||
inputBuffers = codec.getInputBuffers();
|
||||
outputBuffers = codec.getOutputBuffers();
|
||||
} catch (Exception e) {
|
||||
|
|
@ -846,6 +861,19 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void notifyDecoderInitialized(final String decoderName,
|
||||
final long initializedTimestamp, final long initializationDuration) {
|
||||
if (eventHandler != null && eventListener != null) {
|
||||
eventHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
eventListener.onDecoderInitialized(decoderName, initializedTimestamp,
|
||||
initializationDuration);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private int getDecodeOnlyIndex(long presentationTimeUs) {
|
||||
final int size = decodeOnlyPresentationTimestamps.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue