Socket
Socket
Sign inDemoInstall

opentok-react-native

Package Overview
Dependencies
20
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.26.1 to 2.27.0

.nvmrc

117

@types/index.d.ts

@@ -95,2 +95,20 @@ declare module "opentok-react-native" {

interface PublisherAudioNetworkStats {
connectionId?: string,
subscriberId?: string,
audioPacketsLost: number,
audioBytesSent: number,
audioPacketsSent: number,
timeStamp: number,
}
interface PublisherVideoNetworkStats {
connectionId?: string,
subscriberId?: string,
videoPacketsLost: number,
videoBytesSent: number,
videoPacketsSent: number,
timestamp: number,
}
interface PublisherRtcStatsReport {

@@ -103,3 +121,3 @@ connectionId: string,

sessionId: string;
fromConnection: string;
connectionId: string;
type: string;

@@ -109,2 +127,6 @@ data: string;

interface MuteForcedEvent {
active: boolean;
}
interface OTSessionProps extends ViewProps {

@@ -145,2 +167,9 @@ /**

eventHandlers?: OTSessionEventHandlers;
/**
* Used to set the encryption secret in a session that uses end-to-end encryption.
* See https://tokbox.com/developer/guides/end-to-end-encryption.
*/
encryptionSecret?: string
}

@@ -226,3 +255,3 @@

/**
* Sent if the attempt to connect to the session fails or if the connection to the session drops due to an error after a successful connection.
* Sent if the attempt to connect to the session fails or if the connection to the session drops due to an error after a successful connection. Also sent if setting an encryption secret results in an error.
*/

@@ -232,2 +261,7 @@ error?: CallbackWithParam<ErrorEvent, any>;

/**
* Sent when a moderator has forced clients publishing streams to the session to mute audio (the active property of the MuteForcedEvent object is set to true), or a moderator has disabled the mute audio state in the session (the active property of the MuteForcedEvent object is set to false).
*/
muteForced?: CallbackWithParam<MuteForcedEvent, any>;
/**
* Sent if there is an error with the communication between the native session instance and the JS component.

@@ -279,3 +313,3 @@ */

/**
* https://github.com/opentok/opentok-react-native/blob/master/docs/OTSession.md
* https://tokbox.com/developer/sdks/react-native/reference/OTSession.html
*/

@@ -338,4 +372,13 @@ export class OTSession extends React.Component<OTSessionProps, unknown> {

/**
* Whether to turn on audio fallback or not.
* Settings to enable and disable publisher and subscriber audio fallback.
* See https://tokbox.com/developer/guides/audio-fallback.
*/
audioFallback?: {
publisher?: boolean;
subscriber?: boolean;
};
/**
* Deprecated. See the `audioFallback` property.
*/
audioFallbackEnabled?: boolean;

@@ -406,2 +449,6 @@

/**
* Sent when publisher audio stats are available.
*/
audioNetworkStats?: CallbackWithParam<PublisherAudioNetworkStats[], any>;
/**
* Sent if the publisher encounters an error. After this message is sent, the publisher can be considered fully detached from a session and may be released.

@@ -412,2 +459,7 @@ */

/**
* Sent when a moderator has forced this publisher's stream to be muted.
*/
muteForced?: Callback<any>;
/**
* Sent if there is an error with the communication between the native publisher instance and the JS component.

@@ -432,6 +484,31 @@ */

streamDestroyed?: CallbackWithParam<StreamDestroyedEvent, any>;
/**
* Sent when the publisher stops sending video because of publisher audio fallback (see https://tokbox.com/developer/guides/audio-fallback).
*/
videoDisabled?: CallbackWithParam<{reason: string}>;
/**
* 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).
*/
videoDisableWarning?: Callback<any>;
/**
* Sent after a videoDisableWarning event when network conditions improve (see https://tokbox.com/developer/guides/audio-fallback).
*/
videoDisableWarningLifted?: Callback<any>;
/**
* Sent when the publisher resumes sending video after it was disabled because of publisher audio fallback (see https://tokbox.com/developer/guides/audio-fallback).
*/
videoEnabled?: CallbackWithParam<{reason: string}, any>;
/**
* Sent when publisher video stats are available.
*/
videoNetworkStats?: CallbackWithParam<PublisherVideoNetworkStats[], any>;
}
/**
* https://github.com/opentok/opentok-react-native/blob/master/docs/OTPublisher.md
* https://tokbox.com/developer/sdks/react-native/reference/OTPublisher.html
*/

@@ -444,3 +521,3 @@ export class OTPublisher extends React.Component<OTPublisherProps, unknown> {

*/
getRtcStatsReport?: () => void;
getRtcStatsReport: () => void;

@@ -450,3 +527,6 @@ /**

*/
setVideoTransformers?: () => void;
setVideoTransformers: (transformers: Array<{
name: string,
properties?: string,
}>) => void;
}

@@ -488,2 +568,17 @@

/**
* The audio volume, from 0 to 100.
*/
audioVolume?: number;
/**
* The preferred frame rate, in frames per second.
*/
preferredFrameRate?: number;
/**
* The preferred resolution, either "1280x720", "640x480", or "352x288".
*/
preferredResolution?: string;
/**
* Whether to subscribe to audio.

@@ -559,3 +654,3 @@ */

*/
videoDisableWarning?: Callback<any>;
videoDisableWarning?: CallbackWithParam<{stream: Stream});

@@ -565,3 +660,3 @@ /**

*/
videoDisableWarningLifted?: Callback<any>;
videoDisableWarningLifted?: CallbackWithParam<{stream: Stream});

@@ -587,7 +682,7 @@ /**

/**
* https://github.com/opentok/opentok-react-native/blob/main/docs/OTSubscriber.md#custom-rendering-of-streams
* https://tokbox.com/developer/guides/subscribe-stream/react-native/#custom_rendering
*/
export class OTSubscriberView extends React.Component<OTSubscriberViewProps, unknown> {}
/**
* https://github.com/opentok/opentok-react-native/blob/master/docs/OTSubscriber.md
* https://tokbox.com/developer/sdks/react-native/reference/OTSubscriber.html
*/

