Make onInputFormatChanged methods in Renderers take FormatHolders

PiperOrigin-RevId: 257478434
This commit is contained in:
aquilescanta 2019-07-10 22:11:55 +01:00 committed by Oliver Woodman
parent 972c6c2f5c
commit 6796b179a6
2 changed files with 15 additions and 15 deletions

View file

@ -307,7 +307,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
flagsOnlyBuffer.clear(); flagsOnlyBuffer.clear();
int result = readSource(formatHolder, flagsOnlyBuffer, true); int result = readSource(formatHolder, flagsOnlyBuffer, true);
if (result == C.RESULT_FORMAT_READ) { if (result == C.RESULT_FORMAT_READ) {
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
} else if (result == C.RESULT_BUFFER_READ) { } else if (result == C.RESULT_BUFFER_READ) {
// End of stream read having not read a format. // End of stream read having not read a format.
Assertions.checkState(flagsOnlyBuffer.isEndOfStream()); Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
@ -491,15 +491,15 @@ public class LibvpxVideoRenderer extends BaseRenderer {
/** /**
* Called when a new format is read from the upstream source. * Called when a new format is read from the upstream source.
* *
* @param newFormat The new format. * @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
* @throws ExoPlaybackException If an error occurs (re-)initializing the decoder. * @throws ExoPlaybackException If an error occurs (re-)initializing the decoder.
*/ */
@CallSuper @CallSuper
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
Format oldFormat = format; Format oldFormat = format;
format = newFormat; format = formatHolder.format;
pendingFormat = newFormat; pendingFormat = format;
boolean drmInitDataChanged = !Util.areEqual(format.drmInitData, oldFormat == null ? null boolean drmInitDataChanged = !Util.areEqual(format.drmInitData, oldFormat == null ? null
: oldFormat.drmInitData); : oldFormat.drmInitData);
@ -513,7 +513,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
} }
DrmSession<ExoMediaCrypto> session = DrmSession<ExoMediaCrypto> session =
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); drmSessionManager.acquireSession(Looper.myLooper(), format.drmInitData);
if (sourceDrmSession != null) { if (sourceDrmSession != null) {
sourceDrmSession.releaseReference(); sourceDrmSession.releaseReference();
} }
@ -826,7 +826,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
return false; return false;
} }
if (result == C.RESULT_FORMAT_READ) { if (result == C.RESULT_FORMAT_READ) {
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
return true; return true;
} }
if (inputBuffer.isEndOfStream()) { if (inputBuffer.isEndOfStream()) {

View file

@ -274,7 +274,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
flagsOnlyBuffer.clear(); flagsOnlyBuffer.clear();
int result = readSource(formatHolder, flagsOnlyBuffer, true); int result = readSource(formatHolder, flagsOnlyBuffer, true);
if (result == C.RESULT_FORMAT_READ) { if (result == C.RESULT_FORMAT_READ) {
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
} else if (result == C.RESULT_BUFFER_READ) { } else if (result == C.RESULT_BUFFER_READ) {
// End of stream read having not read a format. // End of stream read having not read a format.
Assertions.checkState(flagsOnlyBuffer.isEndOfStream()); Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
@ -438,7 +438,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
return false; return false;
} }
if (result == C.RESULT_FORMAT_READ) { if (result == C.RESULT_FORMAT_READ) {
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
return true; return true;
} }
if (inputBuffer.isEndOfStream()) { if (inputBuffer.isEndOfStream()) {
@ -656,9 +656,9 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { private void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
Format oldFormat = inputFormat; Format oldFormat = inputFormat;
inputFormat = newFormat; inputFormat = formatHolder.format;
boolean drmInitDataChanged = !Util.areEqual(inputFormat.drmInitData, oldFormat == null ? null boolean drmInitDataChanged = !Util.areEqual(inputFormat.drmInitData, oldFormat == null ? null
: oldFormat.drmInitData); : oldFormat.drmInitData);
@ -673,7 +673,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
} }
DrmSession<ExoMediaCrypto> session = DrmSession<ExoMediaCrypto> session =
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); drmSessionManager.acquireSession(Looper.myLooper(), inputFormat.drmInitData);
if (sourceDrmSession != null) { if (sourceDrmSession != null) {
sourceDrmSession.releaseReference(); sourceDrmSession.releaseReference();
} }
@ -694,10 +694,10 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
audioTrackNeedsConfigure = true; audioTrackNeedsConfigure = true;
} }
encoderDelay = newFormat.encoderDelay; encoderDelay = inputFormat.encoderDelay;
encoderPadding = newFormat.encoderPadding; encoderPadding = inputFormat.encoderPadding;
eventDispatcher.inputFormatChanged(newFormat); eventDispatcher.inputFormatChanged(inputFormat);
} }
private void onQueueInputBuffer(DecoderInputBuffer buffer) { private void onQueueInputBuffer(DecoderInputBuffer buffer) {