Date: Fri, 29 Mar 2024 14:17:53 +0100 (CET) Message-ID: <335043581.47511.1711718273032@docs.flashphoner.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_47510_1550667190.1711718273032" ------=_Part_47510_1550667190.1711718273032 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The functions to configure the room connection and local media access ar=
e moved to config.js
module. The configuration file example fo=
llows:
{ "room": { "url": "ws://127.0.0.1:8080", "name": "ROOM1", "pin": "1234", "nickName": "User1" }, "media": { "audio": { "tracks": [{ "source": "mic", "channels": 2 }] }, "video": { "tracks": [ { "source": "camera", "width": 1280, "height": 720, "codec": "H264", "constraints": { "frameRate": 25 }, "encodings": [ { "rid": "720p", "active": true, "maxBitrate": 900000 }, { "rid": "360p", "active": true, "maxBitrate": 500000, "scaleRe= solutionDownBy": 2 }, { "rid": "180p", "active": true, "maxBitrate": 200000, "scaleRe= solutionDownBy": 4 } ] } =20 ] } } }=20
To analyze config.js
source code take the version available=
here which can be downloaded with build 1.0=
.1.36
getRoomConfig() code
const getRoomConfig= =3D function(config) { let roomConfig =3D { url: config.url || "ws://127.0.0.1:8080", roomName: config.name || "ROOM1", pin: config.pin || "1234", nickname: config.nickName || "User1" =20 }; return roomConfig; }=20
getVideoStreams() code
const getVideoStrea= ms =3D async function(config) { let streams =3D []; if (config.media && config.media.video && config.media.= video.tracks) { streams =3D await getStreams(config.media.video.tracks); } return streams; }=20
getAudioStreams) code
const getAudioStrea= ms =3D async function(config) { let streams =3D []; if (config.media && config.media.audio && config.media.= audio.tracks) { streams =3D await getStreams(config.media.audio.tracks); } return streams; }=20
getStreams() code
const getStreams = =3D async function(tracks) { let streams =3D []; for (let track of tracks) { let stream =3D await getMedia(track); if (stream) { streams.push({ stream: stream, encodings: track.encodings, source: track.source }); } } return streams; }=20
getMedia() code
const getMedia =3D = async function(track) { //convert to constraints ... const constraints=3D {}; if (track.source =3D=3D=3D "mic") { //audio constraints.audio =3D {}; if (track.constraints) { constraints.audio =3D track.constraints; } if (track.channels && track.channels =3D=3D=3D 2) { constraints.audio.echoCancellation =3D false; constraints.audio.googEchoCancellation =3D false; } } else if (track.source =3D=3D=3D "camera") { ... } else if (track.source =3D=3D=3D "screen") { ... } ... return stream; }=20
getMedia() code
const getMedia =3D = async function(track) { //convert to constraints ... const constraints=3D {}; if (track.source =3D=3D=3D "mic") { ... } else if (track.source =3D=3D=3D "camera") { constraints.video =3D {}; if (track.constraints) { constraints.video =3D track.constraints; } constraints.video.width =3D track.width; constraints.video.height =3D track.height; } else if (track.source =3D=3D=3D "screen") { ... } ... return stream; }=20
getMedia() code
const getMedia =3D = async function(track) { //convert to constraints let screen =3D false; const constraints=3D {}; if (track.source =3D=3D=3D "mic") { ... } else if (track.source =3D=3D=3D "camera") { ... } else if (track.source =3D=3D=3D "screen") { constraints.video =3D {}; if (track.constraints) { constraints.video =3D track.constraints; } constraints.video.width =3D track.width; constraints.video.height =3D track.height; screen =3D true; } ... return stream; }=20
getMedia() code
const getMedia =3D = async function(track) { //convert to constraints let screen =3D false; const constraints=3D {}; if (track.source =3D=3D=3D "mic") { ... } else if (track.source =3D=3D=3D "camera") { ... } else if (track.source =3D=3D=3D "screen") { ... screen =3D true; } //get access to a/v let stream; if (screen) { stream =3D await navigator.mediaDevices.getDisplayMedia(constraints= ); } else { stream =3D await navigator.mediaDevices.getUserMedia(constraints); } return stream; }=20