From 2f31beabfe5d0d9c5261c83742269c60e319cda0 Mon Sep 17 00:00:00 2001 From: sr90 Date: Thu, 26 Mar 2020 23:16:07 -0700 Subject: [PATCH] Consider DASH stream descriptor field "roles" for WebVTT text streams. (#740) Fixes #708. --- packager/app/test/packager_test.py | 5 +++++ .../bear-english-text.vtt | 10 ++++++++++ .../output.mpd | 14 ++++++++++---- packager/packager.cc | 6 ++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 packager/app/test/testdata/audio-video-with-accessibilities-and-roles/bear-english-text.vtt diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index d60c2b7fc7..fdd33e201b 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -656,6 +656,11 @@ class PackagerFunctionalTest(PackagerAppTest): self._GetStream('video'), ] + streams += self._GetStreams( + ['text'], + test_files=['bear-english.vtt'], + dash_roles='caption') + self.assertPackageSuccess(streams, self._GetFlags(output_dash=True)) self._CheckTestResults('audio-video-with-accessibilities-and-roles') diff --git a/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/bear-english-text.vtt b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/bear-english-text.vtt new file mode 100644 index 0000000000..b72b5181de --- /dev/null +++ b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/bear-english-text.vtt @@ -0,0 +1,10 @@ +WEBVTT + +STYLE +::cue { color:lime } + +00:00:00.000 --> 00:00:00.800 +Yup, that's a bear, eh. + +00:00:01.000 --> 00:00:04.700 +He 's... um... doing bear-like stuff. diff --git a/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd index 174a565c99..43a0b73ab8 100644 --- a/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd +++ b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd @@ -2,18 +2,24 @@ - - + + + + bear-english-text.vtt + + + + bear-640x360-video.mp4 - + - + bear-640x360-audio.mp4 diff --git a/packager/packager.cc b/packager/packager.cc index ea7ac9cc74..a4079abbcc 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -400,6 +400,12 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor, text_media_info->set_bandwidth(kDefaultTextBandwidth); } + if (!stream_descriptor.dash_roles.empty()) { + for (const auto& dash_role : stream_descriptor.dash_roles) { + text_media_info->add_dash_roles(dash_role); + } + } + return true; }