fastrtc
fastrtc copied to clipboard
fix track_constraints support
PR Description
Fixed an issue where track_constraints were not applied in audio-video mode.
Issue
When using track_constraints (either custom or default), the constraints were incorrect. For example:
webrtc = WebRTC(
label="Video Chat",
modality="audio-video",
mode="send-receive",
elem_id="video-source",
track_constraints={
"video": {
"facingMode": "user",
"width": {"ideal": 500},
"height": {"ideal": 1300},
"frameRate": {"ideal": 30},
},
"audio": {
"echoCancellation": True,
"noiseSuppression": {"exact": False},
"autoGainControl": {"exact": True},
"sampleRate": {"ideal": 24000},
"sampleSize": {"ideal": 16},
"channelCount": {"exact": 1},
},
}
)
The constraints were not passed through correctly, as shown here:
Solution
Resolved the issue by properly deconstructing the track_constraints input. This ensures that both video and audio constraints are now correctly applied.