Skip to content
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
30 changes: 16 additions & 14 deletions examples/data-streams/data_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ async def main(room: rtc.Room):
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

active_tasks = []

async def greetParticipant(identity: str):
text_writer = await room.local_participant.stream_text(
destination_identities=[identity], topic="chat"
Expand All @@ -32,8 +34,8 @@ async def on_chat_message_received(reader: rtc.TextStreamReader, participant_ide
logger.info("Received chat message from %s: '%s'", participant_identity, full_text)

async def on_welcome_image_received(reader: rtc.ByteStreamReader, participant_identity: str):
logger.info("Received image from %s: '%s'", participant_identity, reader.info["name"])
with open(reader.info["name"], mode="wb") as f:
logger.info("Received image from %s: '%s'", participant_identity, reader.info.name)
with open(reader.info.name, mode="wb") as f:
async for chunk in reader:
f.write(chunk)

Expand All @@ -44,19 +46,19 @@ def on_participant_connected(participant: rtc.RemoteParticipant):
logger.info("participant connected: %s %s", participant.sid, participant.identity)
asyncio.create_task(greetParticipant(participant.identity))

room.set_text_stream_handler(
"chat",
lambda reader, participant_identity: asyncio.create_task(
on_chat_message_received(reader, participant_identity)
),
)
def _handle_chat_stream(reader, participant_identity):
task = asyncio.create_task(on_chat_message_received(reader, participant_identity))
active_tasks.append(task)
task.add_done_callback(lambda _: active_tasks.remove(task))

room.set_byte_stream_handler(
"files",
lambda reader, participant_identity: asyncio.create_task(
on_welcome_image_received(reader, participant_identity)
),
)
room.set_text_stream_handler("chat", _handle_chat_stream)

def _handle_welcome_image_stream(reader, participant_identity):
task = asyncio.create_task(on_welcome_image_received(reader, participant_identity))
active_tasks.append(task)
task.add_done_callback(lambda _: active_tasks.remove(task))

room.set_byte_stream_handler("files", _handle_welcome_image_stream)

# By default, autosubscribe is enabled. The participant will be subscribed to
# all published tracks in the room
Expand Down
3 changes: 3 additions & 0 deletions livekit-api/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# LiveKit Server APIs

Access LiveKit server APIs and generate access tokens.

See https://docs.livekit.io/reference/server/server-apis for more information.

6 changes: 5 additions & 1 deletion livekit-api/livekit/api/room_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ async def forward_participant(self, forward: ForwardParticipantRequest) -> None:
SVC,
"ForwardParticipant",
forward,
self._auth_header(VideoGrants(room_admin=True, room=forward.room, destination_room=forward.destination_room)),
self._auth_header(
VideoGrants(
room_admin=True, room=forward.room, destination_room=forward.destination_room
)
),
ForwardParticipantResponse,
)

Expand Down
7 changes: 5 additions & 2 deletions livekit-rtc/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# LiveKit Real-time Python SDK
# LiveKit SDK for Python

Python SDK to integrate LiveKit's real-time video, audio, and data capabilities into your Python applications using WebRTC. Designed for use with [LiveKit Agents](https://github.com/livekit/agents) to build powerful voice AI apps.

See https://docs.livekit.io/ for more information.

The LiveKit Python SDK provides a convenient interface for integrating LiveKit's real-time video and audio capabilities into your Python applications. With it, developers can easily leverage LiveKit's WebRTC functionalities, allowing them to focus on building their AI models or other application logic without worrying about the complexities of WebRTC.
6 changes: 5 additions & 1 deletion livekit-rtc/livekit/rtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""LiveKit RTC SDK"""
"""LiveKit SDK for Python
`pip install livekit`

See https://docs.livekit.io/home/client/connect/#installing-the-livekit-sdk for more information.
"""

from ._proto import stats_pb2 as stats
from ._proto.e2ee_pb2 import EncryptionState, EncryptionType
Expand Down
Loading