Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ class CS3IPlayer : IPlayer {
currentSubtitleOffset = offset
CustomDecoder.subtitleOffset = offset
if (currentTextRenderer?.state == STATE_ENABLED || currentTextRenderer?.state == STATE_STARTED) {
exoPlayer?.currentPosition?.let { pos ->
exoPlayer?.currentPosition?.also { pos ->
// This seems to properly refresh all subtitles
// It needs to be done as all subtitle cues with timings are pre-processed
currentTextRenderer?.resetPosition(pos)
currentTextRenderer?.resetPosition(pos, false)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package com.lagradost.cloudstream3.ui.player

import android.net.Uri
import androidx.annotation.GuardedBy
import androidx.media3.common.C
import androidx.media3.common.FileTypes
import androidx.media3.common.Format
import androidx.media3.common.util.TimestampAdjuster
Expand Down Expand Up @@ -48,7 +49,6 @@ import java.lang.reflect.Constructor
import java.lang.reflect.InvocationTargetException
import java.util.concurrent.atomic.AtomicBoolean


/**
* An [ExtractorsFactory] that provides an array of extractors for the following formats:
*
Expand Down Expand Up @@ -103,13 +103,16 @@ class UpdatedDefaultExtractorsFactory : ExtractorsFactory {
private var tsTimestampSearchBytes: Int
private var textTrackTranscodingEnabled: Boolean
private var subtitleParserFactory: SubtitleParser.Factory
private var codecsToParseWithinGopSampleDependencies: @C.VideoCodecFlags Int
private var jpegFlags: @JpegExtractor.Flags Int = 0
private var heifFlags: @HeifExtractor.Flags Int = 0

init {
tsMode = TsExtractor.MODE_SINGLE_PMT
tsTimestampSearchBytes = TsExtractor.DEFAULT_TIMESTAMP_SEARCH_BYTES
subtitleParserFactory = DefaultSubtitleParserFactory()
textTrackTranscodingEnabled = true
codecsToParseWithinGopSampleDependencies = C.VIDEO_CODEC_FLAG_H264 or C.VIDEO_CODEC_FLAG_H265
}

/**
Expand Down Expand Up @@ -346,6 +349,14 @@ class UpdatedDefaultExtractorsFactory : ExtractorsFactory {
return this
}

@Synchronized
override fun experimentalSetCodecsToParseWithinGopSampleDependencies(
codecsToParseWithinGopSampleDependencies: @C.VideoCodecFlags Int
): UpdatedDefaultExtractorsFactory {
this.codecsToParseWithinGopSampleDependencies = codecsToParseWithinGopSampleDependencies
return this
}

/**
* Sets flags for [JpegExtractor] instances created by the factory.
*
Expand All @@ -361,6 +372,21 @@ class UpdatedDefaultExtractorsFactory : ExtractorsFactory {
return this
}

/**
* Sets flags for [HeifExtractor] instances created by the factory.
*
* @see HeifExtractor.HeifExtractor
* @param flags The flags to use.
* @return The factory, for convenience.
*/
@Synchronized
fun setHeifExtractorFlags(
flags: @HeifExtractor.Flags Int
): UpdatedDefaultExtractorsFactory {
this.heifFlags = flags
return this
}

@Synchronized
override fun createExtractors(): Array<Extractor> {
return createExtractors(Uri.EMPTY, HashMap())
Expand Down Expand Up @@ -468,21 +494,26 @@ class UpdatedDefaultExtractorsFactory : ExtractorsFactory {
extractors.add(
FragmentedMp4Extractor(
subtitleParserFactory,
fragmentedMp4Flags
or (if (textTrackTranscodingEnabled)
0
else
FragmentedMp4Extractor.FLAG_EMIT_RAW_SUBTITLE_DATA)
fragmentedMp4Flags or
FragmentedMp4Extractor
.codecsToParseWithinGopSampleDependenciesAsFlags(
codecsToParseWithinGopSampleDependencies
) or
if (textTrackTranscodingEnabled) 0
else FragmentedMp4Extractor.FLAG_EMIT_RAW_SUBTITLE_DATA
)
)

extractors.add(
Mp4Extractor(
subtitleParserFactory,
mp4Flags
or (if (textTrackTranscodingEnabled)
0
else
Mp4Extractor.FLAG_EMIT_RAW_SUBTITLE_DATA)
mp4Flags or
Mp4Extractor
.codecsToParseWithinGopSampleDependenciesAsFlags(
codecsToParseWithinGopSampleDependencies
) or
if (textTrackTranscodingEnabled) 0
else Mp4Extractor.FLAG_EMIT_RAW_SUBTITLE_DATA
)
)
}
Expand Down Expand Up @@ -524,12 +555,7 @@ class UpdatedDefaultExtractorsFactory : ExtractorsFactory {
FileTypes.PNG -> extractors.add(PngExtractor())
FileTypes.WEBP -> extractors.add(WebpExtractor())
FileTypes.BMP -> extractors.add(BmpExtractor())
FileTypes.HEIF -> if ((mp4Flags and Mp4Extractor.FLAG_READ_MOTION_PHOTO_METADATA) == 0
&& (mp4Flags and Mp4Extractor.FLAG_READ_SEF_DATA) == 0
) {
extractors.add(HeifExtractor())
}

FileTypes.HEIF -> extractors.add(HeifExtractor(heifFlags))
FileTypes.AVIF -> extractors.add(AvifExtractor())
FileTypes.WEBVTT, FileTypes.UNKNOWN -> {}
else -> {}
Expand Down
Loading