Skip to content

Commit 1c11c34

Browse files
committed
python server SDK: add unified start_egress convenience method
livekit-api (python) EgressService exposes a unified start_egress that calls the Egress.StartEgress RPC with the v2 StartEgressRequest
1 parent 0ef63ce commit 1c11c34

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

livekit-api/livekit/api/egress_service.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
UpdateStreamRequest,
1010
ListEgressRequest,
1111
StopEgressRequest,
12+
StartEgressRequest,
1213
EgressInfo,
1314
ListEgressResponse,
1415
)
@@ -93,6 +94,16 @@ async def start_track_egress(self, start: TrackEgressRequest) -> EgressInfo:
9394
EgressInfo,
9495
)
9596

97+
async def start_egress(self, start: StartEgressRequest) -> EgressInfo:
98+
"""Starts an egress; the request's source and outputs determine the egress type."""
99+
return await self._client.request(
100+
SVC,
101+
"StartEgress",
102+
start,
103+
self._auth_header(VideoGrants(room_record=True)),
104+
EgressInfo,
105+
)
106+
96107
async def update_layout(self, update: UpdateLayoutRequest) -> EgressInfo:
97108
"""Updates the layout of a composite recording."""
98109
return await self._client.request(

tests/api/test_livekitapi.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,19 @@ async def _egress_smoke():
194194
file=api.DirectFileOutput(filepath="track.mp4"),
195195
)
196196
)
197+
await lk.egress.start_egress(
198+
api.StartEgressRequest(
199+
room_name="test-room",
200+
web=api.WebSource(url="https://example.com/scene"),
201+
outputs=[
202+
api.Output(
203+
file=api.FileOutput(
204+
file_type=api.EncodedFileType.MP4, filepath="unified.mp4"
205+
)
206+
)
207+
],
208+
)
209+
)
197210
await lk.egress.update_layout(
198211
api.UpdateLayoutRequest(egress_id="EG_abc123", layout="speaker")
199212
)

0 commit comments

Comments
 (0)