diff --git a/README.md b/README.md index 51c880ca..319ffe60 100644 --- a/README.md +++ b/README.md @@ -16,44 +16,67 @@ Official LiveKit documentation: https://docs.livekit.io/ ## Installation +RTC Client: ```shell $ pip install livekit ``` +API / Server SDK: +```shell +$ pip install livekit-api +``` + ## Connecting to a room ```python -async def main(): - room = livekit.Room() +from livekit import rtc - # participants and tracks that are already available in the room - # participant_connected and track_published events will *not* be emitted for them - for participant in room.participants.items(): - for publication in participant.tracks.items(): - print("track publication: %s", publication.sid) +async def main(): + room = rtc.Room() @room.on("participant_connected") - def on_participant_connected(participant: livekit.RemoteParticipant): + def on_participant_connected(participant: rtc.RemoteParticipant): logging.info( "participant connected: %s %s", participant.sid, participant.identity) - async def receive_frames(stream: livekit.VideoStream): + async def receive_frames(stream: rtc.VideoStream): async for frame in video_stream: # received a video frame from the track, process it here pass # track_subscribed is emitted whenever the local participant is subscribed to a new track @room.on("track_subscribed") - def on_track_subscribed(track: livekit.Track, publication: livekit.RemoteTrackPublication, participant: livekit.RemoteParticipant): + def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant): logging.info("track subscribed: %s", publication.sid) - if track.kind == livekit.TrackKind.KIND_VIDEO: - video_stream = livekit.VideoStream(track) + if track.kind == rtc.TrackKind.KIND_VIDEO: + video_stream = rtc.VideoStream(track) asyncio.ensure_future(receive_frames(video_stream)) # By default, autosubscribe is enabled. The participant will be subscribed to # all published tracks in the room await room.connect(URL, TOKEN) logging.info("connected to room %s", room.name) + + # participants and tracks that are already available in the room + # participant_connected and track_published events will *not* be emitted for them + for participant in room.participants.items(): + for publication in participant.tracks.items(): + print("track publication: %s", publication.sid) +``` + +## Create a new access token + +```python +from livekit import api + +token = api.AccessToken("API_KEY", "SECRET_KEY") +token = AccessToken() +jwt = ( + token.with_identity("user1") + .with_name("user1") + .with_grants(VideoGrants(room_join=True, room="room1")) + .to_jwt() +) ``` ## Examples diff --git a/livekit-api/livekit/api/version.py b/livekit-api/livekit/api/version.py index 1acd9021..485f44ac 100644 --- a/livekit-api/livekit/api/version.py +++ b/livekit-api/livekit/api/version.py @@ -1 +1 @@ -__version__ = "0.1.1.dev0" +__version__ = "0.1.1" diff --git a/livekit-rtc/livekit/rtc/version.py b/livekit-rtc/livekit/rtc/version.py index c672a18b..3d187266 100644 --- a/livekit-rtc/livekit/rtc/version.py +++ b/livekit-rtc/livekit/rtc/version.py @@ -1 +1 @@ -__version__ = "0.4.7.dev0" +__version__ = "0.5.0"