@sbhjt-gr/react-native-webrtc 124.0.2 → 124.0.3
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/android/src/main/java/com/oney/WebRTCModule/palabra/PalabraClient.java +40 -3
- package/ios/RCTWebRTC/PalabraClient.m +70 -10
- package/lib/commonjs/RTCPeerConnection.js +110 -5
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/getUserMedia.js +23 -0
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +110 -5
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/getUserMedia.js +23 -0
- package/lib/module/getUserMedia.js.map +1 -1
- package/package.json +1 -1
- package/src/RTCPeerConnection.ts +103 -0
- package/src/getUserMedia.ts +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","MediaStream","MediaStreamError","permissions","RTCUtil","WebRTCModule","getUserMedia","constraints","arguments","length","undefined","Promise","reject","TypeError","audio","video","normalizeConstraints","reqPermissions","push","request","name","resolve","all","then","results","audioPerm","videoPerm","error","message","success","id","tracks","trackInfo","c","kind","deepClone","
|
|
1
|
+
{"version":3,"names":["NativeModules","MediaStream","MediaStreamError","permissions","RTCUtil","WebRTCModule","getUserMedia","constraints","arguments","length","undefined","Promise","reject","TypeError","audio","video","console","log","normalizeConstraints","reqPermissions","push","request","name","resolve","_t0","Date","now","all","then","results","audioPerm","videoPerm","error","message","success","id","tracks","trackInfo","c","kind","deepClone","durationMs","streamId","trackCount","trackKinds","map","t","info","streamReactTag","failure","type"],"sources":["getUserMedia.ts"],"sourcesContent":["\nimport { NativeModules } from 'react-native';\n\n\nimport { MediaTrackConstraints } from './Constraints';\nimport MediaStream from './MediaStream';\nimport MediaStreamError from './MediaStreamError';\nimport permissions from './Permissions';\nimport * as RTCUtil from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nexport interface Constraints {\n audio?: boolean | MediaTrackConstraints;\n video?: boolean | MediaTrackConstraints;\n}\n\nexport default function getUserMedia(constraints: Constraints = {}): Promise<MediaStream> {\n // According to\n // https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia,\n // the constraints argument is a dictionary of type MediaStreamConstraints.\n if (typeof constraints !== 'object') {\n return Promise.reject(new TypeError('constraints is not a dictionary'));\n }\n\n if (\n (typeof constraints.audio === 'undefined' || !constraints.audio) &&\n (typeof constraints.video === 'undefined' || !constraints.video)\n ) {\n return Promise.reject(new TypeError('audio and/or video is required'));\n }\n\n console.log('[RNWebRTC] get_user_media_start', {\n audio: !!constraints.audio,\n video: !!constraints.video,\n });\n\n // Normalize constraints.\n constraints = RTCUtil.normalizeConstraints(constraints);\n\n // Request required permissions\n const reqPermissions: Promise<boolean>[] = [];\n\n if (constraints.audio) {\n console.log('[RNWebRTC] requesting_mic_permission');\n reqPermissions.push(permissions.request({ name: 'microphone' }));\n } else {\n reqPermissions.push(Promise.resolve(false));\n }\n\n if (constraints.video) {\n console.log('[RNWebRTC] requesting_camera_permission');\n reqPermissions.push(permissions.request({ name: 'camera' }));\n } else {\n reqPermissions.push(Promise.resolve(false));\n }\n\n const _t0 = Date.now();\n\n return new Promise((resolve, reject) => {\n Promise.all(reqPermissions).then(results => {\n const [ audioPerm, videoPerm ] = results;\n\n console.log('[RNWebRTC] permission_results', { audioPerm, videoPerm });\n\n // Check permission results and remove unneeded permissions.\n\n if (!audioPerm && !videoPerm) {\n // https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia\n // step 4\n console.log('[RNWebRTC] permission_denied_both');\n const error = {\n message: 'Permission denied.',\n name: 'SecurityError'\n };\n\n reject(new MediaStreamError(error));\n\n return;\n }\n\n audioPerm || delete constraints.audio;\n videoPerm || delete constraints.video;\n\n const success = (id, tracks) => {\n // Store initial constraints.\n for (const trackInfo of tracks) {\n const c = constraints[trackInfo.kind];\n\n if (typeof c === 'object') {\n trackInfo.constraints = RTCUtil.deepClone(c);\n }\n }\n\n console.log('[RNWebRTC] get_user_media_success', {\n durationMs: Date.now() - _t0,\n streamId: id,\n trackCount: tracks.length,\n trackKinds: tracks.map(t => t.kind),\n });\n\n const info = {\n streamId: id,\n streamReactTag: id,\n tracks\n };\n\n resolve(new MediaStream(info));\n };\n\n const failure = (type, message) => {\n console.log('[RNWebRTC] get_user_media_error', {\n durationMs: Date.now() - _t0,\n type,\n message,\n });\n\n let error;\n\n switch (type) {\n case 'TypeError':\n error = new TypeError(message);\n break;\n }\n\n if (!error) {\n error = new MediaStreamError({ message, name: type });\n }\n\n reject(error);\n };\n\n WebRTCModule.getUserMedia(constraints, success, failure);\n });\n });\n}\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,cAAc;AAI5C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,WAAW;AAEpC,MAAM;EAAEC;AAAa,CAAC,GAAGL,aAAa;AAOtC,eAAe,SAASM,YAAYA,CAAA,EAAsD;EAAA,IAArDC,WAAwB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC9D;EACA;EACA;EACA,IAAI,OAAOD,WAAW,KAAK,QAAQ,EAAE;IACjC,OAAOI,OAAO,CAACC,MAAM,CAAC,IAAIC,SAAS,CAAC,iCAAiC,CAAC,CAAC;EAC3E;EAEA,IACI,CAAC,OAAON,WAAW,CAACO,KAAK,KAAK,WAAW,IAAI,CAACP,WAAW,CAACO,KAAK,MAC9D,OAAOP,WAAW,CAACQ,KAAK,KAAK,WAAW,IAAI,CAACR,WAAW,CAACQ,KAAK,CAAC,EAClE;IACE,OAAOJ,OAAO,CAACC,MAAM,CAAC,IAAIC,SAAS,CAAC,gCAAgC,CAAC,CAAC;EAC1E;EAEAG,OAAO,CAACC,GAAG,CAAC,iCAAi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EF,IAAID,KAAK;QAET,QAAQkB,IAAI;UACR,KAAK,WAAW;YACZlB,KAAK,GAAG,IAAInB,SAAS,CAACoB,OAAO,CAAC;YAC9B;QACR;QAEA,IAAI,CAACD,KAAK,EAAE;UACRA,KAAK,GAAG,IAAI9B,gBAAgB,CAAC;YAAE+B,OAAO;YAAEX,IAAI,EAAE4B;UAAK,CAAC,CAAC;QACzD;QAEAtC,MAAM,CAACoB,KAAK,CAAC;MACjB,CAAC;MAED3B,YAAY,CAACC,YAAY,CAACC,WAAW,EAAE2B,OAAO,EAAEe,OAAO,CAAC;IAC5D,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
|
package/package.json
CHANGED
package/src/RTCPeerConnection.ts
CHANGED
|
@@ -134,6 +134,12 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
async createOffer(options?:RTCOfferOptions) {
|
|
137
|
+
const _t0 = Date.now();
|
|
138
|
+
console.log(`[RNWebRTC] pc:${this._pcId} create_offer_start`, {
|
|
139
|
+
signalingState: this.signalingState,
|
|
140
|
+
connectionState: this.connectionState,
|
|
141
|
+
iceConnectionState: this.iceConnectionState,
|
|
142
|
+
});
|
|
137
143
|
log.debug(`${this._pcId} createOffer`);
|
|
138
144
|
|
|
139
145
|
const {
|
|
@@ -142,6 +148,11 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
142
148
|
transceiversInfo
|
|
143
149
|
} = await WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options));
|
|
144
150
|
|
|
151
|
+
console.log(`[RNWebRTC] pc:${this._pcId} create_offer_done`, {
|
|
152
|
+
durationMs: Date.now() - _t0,
|
|
153
|
+
sdpType: sdpInfo?.type,
|
|
154
|
+
sdpLen: sdpInfo?.sdp?.length ?? 0,
|
|
155
|
+
});
|
|
145
156
|
log.debug(`${this._pcId} createOffer OK`);
|
|
146
157
|
|
|
147
158
|
newTransceivers?.forEach(t => {
|
|
@@ -165,6 +176,11 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
async createAnswer() {
|
|
179
|
+
const _t0 = Date.now();
|
|
180
|
+
console.log(`[RNWebRTC] pc:${this._pcId} create_answer_start`, {
|
|
181
|
+
signalingState: this.signalingState,
|
|
182
|
+
connectionState: this.connectionState,
|
|
183
|
+
});
|
|
168
184
|
log.debug(`${this._pcId} createAnswer`);
|
|
169
185
|
|
|
170
186
|
const {
|
|
@@ -172,6 +188,12 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
172
188
|
transceiversInfo
|
|
173
189
|
} = await WebRTCModule.peerConnectionCreateAnswer(this._pcId, {});
|
|
174
190
|
|
|
191
|
+
console.log(`[RNWebRTC] pc:${this._pcId} create_answer_done`, {
|
|
192
|
+
durationMs: Date.now() - _t0,
|
|
193
|
+
sdpType: sdpInfo?.type,
|
|
194
|
+
sdpLen: sdpInfo?.sdp?.length ?? 0,
|
|
195
|
+
});
|
|
196
|
+
|
|
175
197
|
this._updateTransceivers(transceiversInfo);
|
|
176
198
|
|
|
177
199
|
return sdpInfo;
|
|
@@ -182,6 +204,12 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
182
204
|
}
|
|
183
205
|
|
|
184
206
|
async setLocalDescription(sessionDescription?: RTCSessionDescription | RTCSessionDescriptionInit): Promise<void> {
|
|
207
|
+
const _t0 = Date.now();
|
|
208
|
+
console.log(`[RNWebRTC] pc:${this._pcId} set_local_desc_start`, {
|
|
209
|
+
type: sessionDescription?.type,
|
|
210
|
+
sdpLen: sessionDescription?.sdp?.length ?? 0,
|
|
211
|
+
signalingState: this.signalingState,
|
|
212
|
+
});
|
|
185
213
|
log.debug(`${this._pcId} setLocalDescription`);
|
|
186
214
|
|
|
187
215
|
let desc;
|
|
@@ -212,10 +240,21 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
212
240
|
|
|
213
241
|
this._updateTransceivers(transceiversInfo, /* removeStopped */ desc?.type === 'answer');
|
|
214
242
|
|
|
243
|
+
console.log(`[RNWebRTC] pc:${this._pcId} set_local_desc_done`, {
|
|
244
|
+
durationMs: Date.now() - _t0,
|
|
245
|
+
signalingState: this.signalingState,
|
|
246
|
+
});
|
|
215
247
|
log.debug(`${this._pcId} setLocalDescription OK`);
|
|
216
248
|
}
|
|
217
249
|
|
|
218
250
|
async setRemoteDescription(sessionDescription: RTCSessionDescription | RTCSessionDescriptionInit): Promise<void> {
|
|
251
|
+
const _t0 = Date.now();
|
|
252
|
+
console.log(`[RNWebRTC] pc:${this._pcId} set_remote_desc_start`, {
|
|
253
|
+
type: sessionDescription?.type,
|
|
254
|
+
sdpLen: sessionDescription?.sdp?.length ?? 0,
|
|
255
|
+
signalingState: this.signalingState,
|
|
256
|
+
connectionState: this.connectionState,
|
|
257
|
+
});
|
|
219
258
|
log.debug(`${this._pcId} setRemoteDescription`);
|
|
220
259
|
|
|
221
260
|
if (!sessionDescription) {
|
|
@@ -322,10 +361,25 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
322
361
|
track._setMutedInternal(false);
|
|
323
362
|
}
|
|
324
363
|
|
|
364
|
+
console.log(`[RNWebRTC] pc:${this._pcId} set_remote_desc_done`, {
|
|
365
|
+
durationMs: Date.now() - _t0,
|
|
366
|
+
signalingState: this.signalingState,
|
|
367
|
+
pendingTrackEventsDispatched: this._pendingTrackEvents.length,
|
|
368
|
+
});
|
|
325
369
|
log.debug(`${this._pcId} setRemoteDescription OK`);
|
|
326
370
|
}
|
|
327
371
|
|
|
328
372
|
async addIceCandidate(candidate): Promise<void> {
|
|
373
|
+
console.log(`[RNWebRTC] pc:${this._pcId} add_ice_candidate`, {
|
|
374
|
+
type: candidate?.type,
|
|
375
|
+
protocol: candidate?.protocol,
|
|
376
|
+
sdpMid: candidate?.sdpMid,
|
|
377
|
+
sdpMLineIndex: candidate?.sdpMLineIndex,
|
|
378
|
+
empty: !candidate?.candidate,
|
|
379
|
+
signalingState: this.signalingState,
|
|
380
|
+
connectionState: this.connectionState,
|
|
381
|
+
iceConnectionState: this.iceConnectionState,
|
|
382
|
+
});
|
|
329
383
|
log.debug(`${this._pcId} addIceCandidate`);
|
|
330
384
|
|
|
331
385
|
if (!candidate || !candidate.candidate) {
|
|
@@ -568,6 +622,12 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
568
622
|
return;
|
|
569
623
|
}
|
|
570
624
|
|
|
625
|
+
console.log(`[RNWebRTC] pc:${this._pcId} negotiation_needed`, {
|
|
626
|
+
signalingState: this.signalingState,
|
|
627
|
+
connectionState: this.connectionState,
|
|
628
|
+
iceConnectionState: this.iceConnectionState,
|
|
629
|
+
});
|
|
630
|
+
|
|
571
631
|
this.dispatchEvent(new Event('negotiationneeded'));
|
|
572
632
|
});
|
|
573
633
|
|
|
@@ -576,7 +636,14 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
576
636
|
return;
|
|
577
637
|
}
|
|
578
638
|
|
|
639
|
+
const prev = this.iceConnectionState;
|
|
579
640
|
this.iceConnectionState = ev.iceConnectionState;
|
|
641
|
+
console.log(`[RNWebRTC] pc:${this._pcId} ice_connection_changed`, {
|
|
642
|
+
prev,
|
|
643
|
+
current: ev.iceConnectionState,
|
|
644
|
+
connectionState: this.connectionState,
|
|
645
|
+
signalingState: this.signalingState,
|
|
646
|
+
});
|
|
580
647
|
|
|
581
648
|
this.dispatchEvent(new Event('iceconnectionstatechange'));
|
|
582
649
|
});
|
|
@@ -586,11 +653,20 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
586
653
|
return;
|
|
587
654
|
}
|
|
588
655
|
|
|
656
|
+
const prev = this.connectionState;
|
|
589
657
|
this.connectionState = ev.connectionState;
|
|
658
|
+
console.log(`[RNWebRTC] pc:${this._pcId} connection_state_changed`, {
|
|
659
|
+
prev,
|
|
660
|
+
current: ev.connectionState,
|
|
661
|
+
iceConnectionState: this.iceConnectionState,
|
|
662
|
+
iceGatheringState: this.iceGatheringState,
|
|
663
|
+
signalingState: this.signalingState,
|
|
664
|
+
});
|
|
590
665
|
|
|
591
666
|
this.dispatchEvent(new Event('connectionstatechange'));
|
|
592
667
|
|
|
593
668
|
if (ev.connectionState === 'closed') {
|
|
669
|
+
console.log(`[RNWebRTC] pc:${this._pcId} disposing`);
|
|
594
670
|
// This PeerConnection is done, clean up.
|
|
595
671
|
removeListener(this);
|
|
596
672
|
|
|
@@ -603,7 +679,13 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
603
679
|
return;
|
|
604
680
|
}
|
|
605
681
|
|
|
682
|
+
const prev = this.signalingState;
|
|
606
683
|
this.signalingState = ev.signalingState;
|
|
684
|
+
console.log(`[RNWebRTC] pc:${this._pcId} signaling_state_changed`, {
|
|
685
|
+
prev,
|
|
686
|
+
current: ev.signalingState,
|
|
687
|
+
connectionState: this.connectionState,
|
|
688
|
+
});
|
|
607
689
|
|
|
608
690
|
this.dispatchEvent(new Event('signalingstatechange'));
|
|
609
691
|
});
|
|
@@ -614,6 +696,13 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
614
696
|
return;
|
|
615
697
|
}
|
|
616
698
|
|
|
699
|
+
console.log(`[RNWebRTC] pc:${this._pcId} track_event_queued`, {
|
|
700
|
+
receiverId: ev.receiver?.id,
|
|
701
|
+
trackKind: ev.receiver?.track?.kind,
|
|
702
|
+
streamCount: ev.streams?.length ?? 0,
|
|
703
|
+
pendingCount: this._pendingTrackEvents.length + 1,
|
|
704
|
+
});
|
|
705
|
+
|
|
617
706
|
log.debug(`${this._pcId} ontrack`);
|
|
618
707
|
|
|
619
708
|
// NOTE: We need to make sure the track event fires right before sRD completes,
|
|
@@ -627,6 +716,7 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
627
716
|
return;
|
|
628
717
|
}
|
|
629
718
|
|
|
719
|
+
console.log(`[RNWebRTC] pc:${this._pcId} remove_track`, { receiverId: ev.receiverId });
|
|
630
720
|
log.debug(`${this._pcId} onremovetrack ${ev.receiverId}`);
|
|
631
721
|
|
|
632
722
|
const receiver = this.getReceivers().find(r => r.id === ev.receiverId);
|
|
@@ -660,6 +750,13 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
660
750
|
return;
|
|
661
751
|
}
|
|
662
752
|
|
|
753
|
+
console.log(`[RNWebRTC] pc:${this._pcId} local_ice_candidate`, {
|
|
754
|
+
type: ev.candidate?.type,
|
|
755
|
+
protocol: ev.candidate?.protocol,
|
|
756
|
+
sdpMid: ev.candidate?.sdpMid,
|
|
757
|
+
iceGatheringState: this.iceGatheringState,
|
|
758
|
+
});
|
|
759
|
+
|
|
663
760
|
const sdpInfo = ev.sdp;
|
|
664
761
|
|
|
665
762
|
// Can happen when doing a rollback.
|
|
@@ -679,7 +776,13 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
679
776
|
return;
|
|
680
777
|
}
|
|
681
778
|
|
|
779
|
+
const prev = this.iceGatheringState;
|
|
682
780
|
this.iceGatheringState = ev.iceGatheringState;
|
|
781
|
+
console.log(`[RNWebRTC] pc:${this._pcId} ice_gathering_state_changed`, {
|
|
782
|
+
prev,
|
|
783
|
+
current: ev.iceGatheringState,
|
|
784
|
+
connectionState: this.connectionState,
|
|
785
|
+
});
|
|
683
786
|
|
|
684
787
|
if (this.iceGatheringState === 'complete') {
|
|
685
788
|
const sdpInfo = ev.sdp;
|
package/src/getUserMedia.ts
CHANGED
|
@@ -30,6 +30,11 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
30
30
|
return Promise.reject(new TypeError('audio and/or video is required'));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
console.log('[RNWebRTC] get_user_media_start', {
|
|
34
|
+
audio: !!constraints.audio,
|
|
35
|
+
video: !!constraints.video,
|
|
36
|
+
});
|
|
37
|
+
|
|
33
38
|
// Normalize constraints.
|
|
34
39
|
constraints = RTCUtil.normalizeConstraints(constraints);
|
|
35
40
|
|
|
@@ -37,26 +42,33 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
37
42
|
const reqPermissions: Promise<boolean>[] = [];
|
|
38
43
|
|
|
39
44
|
if (constraints.audio) {
|
|
45
|
+
console.log('[RNWebRTC] requesting_mic_permission');
|
|
40
46
|
reqPermissions.push(permissions.request({ name: 'microphone' }));
|
|
41
47
|
} else {
|
|
42
48
|
reqPermissions.push(Promise.resolve(false));
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
if (constraints.video) {
|
|
52
|
+
console.log('[RNWebRTC] requesting_camera_permission');
|
|
46
53
|
reqPermissions.push(permissions.request({ name: 'camera' }));
|
|
47
54
|
} else {
|
|
48
55
|
reqPermissions.push(Promise.resolve(false));
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
const _t0 = Date.now();
|
|
59
|
+
|
|
51
60
|
return new Promise((resolve, reject) => {
|
|
52
61
|
Promise.all(reqPermissions).then(results => {
|
|
53
62
|
const [ audioPerm, videoPerm ] = results;
|
|
54
63
|
|
|
64
|
+
console.log('[RNWebRTC] permission_results', { audioPerm, videoPerm });
|
|
65
|
+
|
|
55
66
|
// Check permission results and remove unneeded permissions.
|
|
56
67
|
|
|
57
68
|
if (!audioPerm && !videoPerm) {
|
|
58
69
|
// https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia
|
|
59
70
|
// step 4
|
|
71
|
+
console.log('[RNWebRTC] permission_denied_both');
|
|
60
72
|
const error = {
|
|
61
73
|
message: 'Permission denied.',
|
|
62
74
|
name: 'SecurityError'
|
|
@@ -80,6 +92,13 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
94
|
|
|
95
|
+
console.log('[RNWebRTC] get_user_media_success', {
|
|
96
|
+
durationMs: Date.now() - _t0,
|
|
97
|
+
streamId: id,
|
|
98
|
+
trackCount: tracks.length,
|
|
99
|
+
trackKinds: tracks.map(t => t.kind),
|
|
100
|
+
});
|
|
101
|
+
|
|
83
102
|
const info = {
|
|
84
103
|
streamId: id,
|
|
85
104
|
streamReactTag: id,
|
|
@@ -90,6 +109,12 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
90
109
|
};
|
|
91
110
|
|
|
92
111
|
const failure = (type, message) => {
|
|
112
|
+
console.log('[RNWebRTC] get_user_media_error', {
|
|
113
|
+
durationMs: Date.now() - _t0,
|
|
114
|
+
type,
|
|
115
|
+
message,
|
|
116
|
+
});
|
|
117
|
+
|
|
93
118
|
let error;
|
|
94
119
|
|
|
95
120
|
switch (type) {
|