Skip to content

Commit

Permalink
Merge pull request #728 from opentok/develop
Browse files Browse the repository at this point in the history
v2.27.1
  • Loading branch information
jeffswartz authored Mar 14, 2024
2 parents 57b8d17 + 0322ac5 commit 31ddfe8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
6 changes: 3 additions & 3 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ declare module "opentok-react-native" {
/**
* Sent when the publisher stops sending video because of publisher audio fallback (see https://tokbox.com/developer/guides/audio-fallback).
*/
videoDisabled?: CallbackWithParam<{reason: string}>;
videoDisabled?: CallbackWithParam<{reason: string}, any>;

/**
* Sent when the publisher is close to going to audio-only fallback becuase of declining network conditions (see https://tokbox.com/developer/guides/audio-fallback).
Expand Down Expand Up @@ -637,12 +637,12 @@ declare module "opentok-react-native" {
/**
* This message is sent when the OpenTok Media Router determines that the stream quality has degraded and the video will be disabled if the quality degrades further. If the quality degrades further, the subscriber disables the video and the videoDisabled message is sent. If the stream quality improves, the videoDisableWarningLifted message is sent.
*/
videoDisableWarning?: CallbackWithParam<{stream: Stream});
videoDisableWarning?: CallbackWithParam<{stream: Stream}, any>;

/**
* This message is sent when the subscriber’s video stream starts (when there previously was no video) or resumes (after video was disabled). Check the reason parameter for the reason why the video started (or resumed).
*/
videoDisableWarningLifted?: CallbackWithParam<{stream: Stream});
videoDisableWarningLifted?: CallbackWithParam<{stream: Stream}, any>;

/**
* This message is sent when the subscriber’s video stream starts (when there previously was no video) or resumes (after video was disabled). Check the reason parameter for the reason why the video started (or resumed).
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# 2.27.1 (March 2024)

- [Fix]: On Android, OTPublisher components failed with an error when either `PermissionsAndroid.PERMISSIONS.CAMERA` or `PermissionsAndroid.PERMISSIONS.RECORD_AUDIO` were not `true`. This version fixes that, by having audio-only or video-only publishers skip the `PermissionsAndroid.PERMISSIONS.CAMERA` or `PermissionsAndroid.PERMISSIONS.RECORD_AUDIO` check if the `videoTrack` or `audioTrack` property of the `properties` prop of the OTPublisher component is set to `false`. You can set these props to `false` based on these permissions:

```jsx
import { PermissionsAndroid } from 'react-native';
// ...

<OTPublisher
properties={{
videoTrack={{(Platform.OS === 'ios' || PermissionsAndroid.CAMERA)}}
}}
/>
```

*Note:* In Android 6.0 (`API Level 23`) and higher, the OpenTok React Native SDK automatically adds these permissions. However, an app or user can disable them independently of the SDK.

- [Fix]: On Android, setting the `videoTrack` property of the `properties` prop of the OTPublisher component `false` resulted in the app to crash. This version fixes the issue (issue #652).

- [Fix]: Fixes some TypeScript definitions (issue #725).

# 2.27.0 (March 2024)

- [Update]: Update OpenTok Android SDK and OpenTok iOS SDK to version 2.27.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void initPublisher(String publisherId, ReadableMap properties, Callback c
if (cameraPosition.equals("back")) {
mPublisher.cycleCamera();
}
if (mPublisher.getCapturer() != null) {
if (videoTrack && mPublisher.getCapturer() != null) {
mPublisher.getCapturer().setVideoContentHint(Utils.convertVideoContentHint(properties.getString("videoContentHint")));
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opentok-react-native",
"version": "2.27.0",
"version": "2.27.1",
"description": "React Native components for OpenTok iOS and Android SDKs",
"main": "src/index.js",
"homepage": "https://www.tokbox.com",
Expand Down
10 changes: 6 additions & 4 deletions src/OT.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { each } from 'underscore';
const OT = NativeModules.OTSessionManager;
const nativeEvents = new NativeEventEmitter(OT);

const checkAndroidPermissions = () => new Promise((resolve, reject) => {
PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO])
const checkAndroidPermissions = (audioTrack, videoTrack) => new Promise((resolve, reject) => {
const permissionsToCheck = [
... audioTrack ? [PermissionsAndroid.PERMISSIONS.RECORD_AUDIO] : [],
... videoTrack ? [PermissionsAndroid.PERMISSIONS.CAMERA] : [],
];
PermissionsAndroid.requestMultiple(permissionsToCheck)
.then((result) => {
const permissionsError = {};
permissionsError.permissionsDenied = [];
Expand Down
11 changes: 6 additions & 5 deletions src/OTPublisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,21 @@ class OTPublisher extends Component {
}
};
createPublisher() {
const publisherProperties = sanitizeProperties(this.props.properties);
if (Platform.OS === 'android') {
checkAndroidPermissions()
const { audioTrack, videoTrack } = publisherProperties;
checkAndroidPermissions(audioTrack, videoTrack)
.then(() => {
this.initPublisher();
this.initPublisher(publisherProperties);
})
.catch((error) => {
this.otrnEventHandler(error);
});
} else {
this.initPublisher();
this.initPublisher(publisherProperties);
}
}
initPublisher() {
const publisherProperties = sanitizeProperties(this.props.properties);
initPublisher(publisherProperties) {
OT.initPublisher(
this.state.publisherId,
publisherProperties,
Expand Down

0 comments on commit 31ddfe8

Please sign in to comment.