Skip to content

Commit c740cc0

Browse files
colekas-ssimmauricioabreu
authored andcommitted
Add support for rendering REQ-VIDEO-LAYOUT in stream info classes
1 parent 6a3eba1 commit c740cc0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

m3u8/model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ def __init__(self, uri, stream_info, media, base_uri):
982982
hdcp_level=stream_info.get("hdcp_level"),
983983
pathway_id=stream_info.get("pathway_id"),
984984
stable_variant_id=stream_info.get("stable_variant_id"),
985+
req_video_layout=stream_info.get("req_video_layout")
985986
)
986987
self.media = []
987988
for media_type in ("audio", "video", "subtitles"):
@@ -1047,6 +1048,7 @@ def __init__(self, base_uri, uri, iframe_stream_info):
10471048
frame_rate=None,
10481049
pathway_id=iframe_stream_info.get("pathway_id"),
10491050
stable_variant_id=iframe_stream_info.get("stable_variant_id"),
1051+
req_video_layout=None,
10501052
)
10511053

10521054
def __str__(self):
@@ -1107,6 +1109,7 @@ class StreamInfo:
11071109
hdcp_level = None
11081110
pathway_id = None
11091111
stable_variant_id = None
1112+
req_video_layout = None
11101113

11111114
def __init__(self, **kwargs):
11121115
self.bandwidth = kwargs.get("bandwidth")
@@ -1123,6 +1126,7 @@ def __init__(self, **kwargs):
11231126
self.hdcp_level = kwargs.get("hdcp_level")
11241127
self.pathway_id = kwargs.get("pathway_id")
11251128
self.stable_variant_id = kwargs.get("stable_variant_id")
1129+
self.req_video_layout = kwargs.get("req_video_layout")
11261130

11271131
def __str__(self):
11281132
stream_inf = []
@@ -1152,6 +1156,8 @@ def __str__(self):
11521156
stream_inf.append("PATHWAY-ID=" + quoted(self.pathway_id))
11531157
if self.stable_variant_id is not None:
11541158
stream_inf.append("STABLE-VARIANT-ID=" + quoted(self.stable_variant_id))
1159+
if self.req_video_layout is not None:
1160+
stream_inf.append("REQ-VIDEO_LAYOUT=" + quoted(self.req_video_layout))
11551161
return ",".join(stream_inf)
11561162

11571163

tests/playlists.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@
227227
video-64k.m3u8
228228
"""
229229

230+
VARIANT_PLAYLIST_WITH_REQ_VIDEO_LAYOUT = """
231+
#EXTM3U
232+
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000,CLOSED-CAPTIONS="cc",SUBTITLES="sub",AUDIO="aud",VIDEO="vid",REQ-VIDEO-LAYOUT="CH-STEREO"
233+
http://example.com/with-everything-hi.m3u8
234+
"""
235+
230236
IFRAME_PLAYLIST = """
231237
#EXTM3U
232238
#EXT-X-VERSION:4

tests/test_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,3 +905,9 @@ def test_media_with_stable_rendition_id():
905905
data["media"][0]["stable_rendition_id"]
906906
== "a8213e27c12a158ea8660e0fe8bdcac6072ca26d984e7e8603652bc61fdceffa"
907907
)
908+
909+
def test_req_video_layout():
910+
data = m3u8.parse(playlists.VARIANT_PLAYLIST_WITH_REQ_VIDEO_LAYOUT)
911+
assert data["playlists"][0]["stream_info"]["req_video_layout"] == '"CH-STEREO"'
912+
913+

0 commit comments

Comments
 (0)