mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Make MODE_SINGLE_PMT the default mode
Even though this is not strictly spec compliant, this will make exoplayer behave like it used to before multiple program support. Developers who want to take advantage of the multiple program support are probably less than the ones who only want their stream to "just work". This is particularly useful for streams obtained after a filtering component, like a tv tuner. Issue:#2757 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=155486122
This commit is contained in:
parent
70b628526a
commit
8d6f5d86b4
3 changed files with 38 additions and 8 deletions
|
|
@ -75,7 +75,7 @@ public final class TsExtractorTest extends InstrumentationTestCase {
|
|||
|
||||
public void testCustomPesReader() throws Exception {
|
||||
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
|
||||
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_NORMAL, new TimestampAdjuster(0),
|
||||
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
|
||||
factory);
|
||||
FakeExtractorInput input = new FakeExtractorInput.Builder()
|
||||
.setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts"))
|
||||
|
|
@ -100,7 +100,7 @@ public final class TsExtractorTest extends InstrumentationTestCase {
|
|||
|
||||
public void testCustomInitialSectionReader() throws Exception {
|
||||
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(false, true);
|
||||
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_NORMAL, new TimestampAdjuster(0),
|
||||
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
|
||||
factory);
|
||||
FakeExtractorInput input = new FakeExtractorInput.Builder()
|
||||
.setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample_with_sdt.ts"))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ import com.google.android.exoplayer2.extractor.ts.AdtsExtractor;
|
|||
import com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory;
|
||||
import com.google.android.exoplayer2.extractor.ts.PsExtractor;
|
||||
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
|
||||
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader;
|
||||
import com.google.android.exoplayer2.extractor.wav.WavExtractor;
|
||||
import com.google.android.exoplayer2.util.TimestampAdjuster;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
/**
|
||||
|
|
@ -67,8 +69,13 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
private @MatroskaExtractor.Flags int matroskaFlags;
|
||||
private @FragmentedMp4Extractor.Flags int fragmentedMp4Flags;
|
||||
private @Mp3Extractor.Flags int mp3Flags;
|
||||
private @TsExtractor.Mode int tsMode;
|
||||
private @DefaultTsPayloadReaderFactory.Flags int tsFlags;
|
||||
|
||||
public DefaultExtractorsFactory() {
|
||||
tsMode = TsExtractor.MODE_SINGLE_PMT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags for {@link MatroskaExtractor} instances created by the factory.
|
||||
*
|
||||
|
|
@ -107,6 +114,18 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mode for {@link TsExtractor} instances created by the factory.
|
||||
*
|
||||
* @see TsExtractor#TsExtractor(int, TimestampAdjuster, TsPayloadReader.Factory).
|
||||
* @param mode The mode to use.
|
||||
* @return The factory, for convenience.
|
||||
*/
|
||||
public synchronized DefaultExtractorsFactory setTsExtractorMode(@TsExtractor.Mode int mode) {
|
||||
tsMode = mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags for {@link DefaultTsPayloadReaderFactory}s used by {@link TsExtractor} instances
|
||||
* created by the factory.
|
||||
|
|
@ -130,7 +149,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
extractors[3] = new Mp3Extractor(mp3Flags);
|
||||
extractors[4] = new AdtsExtractor();
|
||||
extractors[5] = new Ac3Extractor();
|
||||
extractors[6] = new TsExtractor(tsFlags);
|
||||
extractors[6] = new TsExtractor(tsMode, tsFlags);
|
||||
extractors[7] = new FlvExtractor();
|
||||
extractors[8] = new OggExtractor();
|
||||
extractors[9] = new PsExtractor();
|
||||
|
|
|
|||
|
|
@ -65,13 +65,13 @@ public final class TsExtractor implements Extractor {
|
|||
* Modes for the extractor.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({MODE_NORMAL, MODE_SINGLE_PMT, MODE_HLS})
|
||||
@IntDef({MODE_MULTI_PMT, MODE_SINGLE_PMT, MODE_HLS})
|
||||
public @interface Mode {}
|
||||
|
||||
/**
|
||||
* Behave as defined in ISO/IEC 13818-1.
|
||||
*/
|
||||
public static final int MODE_NORMAL = 0;
|
||||
public static final int MODE_MULTI_PMT = 0;
|
||||
/**
|
||||
* Assume only one PMT will be contained in the stream, even if more are declared by the PAT.
|
||||
*/
|
||||
|
|
@ -132,12 +132,23 @@ public final class TsExtractor implements Extractor {
|
|||
* {@code FLAG_*} values that control the behavior of the payload readers.
|
||||
*/
|
||||
public TsExtractor(@Flags int defaultTsPayloadReaderFlags) {
|
||||
this(MODE_NORMAL, new TimestampAdjuster(0),
|
||||
new DefaultTsPayloadReaderFactory(defaultTsPayloadReaderFlags));
|
||||
this(MODE_SINGLE_PMT, defaultTsPayloadReaderFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode Mode for the extractor. One of {@link #MODE_NORMAL}, {@link #MODE_SINGLE_PMT}
|
||||
* @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT}, {@link #MODE_SINGLE_PMT}
|
||||
* and {@link #MODE_HLS}.
|
||||
* @param defaultTsPayloadReaderFlags A combination of {@link DefaultTsPayloadReaderFactory}
|
||||
* {@code FLAG_*} values that control the behavior of the payload readers.
|
||||
*/
|
||||
public TsExtractor(@Mode int mode, @Flags int defaultTsPayloadReaderFlags) {
|
||||
this(mode, new TimestampAdjuster(0),
|
||||
new DefaultTsPayloadReaderFactory(defaultTsPayloadReaderFlags));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT}, {@link #MODE_SINGLE_PMT}
|
||||
* and {@link #MODE_HLS}.
|
||||
* @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
|
||||
* @param payloadReaderFactory Factory for injecting a custom set of payload readers.
|
||||
|
|
|
|||
Loading…
Reference in a new issue