Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions examples/e2ee.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import asyncio
import logging
import os
from signal import SIGINT, SIGTERM

import numpy as np
from livekit import rtc

URL = "ws://localhost:7880"
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY" # noqa
URL = os.environ.get("LIVEKIT_URL", "ws://localhost:7880")
TOKEN = os.environ.get(
"LIVEKIT_TOKEN",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY",
) # noqa

# ("livekitrocks") this is our shared key, it must match the one used by your clients
SHARED_KEY = b"livekitrocks"
# This shared key must match the one used by your clients
SHARED_KEY = os.environ.get("E2EE_SHARED_KEY", "livekitrocks").encode()

WIDTH, HEIGHT = 1280, 720

Expand Down Expand Up @@ -106,7 +110,7 @@ def on_e2ee_state_changed(participant: rtc.Participant, state: rtc.EncryptionSta
e2ee_options.key_provider_options.shared_key = SHARED_KEY

await room.connect(
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, e2ee=e2ee_options)
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, encryption=e2ee_options)
)

logging.info("connected to room %s", room.name)
Expand Down
Loading