@@ -594,0 +689,0 @@ export class OTSubscriber extends React.Component<OTSubscriberProps, unknown> {

@@ -0,1 +1,31 @@

# 2.27.0 (March 2024)
- [Update]: Update OpenTok Android SDK and OpenTok iOS SDK to version 2.27.0.
This version adds support for the VP9 codec in relayed sessions. For more information, see the [video codecs](https://tokbox.com/developer/guides/codecs/) documentation.
This version adds support for adaptive media routing. For more information, see the [adaptive media routing](https://tokbox.com/developer/guides/create-session/#adaptive-media-routing) documentation.
For more details, see the release notes for the OpenTok [iOS](https://tokbox.com/developer/sdks/ios/release-notes.html) and [Android](https://tokbox.com/developer/sdks/android/release-notes.html) SDKs.
- [Update]: This version adds support for [end-to-end encryption](https://tokbox.com/developer/guides/end-to-end-encryption). The `OTSession` component includes a new `encryptionSecret` prop, which you can use to set and change the encryption secret used by the local client.
- [Update]: This version adds a new `OTPublisher audioFallback` option, which supports both subscriber and publisher audio fallback. The `audioFallback.subscriber` property replaces the `OTPublisher audioFallbackEnabled` option, which is deprecated.
The OTPublisher component has new callback functions for publisher audio fallback-related events: `videoDisabled()`, `videoEnabled()`, `videoDisableWarning()`, and `videoDisableWarningLifted()`. See the [audio fallback developer guide](https://tokbox.com/developer/guides/audio-fallback).
- [Update]: The `OTPublisher.setVideoTransformer()` method now supports the background image replacement transformer in Android (as well as iOS). And the custom radius option for the background blur filter is now supported in Android (as well as iOS).
- [Update]: The axios package is updated. This updates a vulnerable version of in the follow-redirects dependency.
- [Fix]: This version fixes some issues in the TypeScript definitions.
- [Fix]: This version fixes the following events, which were not being dispatched:
* OTPublisher audioNetworkStats
* OTPublisher videoNetworkStats
* OTPublisher muteForced
* OTSession muteForced
- [Fix]: This version fixes the `OTSession.forceMuteAll()` method in iOS.
# 2.26.1 (October 2023)

@@ -2,0 +32,0 @@

373

docs/EventData.md

@@ -1,372 +0,1 @@

# Event data
You can register event handler functions with the `eventHandlers` property of the
OTSession, OTPublisher, and OTSubscriber components:
```javascript
class App extends Component {
constructor(props) {
super(props);
this.sessionEventHandlers = {
streamCreated: event => {
console.log('Stream created!', event);
},
streamDestroyed: event => {
console.log('Stream destroyed!', event);
},
sessionConnected: event => {
console.log('Connected to the session!');
},
sessionDisconnected: event => {
console.log('Disconnected from the session!');
}
};
this.subscriberEventHandlers = {
streamCreated: event => {
console.log('Stream created!', event);
},
streamDestroyed: event => {
console.log('Stream destroyed!', event);
},
sessionConnected: event => {
this.setState({
isConnected: true,
})
}
};
}
render() {
return (
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token" eventHandlers={this.sesssionEventHandlers}>
<OTPublisher eventHandlers={this.publisherEventHandlers}/>
<OTSubscriber eventHandlers={this.suscriberEventHandlers} />
</OTSession>
);
}
}
```
The following sections define the structure of different event objects.
## ArchiveEvent
The OTSession object dispatches `archiveStarted` and `archiveStopped` events
when an [archive](https://tokbox.com/developer/guides/archiving) starts and stops
for a session. The event object has the following properties:
```javascript
archive = {
archiveId: string, // The archive ID.
name: string, // The archive name.
sessionId: string, // The session ID.
};
```
## AudioNetworkStats
To get audio data for a subscriber, register an event listener for the `audioNetworkStats` event.
The event object has the following properties:
```javascript
event = {
audioBytesReceived: number,
audioPacketsLost: number,
audioPacketsReceived: number,
timeStamp: number,
};
```
## SubscriberCaptionEvent
To get captions for a subscriber, register an event listener for the `captionReceived` event.
The event object has the following properties:
```javascript
event = {
text: string,
isFinal: boolean,
};
```
## ConnectionCreatedEvent
You can find the structure of the object below:
```javascript
event = {
sessionId: string;
connection = {
connectionId: string
creationTime: string,
data: string,
}
}
```
## ConnectionDestroyedEvent
You can find the structure of the object below:
```javascript
event = {
sessionId: string;
connection = {
connectionId: string
creationTime: string,
data: string,
}
}
```
## ErrorEvent
You can find the structure of the object below:
```javascript
event = {
code: string,
message: string,
};
```
## MuteForcedEvent
```javascript
event = {
active: boolean;
}
```
## PublisherVideoNetworkStatsEvent
To get video data for a publisher, register an event listener for the OTPublisher
`videoNetworkStats` event. The object has the following structure:
```javascript
event = [
{
connectionId: string,
subscriberId: string,
videoPacketsLost: number,
videoBytesSent: number,
videoPacketsSent: number,
timestamp: number,
}
];
```
Note that this event object is an array of objects. See the docs for
the OTPublisher `videoNetworkStats` event.
## PublisherAudioNetworkStatsEvent
To get audio data for a publisher, register an event listener for the OTPublisher
`audioNetworkStats` event. The object has the following structure:
```javascript
event = [
{
connectionId: string,
subscriberId: string,
audioPacketsLost: number,
audioPacketsSent: number,
audioBytesSent: number,
timestamp: number,
}
];
```
Note that this event object is an array of objects. See the docs for
the OTPublisher `audioNetworkStats` event.
## RtcStatsReportEvent
You can find the structure of the object below:
```javascript
event = {
connectionId: string,
jsonArrayOfReports: string,
};
```
## SessionConnectEvent
```javascript
event = {
sessionId: string;
connection: {
connectionId: string,
creationTime: string,
data: string,
},
}
```
## SessionDisconnectEvent
```javascript
event = {
sessionId: string;
}
```
## SignalEvent
The OTSession object dispatches a `signal` event when a signal is received.
See the [signaling developer guide](https://tokbox.com/developer/guides/signaling/).
The event object has the following properties:
```javascript
event = {
type: string, // Either 'signal' or 'signal:type'.
data: string, // The data.
connectionId: string, // The connection ID of the client that sent the signal.
};
```
## StreamCreatedEvent
You can find the structure of the object below:
```javascript
stream = {
streamId: string;
name: string;
connectionId: string, // This will be removed after v0.11.0 because it's exposed via the connection object
connection: {
connectionId: string,
creationTime: string,
data: string,
},
hasAudio: boolean,
hasVideo: boolean,
sessionId: string,
creationTime: number,
height: number,
width: number,
videoType: string, // 'camera' or 'screen'
};
```
## StreamDestroyedEvent
```javascript
event = {
streamId: string;
name: string;
connectionId: string;
connection: {
connectionId: string,
creationTime: string,
data: string,
},
hasAudio: boolean,
hasVideo: boolean,
sessionId: string,
creationTime: number,
height: number,
width: number,
videoType: string, // 'camera' or 'screen'
};
```
## StreamPropertyChangedEvent
```javascript
event = {
stream: {
streamId: string,
name: string,
connectionId: string, // This will be removed after v0.11.0 because it's exposed via the connection object
connection: {
connectionId: string,
creationTime: number,
data: string,
},
hasAudio: boolean,
hasVideo: boolean,
sessionId: string,
creationTime: number,
height: number,
width: number,
videoType: string, // 'camera' or 'screen'
},
oldValue: any,
newValue: any,
changedProperty: string,
};
```
## SubscriberAudioLevelEvent
```javascript
event = {
audioLevel: number;
stream: {
streamId: string,
name: string,
connectionId: string, // This will be removed after v0.11.0 because it's exposed via the connection object
connection: {
connectionId: string,
creationTime: number,
data: string,
},
hasAudio: boolean,
hasVideo: boolean,
sessionId: string,
creationTime: number,
height: number,
width: number,
videoType: string, // 'camera' or 'screen'
},
};
```
## VideoNetworkStatsEvent
You can find the structure of the object below:
```javascript
event = {
videoPacketsLost: number,
videoBytesReceived: number,
videoPacketsReceived: number,
timestamp: number
};
```
## SubscriberRtcStatsReportEvent
```javascript
event = {
stream: {
streamId: string;
name: string;
connectionId: string;
connection: {
connectionId: string,
creationTime: string,
data: string,
},
hasAudio: boolean,
hasVideo: boolean,
sessionId: string,
creationTime: number,
height: number,
width: number,
videoType: string, // 'camera' or 'screen'
},
jsonArrayOfReports: string
};
```
## PublisherRtcStatsReportEvent
```javascript
event = [
connectionId: string,
jsonArrayOfReports: string
];
```
This documentation is now maintained at https://tokbox.com/developer/sdks/react-native/reference/EventData.html.
### OpenTok React Native docs
The OpenTok React Native SDK documentation is now maitained at https://tokbox.com/developer/sdks/react-native.
## Basic sample
This simplest use of these opentok-react-native componenents:
See https://tokbox.com/developer/sdks/react-native#basic-sample
```
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token">
<OTPublisher style={{ width: 100, height: 100 }}/>
<OTSubscriber style={{ width: 100, height: 100 }} />
</OTSession>
```
Replace `your-api-key`, `your-session-id`, and `your-session-token` with your
[OpenTok project API key](https://tokbox.com/account/),
an [OpenTok session ID](https://tokbox.com/developer/guides/create-session/),
and a [token for the session](https://tokbox.com/developer/guides/create-token/).
Note that you add the OTPublisher and OTSubscriber components and children of
the OTSession component. Use the `style` and `className` properties to use CSS
to adjust publisher and subscriber layout.
## Reference docs
The OpenTok React Native library includes the following components:
See https://tokbox.com/developer/sdks/react-native/reference/
* [OTPublisher](./OTPublisher.md) -- Represents an OpenTok publisher.
* [OTSession](./OTSession.md) -- Represents an OpenTok session.
* [OTSubscriber](./OTSubscriber.md) -- Represents an OpenTok subscriber.
It also includes an [OT](./OT.md) object that includes methods for logging.
For details on events dispatched by the OTPublisher, OTSession, and OTSubscriber
components, see [Event data](./EventData.md).
## Unsupported features
The OpenTok React Native library provides a React interface for using the
OpenTok Android and iOS client SDKs. The following advanced features of the OpenTok Android and
iOS client SDKs are *unsupported* in the OpenTok React Native library:
See https://tokbox.com/developer/sdks/react-native#unsupported-features.
* **Custom audio drivers** -- An application using OpenTok React Native use the device microphone
to capture audio to transmit to a published stream. And it uses the device speakers (or headphones)
to play back audio from subscribed streams. However, you can set the `enableStereoOutput` property
of the OTSession object to enable stereo output.
* **Custom video capturers** -- (BaseVideoCapturer) -- The OpenTok React Native OTPublisher uses
the standard video capturer that uses video directly from the device's camera. However, you can set
the `videoSource` property of an OTPublisher component to "screen" to publish a screen-sharing stream.
* **Custom video renderers** -- The OTSubscriber and OTPublisher components implement a standard
video renderer that renders streams and provides user interface controls for displaying
the stream name and muting the microphone or camera. Publishers and subscribers use
`mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL)`
* **iOS delegate callback queue** -- For iOS, you cannot assign the delegate callback queue (the
GCD queue). See the docs for the
[OTSession.apiQueue property](https://tokbox.com/developer/sdks/ios/reference/Classes/OTSession.html#//api/name/apiQueue)
in the OpenTok iOS SDK.
To build Android and iOS apps that use these features, use the
[OpenTok Android SDK](https://tokbox.com/developer/sdks/android/)
and the [OpenTok iOS SDK](https://tokbox.com/developer/sdks/ios/).
## More information

@@ -66,0 +18,0 @@

@@ -1,35 +0,1 @@

# OT
This library uses React Native bridging to expose native (iOS & Android) methods via a native module.
`OT` is a custom native module that includes methods for logging.
Please keep in mind that `OT` is not the same as `OT` in the JS SDK, the `OT` in this library refers to the iOS and Android `OTSessionManager` class.
## To enable logs:
By default, the native logs are disabled. Please using the following method to enable native logs.
```javascript
OT.enableLogs(true);
```
## To disable logs:
```javascript
OT.enableLogs(false);
```
## To get supported codecs for the client device
```javascript
const supportedCodecs = await OT.getSupportedCodecs();
console.log(supportedCodecs);
```
The `OT.getSupportedCodecs()` method returns a promise that resolves with an object defining the supported codecs on the device. This object includes two properties:
* `videoDecoderCodecs` -- An array of values, defining the video codecs for decoding that are supported on the device. Supported values are "VP8" and "H.264".
* `videoEncoderCodecs` -- An array of values, defining the video codecs for encoding that are supported on the device.. Supported values are "VP8" and "H.264".
See the OpenTok [video codecs](https://tokbox.com/developer/guides/codecs/) documentattion.
This documentation is now maintained at https://tokbox.com/developer/sdks/react-native/reference/OT.html.

@@ -1,216 +0,1 @@

# OTPublisher component
[Properties](#properties)
[properties object](#properties-object)
[Events](#events)
The `OTPublisher` component will initialize a publisher and publish to the specified session upon mounting. To destroy the publisher, unmount the `OTPublisher` component. Please keep in mind that the publisher view is not removed unless you specifically unmount the `OTPublisher` component.
Add the OTPublisher component as a child of the OTSession component:
```js
class App extends Component {
constructor(props) {
super(props);
this.publisherProperties = {
publishAudio: true,
publishVideo: false,
publishCaptions: true,
cameraPosition: 'front'
};
this.publisherEventHandlers = {
streamCreated: event => {
console.log('Publisher stream created!', event);
},
streamDestroyed: event => {
console.log('Publisher stream destroyed!', event);
}
};
}
render() {
return (
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token">
<OTPublisher
properties={this.publisherProperties}
eventHandlers={this.publisherEventHandlers}
style={{ height: 100, width: 100 }}
/>
</OTSession>
);
}
}
```
## Properties
The OTPublisher component has the following properties, each of which is optional:
* `sessionId` (String) -- The OpenTok session ID. This is auto-populated by wrapping
`OTPublisher` with `OTSession`, so you generally do not need to set this property for the OTPublisher.
* `properties` (Object) -- Options for the publisher instance. See the following section,
[properties object](#properties-object). The `properties` object is used for initial set up
of the Publisher. The `OTPublisher` object watches for changes on a few keys of the `properties` object,
and makes the necessary changes. Currently these are:
* cameraPosition -- Sets the camera to 'front' or 'back'.
* publishAudio -- Toggles audio on (`true`) or off `false`.
* publishVideo -- Toggles video on (`true`) or off `false`.
* publishCaptions -- Toggles captions on (`true`) or off `false` for the published stream.
* `eventHandlers` (Object) -- An object containing key-value pairs of event names and
callback functions for event handlers. See [Events](#events).
## Methods
**getRtcStatsReport()** Gets the RTC stats report for the publisher. This is an asynchronous operation.
The OTPublisher object dispatches an `rtcStatsReport` event when RTC statistics for the publisher are available.
## properties object
The `properties` object passed into the OTPublisher object has the following properties:
**audioBitrate** (Number) -- The desired bitrate for the published audio, in bits per second. The supported range of values is 6,000 - 510,000. (Invalid values are ignored.) Set this value to enable high-quality audio (or to reduce bandwidth usage with lower-quality audio).
The following are recommended settings:
* 8,000 - 12,000 for narrowband (NB) speech
* 16,000 - 20,000 for wideband (WB) speech
* 28,000 - 40,000 for full-band (FB) speech
* 48,000 - 64,000 for full-band (FB) music
* 64,000 - 128,000 for full-band (FB) stereo music
The default value is 40,000.
**audioFallbackEnabled** (Boolean) —- Whether the stream will use the audio-fallback feature
(`true`) or not (`false`). The audio-fallback feature is available in sessions that use the
OpenTok Media Router. With the audio-fallback feature enabled (the default), when the OpenTok Media
Router determines that a stream's quality has degraded significantly for a specific subscriber,
it disables the video in that subscriber in order to preserve audio quality. For streams that use
a camera as a video source, the default setting is true (the audio-fallback feature is enabled).
The default setting is false (the audio-fallback feature is disabled) for screen-sharing streams,
which have the `videoSource` property set to "screen" in OTPublisher component. For more information,
see the Subscriber videoDisabled event and the OpenTok Media Router and media modes.
**audioTrack** (Boolean) -- If this property is set to false, the audio subsystem will not be initialized for the publisher, and setting the `publishAudio` property will have no effect. If your application does not require the use of audio, it is recommended to set this property rather than use the publishAudio property, which only temporarily disables the audio track.
* **cameraPosition** (String) -- The preferred camera position. When setting this property, if the change is possible, the publisher will use the camera with the specified position. Valid inputs are 'front' (the default) and 'back'.
* **enableDtx** (Boolean) - Whether to enable [Opus DTX](https://datatracker.ietf.org/doc/html/rfc7587#section-3.1.3). The default value is `false`. Setting this to true can reduce bandwidth usage in streams that have long periods of silence.
* **frameRate** (Number) - The desired frame rate, in frames per second, of the video. Valid values are 30, 15, 7, and 1. The published stream will use the closest value supported on the publishing client. The frame rate can differ slightly from the value you set, depending on the device of the client. And the video will only use the desired frame rate if the client configuration supports it.
* **name** (String) -- A string that will be associated with this publisher’s stream. This string is displayed at the bottom of publisher videos and at the bottom of subscriber videos associated with the published stream. If you do not specify a value, the name is set to the device name.
* **publishAudio** (Boolean) -- Whether to publish audio. The default is `true`.
* **publishVideo** (Boolean) -- Whether to publish video. The default is `true`.
* **publishCaptions** (Boolean) — Whether to publish captions. Note that the session must have captions enabled (using the Video API REST method or server SDK) and the publisher must be publishing audio. For more information, see the [Live Captions developer guide](https://tokbox.com/developer/guides/live-captions).
* **scalableScreenshare** (Boolean) -- Whether to allow use of
{scalable video}(https://tokbox.com/developer/guides/scalable-video/) for a screen-sharing publisher
(true) or not (false, the default). This only applies to a publisher that has the `videoSource` set
to "screen".
* **resolution** (String) - The desired resolution of the video. The format of the string is "widthxheight", where the width and height are represented in pixels. Valid values are "1920x1080", "1280x720", "640x480", and "352x288". The published video will only use the desired resolution if the client configuration supports it. Some devices and clients do not support each of these resolution settings.
* **videoContentHint** (String) -- Sets the content hint of the video track of the publisher's stream. You can set this to one of the following values: "", "motion", "details" or "text". For additional information, see the [documentation](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher) for the `videoContentHint` option of the
`OT.initPublisher()` method of the OpenTok.js SDK.
* **videoTrack** (Boolean) -- If this property is set to false, the video subsystem will not be initialized for the publisher, and setting the publishVideo property will have no effect. If your application does not require the use of video, it is recommended to set this property rather than use the publishVideo property, which only temporarily disables the video track.
* **videoSource** (String) -- To publish a screen-sharing stream, set this property to "screen". If you do not specify a value, this will default to "camera".
## Events
* **audioLevel** (Number) -- The audio level, from 0 to 1.0. Adjust this value logarithmically for use in adjusting a user interface element, such as a volume meter. Use a moving average to smooth the data.
* **audioNetworkStats** (Object) — Sent periodically to report audio statistics for the publisher.
A [PublisherAudioNetworkStatsEvent](./EventData.md#PublisherAudioNetworkStatsEvent) object is passed into the event handler.
* **error** (Object) -- Sent if the publisher encounters an error. After this message is sent, the publisher can be considered fully detached from a session and may be released.
* **muteForced** -- Sent when a moderator has forced this client to mute audio.
* **otrnError** (Object) -- Sent if there is an error with the communication between the native publisher instance and the JS component.
* **rtcStatsReport** (Object) -- Sent when RTC stats reports are available for the publisher,
in response to calling the `OTPublisher.getRtcStatsReport()` method. A
[PublisherRtcStatsReportEvent](./EventData.md#publisherRtcStatsReportEvent) object is passed into
the event handler. This event has an array of
objects. For a routed session (a seesion that uses the
[OpenTok Media Router](https://tokbox.com/developer/guides/create-session/#media-mode)),
this array includes one object, defining the statistics for the single video media stream that is sent
to the OpenTok Media Router. In a relayed session, the array includes an object for each subscriber
to the published stream. Each object includes two properties:
* `connectionId` -- For a relayed session (in which a publisher sends individual media streams
to each subscriber), this is the unique ID of the client’s connection.
* `jsonArrayOfReports` -- A JSON array of RTC stats reports for the media stream. The structure
of the JSON array is similar to the format of the RtcStatsReport object implemented in web browsers
(see the [Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport)).
Also see [this W3C documentation](https://w3c.github.io/webrtc-stats/).
* **streamCreated** (Object) -- Sent when the publisher starts streaming.
A [streamingEvent](./EventData.md#streamingEvent) object is passed into the event handler.
* **streamDestroyed** (Object) -- Sent when the publisher stops streaming.
A [streamingEvent](./EventData.md#streamingEvent) object is passed into the event handler.
**setVideoTransformers()** -- Sets video transformers for the publisher. This method has one parameter -- and array of objects defining each transformer to apply to the publisher's stream. A transformer object has two properties:
* `name` (String) -- Either 'BackgroundBlur' (for a background blur filter) or 'BackgroundImageReplacement' (for a background image replacement filter). Android only supports the 'BackgroundBlur' transformer (and it is a beta feature in Android).
* `properties` (String) -- A JSON string with the properties of the Vonage video transformer.
For a background blur transformer, the format of the JSON is:
```
`{
"radius" :"None"
}`
```
Valid values for the radius property are "None", "High", and "Low".
For a custom background blur transformer, the format of the JSON is:
```
`{
"radius": "Custom",
"custom_radius": "value"
}
```
`custom_radius` can be any positive integer.
For a background replacement transformer (supported on iOS only), the format of the JSON is:
```
`{
"image_file_path": "path/to/image"
}`
```
Where `image_file_path` is the absolute file path of a local image to use as virtual background. Supported image formats are PNG and JPEG.
*Important:* Media transformations, such as background blur and background replacement, are resource-intensive and require devices with high processing power. It is recommended to only use these transformations on supported devices. See the following documentation:
* [For iOS](https://tokbox.com/developer/guides/vonage-media-processor/ios/#client-requirements)
* [For Android](https://tokbox.com/developer/guides/vonage-media-processor/android/#client-requirements)
For more information on transformers, see [Using the Vonage Media Processor library](https://tokbox.com/developer/guides/vonage-media-processor/)
**videoNetworkStats** (Object) -- Sent periodically to report audio statistics for the publisher.
A [PublisherVideoNetworkStatsEvent](./EventData.md#PublisherVideoNetworkStatsEvent) object is passed into the event handler.
## Methods
This documentation is now maintained at https://tokbox.com/developer/sdks/react-native/reference/OTPublisher.html.

@@ -1,267 +0,1 @@

# OTSession Component
The `OTSession` component manages the connection to an OpenTok Session. It passes the session ID to the
`sessionId` property to its child components. To disconnect the session, unmount the `OTSession` component.
To publish and subscribe, you must nest `OTPublisher` and `OTSubscriber` inside `OTSession`:
```javascript
class App extends Component {
constructor(props) {
super(props);
this.state = {
isConnected: false,
};
this.otSessionRef = React.createRef();
this.sessionEventHandlers = {
streamCreated: event => {
console.log('Stream created!', event);
},
streamDestroyed: event => {
console.log('Stream destroyed!', event);
},
sessionConnected: event => {
this.setState({
isConnected: true,
})
}
};
}
sendSignal = () => {
if (this.state.isConnected) {
this.otSessionRef.current.signal({
data: 'hello',
to: '6d26ca65-24c9-45df-b827-424e9952dece', // optional - connection ID of client to recieve the signal
type: 'greeting', // optional
})
}
}
render() {
return (
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token" eventHandlers={this.sesssionEventHandlers} ref={this.otSessionRef}>
<OTPublisher style={{ width: 100, height: 100 }}/>
<OTSubscriber style={{ width: 100, height: 100 }} />
</OTSession>
);
}
}
```
You can set the session options using the `options` prop:
```javascript
class App extends Component {
constructor(props) {
super(props);
this.sessionOptions = {
connectionEventsSuppressed: true, // default is false
androidZOrder: '', // Android only - valid options are 'mediaOverlay' or 'onTop'
androidOnTop: '', // Android only - valid options are 'publisher' or 'subscriber'
useTextureViews: true, // Android only - default is false
ipWhitelist: false, // https://tokbox.com/developer/sdks/js/reference/OT.html#initSession - ipWhitelist
enableStereoOutput: true // Enable stereo output, default is false
iceConfig:{
transportPolicy: 'all', // Valid options are 'all' or 'relay'. Default is 'all'
includeServers: 'all', // Valid options are 'all' or 'custom'. Default is 'all'
customServers: [
{
urls: [
'turn:123.124.125.126:3478?transport=udp',
'turn:123.124.125.126:3478?transport=tcp'
],
username: 'webrtc',
credential: 'foO0Bar1'
},
],
},
};
}
render() {
return (
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token" options={this.sessionOptions}>
<OTPublisher style={{ width: 100, height: 100 }}/>
<OTSubscriber style={{ width: 100, height: 100 }} />
</OTSession>
);
}
}
```
Please note that all session options are optional. See [Session options](#session-options).
## Properties
The OTSession object has the following properties:
**apiKey** (String, required) -- The OpenTok project API key.
**sessionId** (String, required) -- The OpenTok session ID.
**token** (String, required) -- The OpenTok token for the client.
**options** (Object, optional) -- Used to define session options. See [Session options](session-options).
**signal** (Object, optional) -- Used to send a signal to the session
**eventHandlers** (Object, optional) -- An object containing key-value pairs of event names and
callback functions for event handlers. See [Events](#events).
## Session options
**androidZOrder** (String) -- Set to "mediaOverlay" or "onTop". Android only.
**androidOnTop** (String) -- Set to "publisher" | "subscriber". Android only.
**connectionEventsSuppressed** (Boolean) -- Whether to prevent `connectionCreated` and
`connectionDestroyed` event from being dispatched. You may want to suppress these events in
large sessions, such as those used for
[live interactive video broadcasts](https://tokbox.com/developer/guides/broadcast/live-interactive-video/#suppressing-connection-events).
The default value is false.
**enableStereoOutput** (Boolean) -- Whether to enable stereo output. The default value is false.
**iceConfig** (Object) -- Settings for using the
[configurable TURN feature](https://tokbox.com/developer/guides/configurable-turn-servers/).
This feature is available as an [add-on feature](https://tokbox.com/pricing/plans).
This object has the following properties:
* `includeServers` (String) Whether the client should use your TURN servers exclusively ('custom')
or use them in addition to the OpenTok TURN servers ('all').
* `transportPolicy` 'all' | 'relay';
* `customServers` (Array) -- An array of objects defining custom TURN servers to use.
Each object has the following properties:
- `urls` (Array of strings) -- The URLs of the TURN server.
- `username` (String, optional) -- The user name.
- `credential`: (String, optional) -- The credential for the TURN server.
**ipWhitelist** (Boolean) -- Whether to use the
[allowed IP list](https://tokbox.com/developer/guides/ip-addresses/) feature.
This is available as an [add-on feature](https://www.vonage.com/communications-apis/video/pricing//plans)
The default value is false.
**isCamera2Capable** (Boolean) -- Deprecated and ignored. Android only.
**proxyUrl** (String, optional) -- The proxy URL to use for the session.
This is an [add-on feature](https://www.vonage.com/communications-apis/video/pricing//plans)
feature. See the [OpenTok IP Proxy](https://tokbox.com/developer/guides/ip-proxy/) developer guide.
**useTextureViews** (Boolean) -- Set to `true` to use texture views. The default is `false`. Android only.
## Methods
**disableForceMute()** Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.
After you call to the Session.forceMuteAll() method (or a moderator in another client makes a call to mute all streams), any streams published after the moderation call are published with audio muted. Call the `OTSession.disableForceMute()` method to remove the mute state of a session (so that new published streams are not automatically muted).
Check the `capabilities.canForceMute` property of the object returned by `OTSession.getCapbabilities()` to see if you can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the [Token Creation documentation](https://tokbox.com/developer/guides/create-token/)).
**getSessionInfo()** Returns an object with the following properties:
* `sessionId` (String) -- The session ID.
* `connection` (Object) -- An object defining the local client's connection to the session.
This includes the following properties:
- `connectionId` (String) -- The local client's connection ID.
- `creationTime`(String) -- The time the connection was created.
- `data` (String) -- The [connection data](https://tokbox.com/developer/guides/create-token/#connection-data)
for the local client.
***getCapabilities()*** Indicates whether the client can publish and subscribe to streams in the session, , based on the roles assigned to the [client token](https://tokbox.com/developer/guides/create-token) used to connect to the session. The method returns a Promise that resolves with an object with the following properties:
* `canForceMute` (Boolean) -- Whether the client can force mute streams in the session or disable the active mute state in a session (`true`) or not (`false`).
* `canPublish` (Boolean) -- Whether the client can publish streams to the session (`true`) or not (`false`).
* `canSubscribe` (Boolean) -- Whether the client can subscribe to streams in the session (`true`) or not (`false`).
The promise is rejected if you have not connected to the session and the `connectionCreated` event has been dispatched.
For more information, see the
[OpenTok token documentation](https://tokbox.com/developer/guides/create-token).
**reportIssue()** Lets you report that your app experienced an issue (to view with
[Inspector](http://tokbox.com/developer/tools/Inspector) or to discuss with the Vonage API
support team.) The method returns a Promise that resolves with a string, the issue ID.
**forceMuteAll()** Forces all publishers in the session (except for those publishing excluded streams) to mute audio.
This method has one optional parameter -- `excludedStreams`, and array of stream IDs. A stream published by the moderator calling the forceMuteAll() method is muted along with other streams in the session, unless you add the moderator's stream (or streams) to the `excludedStreams` array. If you leave out the `excludedStreams` parameter, all streams in the session (including those of the moderator) will stop publishing audio. Also, any streams that are published after the call to the `forceMuteAll()` method are published with audio muted. You can remove the mute state of a session by calling the `OTSession.disableForceMute()` method.
After you call the `Session.disableForceMute()` method, new streams published to the session will no longer have audio muted.
Calling this method causes the Publisher objects in the clients publishing the streams to dispatch muteForced events. Also, the Session object in each client connected to the session dispatches the muteForced event (with the active property of the event object set to true).
Check the `capabilities.canForceMute` property of the object returned by `OTSession.getCapbabilities()` to see if you can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the [Token Creation documentation](https://tokbox.com/developer/guides/create-token/)).
**forceMuteStream()** Forces a the publisher of a specified stream to mute its audio. Pass the stream ID
of the stream in as a parameter.
Check the `capabilities.canForceMute` property of the object returned by `OTSession.getCapbabilities()` to see if you can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the [Token Creation documentation](https://tokbox.com/developer/guides/create-token/)).
**signal()** Sends a signal to clients connected to the session. The method has one parameter,
an object that includes the following properties, each of which is optional
(although you usually want to set the `data` property):
* `connectionId` (String) -- The connection ID of the client to send the signal to. If this
is omitted, the signal is sent to all clients connected to the session.
* `type` (string) -- The signal type.
* `data` (string) -- The signal data.
For more information, see the
[OpenTok signaling developer guide](https://tokbox.com/developer/guides/signaling/)
## Events
**archiveStarted** (Object) — Sent when an archive recording of a session starts. If you connect to a session in which recording is already in progress, this message is sent when you connect.
An [ArchiveEvent](./EventData.md#ArchiveEvent) object is passed into the event handler.
**archiveStopped** (String) — Sent when an archive recording of a session stops.
An [ArchiveEvent](./EventData.md#ArchiveEvent) object is passed into the event handler.
**connectionCreated** (Object) — Sent when another client connects to the session. The connection object represents the client’s connection.
A [ConnectionCreatedEvent](./EventData.md#ConnectionCreatedEvent) object is passed into the event handler.
**connectionDestroyed** -- Sent when another client disconnects from the session. The connection object represents the connection that the client had to the session.
A [ConnectionDestroyedEvent](./EventData.md#ConnectionDestroyedEvent) object is passed into the event handler.
**error** (Object) — Sent if the attempt to connect to the session fails or if the connection to the session drops due to an error after a successful connection.
An [ErrorEvent](./EventData.md#ErrorEvent) object is passed into the event handler.
* **muteForced** -- Sent when a moderator has forced clients publishing streams to the session to mute audio (the `active` property of this `MuteForcedEvent` object is set to `true`), or a moderator has disabled the mute audio state in the session (the active property of this `MuteForcedEvent` object is set to `false`). An [ErrorEvent](./EventData.md#MuteForcedEvent) object is passed into the event handler.
**otrnError** -- Sent if there is an error with the communication between the native session instance and the JS component.
**sessionConnected** -- Sent when the client connects to the session.
A [SessionConnectEvent](./EventData.md#SessionConnectEvent) object is passed into the event handler.
**sessionDisconnected** -- Sent when the client disconnects from the session.
A [SessionDisconnectEvent](./EventData.md#SessionDisconnectEvent) object is passed into the event handler.
**sessionReconnected** -- Sent when the local client has reconnected to the OpenTok session after its network connection was lost temporarily.
**sessionReconnecting** -- Sent when the local client has lost its connection to an OpenTok session and is trying to reconnect. This results from a loss in network connectivity. If the client can reconnect to the session, the `sessionReconnected` message is sent. Otherwise, if the client cannot reconnect, the `sessionDisconnected` message is sent.
**signal** -- Sent when a signal is received in the session.
A [SignalEvent](./EventData.md#SignalEvent) object is passed into the event handler.
**streamCreated** -- Sent when a new stream is created in this session.
A [StreamCreatedEvent](./EventData.md#StreamCreatedEvent) object is passed into the event handler.
**streamDestroyed** -- Sent when a stream is no longer published to the session.
A [StreamDestroyedEvent](./EventData.md#StreamDestroyedEvent) object is passed into the event handler.
**streamPropertyChanged** -- Sent when a stream has started or stopped publishing audio or video or if the video dimensions of the stream have changed. A [StreamPropertyChangedEvent](./EventData.md#StreamPropertyChangedEvent) object
is passed into the event handler.
This documentation is now maintained at https://tokbox.com/developer/sdks/react-native/reference/OTSession.html.

@@ -1,172 +0,1 @@

### OTSubscriber Component
| Prop | Type | Required | Description |
| --- | --- | --- | --- |
| sessionId | String | No | OpenTok Session Id. This is auto populated by wrapping `OTSubscriber` with `OTSession`
| streamId | String| No | OpenTok Subscriber streamId. This is auto populated inside the `OTSubscriber` component when `streamCreated` event is fired from the native instance
| properties | Object | No | Properties passed into the native subscriber instance
| streamProperties | Object | No | Used to update individual subscriber instance properties
| eventHandlers | Object&lt;Function&gt; | No | Event handlers passed into the native subscriber instance
| subscribeToSelf | Boolean | No | If set to true, the subscriber can subscribe to it's own publisher stream (default: false)
| children | Function | No | A render prop allowing individual rendering of each stream
## Properties
* **subscribeToAudio** (Boolean) — Whether to subscribe to audio.
* **subscribeToVideo** (Boolean) — Whether to subscribe video.
* **subscribeToCaptions** (Boolean) — Whether to subscribe to captions. Note that the session must have captions enabled (using the Video API REST method or server SDK) and the publisher must be publishing captions. For more information, see the [Live Captions developer guide](https://tokbox.com/developer/guides/live-captions).
* **preferredResolution** (String) — Sets the preferred resolution of the subscriber's video. The format of the string is "widthxheight", where the width and height are represented in pixels. Valid values are "1280x720", "640x480", and "352x288".
* **preferredFrameRate** (Number) — Set this to the desired frame rate (in frames per second). Set this to null to remove the preferred frame rate, and the client will use the highest frame rate available. Valid values are 30, 15, 7, and 1.
* **audioVolume** (Number) — Sets the audio volume, between 0 and 100, of the subscriber. If the value is not in this range, it will be clamped to it.
The `OTSubscriber` component will subscribe to a specified stream from a specified session upon mounting. The `OTSubscriber` component will stop subscribing and unsubscribing when it's unmounting.
## Methods
**getRtcStatsReport(streamId)** Gets the RTC stats report for the subscriber to the stream with the
specified stream ID. This is an asynchronous operation. The OTSubscriber object dispatches an
`rtcStatsReport` event when RTC statistics for the subscriber are available.
## Events
* **audioLevel** (SubscriberAudioLevelEvent) — Sent on a regular interval with the recent representative audio level.
See [SubscriberAudioLevelEvent](./EventData.md#SubscriberAudioLevelEvent)
* **audioNetworkStats** (Object) — Sent periodically to report audio statistics for the subscriber.
A [AudioNetworkStats](./EventData.md#AudioNetworkStats) object is passed into the event handler.
* **captionReceived** (Object) — Sent when a caption is received for the subscriber.
A [CaptionReceived](./EventData.md#SubscriberCaptionEvent) object is passed into the event handler.
* **connected** () — Sent when the subscriber successfully connects to the stream. The event object
includes a `streamId` property, identifying the stream.
* **disconnected** () — Called when the subscriber’s stream has been interrupted.
* **error** (Object) — Sent if the subscriber fails to connect to its stream.
* **otrnError** (Object) — Sent if there is an error with the communication between the native subscriber instance and the JS component.
* **rtcStatsReport** (Object) -- Sent when RTC stats reports are available for the subscriber,
in response to calling the `OTSubscriber.getRtcStatsReport()` method. A
[SubscriberRtcStatsReportEvent](./EventData.md#subscriberRtcStatsReportEvent) object is passed
into the event handler. This event object has the following properties:
* `jsonArrayOfReports` property, which is a JSON array of RTCStatsReport for the media stream.
The structure of the JSON array is similar to the format of the RtcStatsReport object implemented
in web browsers (see the
[Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport)).
Also see [this W3C documentation](https://w3c.github.io/webrtc-stats/).
* `stream` -- An object representing the subscriber's stream. This object includes a `streamId`
property, identifying the stream.
* **videoDataReceived** () - Sent when a frame of video has been decoded. Although the subscriber will connect in a relatively short time, video can take more time to synchronize. This message is sent after the `connected` message is sent.
* **videoDisabled** (String) — This message is sent when the subscriber stops receiving video. Check the reason parameter for the reason why the video stopped.
* **videoDisableWarning** () - 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.
* **videoDisableWarningLifted** () — 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).
* **videoEnabled** (String) - 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).
* **videoNetworkStats** (Object) — Sent periodically to report video statistics for the subscriber.
```js
class App extends Component {
constructor(props) {
super(props);
this.state = {
streamProperties: {},
};
this.subscriberProperties = {
subscribeToAudio: false,
subscribeToVideo: true,
subscribeToCaptions: false,
};
this.sessionEventHandlers = {
streamCreated: event => {
const streamProperties = {...this.state.streamProperties, [event.streamId]: {
subscribeToAudio: true,
subscribeToVideo: false,
style: {
width: 400,
height: 300,
},
}};
this.setState({ streamProperties });
},
};
this.subscriberEventHandlers = {
error: (error) => {
console.log(`There was an error with the subscriber: ${error}`);
},
audioNetworkStats: event => {
console.log('audioNetworkStats', event);
// { timeStamp: 1643203644833, audioPacketsLost: 0, audioPacketsReceived: 64, audioBytesReceived: 5574 }
},
videoNetworkStats: event => {
console.log('videoNetworkStats', event);
// videoBytesReceived: 706635, videoPacketsLost: 0, timeStamp: 1643203644724, videoPacketsReceived: 656 }
},
};
}
render() {
return (
<OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token" eventHandlers={this.sessionEventHandlers}>
<OTSubscriber
properties={this.subscriberProperties}
eventHandlers={this.subscriberEventHandlers}
style={{ height: 100, width: 100 }}
streamProperties={this.state.streamProperties}
/>
</OTSession>
);
}
}
```
## Custom rendering of streams
`OTSubscriber` accepts a render prop function that enables custom rendering of individual streams, e.g. to allow touch interaction or provide individual styling for each `OTSubscriberView`.
An array of stream IDs is passed to the render prop function as its only argument.
For example, to display the stream, pass its ID as `streamId` prop to the `OTSubscriberView` component:
```js
import { OTSubscriberView } from 'opentok-react-native'
// Render method
<OTSubscriber>
{this.renderSubscribers}
</OTSubscriber>
// Render prop function
renderSubscribers = (subscribers) => {
return subscribers.map((streamId) => (
<TouchableOpacity
onPress={() => this.handleStreamPress(streamId)}
key={streamId}
style={subscriberWrapperStyle}
>
<OTSubscriberView streamId={streamId} style={subscriberStyle} />
</TouchableOpacity>
));
};
```
Note: `streamProperties` prop is ignored if a children prop is passed.
This documentation is now maintained at https://tokbox.com/developer/sdks/react-native/reference/OTSubscriber.html.
{
"name": "opentok-react-native",
"version": "2.26.1",
"version": "2.27.0",
"description": "React Native components for OpenTok iOS and Android SDKs",

@@ -29,3 +29,3 @@ "main": "src/index.js",

"dependencies": {
"axios": "^0.21.1",
"axios": "^1.6.5",
"deprecated-react-native-prop-types": "^2.3.0",

@@ -32,0 +32,0 @@ "flow-bin": "^0.180.0",

@@ -47,3 +47,3 @@ # opentok-react-native

# Pods for <YourProject>
pod 'OTXCFramework', '2.26.1'
pod 'OTXCFramework', '2.27.0'
end

@@ -152,3 +152,3 @@

See the [docs](/docs/index.md).
See the [docs](https://tokbox.com/developer/sdks/react-native/reference).

@@ -155,0 +155,0 @@ ## Samples

@@ -72,3 +72,3 @@ import { Platform } from 'react-native';

method: 'post',
data: JSON.stringify(body),
data: body,
})

@@ -75,0 +75,0 @@ .then(() => {

@@ -38,2 +38,27 @@ import { sanitizeBooleanProperty, reassignEvents } from './OTHelper';

const sanitizeSubscriberAudioFallback = (audioFallback, audioFallbackEnabled, videoSource) => {
if (typeof audioFallback === 'undefined') {
if (typeof audioFallbackEnabled !== 'undefined') {
return !!audioFallbackEnabled;
}
}
if (typeof audioFallback !== 'object') {
return !(videoSource === 'screen');
}
if (typeof audioFallback.subscriber !== 'undefined') {
return !!audioFallback.subscriber;
}
return !(videoSource === 'screen');
};
const sanitizePublisherAudioFallback = (audioFallback, videoSource) => {
if (typeof audioFallback !== 'object') {
return !(videoSource === 'screen');
}
if (typeof audioFallback.publisher !== 'undefined') {
return !!audioFallback.publisher;
}
return !(videoSource === 'screen');
};
const sanitizeVideoContentHint = (sanitizeVideoContentHint = '') => {

@@ -62,3 +87,4 @@ switch (sanitizeVideoContentHint) {

cameraPosition: 'front',
audioFallbackEnabled: true,
publisherAudioFallback: false,
subscriberAudioFallback: true,
audioBitrate: 40000,

@@ -71,4 +97,12 @@ enableDtx: false,

scalableScreenshare: false,
};
};
}
if (typeof properties.audioFallbackEnabled !== 'undefined') {
console.log('audioFallbackEnabled is deprecated -- use audioFallback.');
if (properties.audioFallback) {
delete properties.audioFallbackEnabled;
}
}
return {

@@ -82,3 +116,11 @@ videoTrack: sanitizeBooleanProperty(properties.videoTrack),

cameraPosition: sanitizeCameraPosition(properties.cameraPosition),
audioFallbackEnabled: sanitizeBooleanProperty(properties.audioFallbackEnabled),
publisherAudioFallback: sanitizePublisherAudioFallback(
properties.audioFallback,
properties.videoSource,
),
subscriberAudioFallback: sanitizeSubscriberAudioFallback(
properties.audioFallback,
properties.audioFallbackEnabled,
properties.videoSource,
),
audioBitrate: sanitizeAudioBitrate(properties.audioBitrate),

@@ -104,6 +146,10 @@ enableDtx: sanitizeBooleanProperty(properties.enableDtx ? properties.enableDtx : false),

audioLevel: 'audioLevelUpdated',
audioNetworkStats: 'audioStats',
audioNetworkStats: 'audioNetworkStatsUpdated',
rtcStatsReport: 'rtcStatsReport',
videoNetworkStats: 'videoStats',
videoNetworkStats: 'videoNetworkStatsUpdated',
muteForced: 'muteForced',
videoDisabled: 'videoDisabled',
videoEnabled: 'videoEnabled',
videoDisableWarning: 'videoDisableWarning',
videoDisableWarningLifted: 'videoDisableWarningLifted',
},

@@ -119,2 +165,6 @@ android: {

muteForced: 'onMuteForced',
videoDisabled: 'onVideoDisabled',
videoEnabled: 'onVideoEnabled',
videoDisableWarning: 'onVideoDisableWarning',
videoDisableWarningLifted: 'onVideoDisableWarningLifted',
},

@@ -121,0 +171,0 @@ };

@@ -194,2 +194,8 @@ import { Platform } from 'react-native';

const sanitizeEncryptionSecret = (secret) => {
if (typeof secret !== undefined) {
return String(secret);
}
};
const sanitizeCredentials = (credentials) => {

@@ -231,2 +237,3 @@ const _credentials = {};

sanitizeSignalData,
sanitizeEncryptionSecret,
sanitizeCredentials,

@@ -233,0 +240,0 @@ getConnectionStatus,

@@ -8,3 +8,3 @@ import React, { Component, Children, cloneElement } from 'react';

import { sanitizeSessionEvents, sanitizeSessionOptions, sanitizeSignalData,
sanitizeCredentials, getConnectionStatus } from './helpers/OTSessionHelper';
sanitizeCredentials, sanitizeEncryptionSecret, getConnectionStatus } from './helpers/OTSessionHelper';
import { handleError } from './OTError';

@@ -33,5 +33,6 @@ import { logOT, getOtrnErrorEventHandler } from './helpers/OTHelper';

const sessionOptions = sanitizeSessionOptions(this.props.options);
const encryptionSecret = sanitizeEncryptionSecret(this.props.encryptionSecret);
const { apiKey, sessionId, token } = this.sanitizedCredentials;
if (apiKey && sessionId && token) {
this.createSession(this.sanitizedCredentials, sessionOptions);
this.createSession(this.sanitizedCredentials, sessionOptions, encryptionSecret);
logOT({ apiKey, sessionId, action: 'rn_initialize', proxyUrl: sessionOptions.proxyUrl });

@@ -53,3 +54,8 @@ } else {

const value = useDefault(this.props[key], defaultValue);
this.signal(value);
if (key === 'signal') {
this.signal(value);
}
if (key === 'encryptionSecret') {
this.setEncryptionSecret(value);
}
}

@@ -59,2 +65,3 @@ };

updateSessionProperty('signal', {});
updateSessionProperty('encryptionSecret', undefined);
}

@@ -64,6 +71,9 @@ componentWillUnmount() {

}
createSession(credentials, sessionOptions) {
createSession(credentials, sessionOptions, encryptionSecret) {
const { signal } = this.props;
const { apiKey, sessionId, token } = credentials;
OT.initSession(apiKey, sessionId, sessionOptions);
if (encryptionSecret) {
this.setEncryptionSecret(encryptionSecret);
}
OT.connect(sessionId, token, (error) => {

@@ -136,2 +146,10 @@ if (error) {

}
setEncryptionSecret(secret) {
const errorHandler = this.props.eventHandlers.error;
OT.setEncryptionSecret(this.props.sessionId, sanitizeEncryptionSecret(secret), (error) => {
if (error && errorHandler) {
errorHandler(error);
}
});
}
render() {

@@ -165,2 +183,3 @@ const { style, children, sessionId, apiKey, token } = this.props;

signal: PropTypes.object, // eslint-disable-line react/forbid-prop-types
encryptionSecret: PropTypes.string,
};

@@ -167,0 +186,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc