use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class PsExtractorSeekTest method getExtractorInputFromPosition.
private ExtractorInput getExtractorInputFromPosition(long position) throws IOException {
DataSpec dataSpec = new DataSpec(Uri.parse("asset:///" + PS_FILE_PATH), position, C.LENGTH_UNSET);
dataSource.open(dataSpec);
return new DefaultExtractorInput(dataSource, position, totalInputLength);
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class TestUtil method getExtractorInputFromPosition.
/**
* Returns an {@link ExtractorInput} to read from the given input at given position.
*/
public static ExtractorInput getExtractorInputFromPosition(DataSource dataSource, long position, Uri uri) throws IOException {
DataSpec dataSpec = new DataSpec(uri, position, C.LENGTH_UNSET);
long length = dataSource.open(dataSpec);
if (length != C.LENGTH_UNSET) {
length += position;
}
return new DefaultExtractorInput(dataSource, position, length);
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class ContainerMediaChunk method load.
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public final void load() throws IOException {
if (nextLoadPosition == 0) {
// Configure the output and set it as the target for the extractor wrapper.
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(sampleOffsetUs);
chunkExtractor.init(getTrackOutputProvider(output), clippedStartTimeUs == C.TIME_UNSET ? C.TIME_UNSET : (clippedStartTimeUs - sampleOffsetUs), clippedEndTimeUs == C.TIME_UNSET ? C.TIME_UNSET : (clippedEndTimeUs - sampleOffsetUs));
}
try {
// Create and open the input.
DataSpec loadDataSpec = dataSpec.subrange(nextLoadPosition);
ExtractorInput input = new DefaultExtractorInput(dataSource, loadDataSpec.position, dataSource.open(loadDataSpec));
// Load and decode the sample data.
try {
while (!loadCanceled && chunkExtractor.read(input)) {
}
} finally {
nextLoadPosition = input.getPosition() - dataSpec.position;
}
} finally {
DataSourceUtil.closeQuietly(dataSource);
}
loadCompleted = !loadCanceled;
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class InitializationChunk method load.
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException {
if (nextLoadPosition == 0) {
chunkExtractor.init(trackOutputProvider, /* startTimeUs= */
C.TIME_UNSET, /* endTimeUs= */
C.TIME_UNSET);
}
try {
// Create and open the input.
DataSpec loadDataSpec = dataSpec.subrange(nextLoadPosition);
ExtractorInput input = new DefaultExtractorInput(dataSource, loadDataSpec.position, dataSource.open(loadDataSpec));
// Load and decode the initialization data.
try {
while (!loadCanceled && chunkExtractor.read(input)) {
}
} finally {
nextLoadPosition = input.getPosition() - dataSpec.position;
}
} finally {
DataSourceUtil.closeQuietly(dataSource);
}
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class RtpDataLoadable method load.
@Override
public void load() throws IOException {
@Nullable RtpDataChannel dataChannel = null;
try {
dataChannel = rtpDataChannelFactory.createAndOpenDataChannel(trackId);
String transport = dataChannel.getTransport();
RtpDataChannel finalDataChannel = dataChannel;
playbackThreadHandler.post(() -> eventListener.onTransportReady(transport, finalDataChannel));
// Sets up the extractor.
ExtractorInput extractorInput = new DefaultExtractorInput(checkNotNull(dataChannel), /* position= */
0, /* length= */
C.LENGTH_UNSET);
extractor = new RtpExtractor(rtspMediaTrack.payloadFormat, trackId);
extractor.init(output);
while (!loadCancelled) {
if (pendingSeekPositionUs != C.TIME_UNSET) {
extractor.seek(nextRtpTimestamp, pendingSeekPositionUs);
pendingSeekPositionUs = C.TIME_UNSET;
}
@Extractor.ReadResult int readResult = extractor.read(extractorInput, /* seekPosition= */
new PositionHolder());
if (readResult == Extractor.RESULT_END_OF_INPUT) {
// Loading is finished.
break;
}
}
} finally {
DataSourceUtil.closeQuietly(dataChannel);
}
}
Aggregations