Skip to content

Commit e5aa64b

Browse files
committed
Add standalone read method
1 parent 94e88e9 commit e5aa64b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

livekit-rtc/livekit/rtc/data_track.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ def __init__(self, owned_info: proto_data_track.OwnedDataTrackStream) -> None:
244244
)
245245
self._closed = False
246246

247+
async def read(self) -> Optional[DataTrackFrame]:
248+
"""Read a single frame, or ``None`` if the stream has ended."""
249+
try:
250+
return await self.__anext__()
251+
except StopAsyncIteration:
252+
return None
253+
247254
def __aiter__(self) -> AsyncIterator[DataTrackFrame]:
248255
return self
249256

0 commit comments

Comments
 (0)