Skip to content

Commit

Permalink
rtc-v0.5.0 & api-v0.1.1 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Oct 30, 2023
1 parent bdd5c80 commit 1c8d59c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion livekit-api/livekit/api/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.1.dev0"
__version__ = "0.1.1"
2 changes: 1 addition & 1 deletion livekit-rtc/livekit/rtc/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.7.dev0"
__version__ = "0.5.0"

0 comments on commit 1c8d59c

Please sign in to comment.