mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Rename DummyTrackOutput and DummyExtractorOutput
#cherrypick PiperOrigin-RevId: 646434450 (cherry picked from commit 867410fece006122820e26be4e0bea87309a4f2e)
This commit is contained in:
parent
0f18fd87ac
commit
a73d32a795
@ -51,7 +51,7 @@ import androidx.media3.exoplayer.upstream.Allocator;
|
|||||||
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
||||||
import androidx.media3.extractor.DefaultExtractorInput;
|
import androidx.media3.extractor.DefaultExtractorInput;
|
||||||
import androidx.media3.extractor.DefaultExtractorsFactory;
|
import androidx.media3.extractor.DefaultExtractorsFactory;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.Extractor.ReadResult;
|
import androidx.media3.extractor.Extractor.ReadResult;
|
||||||
import androidx.media3.extractor.ExtractorInput;
|
import androidx.media3.extractor.ExtractorInput;
|
||||||
@ -601,7 +601,7 @@ public final class MediaExtractorCompat {
|
|||||||
}
|
}
|
||||||
if (tracksEnded) {
|
if (tracksEnded) {
|
||||||
// The id is new and the extractor has ended the tracks. Discard.
|
// The id is new and the extractor has ended the tracks. Discard.
|
||||||
return new DummyTrackOutput();
|
return new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleQueue = new MediaExtractorSampleQueue(allocator, id);
|
sampleQueue = new MediaExtractorSampleQueue(allocator, id);
|
||||||
|
@ -54,7 +54,7 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo;
|
|||||||
import androidx.media3.exoplayer.upstream.Loader;
|
import androidx.media3.exoplayer.upstream.Loader;
|
||||||
import androidx.media3.exoplayer.upstream.Loader.LoadErrorAction;
|
import androidx.media3.exoplayer.upstream.Loader.LoadErrorAction;
|
||||||
import androidx.media3.exoplayer.upstream.Loader.Loadable;
|
import androidx.media3.exoplayer.upstream.Loader.Loadable;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
import androidx.media3.extractor.ForwardingSeekMap;
|
import androidx.media3.extractor.ForwardingSeekMap;
|
||||||
@ -739,7 +739,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
if (sampleQueuesBuilt) {
|
if (sampleQueuesBuilt) {
|
||||||
Log.w(TAG, "Extractor added new track (id=" + id.id + ") after finishing tracks.");
|
Log.w(TAG, "Extractor added new track (id=" + id.id + ") after finishing tracks.");
|
||||||
return new DummyTrackOutput();
|
return new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
SampleQueue trackOutput =
|
SampleQueue trackOutput =
|
||||||
SampleQueue.createWithDrm(allocator, drmSessionManager, drmEventDispatcher);
|
SampleQueue.createWithDrm(allocator, drmSessionManager, drmEventDispatcher);
|
||||||
|
@ -20,7 +20,7 @@ import androidx.media3.common.util.Log;
|
|||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.exoplayer.source.SampleQueue;
|
import androidx.media3.exoplayer.source.SampleQueue;
|
||||||
import androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider;
|
import androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.TrackOutput;
|
import androidx.media3.extractor.TrackOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ public final class BaseMediaChunkOutput implements TrackOutputProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.e(TAG, "Unmatched track of type: " + type);
|
Log.e(TAG, "Unmatched track of type: " + type);
|
||||||
return new DummyTrackOutput();
|
return new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current absolute write indices of the individual sample queues. */
|
/** Returns the current absolute write indices of the individual sample queues. */
|
||||||
|
@ -29,7 +29,7 @@ import androidx.media3.common.util.ParsableByteArray;
|
|||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.exoplayer.analytics.PlayerId;
|
import androidx.media3.exoplayer.analytics.PlayerId;
|
||||||
import androidx.media3.extractor.ChunkIndex;
|
import androidx.media3.extractor.ChunkIndex;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.ExtractorInput;
|
import androidx.media3.extractor.ExtractorInput;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
@ -282,7 +282,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final int type;
|
private final int type;
|
||||||
@Nullable private final Format manifestFormat;
|
@Nullable private final Format manifestFormat;
|
||||||
private final DummyTrackOutput fakeTrackOutput;
|
private final DiscardingTrackOutput fakeTrackOutput;
|
||||||
|
|
||||||
public @MonotonicNonNull Format sampleFormat;
|
public @MonotonicNonNull Format sampleFormat;
|
||||||
private @MonotonicNonNull TrackOutput trackOutput;
|
private @MonotonicNonNull TrackOutput trackOutput;
|
||||||
@ -292,7 +292,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.manifestFormat = manifestFormat;
|
this.manifestFormat = manifestFormat;
|
||||||
fakeTrackOutput = new DummyTrackOutput();
|
fakeTrackOutput = new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) {
|
public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) {
|
||||||
|
@ -39,7 +39,7 @@ import androidx.media3.exoplayer.source.mediaparser.InputReaderAdapterV30;
|
|||||||
import androidx.media3.exoplayer.source.mediaparser.MediaParserUtil;
|
import androidx.media3.exoplayer.source.mediaparser.MediaParserUtil;
|
||||||
import androidx.media3.exoplayer.source.mediaparser.OutputConsumerAdapterV30;
|
import androidx.media3.exoplayer.source.mediaparser.OutputConsumerAdapterV30;
|
||||||
import androidx.media3.extractor.ChunkIndex;
|
import androidx.media3.extractor.ChunkIndex;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.ExtractorInput;
|
import androidx.media3.extractor.ExtractorInput;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
import androidx.media3.extractor.SeekMap;
|
import androidx.media3.extractor.SeekMap;
|
||||||
@ -77,7 +77,7 @@ public final class MediaParserChunkExtractor implements ChunkExtractor {
|
|||||||
private final InputReaderAdapterV30 inputReaderAdapter;
|
private final InputReaderAdapterV30 inputReaderAdapter;
|
||||||
private final MediaParser mediaParser;
|
private final MediaParser mediaParser;
|
||||||
private final TrackOutputProviderAdapter trackOutputProviderAdapter;
|
private final TrackOutputProviderAdapter trackOutputProviderAdapter;
|
||||||
private final DummyTrackOutput dummyTrackOutput;
|
private final DiscardingTrackOutput discardingTrackOutput;
|
||||||
private long pendingSeekUs;
|
private long pendingSeekUs;
|
||||||
@Nullable private TrackOutputProvider trackOutputProvider;
|
@Nullable private TrackOutputProvider trackOutputProvider;
|
||||||
@Nullable private Format[] sampleFormats;
|
@Nullable private Format[] sampleFormats;
|
||||||
@ -127,7 +127,7 @@ public final class MediaParserChunkExtractor implements ChunkExtractor {
|
|||||||
}
|
}
|
||||||
outputConsumerAdapter.setMuxedCaptionFormats(closedCaptionFormats);
|
outputConsumerAdapter.setMuxedCaptionFormats(closedCaptionFormats);
|
||||||
trackOutputProviderAdapter = new TrackOutputProviderAdapter();
|
trackOutputProviderAdapter = new TrackOutputProviderAdapter();
|
||||||
dummyTrackOutput = new DummyTrackOutput();
|
discardingTrackOutput = new DiscardingTrackOutput();
|
||||||
pendingSeekUs = C.TIME_UNSET;
|
pendingSeekUs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,9 @@ public final class MediaParserChunkExtractor implements ChunkExtractor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TrackOutput track(int id, int type) {
|
public TrackOutput track(int id, int type) {
|
||||||
return trackOutputProvider != null ? trackOutputProvider.track(id, type) : dummyTrackOutput;
|
return trackOutputProvider != null
|
||||||
|
? trackOutputProvider.track(id, type)
|
||||||
|
: discardingTrackOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,8 +55,8 @@ import androidx.media3.common.util.TimestampAdjuster;
|
|||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.extractor.ChunkIndex;
|
import androidx.media3.extractor.ChunkIndex;
|
||||||
import androidx.media3.extractor.DummyExtractorOutput;
|
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
|
import androidx.media3.extractor.NoOpExtractorOutput;
|
||||||
import androidx.media3.extractor.SeekMap;
|
import androidx.media3.extractor.SeekMap;
|
||||||
import androidx.media3.extractor.SeekPoint;
|
import androidx.media3.extractor.SeekPoint;
|
||||||
import androidx.media3.extractor.TrackOutput;
|
import androidx.media3.extractor.TrackOutput;
|
||||||
@ -149,7 +149,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
|
|||||||
lastReceivedCryptoInfos = new ArrayList<>();
|
lastReceivedCryptoInfos = new ArrayList<>();
|
||||||
lastOutputCryptoDatas = new ArrayList<>();
|
lastOutputCryptoDatas = new ArrayList<>();
|
||||||
scratchDataReaderAdapter = new DataReaderAdapter();
|
scratchDataReaderAdapter = new DataReaderAdapter();
|
||||||
extractorOutput = new DummyExtractorOutput();
|
extractorOutput = new NoOpExtractorOutput();
|
||||||
sampleTimestampUpperLimitFilterUs = C.TIME_UNSET;
|
sampleTimestampUpperLimitFilterUs = C.TIME_UNSET;
|
||||||
muxedCaptionFormats = ImmutableList.of();
|
muxedCaptionFormats = ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
|
|||||||
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo;
|
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo;
|
||||||
import androidx.media3.exoplayer.upstream.Loader;
|
import androidx.media3.exoplayer.upstream.Loader;
|
||||||
import androidx.media3.exoplayer.upstream.Loader.LoadErrorAction;
|
import androidx.media3.exoplayer.upstream.Loader.LoadErrorAction;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
import androidx.media3.extractor.SeekMap;
|
import androidx.media3.extractor.SeekMap;
|
||||||
@ -1093,7 +1093,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
if (trackOutput == null) {
|
if (trackOutput == null) {
|
||||||
if (tracksEnded) {
|
if (tracksEnded) {
|
||||||
return createFakeTrackOutput(id, type);
|
return createDiscardingTrackOutput(id, type);
|
||||||
} else {
|
} else {
|
||||||
// The relevant SampleQueue hasn't been constructed yet - so construct it.
|
// The relevant SampleQueue hasn't been constructed yet - so construct it.
|
||||||
trackOutput = createSampleQueue(id, type);
|
trackOutput = createSampleQueue(id, type);
|
||||||
@ -1114,7 +1114,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
* has been created yet.
|
* has been created yet.
|
||||||
*
|
*
|
||||||
* <p>If a {@link SampleQueue} for {@code type} has been created and is mapped, but it has a
|
* <p>If a {@link SampleQueue} for {@code type} has been created and is mapped, but it has a
|
||||||
* different ID, then return a {@link DummyTrackOutput} that does nothing.
|
* different ID, then return a {@link DiscardingTrackOutput} that does nothing.
|
||||||
*
|
*
|
||||||
* <p>If a {@link SampleQueue} for {@code type} has been created but is not mapped, then map it to
|
* <p>If a {@link SampleQueue} for {@code type} has been created but is not mapped, then map it to
|
||||||
* this {@code id} and return it. This situation can happen after a call to {@link
|
* this {@code id} and return it. This situation can happen after a call to {@link
|
||||||
@ -1137,7 +1137,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
}
|
}
|
||||||
return sampleQueueTrackIds[sampleQueueIndex] == id
|
return sampleQueueTrackIds[sampleQueueIndex] == id
|
||||||
? sampleQueues[sampleQueueIndex]
|
? sampleQueues[sampleQueueIndex]
|
||||||
: createFakeTrackOutput(id, type);
|
: createDiscardingTrackOutput(id, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SampleQueue createSampleQueue(int id, int type) {
|
private SampleQueue createSampleQueue(int id, int type) {
|
||||||
@ -1646,9 +1646,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DummyTrackOutput createFakeTrackOutput(int id, int type) {
|
private static DiscardingTrackOutput createDiscardingTrackOutput(int id, int type) {
|
||||||
Log.w(TAG, "Unmapped track with id " + id + " of type " + type);
|
Log.w(TAG, "Unmapped track with id " + id + " of type " + type);
|
||||||
return new DummyTrackOutput();
|
return new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package androidx.media3.extractor;
|
||||||
|
|
||||||
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.media3.common.C;
|
||||||
|
import androidx.media3.common.DataReader;
|
||||||
|
import androidx.media3.common.Format;
|
||||||
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/** A {@link TrackOutput} that consumes and discards all reported samples. */
|
||||||
|
@UnstableApi
|
||||||
|
public final class DiscardingTrackOutput implements TrackOutput {
|
||||||
|
|
||||||
|
// Even though read data is discarded, data source implementations could be making use of the
|
||||||
|
// buffer contents. For example, caches. So we cannot use a static field for this which could be
|
||||||
|
// shared between different threads.
|
||||||
|
private final byte[] readBuffer;
|
||||||
|
|
||||||
|
/** Creates discarding track output. */
|
||||||
|
public DiscardingTrackOutput() {
|
||||||
|
readBuffer = new byte[4096];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void format(Format format) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int sampleData(
|
||||||
|
DataReader input, int length, boolean allowEndOfInput, @SampleDataPart int sampleDataPart)
|
||||||
|
throws IOException {
|
||||||
|
int bytesToSkipByReading = min(readBuffer.length, length);
|
||||||
|
int bytesSkipped = input.read(readBuffer, /* offset= */ 0, bytesToSkipByReading);
|
||||||
|
if (bytesSkipped == C.RESULT_END_OF_INPUT) {
|
||||||
|
if (allowEndOfInput) {
|
||||||
|
return C.RESULT_END_OF_INPUT;
|
||||||
|
}
|
||||||
|
throw new EOFException();
|
||||||
|
}
|
||||||
|
return bytesSkipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sampleData(ParsableByteArray data, int length, @SampleDataPart int sampleDataPart) {
|
||||||
|
data.skipBytes(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sampleMetadata(
|
||||||
|
long timeUs,
|
||||||
|
@C.BufferFlags int flags,
|
||||||
|
int size,
|
||||||
|
int offset,
|
||||||
|
@Nullable CryptoData cryptoData) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
@ -15,15 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.extractor;
|
package androidx.media3.extractor;
|
||||||
|
|
||||||
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
|
||||||
/** A fake {@link ExtractorOutput} implementation. */
|
/**
|
||||||
|
* @deprecated Use {@link NoOpExtractorOutput} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class DummyExtractorOutput implements ExtractorOutput {
|
public final class DummyExtractorOutput implements ExtractorOutput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TrackOutput track(int id, int type) {
|
public TrackOutput track(int id, @C.TrackType int type) {
|
||||||
return new DummyTrackOutput();
|
return new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,53 +15,52 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.extractor;
|
package androidx.media3.extractor;
|
||||||
|
|
||||||
import static java.lang.Math.min;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.DataReader;
|
import androidx.media3.common.DataReader;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/** A fake {@link TrackOutput} implementation. */
|
/**
|
||||||
|
* @deprecated Use {@link DiscardingTrackOutput} instead.
|
||||||
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
|
@Deprecated
|
||||||
public final class DummyTrackOutput implements TrackOutput {
|
public final class DummyTrackOutput implements TrackOutput {
|
||||||
|
|
||||||
// Even though read data is discarded, data source implementations could be making use of the
|
private final DiscardingTrackOutput discardingTrackOutput;
|
||||||
// buffer contents. For example, caches. So we cannot use a static field for this which could be
|
|
||||||
// shared between different threads.
|
|
||||||
private final byte[] readBuffer;
|
|
||||||
|
|
||||||
public DummyTrackOutput() {
|
public DummyTrackOutput() {
|
||||||
readBuffer = new byte[4096];
|
discardingTrackOutput = new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void format(Format format) {
|
public void format(Format format) {
|
||||||
// Do nothing.
|
discardingTrackOutput.format(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int sampleData(DataReader input, int length, boolean allowEndOfInput) throws IOException {
|
||||||
|
return discardingTrackOutput.sampleData(input, length, allowEndOfInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sampleData(ParsableByteArray data, int length) {
|
||||||
|
discardingTrackOutput.sampleData(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int sampleData(
|
public int sampleData(
|
||||||
DataReader input, int length, boolean allowEndOfInput, @SampleDataPart int sampleDataPart)
|
DataReader input, int length, boolean allowEndOfInput, @SampleDataPart int sampleDataPart)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int bytesToSkipByReading = min(readBuffer.length, length);
|
return discardingTrackOutput.sampleData(input, length, allowEndOfInput, sampleDataPart);
|
||||||
int bytesSkipped = input.read(readBuffer, /* offset= */ 0, bytesToSkipByReading);
|
|
||||||
if (bytesSkipped == C.RESULT_END_OF_INPUT) {
|
|
||||||
if (allowEndOfInput) {
|
|
||||||
return C.RESULT_END_OF_INPUT;
|
|
||||||
}
|
|
||||||
throw new EOFException();
|
|
||||||
}
|
|
||||||
return bytesSkipped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sampleData(ParsableByteArray data, int length, @SampleDataPart int sampleDataPart) {
|
public void sampleData(ParsableByteArray data, int length, @SampleDataPart int sampleDataPart) {
|
||||||
data.skipBytes(length);
|
discardingTrackOutput.sampleData(data, length, sampleDataPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,6 +70,6 @@ public final class DummyTrackOutput implements TrackOutput {
|
|||||||
int size,
|
int size,
|
||||||
int offset,
|
int offset,
|
||||||
@Nullable CryptoData cryptoData) {
|
@Nullable CryptoData cryptoData) {
|
||||||
// Do nothing.
|
discardingTrackOutput.sampleMetadata(timeUs, flags, size, offset, cryptoData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package androidx.media3.extractor;
|
||||||
|
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
|
||||||
|
/** An {@link ExtractorOutput} implementation that does nothing. */
|
||||||
|
@UnstableApi
|
||||||
|
public final class NoOpExtractorOutput implements ExtractorOutput {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TrackOutput track(int id, int type) {
|
||||||
|
return new DiscardingTrackOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endTracks() {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void seekMap(SeekMap seekMap) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
@ -27,10 +27,10 @@ import androidx.media3.common.util.Assertions;
|
|||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.extractor.DummyExtractorOutput;
|
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.ExtractorInput;
|
import androidx.media3.extractor.ExtractorInput;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
|
import androidx.media3.extractor.NoOpExtractorOutput;
|
||||||
import androidx.media3.extractor.PositionHolder;
|
import androidx.media3.extractor.PositionHolder;
|
||||||
import androidx.media3.extractor.SeekMap;
|
import androidx.media3.extractor.SeekMap;
|
||||||
import androidx.media3.extractor.TrackOutput;
|
import androidx.media3.extractor.TrackOutput;
|
||||||
@ -181,7 +181,7 @@ public final class AviExtractor implements Extractor {
|
|||||||
parseSubtitlesDuringExtraction = (extractorFlags & FLAG_EMIT_RAW_SUBTITLE_DATA) == 0;
|
parseSubtitlesDuringExtraction = (extractorFlags & FLAG_EMIT_RAW_SUBTITLE_DATA) == 0;
|
||||||
scratch = new ParsableByteArray(/* limit= */ 12);
|
scratch = new ParsableByteArray(/* limit= */ 12);
|
||||||
chunkHeaderHolder = new ChunkHeaderHolder();
|
chunkHeaderHolder = new ChunkHeaderHolder();
|
||||||
extractorOutput = new DummyExtractorOutput();
|
extractorOutput = new NoOpExtractorOutput();
|
||||||
chunkReaders = new ChunkReader[0];
|
chunkReaders = new ChunkReader[0];
|
||||||
moviStart = C.INDEX_UNSET;
|
moviStart = C.INDEX_UNSET;
|
||||||
moviEnd = C.INDEX_UNSET;
|
moviEnd = C.INDEX_UNSET;
|
||||||
|
@ -18,7 +18,7 @@ package androidx.media3.extractor.flv;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -49,7 +49,7 @@ import java.util.Map;
|
|||||||
private long[] keyFrameTagPositions;
|
private long[] keyFrameTagPositions;
|
||||||
|
|
||||||
public ScriptTagPayloadReader() {
|
public ScriptTagPayloadReader() {
|
||||||
super(new DummyTrackOutput());
|
super(new DiscardingTrackOutput());
|
||||||
durationUs = C.TIME_UNSET;
|
durationUs = C.TIME_UNSET;
|
||||||
keyFrameTimesUs = new long[0];
|
keyFrameTimesUs = new long[0];
|
||||||
keyFrameTagPositions = new long[0];
|
keyFrameTagPositions = new long[0];
|
||||||
|
@ -31,7 +31,7 @@ import androidx.media3.common.util.Log;
|
|||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.Extractor;
|
import androidx.media3.extractor.Extractor;
|
||||||
import androidx.media3.extractor.ExtractorInput;
|
import androidx.media3.extractor.ExtractorInput;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
@ -211,7 +211,7 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
gaplessInfoHolder = new GaplessInfoHolder();
|
gaplessInfoHolder = new GaplessInfoHolder();
|
||||||
basisTimeUs = C.TIME_UNSET;
|
basisTimeUs = C.TIME_UNSET;
|
||||||
id3Peeker = new Id3Peeker();
|
id3Peeker = new Id3Peeker();
|
||||||
skippingTrackOutput = new DummyTrackOutput();
|
skippingTrackOutput = new DiscardingTrackOutput();
|
||||||
currentTrackOutput = skippingTrackOutput;
|
currentTrackOutput = skippingTrackOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import androidx.media3.common.util.ParsableByteArray;
|
|||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.extractor.AacUtil;
|
import androidx.media3.extractor.AacUtil;
|
||||||
import androidx.media3.extractor.DummyTrackOutput;
|
import androidx.media3.extractor.DiscardingTrackOutput;
|
||||||
import androidx.media3.extractor.ExtractorOutput;
|
import androidx.media3.extractor.ExtractorOutput;
|
||||||
import androidx.media3.extractor.TrackOutput;
|
import androidx.media3.extractor.TrackOutput;
|
||||||
import androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator;
|
import androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator;
|
||||||
@ -153,7 +153,7 @@ public final class AdtsReader implements ElementaryStreamReader {
|
|||||||
.setSampleMimeType(MimeTypes.APPLICATION_ID3)
|
.setSampleMimeType(MimeTypes.APPLICATION_ID3)
|
||||||
.build());
|
.build());
|
||||||
} else {
|
} else {
|
||||||
id3Output = new DummyTrackOutput();
|
id3Output = new DiscardingTrackOutput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user