Skip to content

Commit 9f4022a

Browse files
committed
Merge branch 'upstream-tag-118.0.3' into main-synced-to-118.0.3
# Conflicts: # README.md # ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m # package-lock.json # package.json # src/MediaDevices.ts
2 parents c72adbf + ebc7f15 commit 9f4022a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1391
-499
lines changed

.github/workflows/android_ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ name: Android CI
22
on:
33
push:
44
branches: [ master ]
5+
paths-ignore:
6+
- '**.md'
57
pull_request:
68
branches: [ master ]
9+
paths-ignore:
10+
- '**.md'
711

812
jobs:
913
android-compile:
@@ -26,4 +30,4 @@ jobs:
2630

2731
- name: Compile Android Example
2832
run: ./gradlew assembleDebug
29-
working-directory: ./examples/GumTestApp/android
33+
working-directory: ./examples/GumTestApp/android

.github/workflows/ios_ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ name: iOS CI
22
on:
33
push:
44
branches: [ master ]
5+
paths-ignore:
6+
- '**.md'
57
pull_request:
68
branches: [ master ]
9+
paths-ignore:
10+
- '**.md'
711

812
jobs:
913
ios-compile:

Documentation/AndroidInstallation.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Starting with React Native 0.60 due to a new auto linking feature you no longer
44

55
See a sample app in the `examples/GumTestApp` directory.
66

7+
**IMPORTANT:** Android API level >= 24 are supported.
8+
79
## Declaring Permissions
810

911
In `android/app/src/main/AndroidManifest.xml` add the following permissions before the `<application>` section.
@@ -62,6 +64,14 @@ In `android/app/main/AndroidManifest.xml` add the following inside the `<applica
6264
android:foregroundServiceType="mediaProjection|camera|microphone" />
6365
```
6466

