Skip to content

Commit

Permalink
Add support for rendering REQ-VIDEO-LAYOUT in stream info classes
Browse files Browse the repository at this point in the history
  • Loading branch information
colekas-ssim committed May 13, 2024
1 parent 6c56da7 commit 6d6c9d4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions m3u8/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ def __init__(self, uri, stream_info, media, base_uri):
hdcp_level=stream_info.get("hdcp_level"),
pathway_id=stream_info.get("pathway_id"),
stable_variant_id=stream_info.get("stable_variant_id"),
req_video_layout=stream_info.get("req_video_layout")
)
self.media = []
for media_type in ("audio", "video", "subtitles"):
Expand Down Expand Up @@ -1047,6 +1048,7 @@ def __init__(self, base_uri, uri, iframe_stream_info):
frame_rate=None,
pathway_id=iframe_stream_info.get("pathway_id"),
stable_variant_id=iframe_stream_info.get("stable_variant_id"),
req_video_layout=None,
)

def __str__(self):
Expand Down Expand Up @@ -1107,6 +1109,7 @@ class StreamInfo:
hdcp_level = None
pathway_id = None
stable_variant_id = None
req_video_layout = None

def __init__(self, **kwargs):
self.bandwidth = kwargs.get("bandwidth")
Expand All @@ -1123,6 +1126,7 @@ def __init__(self, **kwargs):
self.hdcp_level = kwargs.get("hdcp_level")
self.pathway_id = kwargs.get("pathway_id")
self.stable_variant_id = kwargs.get("stable_variant_id")
self.req_video_layout = kwargs.get("req_video_layout")

def __str__(self):
stream_inf = []
Expand Down Expand Up @@ -1152,6 +1156,8 @@ def __str__(self):
stream_inf.append("PATHWAY-ID=" + quoted(self.pathway_id))
if self.stable_variant_id is not None:
stream_inf.append("STABLE-VARIANT-ID=" + quoted(self.stable_variant_id))
if self.req_video_layout is not None:
stream_inf.append("REQ-VIDEO_LAYOUT=" + quoted(self.req_video_layout))
return ",".join(stream_inf)


Expand Down
6 changes: 6 additions & 0 deletions tests/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@
video-64k.m3u8
"""

VARIANT_PLAYLIST_WITH_REQ_VIDEO_LAYOUT = """
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000,CLOSED-CAPTIONS="cc",SUBTITLES="sub",AUDIO="aud",VIDEO="vid",REQ-VIDEO-LAYOUT="CH-STEREO"
http://example.com/with-everything-hi.m3u8
"""

IFRAME_PLAYLIST = """
#EXTM3U
#EXT-X-VERSION:4
Expand Down
6 changes: 6 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,9 @@ def test_media_with_stable_rendition_id():
data["media"][0]["stable_rendition_id"]
== "a8213e27c12a158ea8660e0fe8bdcac6072ca26d984e7e8603652bc61fdceffa"
)

def test_req_video_layout():
data = m3u8.parse(playlists.VARIANT_PLAYLIST_WITH_REQ_VIDEO_LAYOUT)
assert data["playlists"][0]["stream_info"]["req_video_layout"] == '"CH-STEREO"'


0 comments on commit 6d6c9d4

Please sign in to comment.