mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Pull assertion and layer of indirection out from ChunkExtractorWrapper
It should be possible to remove ChunkExtractorWrapper from the track output side as well (currently all extractor output is funneled via ChunkExtractorWrapper just so it can adjust the format, which is kind of unnecessary). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145083620
This commit is contained in:
parent
5407c98526
commit
26b303a449
3 changed files with 10 additions and 17 deletions
|
|
@ -47,7 +47,8 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Extractor extractor;
|
public final Extractor extractor;
|
||||||
|
|
||||||
private final Format manifestFormat;
|
private final Format manifestFormat;
|
||||||
private final boolean preferManifestDrmInitData;
|
private final boolean preferManifestDrmInitData;
|
||||||
private final boolean resendFormatOnInit;
|
private final boolean resendFormatOnInit;
|
||||||
|
|
@ -99,20 +100,6 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads from the provided {@link ExtractorInput}.
|
|
||||||
*
|
|
||||||
* @param input The {@link ExtractorInput} from which to read.
|
|
||||||
* @return One of {@link Extractor#RESULT_CONTINUE} and {@link Extractor#RESULT_END_OF_INPUT}.
|
|
||||||
* @throws IOException If an error occurred reading from the source.
|
|
||||||
* @throws InterruptedException If the thread was interrupted.
|
|
||||||
*/
|
|
||||||
public int read(ExtractorInput input) throws IOException, InterruptedException {
|
|
||||||
int result = extractor.read(input, null);
|
|
||||||
Assertions.checkState(result != Extractor.RESULT_SEEK);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExtractorOutput implementation.
|
// ExtractorOutput implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.google.android.exoplayer2.extractor.SeekMap;
|
||||||
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.SeekMapOutput;
|
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.SeekMapOutput;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||||
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
@ -120,10 +121,12 @@ public class ContainerMediaChunk extends BaseMediaChunk implements SeekMapOutput
|
||||||
}
|
}
|
||||||
// Load and decode the sample data.
|
// Load and decode the sample data.
|
||||||
try {
|
try {
|
||||||
|
Extractor extractor = extractorWrapper.extractor;
|
||||||
int result = Extractor.RESULT_CONTINUE;
|
int result = Extractor.RESULT_CONTINUE;
|
||||||
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
|
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
|
||||||
result = extractorWrapper.read(input);
|
result = extractor.read(input, null);
|
||||||
}
|
}
|
||||||
|
Assertions.checkState(result != Extractor.RESULT_SEEK);
|
||||||
} finally {
|
} finally {
|
||||||
bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
|
bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||||
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.SeekMapOutput;
|
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.SeekMapOutput;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||||
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -142,10 +143,12 @@ public final class InitializationChunk extends Chunk implements SeekMapOutput,
|
||||||
}
|
}
|
||||||
// Load and decode the initialization data.
|
// Load and decode the initialization data.
|
||||||
try {
|
try {
|
||||||
|
Extractor extractor = extractorWrapper.extractor;
|
||||||
int result = Extractor.RESULT_CONTINUE;
|
int result = Extractor.RESULT_CONTINUE;
|
||||||
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
|
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
|
||||||
result = extractorWrapper.read(input);
|
result = extractor.read(input, null);
|
||||||
}
|
}
|
||||||
|
Assertions.checkState(result != Extractor.RESULT_SEEK);
|
||||||
} finally {
|
} finally {
|
||||||
bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
|
bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue