mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
Add DefaultExtractorsFactory.setTsSubtitleFormats
ExoPlayer is unable to detect the presence of subtitle tracks in some MPEG-TS files that don't fully declare them. It's possible for a developer to provide the list instead, but doing so is quite awkward without this helper method. This is consistent for how `DefaultExtractorsFactory` allows other aspects of the delegate `Extractor` implementations to be customised. * Issue: google/ExoPlayer#10175 * Issue: google/ExoPlayer#10505 #minor-release PiperOrigin-RevId: 490214619
This commit is contained in:
parent
c41a5c8420
commit
ff48faec5f
1 changed files with 24 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ import android.net.Uri;
|
|||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.FileTypes;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.util.TimestampAdjuster;
|
||||
|
|
@ -44,6 +45,7 @@ import androidx.media3.extractor.ts.PsExtractor;
|
|||
import androidx.media3.extractor.ts.TsExtractor;
|
||||
import androidx.media3.extractor.ts.TsPayloadReader;
|
||||
import androidx.media3.extractor.wav.WavExtractor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -128,11 +130,13 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
private @Mp3Extractor.Flags int mp3Flags;
|
||||
private @TsExtractor.Mode int tsMode;
|
||||
private @DefaultTsPayloadReaderFactory.Flags int tsFlags;
|
||||
private ImmutableList<Format> tsSubtitleFormats;
|
||||
private int tsTimestampSearchBytes;
|
||||
|
||||
public DefaultExtractorsFactory() {
|
||||
tsMode = TsExtractor.MODE_SINGLE_PMT;
|
||||
tsTimestampSearchBytes = TsExtractor.DEFAULT_TIMESTAMP_SEARCH_BYTES;
|
||||
tsSubtitleFormats = ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -303,6 +307,20 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a list of subtitle formats to pass to the {@link DefaultTsPayloadReaderFactory} used by
|
||||
* {@link TsExtractor} instances created by the factory.
|
||||
*
|
||||
* @see DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory(int, List)
|
||||
* @param subtitleFormats The subtitle formats.
|
||||
* @return The factory, for convenience.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public synchronized DefaultExtractorsFactory setTsSubtitleFormats(List<Format> subtitleFormats) {
|
||||
tsSubtitleFormats = ImmutableList.copyOf(subtitleFormats);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of bytes searched to find a timestamp for {@link TsExtractor} instances created
|
||||
* by the factory.
|
||||
|
|
@ -416,7 +434,12 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
|
|||
extractors.add(new PsExtractor());
|
||||
break;
|
||||
case FileTypes.TS:
|
||||
extractors.add(new TsExtractor(tsMode, tsFlags, tsTimestampSearchBytes));
|
||||
extractors.add(
|
||||
new TsExtractor(
|
||||
tsMode,
|
||||
new TimestampAdjuster(0),
|
||||
new DefaultTsPayloadReaderFactory(tsFlags, tsSubtitleFormats),
|
||||
tsTimestampSearchBytes));
|
||||
break;
|
||||
case FileTypes.WAV:
|
||||
extractors.add(new WavExtractor());
|
||||
|
|
|
|||
Loading…
Reference in a new issue