react-native-webrtc 111.0.1 → 111.0.2
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/GetUserMediaImpl.java +0 -1
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +19 -14
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +20 -1
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +21 -21
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +0 -3
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +19 -9
- package/lib/commonjs/MediaStream.js +15 -8
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +20 -0
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +4 -2
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/MediaStream.js +15 -8
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +20 -0
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +4 -2
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/typescript/MediaStream.d.ts +3 -2
- package/package.json +1 -1
- package/src/MediaStream.ts +17 -7
- package/src/RTCPeerConnection.ts +16 -0
- package/src/RTCRtpTransceiver.ts +2 -2
|
@@ -321,7 +321,6 @@ class GetUserMediaImpl {
|
|
|
321
321
|
trackInfo.putBoolean("enabled", track.enabled());
|
|
322
322
|
trackInfo.putString("id", trackId);
|
|
323
323
|
trackInfo.putString("kind", track.kind());
|
|
324
|
-
trackInfo.putString("label", trackId);
|
|
325
324
|
trackInfo.putString("readyState", track.state().toString().toLowerCase());
|
|
326
325
|
trackInfo.putBoolean("remote", false);
|
|
327
326
|
|
|
@@ -21,30 +21,35 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
|
|
|
21
21
|
|
|
22
22
|
private final Intent mediaProjectionPermissionResultData;
|
|
23
23
|
|
|
24
|
-
private final OrientationEventListener
|
|
24
|
+
private final OrientationEventListener orientationListener;
|
|
25
25
|
|
|
26
26
|
public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData) {
|
|
27
27
|
super(width, height, DEFAULT_FPS);
|
|
28
28
|
|
|
29
29
|
this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
|
|
30
30
|
|
|
31
|
-
this.
|
|
31
|
+
this.orientationListener = new OrientationEventListener(context) {
|
|
32
32
|
@Override
|
|
33
33
|
public void onOrientationChanged(int orientation) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
DisplayMetrics displayMetrics = DisplayUtils.getDisplayMetrics((Activity) context);
|
|
35
|
+
final int width = displayMetrics.widthPixels;
|
|
36
|
+
final int height = displayMetrics.heightPixels;
|
|
37
|
+
|
|
38
|
+
// Pivot to the executor thread because videoCapturer.changeCaptureFormat runs in the main
|
|
39
|
+
// thread and may deadlock.
|
|
40
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
41
|
+
try {
|
|
42
|
+
videoCapturer.changeCaptureFormat(width, height, DEFAULT_FPS);
|
|
43
|
+
} catch (Exception ex) {
|
|
44
|
+
// We ignore exceptions here. The video capturer runs on its own
|
|
45
|
+
// thread and we cannot synchronize with it.
|
|
46
|
+
}
|
|
47
|
+
});
|
|
43
48
|
}
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
if (this.
|
|
47
|
-
this.
|
|
51
|
+
if (this.orientationListener.canDetectOrientation()) {
|
|
52
|
+
this.orientationListener.enable();
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -55,7 +60,7 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
|
|
|
55
60
|
@Override
|
|
56
61
|
public void onStop() {
|
|
57
62
|
Log.w(TAG, "Media projection stopped.");
|
|
58
|
-
|
|
63
|
+
orientationListener.disable();
|
|
59
64
|
stopCapture();
|
|
60
65
|
|
|
61
66
|
if (capturerEventsListener != null) {
|
|
@@ -882,7 +882,8 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
882
882
|
@ReactMethod
|
|
883
883
|
public void peerConnectionCreateOffer(int id, ReadableMap options, Promise promise) {
|
|
884
884
|
ThreadUtils.runOnExecutor(() -> {
|
|
885
|
-
|
|
885
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
|
|
886
|
+
PeerConnection peerConnection = pco.getPeerConnection();
|
|
886
887
|
|
|
887
888
|
if (peerConnection == null) {
|
|
888
889
|
Log.d(TAG, "peerConnectionCreateOffer() peerConnection is null");
|
|
@@ -890,6 +891,11 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
890
891
|
return;
|
|
891
892
|
}
|
|
892
893
|
|
|
894
|
+
List<String> receiversIds = new ArrayList<>();
|
|
895
|
+
for (RtpTransceiver transceiver : peerConnection.getTransceivers()) {
|
|
896
|
+
receiversIds.add(transceiver.getReceiver().id());
|
|
897
|
+
}
|
|
898
|
+
|
|
893
899
|
final SdpObserver observer = new SdpObserver() {
|
|
894
900
|
@Override
|
|
895
901
|
public void onCreateFailure(String s) {
|
|
@@ -908,6 +914,19 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
908
914
|
params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
|
|
909
915
|
params.putMap("sdpInfo", sdpInfo);
|
|
910
916
|
|
|
917
|
+
WritableArray newTransceivers = Arguments.createArray();
|
|
918
|
+
for (RtpTransceiver transceiver : peerConnection.getTransceivers()) {
|
|
919
|
+
if (!receiversIds.contains(transceiver.getReceiver().id())) {
|
|
920
|
+
WritableMap newTransceiver = Arguments.createMap();
|
|
921
|
+
newTransceiver.putInt("transceiverOrder", pco.getNextTransceiverId());
|
|
922
|
+
newTransceiver.putMap(
|
|
923
|
+
"transceiver", SerializeUtils.serializeTransceiver(id, transceiver));
|
|
924
|
+
newTransceivers.pushMap(newTransceiver);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
params.putArray("newTransceivers", newTransceivers);
|
|
929
|
+
|
|
911
930
|
promise.resolve(params);
|
|
912
931
|
});
|
|
913
932
|
}
|
|
@@ -323,13 +323,15 @@ public class WebRTCView extends ViewGroup {
|
|
|
323
323
|
private void removeRendererFromVideoTrack() {
|
|
324
324
|
if (rendererAttached) {
|
|
325
325
|
if (videoTrack != null) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
327
|
+
try {
|
|
328
|
+
videoTrack.removeSink(surfaceViewRenderer);
|
|
329
|
+
} catch (Throwable tr) {
|
|
330
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
331
|
+
// invoked on videoTrack, then it is no longer safe to call removeSink
|
|
332
|
+
// on the instance, it will throw IllegalStateException.
|
|
333
|
+
}
|
|
334
|
+
});
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
surfaceViewRenderer.release();
|
|
@@ -518,27 +520,25 @@ public class WebRTCView extends ViewGroup {
|
|
|
518
520
|
}
|
|
519
521
|
|
|
520
522
|
try {
|
|
521
|
-
surfaceViewRendererInstances++;
|
|
522
523
|
surfaceViewRenderer.init(sharedContext, rendererEvents);
|
|
524
|
+
surfaceViewRendererInstances++;
|
|
523
525
|
} catch (Exception e) {
|
|
524
526
|
Logging.e(
|
|
525
527
|
TAG, "Failed to initialize surfaceViewRenderer on instance " + surfaceViewRendererInstances, e);
|
|
526
|
-
|
|
528
|
+
return;
|
|
527
529
|
}
|
|
528
530
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
Log.e(TAG, "Failed to add renderer", tr);
|
|
531
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
532
|
+
try {
|
|
533
|
+
videoTrack.addSink(surfaceViewRenderer);
|
|
534
|
+
} catch (Throwable tr) {
|
|
535
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
536
|
+
// invoked on videoTrack, then it is no longer safe to call addSink
|
|
537
|
+
// on the instance, it will throw IllegalStateException.
|
|
537
538
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
539
|
+
Log.e(TAG, "Failed to add renderer", tr);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
542
|
|
|
543
543
|
rendererAttached = true;
|
|
544
544
|
}
|
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
@"enabled" : @(track.isEnabled),
|
|
84
84
|
@"id" : trackId,
|
|
85
85
|
@"kind" : track.kind,
|
|
86
|
-
@"label" : trackId,
|
|
87
86
|
@"readyState" : @"live",
|
|
88
87
|
@"remote" : @(NO),
|
|
89
88
|
@"settings" : settings
|
|
@@ -155,7 +154,6 @@ RCT_EXPORT_METHOD(getDisplayMedia : (RCTPromiseResolveBlock)resolve rejecter : (
|
|
|
155
154
|
@"enabled" : @(videoTrack.isEnabled),
|
|
156
155
|
@"id" : videoTrack.trackId,
|
|
157
156
|
@"kind" : videoTrack.kind,
|
|
158
|
-
@"label" : videoTrack.trackId,
|
|
159
157
|
@"readyState" : @"live",
|
|
160
158
|
@"remote" : @(NO)
|
|
161
159
|
};
|
|
@@ -225,7 +223,6 @@ RCT_EXPORT_METHOD(getUserMedia
|
|
|
225
223
|
@"enabled" : @(track.isEnabled),
|
|
226
224
|
@"id" : trackId,
|
|
227
225
|
@"kind" : track.kind,
|
|
228
|
-
@"label" : trackId,
|
|
229
226
|
@"readyState" : @"live",
|
|
230
227
|
@"remote" : @(NO),
|
|
231
228
|
@"settings" : settings
|
|
@@ -120,18 +120,31 @@ RCT_EXPORT_METHOD(peerConnectionCreateOffer
|
|
|
120
120
|
RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:options
|
|
121
121
|
optionalConstraints:nil];
|
|
122
122
|
|
|
123
|
+
NSMutableArray *receiversIds = [NSMutableArray new];
|
|
124
|
+
for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
|
|
125
|
+
[receiversIds addObject:transceiver.receiver.receiverId];
|
|
126
|
+
}
|
|
127
|
+
|
|
123
128
|
RTCCreateSessionDescriptionCompletionHandler handler = ^(RTCSessionDescription *desc, NSError *error) {
|
|
124
129
|
dispatch_async(self.workerQueue, ^{
|
|
125
130
|
if (error) {
|
|
126
131
|
reject(@"E_OPERATION_ERROR", error.localizedDescription, nil);
|
|
127
132
|
} else {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
NSMutableArray *newTransceivers = [NSMutableArray new];
|
|
134
|
+
for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
|
|
135
|
+
if (![receiversIds containsObject:transceiver.receiver.receiverId]) {
|
|
136
|
+
NSMutableDictionary *newTransceiver = [NSMutableDictionary new];
|
|
137
|
+
newTransceiver[@"transceiverOrder"] = [NSNumber numberWithInt:_transceiverNextId++];
|
|
138
|
+
newTransceiver[@"transceiver"] =
|
|
139
|
+
[SerializeUtils transceiverToJSONWithPeerConnectionId:objectID transceiver:transceiver];
|
|
140
|
+
[newTransceivers addObject:newTransceiver];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
131
143
|
id data = @{
|
|
132
|
-
@"sdpInfo" :
|
|
144
|
+
@"sdpInfo" : @{@"type" : [RTCSessionDescription stringForType:desc.type], @"sdp" : desc.sdp},
|
|
133
145
|
@"transceiversInfo" :
|
|
134
|
-
[SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
|
|
146
|
+
[SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection],
|
|
147
|
+
@"newTransceivers" : newTransceivers
|
|
135
148
|
};
|
|
136
149
|
resolve(data);
|
|
137
150
|
}
|
|
@@ -160,11 +173,8 @@ RCT_EXPORT_METHOD(peerConnectionCreateAnswer
|
|
|
160
173
|
if (error) {
|
|
161
174
|
reject(@"E_OPERATION_ERROR", error.localizedDescription, nil);
|
|
162
175
|
} else {
|
|
163
|
-
NSMutableDictionary *sdpInfo = [NSMutableDictionary new];
|
|
164
|
-
sdpInfo[@"type"] = [RTCSessionDescription stringForType:desc.type];
|
|
165
|
-
sdpInfo[@"sdp"] = desc.sdp;
|
|
166
176
|
id data = @{
|
|
167
|
-
@"sdpInfo" :
|
|
177
|
+
@"sdpInfo" : @{@"type" : [RTCSessionDescription stringForType:desc.type], @"sdp" : desc.sdp},
|
|
168
178
|
@"transceiversInfo" :
|
|
169
179
|
[SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
|
|
170
180
|
};
|
|
@@ -44,22 +44,20 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
|
|
|
44
44
|
* built afterwards.
|
|
45
45
|
*/
|
|
46
46
|
constructor(arg) {
|
|
47
|
-
super(); //
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "id", void 0);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "active", true);
|
|
47
|
+
super(); // Assign a UUID to start with. It will get overridden for remote streams.
|
|
52
48
|
|
|
53
49
|
_defineProperty(this, "_tracks", []);
|
|
54
50
|
|
|
51
|
+
_defineProperty(this, "_id", void 0);
|
|
52
|
+
|
|
55
53
|
_defineProperty(this, "_reactTag", void 0);
|
|
56
54
|
|
|
57
|
-
this.
|
|
55
|
+
this._id = (0, _RTCUtil.uniqueID)(); // Local MediaStreams are created by WebRTCModule to have their id and
|
|
58
56
|
// reactTag equal because WebRTCModule follows the respective standard's
|
|
59
57
|
// recommendation for id generation i.e. uses UUID which is unique enough
|
|
60
58
|
// for the purposes of reactTag.
|
|
61
59
|
|
|
62
|
-
this._reactTag = this.
|
|
60
|
+
this._reactTag = this._id;
|
|
63
61
|
|
|
64
62
|
if (typeof arg === 'undefined') {
|
|
65
63
|
WebRTCModule.mediaStreamCreate(this.id);
|
|
@@ -76,7 +74,7 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
|
|
|
76
74
|
this.addTrack(track);
|
|
77
75
|
}
|
|
78
76
|
} else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
|
|
79
|
-
this.
|
|
77
|
+
this._id = arg.streamId;
|
|
80
78
|
this._reactTag = arg.streamReactTag;
|
|
81
79
|
|
|
82
80
|
for (const trackInfo of arg.tracks) {
|
|
@@ -89,6 +87,15 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
|
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
|
|
90
|
+
get id() {
|
|
91
|
+
return this._id;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get active() {
|
|
95
|
+
// TODO: can we reliably report this value?
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
92
99
|
addTrack(track) {
|
|
93
100
|
const index = this._tracks.indexOf(track);
|
|
94
101
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","
|
|
1
|
+
{"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","_id","_reactTag","mediaStreamCreate","id","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","active","index","indexOf","mediaStreamAddTrack","remote","_peerConnectionId","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;;;AA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AACH;;AAEDC,EAAAA,YAAY,CAACC,OAAD,EAAwC;AAChD,WAAO,KAAKf,OAAL,CAAagB,IAAb,CAAkBzB,KAAK,IAAIA,KAAK,CAACD,EAAN,KAAayB,OAAxC,CAAP;AACH;;AAEDE,EAAAA,cAAc,GAAuB;AACjC,WAAO,KAAKjB,OAAL,CAAakB,MAAb,CAAoB3B,KAAK,IAAIA,KAAK,CAAC4B,IAAN,KAAe,OAA5C,CAAP;AACH;;AAEDC,EAAAA,cAAc,GAAuB;AACjC,WAAO,KAAKpB,OAAL,CAAakB,MAAb,CAAoB3B,KAAK,IAAIA,KAAK,CAAC4B,IAAN,KAAe,OAA5C,CAAP;AACH;;AAEDE,EAAAA,KAAK,GAAU;AACX,UAAM,IAAIC,KAAJ,CAAU,kBAAV,CAAN;AACH;;AAEDC,EAAAA,KAAK,GAAW;AACZ,WAAO,KAAKnC,SAAZ;AACH;;AAEDoC,EAAAA,OAAO,GAA6B;AAAA,QAA5BC,aAA4B,uEAAZ,IAAY;AAChC,UAAM3B,MAAM,GAAG,CAAE,GAAG,KAAKE,OAAV,CAAf;;AAEA,SAAK,MAAMT,KAAX,IAAoBO,MAApB,EAA4B;AACxB,WAAKY,WAAL,CAAiBnB,KAAjB;;AAEA,UAAIkC,aAAJ,EAAmB;AACflC,QAAAA,KAAK,CAACiC,OAAN;AACH;AACJ;;AAED3C,IAAAA,YAAY,CAAC6C,kBAAb,CAAgC,KAAKtC,SAArC;AACH;;AAtIoF","sourcesContent":["\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport MediaStreamTrack from './MediaStreamTrack';\nimport { uniqueID } from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = [ 'active', 'inactive', 'addtrack', 'removetrack' ];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n _tracks: MediaStreamTrack[] = [];\n\n _id: string;\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the parameters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assign a UUID to start with. It will get overridden for remote streams.\n this._id = uniqueID();\n\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this._id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this._id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n get id(): string {\n return this._id;\n }\n\n get active(): boolean {\n // TODO: can we reliably report this value?\n\n return true;\n }\n\n addTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index !== -1) {\n return;\n }\n\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n removeTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index === -1) {\n return;\n }\n\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n getTracks(): MediaStreamTrack[] {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n toURL(): string {\n return this._reactTag;\n }\n\n release(releaseTracks = true): void {\n const tracks = [ ...this._tracks ];\n\n for (const track of tracks) {\n this.removeTrack(track);\n\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}
|
|
@@ -99,9 +99,29 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
99
99
|
log.debug(`${this._pcId} createOffer`);
|
|
100
100
|
const {
|
|
101
101
|
sdpInfo,
|
|
102
|
+
newTransceivers,
|
|
102
103
|
transceiversInfo
|
|
103
104
|
} = await WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options));
|
|
104
105
|
log.debug(`${this._pcId} createOffer OK`);
|
|
106
|
+
newTransceivers === null || newTransceivers === void 0 ? void 0 : newTransceivers.forEach(t => {
|
|
107
|
+
const {
|
|
108
|
+
transceiverOrder,
|
|
109
|
+
transceiver
|
|
110
|
+
} = t;
|
|
111
|
+
const newSender = new _RTCRtpSender.default({ ...transceiver.sender,
|
|
112
|
+
track: null
|
|
113
|
+
});
|
|
114
|
+
const remoteTrack = transceiver.receiver.track ? new _MediaStreamTrack.default(transceiver.receiver.track) : null;
|
|
115
|
+
const newReceiver = new _RTCRtpReceiver.default({ ...transceiver.receiver,
|
|
116
|
+
track: remoteTrack
|
|
117
|
+
});
|
|
118
|
+
const newTransceiver = new _RTCRtpTransceiver.default({ ...transceiver,
|
|
119
|
+
sender: newSender,
|
|
120
|
+
receiver: newReceiver
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this._insertTransceiverSorted(transceiverOrder, newTransceiver);
|
|
124
|
+
});
|
|
105
125
|
|
|
106
126
|
this._updateTransceivers(transceiversInfo);
|
|
107
127
|
|