Skip to content

Commit f2adba9

Browse files
committed
Expose buffer size option
1 parent 17008fa commit f2adba9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

livekit-rtc/livekit/rtc/data_track.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,29 @@ def publisher_identity(self) -> str:
193193
"""Identity of the participant who published the track."""
194194
return self._publisher_identity
195195

196-
async def subscribe(self) -> DataTrackSubscription:
196+
async def subscribe(
197+
self, *, buffer_size: Optional[int] = None
198+
) -> DataTrackSubscription:
197199
"""Subscribes to the data track to receive frames.
198200
201+
Args:
202+
buffer_size: Maximum number of received frames to buffer internally.
203+
When ``None``, the default buffer size is used.
204+
Zero is not a valid buffer size; if a value of zero is provided, it will be clamped to one.
205+
199206
Returns a :class:`DataTrackSubscription` that yields
200207
:class:`DataTrackFrame` instances as they arrive.
201208
202209
Raises:
203210
SubscribeDataTrackError: If subscription fails.
204211
"""
212+
opts = proto_data_track.DataTrackSubscribeOptions()
213+
if buffer_size is not None:
214+
opts.buffer_size = buffer_size
215+
205216
req = proto_ffi.FfiRequest()
206217
req.subscribe_data_track.track_handle = self._ffi_handle.handle
207-
req.subscribe_data_track.options.CopyFrom(
208-
proto_data_track.DataTrackSubscribeOptions()
209-
)
218+
req.subscribe_data_track.options.CopyFrom(opts)
210219

211220
queue = FfiClient.instance.queue.subscribe()
212221
try:

0 commit comments

Comments
 (0)