fastrtc icon indicating copy to clipboard operation
fastrtc copied to clipboard

fix track_constraints support

Open bingochaos opened this issue 5 days ago • 0 comments

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: image

Solution

Resolved the issue by properly deconstructing the track_constraints input. This ensures that both video and audio constraints are now correctly applied.

bingochaos avatar Feb 24 '25 03:02 bingochaos