@fluxrtc/sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/VideoClient.js +21 -4
package/package.json
CHANGED
package/src/VideoClient.js
CHANGED
|
@@ -180,14 +180,20 @@ class VideoClient {
|
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
async enableMedia(constraints
|
|
183
|
+
async enableMedia(constraints) {
|
|
184
184
|
if (this.localStream) return this.localStream;
|
|
185
185
|
|
|
186
|
+
const defaults = {
|
|
187
|
+
video: { width: { ideal: 640 }, height: { ideal: 360 }, frameRate: { ideal: 24, max: 30 } },
|
|
188
|
+
audio: true,
|
|
189
|
+
};
|
|
190
|
+
const merged = constraints || defaults;
|
|
191
|
+
|
|
186
192
|
try {
|
|
187
|
-
this.localStream = await navigator.mediaDevices.getUserMedia(
|
|
193
|
+
this.localStream = await navigator.mediaDevices.getUserMedia(merged);
|
|
188
194
|
return this.localStream;
|
|
189
195
|
} catch (err) {
|
|
190
|
-
if (
|
|
196
|
+
if (merged.video && (err.name === 'NotReadableError' || err.name === 'NotFoundError')) {
|
|
191
197
|
this.localStream = await navigator.mediaDevices.getUserMedia({ video: false, audio: true });
|
|
192
198
|
return this.localStream;
|
|
193
199
|
}
|
|
@@ -200,9 +206,20 @@ class VideoClient {
|
|
|
200
206
|
throw new Error('Call enableMedia() and joinRoom() before produce()');
|
|
201
207
|
}
|
|
202
208
|
|
|
209
|
+
const simulcastEncodings = [
|
|
210
|
+
{ maxBitrate: 100000, scaleResolutionDownBy: 4 },
|
|
211
|
+
{ maxBitrate: 300000, scaleResolutionDownBy: 2 },
|
|
212
|
+
{ maxBitrate: 900000, scaleResolutionDownBy: 1 },
|
|
213
|
+
];
|
|
214
|
+
|
|
203
215
|
const producers = [];
|
|
204
216
|
for (const track of this.localStream.getTracks()) {
|
|
205
|
-
const
|
|
217
|
+
const params = { track };
|
|
218
|
+
if (track.kind === 'video') {
|
|
219
|
+
params.encodings = simulcastEncodings;
|
|
220
|
+
params.codecOptions = { videoGoogleStartBitrate: 1000 };
|
|
221
|
+
}
|
|
222
|
+
const producer = await this.sendTransport.produce(params);
|
|
206
223
|
this.producers.set(producer.id, producer);
|
|
207
224
|
producers.push({ id: producer.id, kind: track.kind });
|
|
208
225
|
}
|