mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Rename SampleDataReader to DataReader and move to common
PiperOrigin-RevId: 297603312
This commit is contained in:
parent
1f71830127
commit
a114a0ed7f
10 changed files with 27 additions and 25 deletions
|
|
@ -13,15 +13,15 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.exoplayer2.extractor;
|
||||
package com.google.android.exoplayer2.upstream;
|
||||
|
||||
import com.google.android.exoplayer2.C;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Provides sample data to be consumed by a {@link TrackOutput}. */
|
||||
public interface SampleDataReader {
|
||||
/** Reads bytes from a data stream. */
|
||||
public interface DataReader {
|
||||
/**
|
||||
* Reads up to {@code length} bytes of sample data from the input.
|
||||
* Reads up to {@code length} bytes of data from the input.
|
||||
*
|
||||
* @param target A target array into which data should be written.
|
||||
* @param offset The offset into the target array at which to write.
|
||||
|
|
@ -19,11 +19,11 @@ import androidx.annotation.Nullable;
|
|||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.decoder.CryptoInfo;
|
||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput.CryptoData;
|
||||
import com.google.android.exoplayer2.source.SampleQueue.SampleExtrasHolder;
|
||||
import com.google.android.exoplayer2.upstream.Allocation;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.io.EOFException;
|
||||
|
|
@ -177,7 +177,7 @@ import java.util.Arrays;
|
|||
return totalBytesWritten;
|
||||
}
|
||||
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
length = preAppend(length);
|
||||
int bytesAppended =
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
|||
import com.google.android.exoplayer2.drm.DrmInitData;
|
||||
import com.google.android.exoplayer2.drm.DrmSession;
|
||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
|
|
@ -469,7 +469,7 @@ public class SampleQueue implements TrackOutput {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public final int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
return sampleDataQueue.sampleData(input, length, allowEndOfInput);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import com.google.android.exoplayer2.Format;
|
|||
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
|
||||
import com.google.android.exoplayer2.extractor.Extractor;
|
||||
import com.google.android.exoplayer2.extractor.ExtractorOutput;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.SeekMap;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import java.io.IOException;
|
||||
|
|
@ -203,7 +203,7 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
return castNonNull(trackOutput).sampleData(input, length, allowEndOfInput);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.google.android.exoplayer2.Format;
|
|||
import com.google.android.exoplayer2.FormatHolder;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
|
||||
|
|
@ -35,6 +34,7 @@ import com.google.android.exoplayer2.source.SampleQueue;
|
|||
import com.google.android.exoplayer2.source.chunk.Chunk;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.io.IOException;
|
||||
|
|
@ -295,7 +295,7 @@ public final class PlayerEmsgHandler implements Handler.Callback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
return sampleQueue.sampleData(input, length, allowEndOfInput);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.extractor;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
|
@ -42,7 +43,7 @@ public final class DummyTrackOutput implements TrackOutput {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
int bytesToSkipByReading = Math.min(readBuffer.length, length);
|
||||
int bytesSkipped = input.read(readBuffer, /* offset= */ 0, bytesToSkipByReading);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package com.google.android.exoplayer2.extractor;
|
||||
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -63,7 +64,7 @@ import java.io.InputStream;
|
|||
* (regardless of {@code allowEndOfInput}).
|
||||
* </ul>
|
||||
*/
|
||||
public interface ExtractorInput extends SampleDataReader {
|
||||
public interface ExtractorInput extends DataReader {
|
||||
|
||||
/**
|
||||
* Reads up to {@code length} bytes from the input and resets the peek position.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.extractor;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
|
@ -103,7 +104,7 @@ public interface TrackOutput {
|
|||
/**
|
||||
* Called to write sample data to the output.
|
||||
*
|
||||
* @param input An {@link ExtractorInput} from which to read the sample data.
|
||||
* @param input A {@link DataReader} from which to read the sample data.
|
||||
* @param length The maximum length to read from the input.
|
||||
* @param allowEndOfInput True if encountering the end of the input having read no data is
|
||||
* allowed, and should result in {@link C#RESULT_END_OF_INPUT} being returned. False if it
|
||||
|
|
@ -112,7 +113,7 @@ public interface TrackOutput {
|
|||
* @throws IOException If an error occurred reading from the input.
|
||||
* @throws InterruptedException If the thread was interrupted.
|
||||
*/
|
||||
int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException;
|
||||
|
||||
/**
|
||||
|
|
@ -127,15 +128,14 @@ public interface TrackOutput {
|
|||
* Called when metadata associated with a sample has been extracted from the stream.
|
||||
*
|
||||
* <p>The corresponding sample data will have already been passed to the output via calls to
|
||||
* {@link #sampleData(SampleDataReader, int, boolean)} or {@link #sampleData(ParsableByteArray,
|
||||
* int)}.
|
||||
* {@link #sampleData(DataReader, int, boolean)} or {@link #sampleData(ParsableByteArray, int)}.
|
||||
*
|
||||
* @param timeUs The media timestamp associated with the sample, in microseconds.
|
||||
* @param flags Flags associated with the sample. See {@code C.BUFFER_FLAG_*}.
|
||||
* @param size The size of the sample data, in bytes.
|
||||
* @param offset The number of bytes that have been passed to {@link #sampleData(SampleDataReader,
|
||||
* int, boolean)} or {@link #sampleData(ParsableByteArray, int)} since the last byte belonging
|
||||
* to the sample whose metadata is being passed.
|
||||
* @param offset The number of bytes that have been passed to {@link #sampleData(DataReader, int,
|
||||
* boolean)} or {@link #sampleData(ParsableByteArray, int)} since the last byte belonging to
|
||||
* the sample whose metadata is being passed.
|
||||
* @param encryptionData The encryption data required to decrypt the sample. May be null.
|
||||
*/
|
||||
void sampleMetadata(
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.google.android.exoplayer2.drm.DrmSessionManager;
|
|||
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
|
||||
import com.google.android.exoplayer2.extractor.Extractor;
|
||||
import com.google.android.exoplayer2.extractor.ExtractorOutput;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.SeekMap;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
|
|
@ -48,6 +47,7 @@ import com.google.android.exoplayer2.source.chunk.Chunk;
|
|||
import com.google.android.exoplayer2.source.chunk.MediaChunkIterator;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
|
||||
import com.google.android.exoplayer2.upstream.Loader;
|
||||
import com.google.android.exoplayer2.upstream.Loader.LoadErrorAction;
|
||||
|
|
@ -1459,7 +1459,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
ensureBufferCapacity(bufferPosition + length);
|
||||
int numBytesRead = input.read(buffer, bufferPosition, length);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.extractor.SampleDataReader;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.testutil.Dumper.Dumpable;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.io.EOFException;
|
||||
|
|
@ -65,7 +65,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
|
||||
public int sampleData(DataReader input, int length, boolean allowEndOfInput)
|
||||
throws IOException, InterruptedException {
|
||||
byte[] newData = new byte[length];
|
||||
int bytesAppended = input.read(newData, 0, length);
|
||||
|
|
|
|||
Loading…
Reference in a new issue