fix: Add default video stream priority (#30810)
This commit is contained in:
@@ -90,6 +90,10 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
'url': 'https://1234abc.cloudfront.net/A1234abc.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'desktop_webm': {
|
||||
'url': 'https://123abc.cloudfront.net/A123abc.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'fallback': {
|
||||
'url': 'https://1234abcd.cloudfront.net/A1234abcd.mp4',
|
||||
'file_size': 0
|
||||
@@ -97,6 +101,10 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
'youtube': {
|
||||
'url': 'https://1234abcde.cloudfront.net/A1234abcde.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'new_video_format': {
|
||||
'url': 'https://1234abcdef.cloudfront.net/A1234abcdef.mp4',
|
||||
'file_size': 0
|
||||
}
|
||||
},
|
||||
'only_on_web': False
|
||||
@@ -110,8 +118,12 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
post_transform_data = self.change_encoded_videos_presentation(post_transform_data['encoded_videos'])
|
||||
|
||||
for video_format, stream_priority in post_transform_data.items():
|
||||
assert post_transform_data[video_format] == \
|
||||
VideoBlockStreamPriorityTransformer.DEPRECATE_YOUTUBE_VIDEO_STREAM_PRIORITY[video_format]
|
||||
fetched_stream_priority = VideoBlockStreamPriorityTransformer.\
|
||||
DEPRECATE_YOUTUBE_VIDEO_STREAM_PRIORITY.get(video_format)
|
||||
if fetched_stream_priority is None:
|
||||
assert post_transform_data[video_format] == -1
|
||||
else:
|
||||
assert post_transform_data[video_format] == fetched_stream_priority
|
||||
|
||||
@mock.patch('lms.djangoapps.course_blocks.usage_info.CourseUsageInfo')
|
||||
@mock.patch('openedx.core.djangoapps.waffle_utils.CourseWaffleFlag.is_enabled')
|
||||
@@ -139,6 +151,10 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
'url': 'https://1234abc.cloudfront.net/A1234abc.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'desktop_webm': {
|
||||
'url': 'https://123abc.cloudfront.net/A123abc.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'fallback': {
|
||||
'url': 'https://1234abcd.cloudfront.net/A1234abcd.mp4',
|
||||
'file_size': 0
|
||||
@@ -146,6 +162,10 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
'youtube': {
|
||||
'url': 'https://1234abcde.cloudfront.net/A1234abcde.mp4',
|
||||
'file_size': 0
|
||||
},
|
||||
'new_video_format': {
|
||||
'url': 'https://1234abcdef.cloudfront.net/A1234abcdef.mp4',
|
||||
'file_size': 0
|
||||
}
|
||||
},
|
||||
'only_on_web': False
|
||||
@@ -159,8 +179,12 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase):
|
||||
post_transform_data = self.change_encoded_videos_presentation(post_transform_data['encoded_videos'])
|
||||
|
||||
for video_format, stream_priority in post_transform_data.items():
|
||||
assert post_transform_data[video_format] == \
|
||||
VideoBlockStreamPriorityTransformer.DEFAULT_VIDEO_STREAM_PRIORITY[video_format]
|
||||
fetched_stream_priority = VideoBlockStreamPriorityTransformer.\
|
||||
DEFAULT_VIDEO_STREAM_PRIORITY.get(video_format)
|
||||
if fetched_stream_priority is None:
|
||||
assert post_transform_data[video_format] == -1
|
||||
else:
|
||||
assert post_transform_data[video_format] == fetched_stream_priority
|
||||
|
||||
@mock.patch('xmodule.video_module.VideoBlock.student_view_data')
|
||||
def test_no_priority_for_web_only_videos(self, mock_video_data):
|
||||
|
||||
@@ -15,6 +15,7 @@ class VideoBlockStreamPriorityTransformer(BlockStructureTransformer):
|
||||
If DEPRECATE_YOUTUBE waffle flag is on for a course, Youtube videos
|
||||
have highest priority i.e. 0. Else, the default priority for videos
|
||||
is as shown in DEFAULT_VIDEO_STREAM_PRIORITY below.
|
||||
In case video_format not found in given, set stream_priority to -1.
|
||||
"""
|
||||
|
||||
WRITE_VERSION = 1
|
||||
@@ -24,8 +25,9 @@ class VideoBlockStreamPriorityTransformer(BlockStructureTransformer):
|
||||
'mobile_low': 1,
|
||||
'mobile_high': 2,
|
||||
'desktop_mp4': 3,
|
||||
'fallback': 4,
|
||||
'youtube': 5,
|
||||
'desktop_webm': 4,
|
||||
'fallback': 5,
|
||||
'youtube': 6,
|
||||
}
|
||||
DEPRECATE_YOUTUBE_VIDEO_STREAM_PRIORITY = {
|
||||
'youtube': 0,
|
||||
@@ -33,7 +35,8 @@ class VideoBlockStreamPriorityTransformer(BlockStructureTransformer):
|
||||
'mobile_low': 2,
|
||||
'mobile_high': 3,
|
||||
'desktop_mp4': 4,
|
||||
'fallback': 5,
|
||||
'desktop_webm': 5,
|
||||
'fallback': 6,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -66,6 +69,6 @@ class VideoBlockStreamPriorityTransformer(BlockStructureTransformer):
|
||||
encoded_videos = student_view_data.get('encoded_videos')
|
||||
for video_format, video_data in encoded_videos.items():
|
||||
if DEPRECATE_YOUTUBE.is_enabled(usage_info.course_key):
|
||||
video_data['stream_priority'] = self.DEPRECATE_YOUTUBE_VIDEO_STREAM_PRIORITY[video_format]
|
||||
video_data['stream_priority'] = self.DEPRECATE_YOUTUBE_VIDEO_STREAM_PRIORITY.get(video_format, -1)
|
||||
else:
|
||||
video_data['stream_priority'] = self.DEFAULT_VIDEO_STREAM_PRIORITY[video_format]
|
||||
video_data['stream_priority'] = self.DEFAULT_VIDEO_STREAM_PRIORITY.get(video_format, -1)
|
||||
|
||||
Reference in New Issue
Block a user