react-native-webrtc 1.92.2 → 1.94.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.
Files changed (44) hide show
  1. package/.prettierignore +9 -0
  2. package/.prettierrc.json +10 -0
  3. package/android/libs/.placeholder +0 -0
  4. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
  5. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +199 -255
  6. package/apple/.placeholder +0 -0
  7. package/ios/RCTWebRTC/VideoCaptureController.m +5 -3
  8. package/metro.config.js +3 -4
  9. package/metro.config.macos.js +7 -8
  10. package/package.json +20 -12
  11. package/react-native.config.js +5 -6
  12. package/src/EventEmitter.js +1 -1
  13. package/src/MediaDevices.js +6 -12
  14. package/src/MediaStream.js +120 -131
  15. package/src/MediaStreamError.js +8 -10
  16. package/src/MediaStreamErrorEvent.js +6 -7
  17. package/src/MediaStreamEvent.js +6 -7
  18. package/src/MediaStreamTrack.js +89 -103
  19. package/src/MediaStreamTrackEvent.js +6 -7
  20. package/src/MessageEvent.js +7 -8
  21. package/src/Permissions.js +26 -23
  22. package/src/RTCDataChannel.js +127 -145
  23. package/src/RTCDataChannelEvent.js +6 -7
  24. package/src/RTCEvent.js +5 -6
  25. package/src/RTCIceCandidate.js +15 -16
  26. package/src/RTCIceCandidateEvent.js +8 -9
  27. package/src/RTCPeerConnection.js +295 -325
  28. package/src/RTCSessionDescription.js +15 -16
  29. package/src/RTCUtil.js +56 -57
  30. package/src/RTCView.js +59 -69
  31. package/src/ScreenCapturePickerView.js +2 -5
  32. package/src/getDisplayMedia.js +7 -6
  33. package/src/getUserMedia.js +85 -85
  34. package/src/index.js +28 -34
  35. package/tools/build-webrtc.py +61 -49
  36. package/tools/downloadBitcode.sh +4 -16
  37. package/tools/downloadWebRTC.js +100 -0
  38. package/android/libs/libjingle_peerconnection.so.jar +0 -0
  39. package/android/libs/libwebrtc.jar +0 -0
  40. package/apple/WebRTC.xcframework.tgz +0 -0
  41. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  42. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  43. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  44. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -22,17 +22,11 @@ ANDROID_BUILD_CPUS = [
22
22
  'x86',
23
23
  'x64'
24
24
  ]
25
- IOS_ARCH_MAP = {
26
- 'arm64': 'ios-arm64',
27
- 'x64' : 'ios-x86_64-simulator'
28
- }
29
25
  IOS_BUILD_ARCHS = [
30
- 'arm64',
31
- 'x64'
26
+ 'device:arm64',
27
+ 'simulator:arm64',
28
+ 'simulator:x64'
32
29
  ]
33
- MACOS_ARCH_MAP = {
34
- 'x64' : 'macos-x86_64'
35
- }
36
30
  MACOS_BUILD_ARCHS = [
37
31
  'x64'
38
32
  ]
@@ -41,9 +35,6 @@ def build_gn_args(platform_args):
41
35
  return "--args='" + ' '.join(GN_COMMON_ARGS + platform_args) + "'"
42
36
 
