-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41793b4
commit e10ba5c
Showing
8 changed files
with
274 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import aiohttp | ||
import os | ||
|
||
|
||
class LivekitAPI: | ||
def __init__( | ||
self, | ||
url: str = os.getenv("LIVEKIT_URL", "http://localhost:7880"), | ||
api_key: str = os.getenv("LIVEKIT_API_KEY", ""), | ||
api_secret: str = os.getenv("LIVEKIT_API_SECRET", ""), | ||
): | ||
self._session = aiohttp.ClientSession() | ||
self._room = RoomService(url, api_key, api_secret, self._session) | ||
self._ingress = IngressService(url, api_key, api_secret, self._session) | ||
self._egress = EgressService(url, api_key, api_secret, self._session) | ||
|
||
@property | ||
def room(self): | ||
return self._room | ||
|
||
@property | ||
def ingress(self): | ||
return self._ingress | ||
|
||
@property | ||
def egress(self): | ||
return self._egress | ||
|
||
async def aclose(self): | ||
await self._session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import aiohttp | ||
from livekit.protocol import egress as proto_egress | ||
from livekit.protocol import models as proto_models | ||
from ._service import Service | ||
from .access_token import VideoGrants | ||
|
||
SVC = "Egress" | ||
|
||
|
||
class EgressService(Service): | ||
def __init__(self, session: aiohttp.ClientSession, url: str, api_key: str, api_secret: str): | ||
super().__init__(session, url, api_key, api_secret) | ||
|
||
async def start_room_composite_egress( | ||
self, start: proto_egress.StartRoomCompositeEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StartRoomCompositeEgress", | ||
start, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def start_web_egress( | ||
self, start: proto_egress.StartWebEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StartWebEgress", | ||
start, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def start_participant_egress( | ||
self, start: proto_egress.ParticipantEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StartParticipantEgress", | ||
start, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def start_track_composite_egress( | ||
self, start: proto_egress.TrackCompositeEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StartTrackCompositeEgress", | ||
start, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def start_track_egress( | ||
self, start: proto_egress.TrackEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StartTrackEgress", | ||
start, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def update_layout( | ||
self, update: proto_egress.UpdateLayoutRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"UpdateLayout", | ||
update, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def update_stream( | ||
self, update: proto_egress.UpdateStreamRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"UpdateStream", | ||
update, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) | ||
|
||
async def list_egress( | ||
self, list: proto_egress.ListEgressRequest | ||
) -> proto_egress.ListEgressResponse: | ||
return await self._client.request( | ||
SVC, | ||
"ListEgress", | ||
list, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.ListEgressResponse, | ||
) | ||
|
||
async def stop_egress( | ||
self, stop: proto_egress.StopEgressRequest | ||
) -> proto_egress.EgressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"StopEgress", | ||
stop, | ||
self._auth_header(VideoGrants(room_record=True)), | ||
proto_egress.EgressInfo, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import aiohttp | ||
from livekit.protocol import ingress as proto_ingress | ||
from livekit.protocol import models as proto_models | ||
from ._service import Service | ||
from .access_token import VideoGrants | ||
|
||
SVC = "Ingress" | ||
|
||
|
||
class IngressService(Service): | ||
def __init__(self, session: aiohttp.ClientSession, url: str, api_key: str, api_secret: str): | ||
super().__init__(session, url, api_key, api_secret) | ||
|
||
async def create_ingress( | ||
self, create: proto_ingress.CreateIngressRequest | ||
) -> proto_ingress.IngressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"CreateIngress", | ||
create, | ||
self._auth_header(VideoGrants(ingress_admin=True)), | ||
proto_ingress.IngressInfo, | ||
) | ||
|
||
async def update_ingress( | ||
self, update: proto_ingress.UpdateIngressRequest | ||
) -> proto_ingress.IngressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"UpdateIngress", | ||
update, | ||
self._auth_header(VideoGrants(ingress_admin=True)), | ||
proto_ingress.IngressInfo, | ||
) | ||
|
||
async def list_ingress( | ||
self, list: proto_ingress.ListIngressRequest | ||
) -> proto_ingress.ListIngressResponse: | ||
return await self._client.request( | ||
SVC, | ||
"ListIngress", | ||
list, | ||
self._auth_header(VideoGrants(ingress_admin=True)), | ||
proto_ingress.ListIngressResponse, | ||
) | ||
|
||
async def delete_ingress( | ||
self, delete: proto_ingress.DeleteIngressRequest | ||
) -> proto_ingress.IngressInfo: | ||
return await self._client.request( | ||
SVC, | ||
"DeleteIngress", | ||
delete, | ||
self._auth_header(VideoGrants(ingress_admin=True)), | ||
proto_ingress.IngressInfo, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.