Skip to content

Commit 15000d5

Browse files
authored
v0.4.2 (#65)
1 parent 27e0963 commit 15000d5

File tree

8 files changed

+211
-126
lines changed

8 files changed

+211
-126
lines changed

client-sdk-rust

examples/publish_wave.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
NUM_CHANNELS = 1
1414

1515

16-
async def publish_frames(source: livekit.AudioSource):
17-
frequency = 440
16+
async def publish_frames(source: livekit.AudioSource, frequency: int):
1817
amplitude = 32767 # for 16-bit audio
1918
samples_per_channel = 480 # 10ms at 48kHz
2019
time = np.arange(samples_per_channel) / SAMPLE_RATE
@@ -38,9 +37,20 @@ async def publish_frames(source: livekit.AudioSource):
3837

3938

4039
async def main(room: livekit.Room) -> None:
40+
41+
@room.on("participant_disconnected")
42+
def on_participant_disconnect(participant: livekit.Participant, *_):
43+
logging.info("participant disconnected: %s", participant.identity)
44+
4145
logging.info("connecting to %s", URL)
4246
try:
43-
await room.connect(URL, TOKEN)
47+
e2ee_options = livekit.E2EEOptions()
48+
e2ee_options.key_provider_options.shared_key = b"password"
49+
50+
await room.connect(URL, TOKEN, options=livekit.RoomOptions(
51+
auto_subscribe=True,
52+
e2ee=e2ee_options
53+
))
4454
logging.info("connected to room %s", room.name)
4555
except livekit.ConnectError as e:
4656
logging.error("failed to connect to the room: %s", e)
@@ -54,7 +64,7 @@ async def main(room: livekit.Room) -> None:
5464
publication = await room.local_participant.publish_track(track, options)
5565
logging.info("published track %s", publication.sid)
5666

57-
asyncio.ensure_future(publish_frames(source))
67+
asyncio.ensure_future(publish_frames(source, 440))
5868

5969

6070
if __name__ == "__main__":

livekit/_proto/e2ee_pb2.py

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit/_proto/e2ee_pb2.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,23 @@ class KeyProviderOptions(google.protobuf.message.Message):
105105
SHARED_KEY_FIELD_NUMBER: builtins.int
106106
RATCHET_WINDOW_SIZE_FIELD_NUMBER: builtins.int
107107
RATCHET_SALT_FIELD_NUMBER: builtins.int
108-
UNCRYPTED_MAGIC_BYTES_FIELD_NUMBER: builtins.int
108+
FAILURE_TOLERANCE_FIELD_NUMBER: builtins.int
109109
shared_key: builtins.bytes
110110
"""Only specify if you want to use a shared_key"""
111111
ratchet_window_size: builtins.int
112112
ratchet_salt: builtins.bytes
113-
uncrypted_magic_bytes: builtins.bytes
113+
failure_tolerance: builtins.int
114+
"""-1 = no tolerence"""
114115
def __init__(
115116
self,
116117
*,
117118
shared_key: builtins.bytes | None = ...,
118119
ratchet_window_size: builtins.int = ...,
119120
ratchet_salt: builtins.bytes = ...,
120-
uncrypted_magic_bytes: builtins.bytes = ...,
121+
failure_tolerance: builtins.int = ...,
121122
) -> None: ...
122123
def HasField(self, field_name: typing_extensions.Literal["_shared_key", b"_shared_key", "shared_key", b"shared_key"]) -> builtins.bool: ...
123-
def ClearField(self, field_name: typing_extensions.Literal["_shared_key", b"_shared_key", "ratchet_salt", b"ratchet_salt", "ratchet_window_size", b"ratchet_window_size", "shared_key", b"shared_key", "uncrypted_magic_bytes", b"uncrypted_magic_bytes"]) -> None: ...
124+
def ClearField(self, field_name: typing_extensions.Literal["_shared_key", b"_shared_key", "failure_tolerance", b"failure_tolerance", "ratchet_salt", b"ratchet_salt", "ratchet_window_size", b"ratchet_window_size", "shared_key", b"shared_key"]) -> None: ...
124125
def WhichOneof(self, oneof_group: typing_extensions.Literal["_shared_key", b"_shared_key"]) -> typing_extensions.Literal["shared_key"] | None: ...
125126

126127
global___KeyProviderOptions = KeyProviderOptions

livekit/_proto/room_pb2.py

Lines changed: 65 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit/_proto/room_pb2.pyi

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ else:
3636

3737
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
3838

39+
class _IceTransportPolicy:
40+
ValueType = typing.NewType("ValueType", builtins.int)
41+
V: typing_extensions.TypeAlias = ValueType
42+
43+
class _IceTransportPolicyEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_IceTransportPolicy.ValueType], builtins.type):
44+
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
45+
TRANSPORT_NONE: _IceTransportPolicy.ValueType # 0
46+
TRANSPORT_RELAY: _IceTransportPolicy.ValueType # 1
47+
TRANSPORT_NOHOST: _IceTransportPolicy.ValueType # 2
48+
TRANSPORT_ALL: _IceTransportPolicy.ValueType # 3
49+
50+
class IceTransportPolicy(_IceTransportPolicy, metaclass=_IceTransportPolicyEnumTypeWrapper): ...
51+
52+
TRANSPORT_NONE: IceTransportPolicy.ValueType # 0
53+
TRANSPORT_RELAY: IceTransportPolicy.ValueType # 1
54+
TRANSPORT_NOHOST: IceTransportPolicy.ValueType # 2
55+
TRANSPORT_ALL: IceTransportPolicy.ValueType # 3
56+
global___IceTransportPolicy = IceTransportPolicy
57+
3958
class _ConnectionQuality:
4059
ValueType = typing.NewType("ValueType", builtins.int)
4160
V: typing_extensions.TypeAlias = ValueType
@@ -521,6 +540,47 @@ class TrackPublishOptions(google.protobuf.message.Message):
521540