43
37
  GN_COMMON_ARGS = [
44
- # Xcode 12 Clang consider warning as error by default
45
- # See https://bugs.chromium.org/p/webrtc/issues/detail?id=11729
46
- 'treat_warnings_as_errors=false',
47
38
  'is_component_build=false',
48
39
  'rtc_libvpx_build_vp9=true',
49
40
  'is_debug=%s',
@@ -58,10 +49,11 @@ _GN_APPLE_COMMON = [
58
49
 
59
50
  _GN_IOS_ARGS = [
60
51
  'enable_ios_bitcode=true',
61
- 'ios_deployment_target="11.0"',
52
+ 'ios_deployment_target="12.0"',
62
53
  'ios_enable_code_signing=false',
63
54
  'target_os="ios"',
64
55
  'use_xcode_clang=true',
56
+ 'target_environment="%s"'
65
57
  ]
66
58
  GN_IOS_ARGS = build_gn_args(_GN_APPLE_COMMON + _GN_IOS_ARGS)
67
59
 
@@ -72,18 +64,17 @@ _GN_MACOS_ARGS = [
72
64
  GN_MACOS_ARGS = build_gn_args(_GN_APPLE_COMMON + _GN_MACOS_ARGS)
73
65
 
74
66
  _GN_ANDROID_ARGS = [
75
- 'target_os="android"',
76
- 'strip_debug_info=%s',
67
+ 'target_os="android"'
77
68
  ]
78
69
  GN_ANDROID_ARGS = build_gn_args(_GN_ANDROID_ARGS)
79
70
 
80
71
 
81
72
  # Utilities
82
73
 
83
- def sh(cmd, env=None):
74
+ def sh(cmd, env=None, cwd=None):
84
75
  print('Running cmd: %s' % cmd)
85
76
  try:
86
- subprocess.check_call(cmd, env=env, shell=True, stdin=sys.stdin, stdout=sys.stdout, stderr=subprocess.STDOUT)
77
+ subprocess.check_call(cmd, env=env, cwd=cwd, shell=True, stdin=sys.stdin, stdout=sys.stdout, stderr=subprocess.STDOUT)
87
78
  except subprocess.CalledProcessError as e:
88
79
  sys.exit(e.returncode)
89
80
  except KeyboardInterrupt:
@@ -191,33 +182,35 @@ def build(target_dir, platform, debug):
191
182
 
192
183
  # Run GN
193
184
  if platform == 'ios':
185
+ for item in IOS_BUILD_ARCHS:
186
+ tenv, arch = item.split(':')
187
+ gn_out_dir = 'out/%s-ios-%s-%s' % (build_type, tenv, arch)
188
+ gn_args = GN_IOS_ARGS % (str(debug).lower(), arch, tenv)
189
+ gn_cmd = 'gn gen %s %s' % (gn_out_dir, gn_args)
190
+ sh(gn_cmd, env)
194
191
  for arch in MACOS_BUILD_ARCHS:
195
192
  gn_out_dir = 'out/%s-macos-%s' % (build_type, arch)
196
193
  gn_args = GN_MACOS_ARGS % (str(debug).lower(), arch)
197
194
  gn_cmd = 'gn gen %s %s' % (gn_out_dir, gn_args)
198
195
  sh(gn_cmd, env)
199
- for arch in IOS_BUILD_ARCHS:
200
- gn_out_dir = 'out/%s-ios-%s' % (build_type, arch)
201
- gn_args = GN_IOS_ARGS % (str(debug).lower(), arch)
202
- gn_cmd = 'gn gen %s %s' % (gn_out_dir, gn_args)
203
- sh(gn_cmd, env)
204
196
  else:
205
197
  for cpu in ANDROID_BUILD_CPUS:
206
198
  gn_out_dir = 'out/%s-%s' % (build_type, cpu)
207
- gn_args = GN_ANDROID_ARGS % (str(debug).lower(), cpu, str(not debug).lower())
199
+ gn_args = GN_ANDROID_ARGS % (str(debug).lower(), cpu)
208
200
  gn_cmd = 'gn gen %s %s' % (gn_out_dir, gn_args)
209
201
  sh(gn_cmd, env)
210
202
 
211
203
  # Build with Ninja
212
204
  if platform == 'ios':
205
+ for item in IOS_BUILD_ARCHS:
206
+ tenv, arch = item.split(':')
207
+ gn_out_dir = 'out/%s-ios-%s-%s' % (build_type, tenv, arch)
208
+ ninja_cmd = 'ninja -C %s framework_objc' % gn_out_dir
209
+ sh(ninja_cmd, env)
213
210
  for arch in MACOS_BUILD_ARCHS:
214
211
  gn_out_dir = 'out/%s-macos-%s' % (build_type, arch)
215
212
  ninja_cmd = 'ninja -C %s mac_framework_objc' % gn_out_dir
216
213
  sh(ninja_cmd, env)
217
- for arch in IOS_BUILD_ARCHS:
218
- gn_out_dir = 'out/%s-ios-%s' % (build_type, arch)
219
- ninja_cmd = 'ninja -C %s framework_objc' % gn_out_dir
220
- sh(ninja_cmd, env)
221
214
  else:
222
215
  for cpu in ANDROID_BUILD_CPUS:
223
216
  gn_out_dir = 'out/%s-%s' % (build_type, cpu)
@@ -230,37 +223,57 @@ def build(target_dir, platform, debug):
230
223
 
231
224
  # Copy build artifacts to build directory
232
225
  if platform == 'ios':
226
+ # Fat simulators (we need a single slice for both simulators)
227
+ simulators = [item for item in IOS_BUILD_ARCHS if item.startswith('simulator')]
228
+ tenv, arch = simulators[0].split(':')
229
+ gn_out_dir = 'out/%s-ios-%s-%s' % (build_type, tenv, arch)
230
+ shutil.copytree(os.path.join(gn_out_dir, 'WebRTC.framework'), os.path.join(gn_out_dir, 'fat-WebRTC.framework'))
231
+ out_lib_path = os.path.join(gn_out_dir, 'fat-WebRTC.framework', 'WebRTC')
232
+ slice_paths = []
233
+ for item in simulators:
234
+ tenv, arch = item.split(':')
235
+ lib_path = os.path.join('out/%s-ios-%s-%s' % (build_type, tenv, arch), 'WebRTC.framework', 'WebRTC')
236
+ slice_paths.append(lib_path)
237
+ sh('lipo %s -create -output %s' % (' '.join(slice_paths), out_lib_path))
238
+
239
+ orig_framework_path = os.path.join(gn_out_dir, 'WebRTC.framework')
240
+ bak_framework_path = os.path.join(gn_out_dir, 'bak-WebRTC.framework')
241
+ fat_framework_path = os.path.join(gn_out_dir, 'fat-WebRTC.framework')
242
+ shutil.move(orig_framework_path, bak_framework_path)
243
+ shutil.move(fat_framework_path, orig_framework_path)
244
+
245
+ _IOS_BUILD_ARCHS = [item for item in IOS_BUILD_ARCHS if not item.startswith('simulator')]
246
+ _IOS_BUILD_ARCHS.append(simulators[0])
247
+
233
248
  # XCFramework
234
- xcodebuild_cmd = 'xcodebuild -create-xcframework -output %s' % os.path.join(build_dir, 'WebRTC.xcframework')
249
+ xcframework_path = os.path.join(build_dir, 'WebRTC.xcframework')
250
+ xcodebuild_cmd = 'xcodebuild -create-xcframework -output %s' % xcframework_path
251
+ for item in _IOS_BUILD_ARCHS:
252
+ tenv, arch = item.split(':')
253
+ gn_out_dir = 'out/%s-ios-%s-%s' % (build_type, tenv, arch)
254
+ xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
235
255
  for arch in MACOS_BUILD_ARCHS:
236
256
  gn_out_dir = 'out/%s-macos-%s' % (build_type, arch)
237
257
  xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
238
- for arch in IOS_BUILD_ARCHS:
239
- gn_out_dir = 'out/%s-ios-%s' % (build_type, arch)
240
- xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
241
258
  sh(xcodebuild_cmd)
259
+ sh('tar zcf WebRTC.xcframework-bitcode.tgz WebRTC.xcframework', cwd=build_dir)
260
+ rmr(xcframework_path)
242
261
 
243
262
  # XCFramework (stripped)
244
- xcodebuild_cmd = 'xcodebuild -create-xcframework -output %s' % os.path.join(build_dir, 'stripped', 'WebRTC.xcframework')
263
+ xcodebuild_cmd = 'xcodebuild -create-xcframework -output %s' % xcframework_path
245
264
  bitcode_strip_cmd = 'xcrun bitcode_strip -r %s -o %s'
246
- for arch in MACOS_BUILD_ARCHS:
247
- gn_out_dir = 'out/%s-macos-%s' % (build_type, arch)
265
+ for item in _IOS_BUILD_ARCHS:
266
+ tenv, arch = item.split(':')
267
+ gn_out_dir = 'out/%s-ios-%s-%s' % (build_type, tenv, arch)
248
268
  xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
249
- for arch in IOS_BUILD_ARCHS:
250
- gn_out_dir = 'out/%s-ios-%s' % (build_type, arch)
251
269
  framework_path = os.path.join(gn_out_dir, 'WebRTC.framework', 'WebRTC')
252
270
  sh(bitcode_strip_cmd % (framework_path, framework_path))
253
- xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
254
- sh(xcodebuild_cmd)
255
-
256
- # dSYMs
257
- dsyms_dir = os.path.join(build_dir, 'WebRTC.dSYMs')
258
271
  for arch in MACOS_BUILD_ARCHS:
259
272
  gn_out_dir = 'out/%s-macos-%s' % (build_type, arch)
260
- shutil.copytree(os.path.join(gn_out_dir, 'WebRTC.dSYM'), os.path.join(dsyms_dir, 'WebRTC.framework.%s.dSYM' % MACOS_ARCH_MAP[arch]))
261
- for arch in IOS_BUILD_ARCHS:
262
- gn_out_dir = 'out/%s-ios-%s' % (build_type, arch)
263
- shutil.copytree(os.path.join(gn_out_dir, 'WebRTC.dSYM'), os.path.join(dsyms_dir, 'WebRTC.framework.%s.dSYM' % IOS_ARCH_MAP[arch]))
273
+ xcodebuild_cmd += ' -framework %s' % os.path.join(gn_out_dir, 'WebRTC.framework')
274
+ sh(xcodebuild_cmd)
275
+ sh('tar zcf WebRTC.xcframework.tgz WebRTC.xcframework', cwd=build_dir)
276
+ rmr(xcframework_path)
264
277
  else:
265
278
  gn_out_dir = 'out/%s-%s' % (build_type, ANDROID_BUILD_CPUS[0])
266
279
  shutil.copy(os.path.join(gn_out_dir, 'lib.java/sdk/android/libwebrtc.jar'), build_dir)
@@ -271,9 +284,9 @@ def build(target_dir, platform, debug):
271
284
  gn_out_dir = 'out/%s-%s' % (build_type, cpu)
272
285
  shutil.copy(os.path.join(gn_out_dir, 'libjingle_peerconnection_so.so'), lib_dir)
273
286
 
274
- os.chdir(build_dir)
275
- sh('jar cvfM libjingle_peerconnection.so.jar lib')
276
- rmr('lib')
287
+ sh('jar cvfM libjingle_peerconnection.so.jar lib', cwd=build_dir)
288
+ rmr(os.path.join(build_dir, 'lib'))
289
+ sh('tar zcf android-webrtc.tgz *.jar', cwd=build_dir)
277
290
 
278
291
 
279
292
  if __name__ == "__main__":
@@ -325,4 +338,3 @@ if __name__ == "__main__":
325
338
  build(target_dir, platform, args.debug)
326
339
  print('WebRTC build for %s completed in %s' % (platform, target_dir))
327
340
  sys.exit(0)
328
-
@@ -3,24 +3,12 @@
3
3
  set -euo pipefail
4
4
 
5
5
  THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
6
- PACKAGE_VERSION=$(cat "${THIS_DIR}/../package.json" \
7
- | grep "\"version\":" \
8
- | head -1 \
9
- | awk -F: '{ print $2 }' \
10
- | sed 's/[",]//g' \
11
- | tr -d '[[:space:]]')
12
- WEBRTC_DL="https://github.com/react-native-webrtc/react-native-webrtc/releases/download/${PACKAGE_VERSION}/WebRTC.tar.xz"
13
6
 
7
+ pushd ${THIS_DIR}
14
8
 
15
- pushd "${THIS_DIR}/../apple"
9
+ export RN_WEBRTC_BITCODE=1
10
+ export RN_WEBRTC_FORCE_DOWNLOAD=1
16
11
 
17
- # Cleanup
18
- rm -rf WebRTC.xcframework WebRTC.dSYMs
19
-
20
- # Download
21
- echo "Downloading files..."
22
- echo $PACKAGE_VERSION
23
- curl -L -s ${WEBRTC_DL} | tar Jxf -
24
- echo "Done!"
12
+ node downloadWebRTC.js
25
13
 
26
14
  popd
@@ -0,0 +1,100 @@
1
+
2
+ const fs = require('fs');
3
+ const https = require('https');
4
+ const path = require('path');
5
+ const process = require('process');
6
+ const tar = require('tar');
7
+
8
+ const pkg = require('../package.json');
9
+ const builds = pkg['webrtc-builds'];
10
+
11
+
12
+ async function download(url, filePath) {
13
+ return new Promise((resolve, reject) => {
14
+ const request = https.get(url, response => {
15
+ if (response.statusCode === 301 || response.statusCode === 302) {
16
+ resolve(download(response.headers.location, filePath));
17
+ return;
18
+ }
19
+
20
+ if (response.statusCode !== 200) {
21
+ reject(new Error(`Failed to get '${url}' (${response.statusCode})`));
22
+ return;
23
+ }
24
+
25
+ const file = fs.createWriteStream(filePath);
26
+
27
+ file.on('finish', () => resolve());
28
+
29
+ file.on('error', err => {
30
+ fs.unlink(filePath, () => reject(err));
31
+ });
32
+
33
+ response.pipe(file);
34
+ });
35
+
36
+ request.on('error', err => {
37
+ fs.unlink(filePath, () => reject(err));
38
+ });
39
+
40
+ request.end();
41
+ });
42
+ }
43
+
44
+ (async () => {
45
+ if (process.env.RN_WEBRTC_SKIP_DOWNLOAD) {
46
+ console.log('Skipping WebRTC build downloads')
47
+ return process.exit(0);
48
+ }
49
+
50
+ const items = [];
51
+
52
+ // iOS
53
+ //
54
+
55
+ if (process.platform === 'darwin') {
56
+ const bitcode = process.env.RN_WEBRTC_BITCODE;
57
+ const url = bitcode ? builds['ios-bitcode'] : builds['ios'];
58
+
59
+ items.push({
60
+ url,
61
+ dstFileName: 'WebRTC.xcframework.tgz',
62
+ dstDir: `${__dirname}/../apple/`
63
+ });
64
+ }
65
+
66
+ // Android
67
+ //
68
+
69
+ items.push({
70
+ url: builds['android'],
71
+ dstFileName: 'android-webrtc.tgz',
72
+ dstDir: `${__dirname}/../android/libs/`
73
+ });
74
+
75
+ // Download them all!
76
+ //
77
+
78
+ for (const item of items) {
79
+ const { url, dstFileName, dstDir } = item;
80
+ const dstPath = path.join(dstDir, dstFileName);
81
+
82
+ if (fs.existsSync(dstPath) && process.env.RN_WEBRTC_FORCE_DOWNLOAD) {
83
+ console.log('Removing previously downloaded file')
84
+ fs.rmSync(dstPath);
85
+ }
86
+
87
+ console.log(`Downloading ${url}...`);
88
+
89
+ await download(url, dstPath);
90
+
91
+ tar.extract({
92
+ file: dstPath,
93
+ cwd: dstDir,
94
+ sync: true,
95
+ strict: true
96
+ });
97
+
98
+ console.log('Done!');
99
+ }
100
+ })();
Binary file
Binary file
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>RCTWebRTC.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>