mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Allow setting constant bitrate flags in DefaultExtractorsFactory
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=207566605
This commit is contained in:
parent
4558eb4e99
commit
cab1d02c0c
@ -16,6 +16,9 @@
|
||||
* Support approximate seeking in AMR using a constant bitrate assumption.
|
||||
Note that the `FLAG_ENABLE_CONSTANT_BITRATE_SEEKING` flag must be set on the
|
||||
extractor to enable this functionality.
|
||||
* Add `DefaultExtractorsFactory.setConstantBitrateSeekingEnabled` to enable
|
||||
approximate seeking using a constant bitrate assumption for all extractors
|
||||
that support it.
|
||||
* MPEG-TS: Support CEA-608/708 in H262
|
||||
([#2565](https://github.com/google/ExoPlayer/issues/2565)).
|
||||
* MediaSession extension: Allow apps to set custom errors.
|
||||
|
@ -72,6 +72,9 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
||||
FLAC_EXTRACTOR_CONSTRUCTOR = flacExtractorConstructor;
|
||||
}
|
||||
|
||||
private boolean constantBitrateSeekingEnabled;
|
||||
private @AdtsExtractor.Flags int adtsFlags;
|
||||
private @AmrExtractor.Flags int amrFlags;
|
||||
private @MatroskaExtractor.Flags int matroskaFlags;
|
||||
private @Mp4Extractor.Flags int mp4Flags;
|
||||
private @FragmentedMp4Extractor.Flags int fragmentedMp4Flags;
|
||||
@ -83,6 +86,45 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
||||
tsMode = TsExtractor.MODE_SINGLE_PMT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to set whether approximate seeking using constant bitrate assumptions should
|
||||
* be enabled for all extractors that support it. If set to true, the flags required to enable
|
||||
* this functionality will be OR'd with those passed to the setters when creating extractor
|
||||
* instances. If set to false then the flags passed to the setters will be used without
|
||||
* modification.
|
||||
*
|
||||
* @param constantBitrateSeekingEnabled Whether approximate seeking using a constant bitrate
|
||||
* assumption should be enabled for all extractors that support it.
|
||||
*/
|
||||
public void setConstantBitrateSeekingEnabled(boolean constantBitrateSeekingEnabled) {
|
||||
this.constantBitrateSeekingEnabled = constantBitrateSeekingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags for {@link AdtsExtractor} instances created by the factory.
|
||||
*
|
||||
* @see AdtsExtractor#AdtsExtractor(long, int)
|
||||
* @param flags The flags to use.
|
||||
* @return The factory, for convenience.
|
||||
*/
|
||||
public synchronized DefaultExtractorsFactory setAdtsExtractorFlags(
|
||||
@AdtsExtractor.Flags int flags) {
|
||||
this.adtsFlags = flags;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags for {@link AmrExtractor} instances created by the factory.
|
||||
*
|
||||
* @see AmrExtractor#AmrExtractor(int)
|
||||
* @param flags The flags to use.
|
||||
* @return The factory, for convenience.
|
||||
*/
|
||||
public synchronized DefaultExtractorsFactory setAmrExtractorFlags(@AmrExtractor.Flags int flags) {
|
||||
this.amrFlags = flags;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags for {@link MatroskaExtractor} instances created by the factory.
|
||||
*
|
||||
@ -165,15 +207,31 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
||||
extractors[0] = new MatroskaExtractor(matroskaFlags);
|
||||
extractors[1] = new FragmentedMp4Extractor(fragmentedMp4Flags);
|
||||
extractors[2] = new Mp4Extractor(mp4Flags);
|
||||
extractors[3] = new Mp3Extractor(mp3Flags);
|
||||
extractors[4] = new AdtsExtractor();
|
||||
extractors[3] =
|
||||
new Mp3Extractor(
|
||||
mp3Flags
|
||||
| (constantBitrateSeekingEnabled
|
||||
? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING
|
||||
: 0));
|
||||
extractors[4] =
|
||||
new AdtsExtractor(
|
||||
/* firstStreamSampleTimestampUs= */ 0,
|
||||
adtsFlags
|
||||
| (constantBitrateSeekingEnabled
|
||||
? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING
|
||||
: 0));
|
||||
extractors[5] = new Ac3Extractor();
|
||||
extractors[6] = new TsExtractor(tsMode, tsFlags);
|
||||
extractors[7] = new FlvExtractor();
|
||||
extractors[8] = new OggExtractor();
|
||||
extractors[9] = new PsExtractor();
|
||||
extractors[10] = new WavExtractor();
|
||||
extractors[11] = new AmrExtractor();
|
||||
extractors[11] =
|
||||
new AmrExtractor(
|
||||
amrFlags
|
||||
| (constantBitrateSeekingEnabled
|
||||
? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING
|
||||
: 0));
|
||||
if (FLAC_EXTRACTOR_CONSTRUCTOR != null) {
|
||||
try {
|
||||
extractors[12] = FLAC_EXTRACTOR_CONSTRUCTOR.newInstance();
|
||||
|
Loading…
x
Reference in New Issue
Block a user