Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtc-v0.5.0 & api-v0.1.1 #81

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
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
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"
Loading