Skip to content

Commit

Permalink
Transcode completion % should reflect that there's now a DTSH generat…
Browse files Browse the repository at this point in the history
…ion stage after transcoding (#164)

* Transcode completion % should reflect that there's now a DTSH generation stage after transcoding

* Fix failing test
  • Loading branch information
thomshutt authored Nov 10, 2022
1 parent a336434 commit d997701
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions clients/callback_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ func overallCompletionRatio(status TranscodeStatus, currentStageCompletionRatio
switch status {
case TranscodeStatusPreparing, TranscodeStatusPreparingCompleted:
return scaleProgress(currentStageCompletionRatio, 0, 0.4)
case TranscodeStatusTranscoding, TranscodeStatusCompleted:
return scaleProgress(currentStageCompletionRatio, 0.4, 1)
case TranscodeStatusTranscoding:
return scaleProgress(currentStageCompletionRatio, 0.4, 0.9)
case TranscodeStatusCompleted:
return scaleProgress(currentStageCompletionRatio, 0.9, 1)
}

// Either unhandled or an error
Expand Down
2 changes: 1 addition & 1 deletion clients/callback_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestItCalculatesTheOverallCompletionRatioCorrectly(t *testing.T) {
}{
{TranscodeStatusPreparing, 0.5, 0.2}, // Half complete in the Preparing stage (i.e half way between 0 and 0.4)
{TranscodeStatusPreparingCompleted, 1234, 0.4}, // Preparing Completed should always == 0.4 for now, regardless of what's reported as the stage ratio
{TranscodeStatusTranscoding, 0.5, 0.7}, // Half complete in the Transcoding stage (i.e half way between 0.4 and 1)
{TranscodeStatusTranscoding, 0.5, 0.65}, // Half complete in the Transcoding stage (i.e half way between 0.4 and 0.9)
{TranscodeStatusCompleted, 5678, 1}, // Completed should always == 1, regardless of what's reported as the stage ratio
}
for _, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions transcode/transcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ low-bitrate/index.m3u8

// Check we received a progress callback for each segment
require.Equal(t, 2, len(callbacks))
require.Equal(t, 0.7, callbacks[0]["completion_ratio"])
require.Equal(t, 1.0, callbacks[1]["completion_ratio"])
require.Equal(t, 0.65, callbacks[0]["completion_ratio"])
require.Equal(t, 0.9, callbacks[1]["completion_ratio"])

// Check we received a final Transcode Completed callback
require.Equal(t, 1, len(outputs))
Expand Down

0 comments on commit d997701

Please sign in to comment.