522541
global___TrackPublishOptions = TrackPublishOptions
523542

543+
@typing_extensions.final
544+
class IceServer(google.protobuf.message.Message):
545+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
546+
547+
URLS_FIELD_NUMBER: builtins.int
548+
USERNAME_FIELD_NUMBER: builtins.int
549+
CREDENTIAL_FIELD_NUMBER: builtins.int
550+
@property
551+
def urls(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
552+
username: builtins.str
553+
credential: builtins.str
554+
def __init__(
555+
self,
556+
*,
557+
urls: collections.abc.Iterable[builtins.str] | None = ...,
558+
username: builtins.str = ...,
559+
credential: builtins.str = ...,
560+
) -> None: ...
561+
def ClearField(self, field_name: typing_extensions.Literal["credential", b"credential", "urls", b"urls", "username", b"username"]) -> None: ...
562+
563+
global___IceServer = IceServer
564+
565+
@typing_extensions.final
566+
class RtcConfig(google.protobuf.message.Message):
567+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
568+
569+
ICE_TRANSPORT_POLICY_FIELD_NUMBER: builtins.int
570+
ICE_SERVERS_FIELD_NUMBER: builtins.int
571+
ice_transport_policy: global___IceTransportPolicy.ValueType
572+
@property
573+
def ice_servers(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___IceServer]: ...
574+
def __init__(
575+
self,
576+
*,
577+
ice_transport_policy: global___IceTransportPolicy.ValueType = ...,
578+
ice_servers: collections.abc.Iterable[global___IceServer] | None = ...,
579+
) -> None: ...
580+
def ClearField(self, field_name: typing_extensions.Literal["ice_servers", b"ice_servers", "ice_transport_policy", b"ice_transport_policy"]) -> None: ...
581+
582+
global___RtcConfig = RtcConfig
583+
524584
@typing_extensions.final
525585
class RoomOptions(google.protobuf.message.Message):
526586
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -529,22 +589,30 @@ class RoomOptions(google.protobuf.message.Message):
529589
ADAPTIVE_STREAM_FIELD_NUMBER: builtins.int
530590
DYNACAST_FIELD_NUMBER: builtins.int
531591
E2EE_FIELD_NUMBER: builtins.int
592+
RTC_CONFIG_FIELD_NUMBER: builtins.int
532593
auto_subscribe: builtins.bool
533594
adaptive_stream: builtins.bool
534595
dynacast: builtins.bool
535596
@property
536597
def e2ee(self) -> e2ee_pb2.E2eeOptions: ...
598+
@property
599+
def rtc_config(self) -> global___RtcConfig:
600+
"""allow to setup a custom RtcConfiguration"""
537601
def __init__(
538602
self,
539603
*,
540604
auto_subscribe: builtins.bool = ...,
541605
adaptive_stream: builtins.bool = ...,
542606
dynacast: builtins.bool = ...,
543607
e2ee: e2ee_pb2.E2eeOptions | None = ...,
608+
rtc_config: global___RtcConfig | None = ...,
544609
) -> None: ...
545-
def HasField(self, field_name: typing_extensions.Literal["_e2ee", b"_e2ee", "e2ee", b"e2ee"]) -> builtins.bool: ...
546-
def ClearField(self, field_name: typing_extensions.Literal["_e2ee", b"_e2ee", "adaptive_stream", b"adaptive_stream", "auto_subscribe", b"auto_subscribe", "dynacast", b"dynacast", "e2ee", b"e2ee"]) -> None: ...
610+
def HasField(self, field_name: typing_extensions.Literal["_e2ee", b"_e2ee", "_rtc_config", b"_rtc_config", "e2ee", b"e2ee", "rtc_config", b"rtc_config"]) -> builtins.bool: ...
611+
def ClearField(self, field_name: typing_extensions.Literal["_e2ee", b"_e2ee", "_rtc_config", b"_rtc_config", "adaptive_stream", b"adaptive_stream", "auto_subscribe", b"auto_subscribe", "dynacast", b"dynacast", "e2ee", b"e2ee", "rtc_config", b"rtc_config"]) -> None: ...
612+
@typing.overload
547613
def WhichOneof(self, oneof_group: typing_extensions.Literal["_e2ee", b"_e2ee"]) -> typing_extensions.Literal["e2ee"] | None: ...
614+
@typing.overload
615+
def WhichOneof(self, oneof_group: typing_extensions.Literal["_rtc_config", b"_rtc_config"]) -> typing_extensions.Literal["rtc_config"] | None: ...
548616

549617
global___RoomOptions = RoomOptions
550618

livekit/e2ee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
from ._proto import ffi_pb2 as proto_ffi
2121

2222
DEFAULT_RATCHET_SALT = b"LKFrameEncryptionKey"
23-
DEFAULT_MAGIC_BYTES = b"LK-ROCKS"
2423
DEFAULT_RATCHET_WINDOW_SIZE = 16
24+
DEFAULT_FAILURE_TOLERANCE = -1
2525

2626

2727
@dataclass
2828
class KeyProviderOptions:
2929
shared_key: Optional[bytes] = None
3030
ratchet_salt: bytes = DEFAULT_RATCHET_SALT
31-
uncrypted_magic_bytes: bytes = DEFAULT_MAGIC_BYTES
3231
ratchet_window_size: int = DEFAULT_RATCHET_WINDOW_SIZE
32+
failure_tolerance: int = DEFAULT_FAILURE_TOLERANCE
3333

3434

3535
@dataclass

livekit/room.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ async def connect(self,
9797
options.e2ee.key_provider_options.shared_key # type: ignore
9898
req.connect.options.e2ee.key_provider_options.ratchet_salt = \
9999
options.e2ee.key_provider_options.ratchet_salt
100-
req.connect.options.e2ee.key_provider_options.uncrypted_magic_bytes = \
101-
options.e2ee.key_provider_options.uncrypted_magic_bytes
100+
req.connect.options.e2ee.key_provider_options.failure_tolerance = \
101+
options.e2ee.key_provider_options.failure_tolerance
102102
req.connect.options.e2ee.key_provider_options.ratchet_window_size = \
103103
options.e2ee.key_provider_options.ratchet_window_size
104104

0 commit comments

Comments
 (0)