From d55ed7a47a42f770183d41890eef32fa514c1b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Sun, 29 Oct 2023 13:38:07 -0700 Subject: [PATCH] wip --- examples/basic_room.py | 10 +++++++--- examples/e2ee.py | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/basic_room.py b/examples/basic_room.py index 3859f755..fcef74f0 100644 --- a/examples/basic_room.py +++ b/examples/basic_room.py @@ -10,6 +10,7 @@ async def main(room: rtc.Room) -> None: + @room.on("participant_connected") def on_participant_connected(participant: rtc.RemoteParticipant) -> None: logging.info( @@ -105,7 +106,8 @@ def on_connection_quality_changed( def on_track_subscription_failed( participant: rtc.RemoteParticipant, track_sid: str, error: str ): - logging.info("track subscription failed: %s %s", participant.identity, error) + logging.info("track subscription failed: %s %s", + participant.identity, error) @room.on("connection_state_changed") def on_connection_state_changed(state: rtc.ConnectionState): @@ -138,7 +140,8 @@ def on_reconnected() -> None: if __name__ == "__main__": logging.basicConfig( level=logging.INFO, - handlers=[logging.FileHandler("basic_room.log"), logging.StreamHandler()], + handlers=[logging.FileHandler( + "basic_room.log"), logging.StreamHandler()], ) loop = asyncio.get_event_loop() @@ -150,7 +153,8 @@ async def cleanup(): asyncio.ensure_future(main(room)) for signal in [SIGINT, SIGTERM]: - loop.add_signal_handler(signal, lambda: asyncio.ensure_future(cleanup())) + loop.add_signal_handler( + signal, lambda: asyncio.ensure_future(cleanup())) try: loop.run_forever() diff --git a/examples/e2ee.py b/examples/e2ee.py index c8e86a4f..f3816e8a 100644 --- a/examples/e2ee.py +++ b/examples/e2ee.py @@ -9,7 +9,7 @@ TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY" # noqa # ("livekitrocks") this is our shared key, it must match the one used by your clients -SHARED_KEY = b"liveitrocks" +SHARED_KEY = b"livekitrocks" async def draw_cube(source: rtc.VideoSource): @@ -45,8 +45,8 @@ async def draw_cube(source: rtc.VideoSource): [3, 7], ] - frame = rtc.ArgbFrame(rtc.VideoFormatType.FORMAT_ARGB, W, H) - arr = np.ctypeslib.as_array(frame.data) + frame = rtc.ArgbFrame.create(rtc.VideoFormatType.FORMAT_ARGB, W, H) + arr = np.frombuffer(frame.data, dtype=np.uint8) angle = 0 while True: @@ -95,7 +95,7 @@ async def draw_cube(source: rtc.VideoSource): async def main(room: rtc.Room): - @room.listens_to("e2ee_state_changed") + @room.on("e2ee_state_changed") def on_e2ee_state_changed( participant: rtc.Participant, state: rtc.EncryptionState ) -> None: