MenuMenu

RTCMultiConnection.mediaConstraints

Set getUserMedia parameters e.g. resolutions and framerates

Choose front or back camera, set resolutions, choose camera/microphone by device-id etc.

Usage

connection.mediaConstraints = {
    video: true,
    audio: true
};

Description

parameterdescription
audio it can be a boolean (true|false) or a javascript object
use this to enable microphone
set microphone device-id
set echo-cancellation browser-specific attributes
etc.
video it can be a boolean (true|false) or a javascript object
use this to enable camera
set camera device-id
choose front or back camera
set frame-rates, aspect-ratio
etc.

Choose front camera on Android

connection.mediaConstraints = {
    audio: true,
    video: {
        mandatory: {},
        optional: [{
            facingMode: 'user' // or "application" for back camera
        }]
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: {
            facingMode: 'user' // or "application" for back camera
        }
    };
}

Set frame-rates

connection.mediaConstraints = {
    audio: true,
    video: {
        mandatory: {
            minFrameRate: 15,
            maxFrameRate: 15
        },
        optional: []
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: {
            frameRate: {
                min: 15,
                max: 15
            }
        }
    };
}

Set aspect-ratio

connection.mediaConstraints = {
    audio: true,
    video: {
        mandatory: {
            minAspectRatio: 1.77
        },
        optional: []
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: {
            aspectRatio: 1.77
        }
    };
}

Set resolutions

connection.mediaConstraints = {
    audio: true,
    video: {
        mandatory: {
            minWidth: 1280,
            maxWidth: 1280,
            minHeight: 720,
            maxHeight: 720
        },
        optional: []
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: {
            width: 1280,
            height: 720
        }
    };
}

Echo cancellation (browser specific)

connection.mediaConstraints = {
    video: true,
    audio: {
        mandatory: {
            echoCancellation: false, // disabling audio processing
            googAutoGainControl: true,
            googNoiseSuppression: true,
            googHighpassFilter: true,
            googTypingNoiseDetection: true,
            //googAudioMirroring: true
        },
        optional: []
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: true
    };
}

Choose secondary camera

DetectRTC.load(function() {
    var secondaryCamera = DetectRTC.videoInputDevices[1];
    if (!secondaryCamera) {
        alert('Please attach another camera device.');
        return;
    }

    connection.mediaConstraints = {
        audio: true,
        video: {
            mandatory: {},
            optional: [{
                sourceId: secondaryCamera.id
            }]
        }
    };

    if (DetectRTC.browser.name === 'Firefox') {
        connection.mediaConstraints = {
            audio: true,
            video: {
                deviecId: secondaryCamera.id
            }
        };
    }
});

Demo

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
connection.session = {
    audio: true,
    video: true
};

connection.mediaConstraints = {
    audio: true,
    video: {
        mandatory: {
            minWidth: 1280,
            maxWidth: 1280,
            minHeight: 720,
            maxHeight: 720,
            minFrameRate: 30,
            minAspectRatio: 1.77
        },
        optional: [{
            facingMode: 'user' // or "application"
        }]
    }
};

if (DetectRTC.browser.name === 'Firefox') {
    connection.mediaConstraints = {
        audio: true,
        video: {
            width: 1280,
            height: 720,
            frameRate: 30,
            aspectRatio: 1.77,
            facingMode: 'user' // or "application"
        }
    };
}

connection.openOrJoin('your-room-id');
</script>