react-native-altibbi 0.1.9 → 0.3.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 (117) hide show
  1. package/README.md +8 -8
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/altibbi/OTPublisherLayout.java +2 -1
  4. package/android/src/main/java/com/altibbi/OTPublisherViewManager.java +2 -1
  5. package/android/src/main/java/com/altibbi/OTRN.java +2 -1
  6. package/android/src/main/java/com/altibbi/OTScreenCapturer.java +1 -0
  7. package/android/src/main/java/com/altibbi/OTSessionManager.java +91 -33
  8. package/android/src/main/java/com/altibbi/OTSubscriberLayout.java +0 -1
  9. package/android/src/main/java/com/altibbi/OTSubscriberViewManager.java +2 -1
  10. package/android/src/main/java/com/altibbi/utils/EventUtils.java +1 -1
  11. package/android/src/main/java/com/altibbi/utils/Utils.java +8 -11
  12. package/ios/OTSessionManager.m +7 -4
  13. package/ios/OTSessionManager.swift +156 -80
  14. package/ios/Utils/EventUtils.swift +51 -12
  15. package/ios/Utils/Utils.swift +21 -12
  16. package/lib/commonjs/connection.js +101 -6
  17. package/lib/commonjs/connection.js.map +1 -1
  18. package/lib/commonjs/index.js +12 -0
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/scoket.js.map +1 -1
  21. package/lib/commonjs/video/OT.d.js +3 -0
  22. package/lib/commonjs/video/OT.d.js.map +1 -1
  23. package/lib/commonjs/video/OT.js +3 -2
  24. package/lib/commonjs/video/OT.js.map +1 -1
  25. package/lib/commonjs/video/OTError.js.map +1 -1
  26. package/lib/commonjs/video/OTPublisher.d.js +2 -2
  27. package/lib/commonjs/video/OTPublisher.d.js.map +1 -1
  28. package/lib/commonjs/video/OTPublisher.js +27 -7
  29. package/lib/commonjs/video/OTPublisher.js.map +1 -1
  30. package/lib/commonjs/video/OTSession.d.js +2 -1
  31. package/lib/commonjs/video/OTSession.d.js.map +1 -1
  32. package/lib/commonjs/video/OTSession.js +25 -5
  33. package/lib/commonjs/video/OTSession.js.map +1 -1
  34. package/lib/commonjs/video/OTSubscriber.d.js +2 -2
  35. package/lib/commonjs/video/OTSubscriber.d.js.map +1 -1
  36. package/lib/commonjs/video/OTSubscriber.js +20 -4
  37. package/lib/commonjs/video/OTSubscriber.js.map +1 -1
  38. package/lib/commonjs/video/contexts/OTContext.js +1 -1
  39. package/lib/commonjs/video/contexts/OTContext.js.map +1 -1
  40. package/lib/commonjs/video/helpers/OTHelper.js +2 -2
  41. package/lib/commonjs/video/helpers/OTHelper.js.map +1 -1
  42. package/lib/commonjs/video/helpers/OTPublisherHelper.js +47 -8
  43. package/lib/commonjs/video/helpers/OTPublisherHelper.js.map +1 -1
  44. package/lib/commonjs/video/helpers/OTSessionHelper.js +7 -1
  45. package/lib/commonjs/video/helpers/OTSessionHelper.js.map +1 -1
  46. package/lib/commonjs/video/helpers/OTSubscriberHelper.js +1 -1
  47. package/lib/commonjs/video/index.d.js +1 -1
  48. package/lib/commonjs/video/index.d.js.map +1 -1
  49. package/lib/commonjs/video/index.js +1 -1
  50. package/lib/commonjs/video/index.js.map +1 -1
  51. package/lib/module/connection.js +92 -4
  52. package/lib/module/connection.js.map +1 -1
  53. package/lib/module/index.js +1 -1
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/scoket.js.map +1 -1
  56. package/lib/module/video/OT.d.js +2 -1
  57. package/lib/module/video/OT.d.js.map +1 -1
  58. package/lib/module/video/OT.js +3 -2
  59. package/lib/module/video/OT.js.map +1 -1
  60. package/lib/module/video/OTError.js.map +1 -1
  61. package/lib/module/video/OTPublisher.d.js +1 -1
  62. package/lib/module/video/OTPublisher.d.js.map +1 -1
  63. package/lib/module/video/OTPublisher.js +26 -6
  64. package/lib/module/video/OTPublisher.js.map +1 -1
  65. package/lib/module/video/OTSession.d.js +1 -1
  66. package/lib/module/video/OTSession.d.js.map +1 -1
  67. package/lib/module/video/OTSession.js +25 -5
  68. package/lib/module/video/OTSession.js.map +1 -1
  69. package/lib/module/video/OTSubscriber.d.js +1 -1
  70. package/lib/module/video/OTSubscriber.d.js.map +1 -1
  71. package/lib/module/video/OTSubscriber.js +19 -3
  72. package/lib/module/video/OTSubscriber.js.map +1 -1
  73. package/lib/module/video/helpers/OTHelper.js +1 -1
  74. package/lib/module/video/helpers/OTHelper.js.map +1 -1
  75. package/lib/module/video/helpers/OTPublisherHelper.js +47 -8
  76. package/lib/module/video/helpers/OTPublisherHelper.js.map +1 -1
  77. package/lib/module/video/helpers/OTSessionHelper.js +6 -1
  78. package/lib/module/video/helpers/OTSessionHelper.js.map +1 -1
  79. package/lib/module/video/helpers/OTSubscriberHelper.js +1 -1
  80. package/lib/typescript/src/connection.d.ts +11 -3
  81. package/lib/typescript/src/connection.d.ts.map +1 -1
  82. package/lib/typescript/src/index.d.ts +1 -1
  83. package/lib/typescript/src/index.d.ts.map +1 -1
  84. package/lib/typescript/src/types.d.ts +73 -13
  85. package/lib/typescript/src/types.d.ts.map +1 -1
  86. package/lib/typescript/src/video/OT.d.ts +1 -1
  87. package/lib/typescript/src/video/OT.d.ts.map +1 -1
  88. package/lib/typescript/src/video/OTPublisher.d.ts +7 -1
  89. package/lib/typescript/src/video/OTPublisher.d.ts.map +1 -1
  90. package/lib/typescript/src/video/OTSession.d.ts +3 -1
  91. package/lib/typescript/src/video/OTSession.d.ts.map +1 -1
  92. package/lib/typescript/src/video/OTSubscriber.d.ts +7 -1
  93. package/lib/typescript/src/video/OTSubscriber.d.ts.map +1 -1
  94. package/lib/typescript/src/video/helpers/OTPublisherHelper.d.ts +2 -1
  95. package/lib/typescript/src/video/helpers/OTPublisherHelper.d.ts.map +1 -1
  96. package/lib/typescript/src/video/helpers/OTSessionHelper.d.ts +1 -0
  97. package/lib/typescript/src/video/helpers/OTSessionHelper.d.ts.map +1 -1
  98. package/lib/typescript/src/video/views/OTPublisherView.d.ts.map +1 -1
  99. package/lib/typescript/src/video/views/OTSubscriberView.d.ts.map +1 -1
  100. package/package.json +1 -1
  101. package/react-native-altibbi.podspec +2 -2
  102. package/src/connection.ts +123 -6
  103. package/src/index.tsx +2 -0
  104. package/src/types.ts +77 -11
  105. package/src/video/OT.d.ts +5 -14
  106. package/src/video/OT.js +6 -4
  107. package/src/video/OTPublisher.d.ts +16 -10
  108. package/src/video/OTPublisher.js +37 -5
  109. package/src/video/OTSession.d.ts +42 -41
  110. package/src/video/OTSession.js +23 -4
  111. package/src/video/OTSubscriber.d.ts +12 -6
  112. package/src/video/OTSubscriber.js +25 -3
  113. package/src/video/helpers/OTHelper.js +1 -1
  114. package/src/video/helpers/OTPublisherHelper.js +56 -6
  115. package/src/video/helpers/OTSessionHelper.js +7 -0
  116. package/src/video/helpers/OTSubscriberHelper.js +1 -1
  117. package/android/src/main/java/com/altibbi/OTCustomAudioDevice.java +0 -1146
