Skip to content

Commit 0c1312f

Browse files
committed
added TODO
1 parent b234725 commit 0c1312f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

inference/core/env.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@
785785
WEBRTC_DATA_CHANNEL_BUFFER_DRAINING_DELAY = float(
786786
os.getenv("WEBRTC_DATA_CHANNEL_BUFFER_DRAINING_DELAY", "0.1")
787787
)
788+
WEBRTC_DATA_CHANNEL_BUFFER_SIZE_LIMIT = int(
789+
os.getenv("WEBRTC_DATA_CHANNEL_BUFFER_SIZE_LIMIT", str(1024 * 1024)) # 1MB
790+
)
788791

789792
HTTP_API_SHARED_WORKFLOWS_THREAD_POOL_ENABLED = str2bool(
790793
os.getenv("HTTP_API_SHARED_WORKFLOWS_THREAD_POOL_ENABLED", "True")

inference/core/interfaces/webrtc_worker/webrtc.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from inference.core import logger
2727
from inference.core.env import (
2828
WEBRTC_DATA_CHANNEL_BUFFER_DRAINING_DELAY,
29+
WEBRTC_DATA_CHANNEL_BUFFER_SIZE_LIMIT,
2930
WEBRTC_MODAL_PUBLIC_STUN_SERVERS,
3031
WEBRTC_MODAL_RTSP_PLACEHOLDER,
3132
WEBRTC_MODAL_RTSP_PLACEHOLDER_URL,
@@ -71,9 +72,6 @@
7172
# WebRTC data channel chunking configuration
7273
CHUNK_SIZE = 48 * 1024 # 48KB - safe for all WebRTC implementations
7374

74-
# Rate limiting for data channel sends (prevents SCTP buffer overflow)
75-
DATA_CHANNEL_BUFFER_SIZE_LIMIT = 1024 * 1024 # 1MB
76-
7775

7876
def create_chunked_binary_message(
7977
frame_id: int, chunk_index: int, total_chunks: int, payload: bytes
@@ -149,7 +147,6 @@ class VideoFileUploadHandler:
149147
"""
150148

151149
def __init__(self):
152-
import tempfile
153150

154151
self._chunks: Dict[int, bytes] = {}
155152
self._total_chunks: Optional[int] = None
@@ -174,6 +171,7 @@ def handle_chunk(self, chunk_index: int, total_chunks: int, data: bytes) -> None
174171
logger.info("Upload progress: %s/%s chunks", len(self._chunks), total_chunks)
175172

176173
# Auto-complete when all chunks received
174+
# TODO: Handle the file writing without keeping all chunks in memory
177175
if len(self._chunks) == total_chunks:
178176
self._write_to_temp_file()
179177
self._state = VideoFileUploadState.COMPLETE
@@ -242,7 +240,7 @@ async def send_chunked_data(
242240
return
243241

244242
sleep_count = 0
245-
while data_channel.bufferedAmount > DATA_CHANNEL_BUFFER_SIZE_LIMIT:
243+
while data_channel.bufferedAmount > WEBRTC_DATA_CHANNEL_BUFFER_SIZE_LIMIT:
246244
sleep_count += 1
247245
if sleep_count % 10 == 0:
248246
logger.debug(

0 commit comments

Comments
 (0)