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