package/src/video/OT.d.ts CHANGED
@@ -1,15 +1,6 @@
1
- declare const OT: any;
2
- declare const nativeEvents: NativeEventEmitter;
3
- declare function checkAndroidPermissions(): Promise<any>;
4
- declare function setNativeEvents(events: any): void;
5
- declare function removeNativeEvents(events: any): void;
1
+ export let OT: any;
2
+ export let nativeEvents: NativeEventEmitter;
3
+ export function checkAndroidPermissions(audioTrack: any, videoTrack: any, isScreenSharing: any): Promise<any>;
4
+ export function setNativeEvents(events: any): void;
5
+ export function removeNativeEvents(events: any): void;
6
6
  import { NativeEventEmitter } from 'react-native';
7
-
8
- // Export the declared types
9
- export {
10
- OT,
11
- nativeEvents,
12
- checkAndroidPermissions,
13
- setNativeEvents,
14
- removeNativeEvents,
15
- };
package/src/video/OT.js CHANGED
@@ -4,10 +4,12 @@ import { each } from 'underscore';
4
4
  const OT = NativeModules.OTSessionManager;
5
5
  const nativeEvents = new NativeEventEmitter(OT);
6
6
 
7
- const checkAndroidPermissions = () => new Promise((resolve, reject) => {
8
- PermissionsAndroid.requestMultiple([
9
- PermissionsAndroid.PERMISSIONS.CAMERA,
10
- PermissionsAndroid.PERMISSIONS.RECORD_AUDIO])
7
+ const checkAndroidPermissions = (audioTrack, videoTrack, isScreenSharing) => new Promise((resolve, reject) => {
8
+ const permissionsToCheck = [
9
+ ... audioTrack ? [PermissionsAndroid.PERMISSIONS.RECORD_AUDIO] : [],
10
+ ... (videoTrack && !isScreenSharing) ? [PermissionsAndroid.PERMISSIONS.CAMERA] : [],
11
+ ];
12
+ PermissionsAndroid.requestMultiple(permissionsToCheck)
11
13
  .then((result) => {
12
14
  const permissionsError = {};
13
15
  permissionsError.permissionsDenied = [];
@@ -1,27 +1,33 @@
1
1
  export default OTPublisher;
2
- declare class OTPublisher extends Component<any, any, any> {
2
+ declare class OTPublisher extends React.Component<any, any, any> {
3
3
  constructor(props: any, context: any);
4
4
  state: {
5
- initError: any;
6
- publisher: any;
5
+ initError: null;
6
+ publisher: null;
7
7
  publisherId: any;
8
8
  };
9
9
  initComponent: () => void;
10
10
  componentEvents: {
11
+ publisherStreamCreated: string;
12
+ publisherStreamDestroyed: string;
11
13
  sessionConnected: string;
12
- };
13
- componentEventsArray: string[];
14
- otrnEventHandler: (event: any) => void;
15
- publisherEvents: {};
16
- sessionConnected: import("react-native").EmitterSubscription;
14
+ } | undefined;
15
+ componentEventsArray: string[] | undefined;
16
+ otrnEventHandler: ((event: any) => void) | undefined;
17
+ publisherEvents: {} | undefined;
18
+ publisherStreamCreated: import("react-native").EmitterSubscription | undefined;
19
+ publisherStreamDestroyed: import("react-native").EmitterSubscription | undefined;
20
+ sessionConnected: import("react-native").EmitterSubscription | undefined;
17
21
  componentDidMount(): void;
18
22
  componentDidUpdate(previousProps: any): void;
19
23
  componentWillUnmount(): void;
20
24
  sessionConnectedHandler: () => void;
21
25
  createPublisher(): void;
22
- initPublisher(): void;
26
+ initPublisher(publisherProperties: any): void;
23
27
  publish(): void;
24
28
  getRtcStatsReport(): void;
29
+ publisherStreamCreatedHandler: (stream: any) => void;
30
+ publisherStreamDestroyedHandler: (stream: any) => void;
25
31
  setVideoTransformers(videoTransformers: any): void;
26
32
  render(): JSX.Element;
27
33
  }
@@ -34,5 +40,5 @@ declare namespace OTPublisher {
34
40
  }
35
41
  export { OTContext as contextType };
36
42
  }
37
- import { Component } from 'react';
43
+ import React from 'react';
38
44
  import OTContext from './contexts/OTContext';
@@ -31,6 +31,8 @@ class OTPublisher extends Component {
31
31
  }
32
32
  initComponent = () => {
33
33
  this.componentEvents = {
34
+ publisherStreamCreated: 'publisherStreamCreated',
35
+ publisherStreamDestroyed: 'publisherStreamDestroyed:',
34
36
  sessionConnected:
35
37
  Platform.OS === 'android'
36
38
  ? 'session:onConnected'
@@ -44,6 +46,14 @@ class OTPublisher extends Component {
44
46
  );
45
47
  setNativeEvents(this.publisherEvents);
46
48
  OT.setJSComponentEvents(this.componentEventsArray);
49
+ this.publisherStreamCreated = nativeEvents.addListener(
50
+ 'publisherStreamCreated',
51
+ stream => this.publisherStreamCreatedHandler(stream)
52
+ );
53
+ this.publisherStreamDestroyed = nativeEvents.addListener(
54
+ 'publisherStreamDestroyed',
55
+ stream => this.publisherStreamDestroyedHandler(stream)
56
+ );
47
57
  if (this.context.sessionId) {
48
58
  this.sessionConnected = nativeEvents.addListener(
49
59
  `${this.context.sessionId}:${this.componentEvents.sessionConnected}`,
@@ -99,20 +109,22 @@ class OTPublisher extends Component {
99
109
  }
100
110
  };
101
111
  createPublisher() {
112
+ const publisherProperties = sanitizeProperties(this.props.properties);
102
113
  if (Platform.OS === 'android') {
103
- checkAndroidPermissions()
114
+ const { audioTrack, videoTrack, videoSource } = publisherProperties;
115
+ const isScreenSharing = (videoSource === 'screen');
116
+ checkAndroidPermissions(audioTrack, videoTrack, isScreenSharing)
104
117
  .then(() => {
105
- this.initPublisher();
118
+ this.initPublisher(publisherProperties);
106
119
  })
107
120
  .catch((error) => {
108
121
  this.otrnEventHandler(error);
109
122
  });
110
123
  } else {
111
- this.initPublisher();
124
+ this.initPublisher(publisherProperties);
112
125
  }
113
126
  }
114
- initPublisher() {
115
- const publisherProperties = sanitizeProperties(this.props.properties);
127
+ initPublisher(publisherProperties) {
116
128
  OT.initPublisher(
117
129
  this.state.publisherId,
118
130
  publisherProperties,
@@ -157,6 +169,26 @@ class OTPublisher extends Component {
157
169
  OT.getRtcStatsReport(this.state.publisherId);
158
170
  }
159
171
 
172
+ publisherStreamCreatedHandler = (stream) => {
173
+ if (
174
+ this.props.eventHandlers
175
+ && this.props.eventHandlers.streamCreated
176
+ && stream.publisherId === this.state.publisherId
177
+ ) {
178
+ this.props.eventHandlers.streamCreated(stream);
179
+ }
180
+ }
181
+
182
+ publisherStreamDestroyedHandler = (stream) => {
183
+ if (
184
+ this.props.eventHandlers
185
+ && this.props.eventHandlers.streamCreated
186
+ && stream.publisherId === this.state.publisherId
187
+ ) {
188
+ this.props.eventHandlers.streamDestroyed(stream);
189
+ }
190
+ }
191
+
160
192
  setVideoTransformers(videoTransformers) {
161
193
  OT.setVideoTransformers(this.state.publisherId, videoTransformers);
162
194
  }
@@ -1,48 +1,49 @@
1
- import { Component } from 'react';
2
-
3
- declare class OTSession extends Component<any, any> {
4
- constructor(props: any);
5
- state: {
6
- sessionInfo: any;
7
- };
8
- otrnEventHandler: (event: any) => void;
9
- initComponent: () => void;
10
- sanitizedCredentials: {};
11
- componentDidMount(): void;
12
- componentDidUpdate(previousProps: any): void;
13
- componentWillUnmount(): void;
14
- createSession(credentials: any, sessionOptions: any): void;
15
- disconnectSession(): void;
16
- getSessionInfo(): any;
17
- getCapabilities(): Promise<any>;
18
- reportIssue(): Promise<any>;
19
- signal(signal: any): void;
20
- forceMuteAll(excludedStreamIds: any): any;
21
- forceMuteStream(streamId: any): any;
22
- disableForceMute(): any;
23
- render(): JSX.Element;
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ declare class OTSession extends React.Component<any, any, any> {
4
+ constructor(props: any);
5
+ state: {
6
+ sessionInfo: null;
7
+ };
8
+ otrnEventHandler: (event: any) => void;
9
+ initComponent: () => void;
10
+ sanitizedCredentials: {} | undefined;
11
+ componentDidMount(): void;
12
+ componentDidUpdate(previousProps: any): void;
13
+ componentWillUnmount(): void;
14
+ createSession(credentials: any, sessionOptions: any, encryptionSecret: any): void;
15
+ disconnectSession(): void;
16
+ getSessionInfo(): null;
17
+ getCapabilities(): Promise<any>;
18
+ reportIssue(): Promise<any>;
19
+ signal(signal: any): void;
20
+ forceMuteAll(excludedStreamIds: any): any;
21
+ forceMuteStream(streamId: any): any;
22
+ disableForceMute(): any;
23
+ setEncryptionSecret(secret: any): void;
24
+ render(): JSX.Element;
24
25
  }
25
-
26
26
  declare namespace OTSession {
27
- let propTypes: {
28
- apiKey: any;
29
- sessionId: any;
30
- token: any;
31
- children: any;
32
- style: any;
33
- eventHandlers: any;
34
- options: any;
35
- signal: any;
36
- };
27
+ namespace propTypes {
28
+ let apiKey: PropTypes.Validator<string>;
29
+ let sessionId: PropTypes.Validator<string>;
30
+ let token: PropTypes.Validator<string>;
31
+ let children: PropTypes.Requireable<NonNullable<PropTypes.ReactElementLike | (PropTypes.ReactElementLike | null | undefined)[] | null | undefined>>;
32
+ let style: any;
33
+ let eventHandlers: PropTypes.Requireable<object>;
34
+ let options: PropTypes.Requireable<object>;
35
+ let signal: PropTypes.Requireable<object>;
36
+ let encryptionSecret: PropTypes.Requireable<string>;
37
+ }
37
38
 
38
- let defaultProps: {
39
- eventHandlers: {};
40
- options: {};
41
- signal: {};
42
- style: {
39
+ namespace defaultProps {
40
+ // Declare the types (no initialization)
41
+ let eventHandlers: object;
42
+ let options: object;
43
+ let signal: object;
44
+ let style: {
43
45
  flex: number;
44
46
  };
45
- };
47
+ }
46
48
  }
47
-
48
49
  export default OTSession;
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
5
5
  import { pick, isNull } from 'underscore';
6
6
  import { setNativeEvents, removeNativeEvents, OT } from './OT';
7
7
  import { sanitizeSessionEvents, sanitizeSessionOptions, sanitizeSignalData,
8
- sanitizeCredentials, getConnectionStatus } from './helpers/OTSessionHelper';
8
+ sanitizeCredentials, sanitizeEncryptionSecret, getConnectionStatus } from './helpers/OTSessionHelper';
9
9
  import { handleError } from './OTError';
10
10
  import { logOT, getOtrnErrorEventHandler } from './helpers/OTHelper';
11
11
  import OTContext from './contexts/OTContext';
@@ -29,9 +29,10 @@ export default class OTSession extends Component {
29
29
  }
30
30
  componentDidMount() {
31
31
  const sessionOptions = sanitizeSessionOptions(this.props.options);
32
+ const encryptionSecret = sanitizeEncryptionSecret(this.props.encryptionSecret);
32
33
  const { apiKey, sessionId, token } = this.sanitizedCredentials;
33
34
  if (apiKey && sessionId && token) {
34
- this.createSession(this.sanitizedCredentials, sessionOptions);
35
+ this.createSession(this.sanitizedCredentials, sessionOptions, encryptionSecret);
35
36
  logOT({ apiKey, sessionId, action: 'rn_initialize', proxyUrl: sessionOptions.proxyUrl });
36
37
  } else {
37
38
  handleError('Please check your OpenTok credentials.');
@@ -48,19 +49,28 @@ export default class OTSession extends Component {
48
49
  const updateSessionProperty = (key, defaultValue) => {
49
50
  if (shouldUpdate(key, defaultValue)) {
50
51
  const value = useDefault(this.props[key], defaultValue);
51
- this.signal(value);
52
+ if (key === 'signal') {
53
+ this.signal(value);
54
+ }
55
+ if (key === 'encryptionSecret') {
56
+ this.setEncryptionSecret(value);
57
+ }
52
58
  }
53
59
  };
54
60
 
55
61
  updateSessionProperty('signal', {});
62
+ updateSessionProperty('encryptionSecret', undefined);
56
63
  }
57
64
  componentWillUnmount() {
58
65
  this.disconnectSession();
59
66
  }
60
- createSession(credentials, sessionOptions) {
67
+ createSession(credentials, sessionOptions, encryptionSecret) {
61
68
  const { signal } = this.props;
62
69
  const { apiKey, sessionId, token } = credentials;
63
70
  OT.initSession(apiKey, sessionId, sessionOptions);
71
+ if (encryptionSecret) {
72
+ this.setEncryptionSecret(encryptionSecret);
73
+ }
64
74
  OT.connect(sessionId, token, (error) => {
65
75
  if (error) {
66
76
  this.otrnEventHandler(error);
@@ -128,6 +138,14 @@ export default class OTSession extends Component {
128
138
  disableForceMute() {
129
139
  return OT.disableForceMute(this.props.sessionId);
130
140
  }
141
+ setEncryptionSecret(secret) {
142
+ const errorHandler = this.props.eventHandlers.error;
143
+ OT.setEncryptionSecret(this.props.sessionId, sanitizeEncryptionSecret(secret), (error) => {
144
+ if (error && errorHandler) {
145
+ errorHandler(error);
146
+ }
147
+ });
148
+ }
131
149
  render() {
132
150
  const { style, children, sessionId, apiKey, token } = this.props;
133
151
  const { sessionInfo } = this.state;
@@ -156,6 +174,7 @@ OTSession.propTypes = {
156
174
  eventHandlers: PropTypes.object, // eslint-disable-line react/forbid-prop-types
157
175
  options: PropTypes.object, // eslint-disable-line react/forbid-prop-types
158
176
  signal: PropTypes.object, // eslint-disable-line react/forbid-prop-types
177
+ encryptionSecret: PropTypes.string,
159
178
  };
160
179
 
161
180
  OTSession.defaultProps = {
@@ -1,24 +1,30 @@
1
- declare class OTSubscriber extends Component<any, any, any> {
1
+ declare class OTSubscriber extends React.Component<any, any, any> {
2
2
  constructor(props: any, context: any);
3
3
  state: {
4
- streams: any[];
4
+ streams: never[];
5
5
  subscribeToSelf: any;
6
6
  };
7
7
  componentEvents: {
8
8
  streamDestroyed: string;
9
9
  streamCreated: string;
10
10
  captionReceived: string;
11
+ publisherStreamCreated: string;
12
+ publisherStreamDestroyed: string;
11
13
  };
12
14
  componentEventsArray: string[];
13
15
  otrnEventHandler: (event: any) => void;
14
16
  initComponent: () => void;
15
- streamCreated: import("react-native").EmitterSubscription;
16
- streamDestroyed: import("react-native").EmitterSubscription;
17
+ streamCreated: import("react-native").EmitterSubscription | undefined;
18
+ streamDestroyed: import("react-native").EmitterSubscription | undefined;
19
+ publisherStreamCreated: import("react-native").EmitterSubscription | undefined;
20
+ publisherStreamDestroyed: import("react-native").EmitterSubscription | undefined;
17
21
  componentDidUpdate(): void;
18
22
  componentWillUnmount(): void;
19
23
  streamCreatedHandler: (stream: any) => void;
20
24
  streamDestroyedHandler: (stream: any) => void;
21
- getRtcStatsReport(streamId: any): void;
25
+ publisherStreamCreatedHandler: (stream: any) => void;
26
+ publisherStreamDestroyedHandler: (stream: any) => void;
27
+ getRtcStatsReport(): void;
22
28
  render(): any;
23
29
  }
24
30
  declare namespace OTSubscriber {
@@ -35,5 +41,5 @@ declare namespace OTSubscriber {
35
41
  export { OTContext as contextType };
36
42
  }
37
43
  export default OTSubscriber;
38
- import { Component } from 'react';
44
+ import React from 'react';
39
45
  import OTContext from './contexts/OTContext';
@@ -19,6 +19,8 @@ export default class OTSubscriber extends Component {
19
19
  streamDestroyed: Platform.OS === 'android' ? 'session:onStreamDropped' : 'session:streamDestroyed',
20
20
  streamCreated: Platform.OS === 'android' ? 'session:onStreamReceived' : 'session:streamCreated',
21
21
  captionReceived: Platform.OS === 'android' ? 'session:onCaptionText' : 'subscriber:subscriberCaptionReceived:',
22
+ publisherStreamCreated: 'publisherStreamCreated',
23
+ publisherStreamDestroyed: 'publisherStreamDestroyed'
22
24
  };
23
25
  this.componentEventsArray = Object.values(this.componentEvents);
24
26
  this.otrnEventHandler = getOtrnErrorEventHandler(this.props.eventHandlers);
@@ -36,6 +38,14 @@ export default class OTSubscriber extends Component {
36
38
  OT.setJSComponentEvents(this.componentEventsArray);
37
39
  setNativeEvents(subscriberEvents);
38
40
  }
41
+ this.publisherStreamCreated = nativeEvents.addListener(
42
+ 'publisherStreamCreated',
43
+ stream => this.publisherStreamCreatedHandler(stream)
44
+ );
45
+ this.publisherStreamDestroyed = nativeEvents.addListener(
46
+ 'publisherStreamDestroyed',
47
+ stream => this.publisherStreamDestroyedHandler(stream)
48
+ );
39
49
  }
40
50
  componentDidUpdate() {
41
51
  const { streamProperties } = this.props;
@@ -67,6 +77,8 @@ export default class OTSubscriber extends Component {
67
77
  componentWillUnmount() {
68
78
  this.streamCreated.remove();
69
79
  this.streamDestroyed.remove();
80
+ this.publisherStreamCreated.remove();
81
+ this.publisherStreamDestroyed.remove();
70
82
  OT.removeJSComponentEvents(this.componentEventsArray);
71
83
  const events = sanitizeSubscriberEvents(this.props.eventHandlers);
72
84
  removeNativeEvents(events);
@@ -78,7 +90,7 @@ export default class OTSubscriber extends Component {
78
90
  const subscriberProperties = streamProperties[stream.streamId] ?
79
91
  sanitizeProperties(streamProperties[stream.streamId]) :
80
92
  sanitizeProperties(properties);
81
- // Subscribe to streams. If subscribeToSelf is true, subscribe also to his own stream
93
+ // Subscribe to streams. If subscribeToSelf is true, subscribe also to his own stream
82
94
  const sessionInfoConnectionId = sessionInfo && sessionInfo.connection ? sessionInfo.connection.connectionId : null;
83
95
  if (subscribeToSelf || (sessionInfoConnectionId !== stream.connectionId)) {
84
96
  OT.subscribeToStream(stream.streamId, sessionId, subscriberProperties, (error) => {
@@ -106,8 +118,18 @@ export default class OTSubscriber extends Component {
106
118
  }
107
119
  });
108
120
  }
109
- getRtcStatsReport(streamId) {
110
- OT.getSubscriberRtcStatsReport(streamId);
121
+ publisherStreamCreatedHandler = (stream) => {
122
+ if (this.state.subscribeToSelf) {
123
+ this.streamCreatedHandler(stream);
124
+ }
125
+ }
126
+ publisherStreamDestroyedHandler = (stream) => {
127
+ if (this.state.subscribeToSelf) {
128
+ this.streamDestroyedHandler(stream);
129
+ }
130
+ }
131
+ getRtcStatsReport() {
132
+ OT.getSubscriberRtcStatsReport();
111
133
  }
112
134
  render() {
113
135
  if (!this.props.children) {
@@ -69,7 +69,7 @@ const logRequest = (body, proxyUrl) => {
69
69
  axios({
70
70
  url,
71
71
  method: 'post',
72
- data: JSON.stringify(body),
72
+ data: body,
73
73
  })
74
74
  .then(() => {
75
75
  // response complete
@@ -35,6 +35,31 @@ const sanitizeVideoSource = (videoSource = 'camera') => (videoSource === 'camera
35
35
  const sanitizeAudioBitrate = (audioBitrate = 40000) =>
36
36
  (audioBitrate < 6000 || audioBitrate > 510000 ? 40000 : audioBitrate);
37
37
 
38
+ const sanitizeSubscriberAudioFallback = (audioFallback, audioFallbackEnabled, videoSource) => {
39
+ if (typeof audioFallback === 'undefined') {
40
+ if (typeof audioFallbackEnabled !== 'undefined') {
41
+ return !!audioFallbackEnabled;
42
+ }
43
+ }
44
+ if (typeof audioFallback !== 'object') {
45
+ return !(videoSource === 'screen');
46
+ }
47
+ if (typeof audioFallback.subscriber !== 'undefined') {
48
+ return !!audioFallback.subscriber;
49
+ }
50
+ return !(videoSource === 'screen');
51
+ };
52
+
53
+ const sanitizePublisherAudioFallback = (audioFallback, videoSource) => {
54
+ if (typeof audioFallback !== 'object') {
55
+ return !(videoSource === 'screen');
56
+ }
57
+ if (typeof audioFallback.publisher !== 'undefined') {
58
+ return !!audioFallback.publisher;
59
+ }
60
+ return !(videoSource === 'screen');
61
+ };
62
+
38
63
  const sanitizeVideoContentHint = (sanitizeVideoContentHint = '') => {
39
64
  switch (sanitizeVideoContentHint) {
40
65
  case 'motion':
@@ -58,7 +83,8 @@ const sanitizeProperties = (properties) => {
58
83
  publishCaptions: false,
59
84
  name: '',
60
85
  cameraPosition: 'front',
61
- audioFallbackEnabled: true,
86
+ publisherAudioFallback: false,
87
+ subscriberAudioFallback: true,
62
88
  audioBitrate: 40000,
63
89
  enableDtx: false,
64
90
  frameRate: 30,
@@ -68,6 +94,14 @@ const sanitizeProperties = (properties) => {
68
94
  scalableScreenshare: false,
69
95
  };
70
96
  }
97
+
98
+ if (typeof properties.audioFallbackEnabled !== 'undefined') {
99
+ console.log('audioFallbackEnabled is deprecated -- use audioFallback.');
100
+ if (properties.audioFallback) {
101
+ delete properties.audioFallbackEnabled;
102
+ }
103
+ }
104
+
71
105
  return {
72
106
  videoTrack: sanitizeBooleanProperty(properties.videoTrack),
73
107
  audioTrack: sanitizeBooleanProperty(properties.audioTrack),
@@ -76,7 +110,15 @@ const sanitizeProperties = (properties) => {
76
110
  publishCaptions: sanitizeBooleanProperty(properties.publishCaptions),
77
111
  name: properties.name ? properties.name : '',
78
112
  cameraPosition: sanitizeCameraPosition(properties.cameraPosition),
79
- audioFallbackEnabled: sanitizeBooleanProperty(properties.audioFallbackEnabled),
113
+ publisherAudioFallback: sanitizePublisherAudioFallback(
114
+ properties.audioFallback,
115
+ properties.videoSource,
116
+ ),
117
+ subscriberAudioFallback: sanitizeSubscriberAudioFallback(
118
+ properties.audioFallback,
119
+ properties.audioFallbackEnabled,
120
+ properties.videoSource,
121
+ ),
80
122
  audioBitrate: sanitizeAudioBitrate(properties.audioBitrate),
81
123
  enableDtx: sanitizeBooleanProperty(properties.enableDtx ? properties.enableDtx : false),
82
124
  frameRate: sanitizeFrameRate(properties.frameRate),
@@ -97,20 +139,28 @@ const sanitizePublisherEvents = (publisherId, events) => {
97
139
  streamDestroyed: 'streamDestroyed',
98
140
  error: 'didFailWithError',
99
141
  audioLevel: 'audioLevelUpdated',
100
- audioNetworkStats: 'audioStats',
142
+ audioNetworkStats: 'audioNetworkStatsUpdated',
101
143
  rtcStatsReport: 'rtcStatsReport',
102
- videoNetworkStats: 'videoStats',
144
+ videoNetworkStats: 'videoNetworkStatsUpdated',
103
145
  muteForced: 'muteForced',
146
+ videoDisabled: 'videoDisabled',
147
+ videoEnabled: 'videoEnabled',
148
+ videoDisableWarning: 'videoDisableWarning',
149
+ videoDisableWarningLifted: 'videoDisableWarningLifted',
104
150
  },
105
151
  android: {
106
- streamCreated: 'onStreamCreated',
107
- streamDestroyed: 'onStreamDestroyed',
152
+ streamCreated: 'streamCreated',
153
+ streamDestroyed: 'streamDestroyed',
108
154
  error: 'onError',
109
155
  audioLevel: 'onAudioLevelUpdated',
110
156
  audioNetworkStats: 'onAudioStats',
111
157
  rtcStatsReport: 'onRtcStatsReport',
112
158
  videoNetworkStats: 'onVideoStats',
113
159
  muteForced: 'onMuteForced',
160
+ videoDisabled: 'onVideoDisabled',
161
+ videoEnabled: 'onVideoEnabled',
162
+ videoDisableWarning: 'onVideoDisableWarning',
163
+ videoDisableWarningLifted: 'onVideoDisableWarningLifted',
114
164
  },
115
165
  };
116
166
  return reassignEvents('publisher', customEvents, events, publisherId);
@@ -191,6 +191,12 @@ const sanitizeSignalData = (signal) => {
191
191
  };
192
192
  };
193
193
 
194
+ const sanitizeEncryptionSecret = (secret) => {
195
+ if (typeof secret !== undefined) {
196
+ return String(secret);
197
+ }
198
+ };
199
+
194
200
  const sanitizeCredentials = (credentials) => {
195
201
  const _credentials = {};
196
202
  each(credentials, (value, key) => {
@@ -227,6 +233,7 @@ export {
227
233
  sanitizeSessionEvents,
228
234
  sanitizeSessionOptions,
229
235
  sanitizeSignalData,
236
+ sanitizeEncryptionSecret,
230
237
  sanitizeCredentials,
231
238
  getConnectionStatus,
232
239
  isConnected
@@ -27,7 +27,7 @@ const sanitizeSubscriberEvents = (events) => {
27
27
  videoDisableWarning: 'subscriberVideoDisableWarning',
28
28
  videoDisableWarningLifted: 'subscriberVideoDisableWarningLifted',
29
29
  videoDataReceived: 'subscriberVideoDataReceived',
30
- captionReceived: 'subscriberCaptionReceived:',
30
+ captionReceived: 'subscriberCaptionReceived',
31
31
  },
32
32
  android: {
33
33
  connected: 'onConnected',