Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b63d010

Browse files
committed
Reassign TrackStatus in some conditions
1 parent 18f5bfd commit b63d010

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

‎lib/src/main/java/com/otaliastudios/transcoder/internal/DefaultEngine.kt

+2-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class DefaultEngine(
3131

3232
private val log = Logger("DefaultEngine")
3333

34-
private val tracks = Tracks(strategies, dataSources)
34+
private val tracks = Tracks(strategies, dataSources, videoRotation)
3535

3636
private val segments = Segments(dataSources, tracks, ::createPipeline)
3737

@@ -78,11 +78,7 @@ internal class DefaultEngine(
7878
}
7979

8080
override fun validate(): Boolean {
81-
// If we have to apply some rotation, and the video should be transcoded,
82-
// ignore any Validator trying to abort the operation. The operation must happen
83-
// because we must apply the rotation.
84-
val ignoreValidatorResult = tracks.active.hasVideo && videoRotation != 0
85-
if (!validator.validate(tracks.all.video, tracks.all.audio) && !ignoreValidatorResult) {
81+
if (!validator.validate(tracks.all.video, tracks.all.audio)) {
8682
LOG.i("Validator has decided that the input is fine and transcoding is not necessary.")
8783
return false
8884
}

‎lib/src/main/java/com/otaliastudios/transcoder/internal/Tracks.kt

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import com.otaliastudios.transcoder.strategy.TrackStrategy
1212

1313
internal class Tracks(
1414
strategies: TrackMap<TrackStrategy>,
15-
sources: DataSources
15+
sources: DataSources,
16+
videoRotation: Int
1617
) {
1718

1819
private val log = Logger("Tracks")
@@ -26,7 +27,10 @@ internal class Tracks(
2627
val (videoFormat, videoStatus) = resolveTrack(TrackType.VIDEO, strategies.video, sources.videoOrNull())
2728
log.i("init: videoStatus=$videoStatus, videoFormat=$videoFormat")
2829
log.i("init: audioStatus=$audioStatus, audioFormat=$audioFormat")
29-
all = trackMapOf(video = videoStatus, audio = audioStatus)
30+
all = trackMapOf(
31+
video = resolveVideoStatus(videoStatus, videoRotation),
32+
audio = audioStatus
33+
)
3034
outputFormats = trackMapOf(video = videoFormat, audio = audioFormat)
3135
}
3236

@@ -35,6 +39,12 @@ internal class Tracks(
3539
audio = all.audio.takeIf { it.isTranscoding }
3640
)
3741

42+
private fun resolveVideoStatus(status: TrackStatus, rotation: Int): TrackStatus {
43+
return if (status == TrackStatus.PASS_THROUGH && rotation != 0) {
44+
TrackStatus.COMPRESSING
45+
} else status
46+
}
47+
3848
private fun resolveTrack(
3949
type: TrackType,
4050
strategy: TrackStrategy,

0 commit comments

Comments
 (0)