67+
Additionally, add the respective foreground service type permissions before the `<application>` section.
68+
69+
```xml
70+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
71+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
72+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
73+
```
74+
6575
The following will create an ongoing persistent notification which also comes with a foreground service.
6676
You will be prompted for permissions automatically each time you want to initialise screen capturing.
6777
A notification channel is also required and created.
@@ -102,8 +112,8 @@ try {
102112
};
103113
```
104114

105-
Lastly you'll need to add this to your projects main `index.js` file.
106-
Otherwise you'll receive errors relating to the foreground service not being registered correctly.
115+
Lastly, you'll need to add this to your project's main `index.js` file.
116+
Otherwise, you'll receive errors relating to the foreground service not being registered correctly.
107117

108118
```javascript
109119
notifee.registerForegroundService( notification => {
@@ -169,7 +179,7 @@ java.lang.Thread in run at line 764
169179

170180
From a more specific [similar Error](https://github.com/msgpack/msgpack-java/issues/516) explaining FloatBuffer change in java 8 and in java 11.
171181

172-
We verifying that the jar files in android/libs/ are compiled for JRE11 (Major version 55),
182+
We are verifying that the jar files in android/libs/ are compiled for JRE11 (Major version 55),
173183

174184
We think that the library being compiled against the JRE 11 runtime and osVersion 9 seems to use the Java 8 context where the classByteBuffer inherits the position method from Buffer and has a return type of java.nio.Buffer.
175185
(On Java 11 the method is overridden with an implementation that returns java.nio.ByteBuffer.)

Documentation/BasicUsage.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Basic Usage
22

3-
For starters we're going to import everything ready to use.
3+
For starters, we're going to import everything ready to use.
44
Most of the included functionality is similar to how you would deal with WebRTC in your browser.
55
We support a lot of the official WebRTC APIs, see this [document](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection) for more details.
66
If you see functions that are listed in the document above but not listed below then they are likely not supported by this module yet and will most likely be supported in the near future, we're open to contributions.
@@ -41,7 +41,7 @@ You can also find a shim for react-native-web over [here](https://github.com/rea
4141

4242
## Get Available Media Devices
4343

44-
Some devices might not have more than 1 camera. The following will allow you to know how many cameras the device has. You can ofcourse use `enumerateDevices` to list other media device information too.
44+
Some devices might not have more than 1 camera. The following will allow you to know how many cameras the device has. You can use `enumerateDevices` to list other media device information too.
4545

4646
```javascript
4747
let cameraCount = 0;
@@ -115,7 +115,7 @@ try {
115115
## Destroying the Media Stream
116116

117117
Cycling all of the tracks and stopping them is more than enough to clean up after a call has finished.
118-
You won't usually need to do this for remote tracks, only local.
118+
You usually won't need to do this for remote tracks, only local.
119119

120120
```javascript
121121
localMediaStream.getTracks().forEach(
@@ -142,7 +142,7 @@ let peerConstraints = {
142142

143143
## Creating a Peer Connection
144144

145-
Here we're creating a peer connection required to get a call started.
145+
Here, we're creating a peer connection required to get a call started.
146146
You can also hook up events by directly overwriting functions instead of using event listeners.
147147

148148
```javascript
@@ -170,8 +170,8 @@ peerConnection = null;
170170

171171
## Adding the Media Stream
172172

173-
After using one of the media functions above you can then add the media stream to the peer.
174-
The negotiation needed event will be triggered on the peer connection afterwords.
173+
After using one of the media functions above, you can then add the media stream to the peer.
174+
The negotiation needed event will be triggered on the peer connection afterwards.
175175

176176
```javascript
177177
localMediaStream.getTracks().forEach(
@@ -195,7 +195,7 @@ datachannel.addEventListener( 'message', message => {} );
195195
## Handling Data Channels
196196

197197
The following event is for the second client, not the client which created the data channel.
198-
Unless ofcourse you want both sides to create separate data channels.
198+
Unless you want both sides to create separate data channels.
199199

200200
```javascript
201201
peerConnection.addEventListener( 'datachannel', event => {
@@ -208,8 +208,8 @@ peerConnection.addEventListener( 'datachannel', event => {
208208

209209
## Sending a Message via the Data Channel
210210

211-
You can send a range of different data types over data channels, we're gong to send a simple string.
212-
Bare in mind there are limits so sending large amounts of data isn't usually advised.
211+
You can send a range of different data types over data channels, we're going to send a simple string.
212+
Bear in mind that there are limits to sending large amounts of data which isn't usually advised.
213213

214214
```javascript
215215
datachannel.send( 'Hey There!' );
@@ -227,7 +227,7 @@ datachannel = null;
227227

228228
## Defining Session Constraints
229229

230-
As mentioned above by default we're going for the approach of offering both video and voice.
230+
As mentioned above, by default we're going for the approach of offering both video and voice.
231231
That will allow you to enable and disable video streams on demand while a call is active.
232232

233233
```javascript
@@ -258,8 +258,8 @@ try {
258258

259259
## Creating an Answer
260260

261-
All parties will need to ensure they are handling ICE Candidates correctly.
262-
Otherwise the offer and answer handshake stage will go a little wonky.
261+
All parties must ensure the proper handling of ICE Candidates.
262+
Otherwise, the offer-answer handshake stage might encounter some unexpected behavior.
263263

264264
```javascript
265265
try {
@@ -278,8 +278,9 @@ try {
278278

279279
## Toggle the Active Microphone
280280

281-
During an active call you might want to mute your microphone.
282-
Easy to accomplish by flipping the track enabled value to false, also possible on remote tracks.
281+
While engaging in a live call, you may find it necessary to mute your microphone.
282+
This can be easily achieved by toggling the track enabled value to false.
283+
This functionality is also applicable to remote tracks.
283284

284285
```javascript
285286
let isMuted = false;
@@ -296,7 +297,7 @@ try {
296297

297298
## Switching the Active Camera
298299

299-
Naturally we assume you'll be using the front camera by default when starting a call.
300+
Naturally, we assume you'll be using the front camera by default when starting a call.
300301
So we set `isFrontCam` as `true` and let the value flip on execution.
301302

302303
```javascript

Documentation/BuildingWebRTC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ python build-webrtc.py --setup --ios ~/src/
2222
### Android
2323

2424
NOTE: Make sure you have the Java JDK installed beforehand. On Debian and
25-
Ubuntu systems this can be accomplished by installing the `default-jdk-headless`
25+
Ubuntu systems, this can be accomplished by installing the `default-jdk-headless`
2626
package.
2727

2828
```

Documentation/tvOSInstallation.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# tvOS Installation
2+
3+
In order to use React Native on tvOS, you will need to use [react-native-tvos](https://www.npmjs.com/package/react-native-tvos).
4+
tvOS support was deprecated and removed from current/future versions of React Native.
5+
We strongly recommend using React Native 0.69+ with React 18+
6+
7+
Change the following dependency in your projects `package.json` file to get started.
8+
```
9+
"react-native": "npm:[email protected]"
10+
```
11+
12+
## Adjusting the supported platform version
13+
14+
**IMPORTANT:** Make sure you are using CocoaPods 1.10 or higher.
15+
You may have to change the `platform` field in your podfile.
16+
`react-native-webrtc` doesn't support tvOS < 16. Set it to '16.0' or above.
17+
Older versions of tvOS don't support WebRTC.
18+
19+
```
20+
platform :tvos, '16.0'
21+
```

ISSUE_TEMPLATE.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
<!--
2-
If you have a question then please ask it on our community Discourse: https://react-native-webrtc.discourse.group/
3-
otherwise if you wanted to report a bug then you are in the right place!
2+
If you have any questions then please use our Community Discourse: https://react-native-webrtc.discourse.group/
3+
Otherwise you are in the right place for reporting bugs.
44
55
Please include as much information as possible and make the issue title as descriptive as you can.
6-
-->
7-
8-
#### Expected Behavior
9-
6+
But most of all please take your time and explain to the best of your abilities.
107
8+
Code samples can be very helpful but even more so if displayed correctly.
9+
Here is an example of how you can use syntax highlighting.
1110
12-
#### Observed Behavior
11+
```javascript
1312
13+
console.log( 'Hello World' );
1414
15+
```
1516
16-
#### Steps to reproduce the issue
17+
More info can be found over here.
18+
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting
19+
-->
1720

21+
#### Expected Behavior:
22+
<!--
23+
Explain what you expect to happen.
24+
-->
1825

26+
#### Observed Behavior:
27+
<!--
28+
Explain what is actually happening.
29+
-->
1930

20-
#### Platform Information
31+
#### Steps to reproduce the issue:
32+
<!--
33+
Explain how the issue can be reproduced.
34+
If we manage to reproduce the issue then it is more likely to be addressed in an update.
35+
-->
2136

37+
#### Platform Information
2238
* **React Native Version**:
23-
* **Plugin Version**:
24-
* **OS**: <!-- Android / iOS / macOS / Web / Expo -->
25-
* **OS Version**:
39+
* **WebRTC Module Version**:
40+
* **Platform OS + Version**: <!-- Android / iOS / macOS / Web / Expo -->

android/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ def safeExtGet(prop, fallback) {
55
}
66

77
android {
8-
compileSdkVersion safeExtGet('compileSdkVersion', 23)
8+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
9+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
10+
namespace "com.oney.WebRTCModule"
11+
}
12+
13+
compileSdkVersion safeExtGet('compileSdkVersion', 24)
914
buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")
1015

1116
defaultConfig {
12-
minSdkVersion safeExtGet('minSdkVersion', 19)
13-
targetSdkVersion safeExtGet('targetSdkVersion', 23)
17+
minSdkVersion safeExtGet('minSdkVersion', 24)
18+
targetSdkVersion safeExtGet('targetSdkVersion', 24)
1419
versionCode 1
1520
versionName "1.0"
1621
}
@@ -25,5 +30,6 @@ android {
2530

2631
dependencies {
2732
implementation 'com.facebook.react:react-native:+'
28-
api 'org.jitsi:webrtc:111.+'
33+
implementation 'com.github.jiangdongguo.AndroidUSBCamera:libausbc:3.3.3'
34+
api 'org.jitsi:webrtc:118.+'
2935
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.oney.WebRTCModule">
2+
package="com.oney.WebRTCModule"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
>
5+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
7+
<application>
8+
<service
9+
android:name=".MediaProjectionService"
10+
android:foregroundServiceType="mediaProjection">
11+
</service>
12+
</application>
13+
<uses-feature
14+
android:name="android.hardware.usb.host"
15+
android:required="false"
16+
tools:node="replace"
17+
/>
318
</manifest>

android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ class GetUserMediaImpl {
7070
}
7171

7272
if (camera2supported) {
73-
Log.d(TAG, "Creating video capturer using Camera2 API.");
74-
cameraEnumerator = new Camera2Enumerator(reactContext);
73+
if (UVCCamera2Enumerator.isSupported(reactContext)) {
74+
Log.d(TAG, "Creating video capturer using Camera2 API with UVC support.");
75+
cameraEnumerator = new UVCCamera2Enumerator(reactContext);
76+
} else {
77+
Log.d(TAG, "Creating video capturer using Camera2 API.");
78+
cameraEnumerator = new Camera2Enumerator(reactContext);
79+
}
7580
} else {
7681
Log.d(TAG, "Creating video capturer using Camera1 API.");
7782
cameraEnumerator = new Camera1Enumerator(false);
@@ -89,7 +94,11 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
8994
}
9095

9196
mediaProjectionPermissionResultData = data;
92-
createScreenStream();
97+
98+
ThreadUtils.runOnExecutor(() -> {
99+
MediaProjectionService.launch(activity);
100+
createScreenStream();
101+
});
93102
}
94103
}
95104
});
@@ -332,8 +341,7 @@ void createStream(MediaStreamTrack[] tracks, BiConsumer<String, ArrayList<Writab
332341
trackInfo.putBoolean("enabled", track.enabled());
333342
trackInfo.putString("id", trackId);
334343
trackInfo.putString("kind", track.kind());
335-
trackInfo.putString("label", trackId);
336-
trackInfo.putString("readyState", track.state().toString().toLowerCase());
344+
trackInfo.putString("readyState", "live");
337345
trackInfo.putBoolean("remote", false);
338346

339347
if (track instanceof VideoTrack) {
@@ -500,7 +508,5 @@ public void dispose() {
500508
}
501509
}
502510

503-
public interface BiConsumer<T, U> {
504-
void accept(T t, U u);
505-
}
511+
public interface BiConsumer<T, U> { void accept(T t, U u); }
506512
}

0 commit comments

Comments
 (0)