From d997701a58ee17e7de07b03bef960cf6e2d23a79 Mon Sep 17 00:00:00 2001 From: Thom Shutt Date: Thu, 10 Nov 2022 11:19:56 +0000 Subject: [PATCH] Transcode completion % should reflect that there's now a DTSH generation stage after transcoding (#164) * Transcode completion % should reflect that there's now a DTSH generation stage after transcoding * Fix failing test --- clients/callback_client.go | 6 ++++-- clients/callback_client_test.go | 2 +- transcode/transcode_test.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clients/callback_client.go b/clients/callback_client.go index a6219c901..a5495d7cc 100644 --- a/clients/callback_client.go +++ b/clients/callback_client.go @@ -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 diff --git a/clients/callback_client_test.go b/clients/callback_client_test.go index 15e104bfd..a8deb7809 100644 --- a/clients/callback_client_test.go +++ b/clients/callback_client_test.go @@ -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 { diff --git a/transcode/transcode_test.go b/transcode/transcode_test.go index 27f21f1d1..76b2b1328 100644 --- a/transcode/transcode_test.go +++ b/transcode/transcode_test.go @@ -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))