|
1 | 1 | import aiohttp |
2 | | -from livekit.protocol import egress as proto_egress |
| 2 | +from livekit.protocol.egress import ( |
| 3 | + RoomCompositeEgressRequest, |
| 4 | + WebEgressRequest, |
| 5 | + ParticipantEgressRequest, |
| 6 | + TrackCompositeEgressRequest, |
| 7 | + TrackEgressRequest, |
| 8 | + UpdateLayoutRequest, |
| 9 | + UpdateStreamRequest, |
| 10 | + ListEgressRequest, |
| 11 | + StopEgressRequest, |
| 12 | + EgressInfo, |
| 13 | + ListEgressResponse, |
| 14 | +) |
3 | 15 | from ._service import Service |
4 | 16 | from .access_token import VideoGrants |
5 | 17 |
|
6 | 18 | SVC = "Egress" |
| 19 | +"""@private""" |
7 | 20 |
|
8 | 21 |
|
9 | 22 | class EgressService(Service): |
| 23 | + """Client for LiveKit Egress Service API |
| 24 | +
|
| 25 | + Recommended way to use this service is via `livekit.api.LiveKitAPI`: |
| 26 | +
|
| 27 | + ```python |
| 28 | + from livekit import api |
| 29 | + lkapi = api.LiveKitAPI() |
| 30 | + egress = lkapi.egress |
| 31 | + ``` |
| 32 | +
|
| 33 | + Also see https://docs.livekit.io/home/egress/overview/ |
| 34 | + """ |
| 35 | + |
10 | 36 | def __init__( |
11 | 37 | self, session: aiohttp.ClientSession, url: str, api_key: str, api_secret: str |
12 | 38 | ): |
13 | 39 | super().__init__(session, url, api_key, api_secret) |
14 | 40 |
|
15 | 41 | async def start_room_composite_egress( |
16 | | - self, start: proto_egress.RoomCompositeEgressRequest |
17 | | - ) -> proto_egress.EgressInfo: |
| 42 | + self, start: RoomCompositeEgressRequest |
| 43 | + ) -> EgressInfo: |
18 | 44 | return await self._client.request( |
19 | 45 | SVC, |
20 | 46 | "StartRoomCompositeEgress", |
21 | 47 | start, |
22 | 48 | self._auth_header(VideoGrants(room_record=True)), |
23 | | - proto_egress.EgressInfo, |
| 49 | + EgressInfo, |
24 | 50 | ) |
25 | 51 |
|
26 | | - async def start_web_egress( |
27 | | - self, start: proto_egress.WebEgressRequest |
28 | | - ) -> proto_egress.EgressInfo: |
| 52 | + async def start_web_egress(self, start: WebEgressRequest) -> EgressInfo: |
29 | 53 | return await self._client.request( |
30 | 54 | SVC, |
31 | 55 | "StartWebEgress", |
32 | 56 | start, |
33 | 57 | self._auth_header(VideoGrants(room_record=True)), |
34 | | - proto_egress.EgressInfo, |
| 58 | + EgressInfo, |
35 | 59 | ) |
36 | 60 |
|
37 | 61 | async def start_participant_egress( |
38 | | - self, start: proto_egress.ParticipantEgressRequest |
39 | | - ) -> proto_egress.EgressInfo: |
| 62 | + self, start: ParticipantEgressRequest |
| 63 | + ) -> EgressInfo: |
40 | 64 | return await self._client.request( |
41 | 65 | SVC, |
42 | 66 | "StartParticipantEgress", |
43 | 67 | start, |
44 | 68 | self._auth_header(VideoGrants(room_record=True)), |
45 | | - proto_egress.EgressInfo, |
| 69 | + EgressInfo, |
46 | 70 | ) |
47 | 71 |
|
48 | 72 | async def start_track_composite_egress( |
49 | | - self, start: proto_egress.TrackCompositeEgressRequest |
50 | | - ) -> proto_egress.EgressInfo: |
| 73 | + self, start: TrackCompositeEgressRequest |
| 74 | + ) -> EgressInfo: |
51 | 75 | return await self._client.request( |
52 | 76 | SVC, |
53 | 77 | "StartTrackCompositeEgress", |
54 | 78 | start, |
55 | 79 | self._auth_header(VideoGrants(room_record=True)), |
56 | | - proto_egress.EgressInfo, |
| 80 | + EgressInfo, |
57 | 81 | ) |
58 | 82 |
|
59 | | - async def start_track_egress( |
60 | | - self, start: proto_egress.TrackEgressRequest |
61 | | - ) -> proto_egress.EgressInfo: |
| 83 | + async def start_track_egress(self, start: TrackEgressRequest) -> EgressInfo: |
62 | 84 | return await self._client.request( |
63 | 85 | SVC, |
64 | 86 | "StartTrackEgress", |
65 | 87 | start, |
66 | 88 | self._auth_header(VideoGrants(room_record=True)), |
67 | | - proto_egress.EgressInfo, |
| 89 | + EgressInfo, |
68 | 90 | ) |
69 | 91 |
|
70 | | - async def update_layout( |
71 | | - self, update: proto_egress.UpdateLayoutRequest |
72 | | - ) -> proto_egress.EgressInfo: |
| 92 | + async def update_layout(self, update: UpdateLayoutRequest) -> EgressInfo: |
73 | 93 | return await self._client.request( |
74 | 94 | SVC, |
75 | 95 | "UpdateLayout", |
76 | 96 | update, |
77 | 97 | self._auth_header(VideoGrants(room_record=True)), |
78 | | - proto_egress.EgressInfo, |
| 98 | + EgressInfo, |
79 | 99 | ) |
80 | 100 |
|
81 | | - async def update_stream( |
82 | | - self, update: proto_egress.UpdateStreamRequest |
83 | | - ) -> proto_egress.EgressInfo: |
| 101 | + async def update_stream(self, update: UpdateStreamRequest) -> EgressInfo: |
84 | 102 | return await self._client.request( |
85 | 103 | SVC, |
86 | 104 | "UpdateStream", |
87 | 105 | update, |
88 | 106 | self._auth_header(VideoGrants(room_record=True)), |
89 | | - proto_egress.EgressInfo, |
| 107 | + EgressInfo, |
90 | 108 | ) |
91 | 109 |
|
92 | | - async def list_egress( |
93 | | - self, list: proto_egress.ListEgressRequest |
94 | | - ) -> proto_egress.ListEgressResponse: |
| 110 | + async def list_egress(self, list: ListEgressRequest) -> ListEgressResponse: |
95 | 111 | return await self._client.request( |
96 | 112 | SVC, |
97 | 113 | "ListEgress", |
98 | 114 | list, |
99 | 115 | self._auth_header(VideoGrants(room_record=True)), |
100 | | - proto_egress.ListEgressResponse, |
| 116 | + ListEgressResponse, |
101 | 117 | ) |
102 | 118 |
|
103 | | - async def stop_egress( |
104 | | - self, stop: proto_egress.StopEgressRequest |
105 | | - ) -> proto_egress.EgressInfo: |
| 119 | + async def stop_egress(self, stop: StopEgressRequest) -> EgressInfo: |
106 | 120 | return await self._client.request( |
107 | 121 | SVC, |
108 | 122 | "StopEgress", |
109 | 123 | stop, |
110 | 124 | self._auth_header(VideoGrants(room_record=True)), |
111 | | - proto_egress.EgressInfo, |
| 125 | + EgressInfo, |
112 | 126 | ) |
0 commit comments