Commit 0b8e9754 by aquilescanta Committed by Oliver Woodman

Pass initialization parameters to section readers

Unlike with PesReaders, sections don't have a standard way
of providing timestmaps or even generating tracks. We need
to pass this information so that readers decide what to do
with it.

Issue:#726

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=137162494
parent 1809836c
...@@ -208,6 +208,12 @@ public final class TsExtractorTest extends InstrumentationTestCase { ...@@ -208,6 +208,12 @@ public final class TsExtractorTest extends InstrumentationTestCase {
private int consumedSdts; private int consumedSdts;
@Override @Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator) {
// Do nothing.
}
@Override
public void consume(ParsableByteArray sectionData) { public void consume(ParsableByteArray sectionData) {
// table_id(8), section_syntax_indicator(1), reserved_future_use(1), reserved(2), // table_id(8), section_syntax_indicator(1), reserved_future_use(1), reserved(2),
// section_length(12), transport_stream_id(16), reserved(2), version_number(5), // section_length(12), transport_stream_id(16), reserved(2), version_number(5),
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
*/ */
package com.google.android.exoplayer2.extractor.ts; package com.google.android.exoplayer2.extractor.ts;
import com.google.android.exoplayer2.extractor.ExtractorOutput;
import com.google.android.exoplayer2.extractor.TimestampAdjuster;
import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
/** /**
...@@ -23,6 +27,17 @@ import com.google.android.exoplayer2.util.ParsableByteArray; ...@@ -23,6 +27,17 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
public interface SectionPayloadReader { public interface SectionPayloadReader {
/** /**
* Initializes the section payload reader.
*
* @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
* @param extractorOutput The {@link ExtractorOutput} that receives the extracted data.
* @param idGenerator A {@link PesReader.TrackIdGenerator} that generates unique track ids for the
* {@link TrackOutput}s.
*/
void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator);
/**
* Called by a {@link SectionReader} when a full section is received. * Called by a {@link SectionReader} when a full section is received.
* *
* @param sectionData The data belonging to a section, including the section header but excluding * @param sectionData The data belonging to a section, including the section header but excluding
......
...@@ -43,8 +43,7 @@ public final class SectionReader implements TsPayloadReader { ...@@ -43,8 +43,7 @@ public final class SectionReader implements TsPayloadReader {
@Override @Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator) { TrackIdGenerator idGenerator) {
// TODO: Injectable section readers might want to generate metadata tracks. reader.init(timestampAdjuster, extractorOutput, idGenerator);
// Do nothing.
} }
@Override @Override
......
...@@ -65,8 +65,6 @@ public final class TsExtractor implements Extractor { ...@@ -65,8 +65,6 @@ public final class TsExtractor implements Extractor {
public static final int TS_STREAM_TYPE_H265 = 0x24; public static final int TS_STREAM_TYPE_H265 = 0x24;
public static final int TS_STREAM_TYPE_ID3 = 0x15; public static final int TS_STREAM_TYPE_ID3 = 0x15;
private static final String TAG = "TsExtractor";
private static final int TS_PACKET_SIZE = 188; private static final int TS_PACKET_SIZE = 188;
private static final int TS_SYNC_BYTE = 0x47; // First byte of each TS packet. private static final int TS_SYNC_BYTE = 0x47; // First byte of each TS packet.
private static final int TS_PAT_PID = 0; private static final int TS_PAT_PID = 0;
...@@ -275,6 +273,12 @@ public final class TsExtractor implements Extractor { ...@@ -275,6 +273,12 @@ public final class TsExtractor implements Extractor {
} }
@Override @Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator) {
// Do nothing.
}
@Override
public void consume(ParsableByteArray sectionData) { public void consume(ParsableByteArray sectionData) {
// table_id(8), section_syntax_indicator(1), '0'(1), reserved(2), section_length(12), // table_id(8), section_syntax_indicator(1), '0'(1), reserved(2), section_length(12),
// transport_stream_id (16), reserved (2), version_number (5), current_next_indicator (1), // transport_stream_id (16), reserved (2), version_number (5), current_next_indicator (1),
...@@ -317,6 +321,12 @@ public final class TsExtractor implements Extractor { ...@@ -317,6 +321,12 @@ public final class TsExtractor implements Extractor {
} }
@Override @Override
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator) {
// Do nothing.
}
@Override
public void consume(ParsableByteArray sectionData) { public void consume(ParsableByteArray sectionData) {
// table_id(8), section_syntax_indicator(1), '0'(1), reserved(2), section_length(12), // table_id(8), section_syntax_indicator(1), '0'(1), reserved(2), section_length(12),
// program_number (16), reserved (2), version_number (5), current_next_indicator (1), // program_number (16), reserved (2), version_number (5), current_next_indicator (1),
......
...@@ -99,9 +99,10 @@ public interface TsPayloadReader { ...@@ -99,9 +99,10 @@ public interface TsPayloadReader {
/** /**
* Initializes the payload reader. * Initializes the payload reader.
* *
* @param timestampAdjuster * @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
* @param extractorOutput * @param extractorOutput The {@link ExtractorOutput} that receives the extracted data.
* @param idGenerator * @param idGenerator A {@link PesReader.TrackIdGenerator} that generates unique track ids for the
* {@link TrackOutput}s.
*/ */
void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput,
TrackIdGenerator idGenerator); TrackIdGenerator idGenerator);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment