@100mslive/react-native-hms 1.12.2 → 2.0.0-alpha.1
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.
- package/android/build.gradle +70 -12
- package/android/src/main/java/com/reactnativehmssdk/HMSAudioshareActivity.kt +8 -8
- package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayer.kt +38 -12
- package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManagerImpl.kt +185 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +20 -10
- package/android/src/main/java/com/reactnativehmssdk/{HMSManager.kt → HMSManagerImpl.kt} +28 -111
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +3 -3
- package/android/src/main/java/com/reactnativehmssdk/HMSReactNativeEvent.kt +29 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManagerImpl.kt +119 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +33 -5
- package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +9 -9
- package/android/src/main/java/com/reactnativehmssdk/HmssdkPackage.kt +42 -3
- package/android/src/newarch/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt +128 -0
- package/android/src/newarch/java/com/reactnativehmssdk/HMSManager.kt +332 -0
- package/android/src/newarch/java/com/reactnativehmssdk/HMSSDKViewManager.kt +102 -0
- package/android/src/oldarch/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt +61 -0
- package/android/src/oldarch/java/com/reactnativehmssdk/HMSManager.kt +351 -0
- package/android/src/oldarch/java/com/reactnativehmssdk/HMSSDKViewManager.kt +87 -0
- package/ios/HMSHLSPlayerComponentView.mm +325 -0
- package/ios/HMSHLSPlayerManager.m +10 -0
- package/ios/HMSHLSPlayerManager.swift +91 -79
- package/ios/HMSManager.m +13 -0
- package/ios/HMSManager.mm +365 -0
- package/ios/HMSManager.swift +109 -103
- package/ios/HMSView.m +9 -0
- package/ios/HMSView.swift +44 -14
- package/ios/HMSViewComponentView.mm +229 -0
- package/lib/commonjs/classes/HmsView.js +45 -48
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js +46 -26
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/commonjs/components/HMSHLSPlayer/RCTHMSHLSPlayer.js +5 -4
- package/lib/commonjs/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
- package/lib/commonjs/modules/HMSManagerModule.js +3 -10
- package/lib/commonjs/modules/HMSManagerModule.js.map +1 -1
- package/lib/commonjs/specs/HMSHLSPlayerNativeComponent.js +75 -0
- package/lib/commonjs/specs/HMSHLSPlayerNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/HMSViewNativeComponent.js +55 -0
- package/lib/commonjs/specs/HMSViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeHMSManager.js +38 -0
- package/lib/commonjs/specs/NativeHMSManager.js.map +1 -0
- package/lib/module/classes/HmsView.js +46 -49
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js +48 -28
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/module/components/HMSHLSPlayer/RCTHMSHLSPlayer.js +3 -3
- package/lib/module/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
- package/lib/module/modules/HMSManagerModule.js +1 -9
- package/lib/module/modules/HMSManagerModule.js.map +1 -1
- package/lib/module/specs/HMSHLSPlayerNativeComponent.js +69 -0
- package/lib/module/specs/HMSHLSPlayerNativeComponent.js.map +1 -0
- package/lib/module/specs/HMSViewNativeComponent.js +49 -0
- package/lib/module/specs/HMSViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeHMSManager.js +33 -0
- package/lib/module/specs/NativeHMSManager.js.map +1 -0
- package/lib/typescript/components/HMSHLSPlayer/RCTHMSHLSPlayer.d.ts +6 -9
- package/lib/typescript/specs/HMSHLSPlayerNativeComponent.d.ts +115 -0
- package/lib/typescript/specs/HMSViewNativeComponent.d.ts +97 -0
- package/lib/typescript/specs/NativeHMSManager.d.ts +147 -0
- package/package.json +16 -1
- package/react-native-hms.podspec +43 -0
- package/src/classes/HmsView.tsx +60 -78
- package/src/components/HMSHLSPlayer/HMSHLSPlayer.tsx +62 -128
- package/src/components/HMSHLSPlayer/RCTHMSHLSPlayer.ts +8 -13
- package/src/modules/HMSManagerModule.ts +1 -14
- package/src/specs/HMSHLSPlayerNativeComponent.ts +203 -0
- package/src/specs/HMSViewNativeComponent.ts +119 -0
- package/src/specs/NativeHMSManager.ts +307 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt +0 -144
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +0 -111
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fabric component spec for `<HMSHLSPlayer />`.
|
|
3
|
+
*
|
|
4
|
+
* Renders an HLS stream from the live room (host-published or recorded).
|
|
5
|
+
* Today's implementation lives in `ios/HMSHLSPlayerManager.swift` (paper)
|
|
6
|
+
* and `android/.../HMSHLSPlayerManager.kt` + `HMSHLSPlayer.kt` (paper).
|
|
7
|
+
* Phase 1 adds Fabric counterparts.
|
|
8
|
+
*
|
|
9
|
+
* This is the most surface-heavy component in the SDK:
|
|
10
|
+
* - 3 props (`url`, `enableStats`, `enableControls`)
|
|
11
|
+
* - 4 events (playback state, stats, request-response, captions)
|
|
12
|
+
* - 13 imperative commands
|
|
13
|
+
*
|
|
14
|
+
* Like {@link HMSViewNativeComponent}, Fabric requires explicit prop and
|
|
15
|
+
* event payload shapes. For Phase 1 we use minimal shapes that capture
|
|
16
|
+
* essential fields (e.g. `requestId` for response events) and leave the
|
|
17
|
+
* rest loose. Phase 2 tightens.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type * as React from 'react';
|
|
21
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
22
|
+
import type {
|
|
23
|
+
DirectEventHandler,
|
|
24
|
+
Double,
|
|
25
|
+
Int32,
|
|
26
|
+
WithDefault,
|
|
27
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
28
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
29
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
30
|
+
|
|
31
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
32
|
+
// Event payload shapes
|
|
33
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Playback state-change event payload.
|
|
37
|
+
* Today's emitter in `HMSHLSPlayer.kt` / iOS counterpart sends an
|
|
38
|
+
* `eventType` plus a state-specific data object. Phase 2 will type the
|
|
39
|
+
* `data` field per state; Phase 1 carries it as a string blob.
|
|
40
|
+
*/
|
|
41
|
+
type OnHmsHlsPlaybackEventPayload = Readonly<{
|
|
42
|
+
event: string;
|
|
43
|
+
data: string;
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Stats event payload (RTC-shape stats: bitrate, dropped frames, etc.).
|
|
48
|
+
* Carried as a stringified JSON blob for Phase 1; Phase 2 types it.
|
|
49
|
+
*/
|
|
50
|
+
type OnHmsHlsStatsEventPayload = Readonly<{
|
|
51
|
+
event: string;
|
|
52
|
+
data: string;
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Response event for the request-style commands (`areClosedCaptionSupported`,
|
|
57
|
+
* `isClosedCaptionEnabled`, `getPlayerDurationDetails`). The JS-side
|
|
58
|
+
* matches the response to the in-flight Promise via `requestId`.
|
|
59
|
+
*/
|
|
60
|
+
type OnDataReturnedPayload = Readonly<{
|
|
61
|
+
requestId: Int32;
|
|
62
|
+
result?: string;
|
|
63
|
+
error?: string;
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Closed-captions cue payload. Native-side fires a cue object with start
|
|
68
|
+
* time, end time, payload string, etc. Phase 1 keeps it as a stringified
|
|
69
|
+
* blob; Phase 2 will type it.
|
|
70
|
+
*/
|
|
71
|
+
type OnHlsPlayerCuesEventPayload = Readonly<{
|
|
72
|
+
event: string;
|
|
73
|
+
data: string;
|
|
74
|
+
}>;
|
|
75
|
+
|
|
76
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
77
|
+
// Props
|
|
78
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
export interface NativeProps extends ViewProps {
|
|
81
|
+
/** HLS stream URL to play. */
|
|
82
|
+
url?: string;
|
|
83
|
+
|
|
84
|
+
/** Emit periodic stats events via `onHmsHlsStatsEvent`. */
|
|
85
|
+
enableStats?: WithDefault<boolean, false>;
|
|
86
|
+
|
|
87
|
+
/** Show the native player's built-in controls UI overlay. */
|
|
88
|
+
enableControls?: WithDefault<boolean, false>;
|
|
89
|
+
|
|
90
|
+
/** Playback state changes (started/paused/buffering/ended/...). */
|
|
91
|
+
onHmsHlsPlaybackEvent?: DirectEventHandler<OnHmsHlsPlaybackEventPayload>;
|
|
92
|
+
|
|
93
|
+
/** Periodic stats (only fired when `enableStats=true`). */
|
|
94
|
+
onHmsHlsStatsEvent?: DirectEventHandler<OnHmsHlsStatsEventPayload>;
|
|
95
|
+
|
|
96
|
+
/** Response for request-style commands; matched by `requestId`. */
|
|
97
|
+
onDataReturned?: DirectEventHandler<OnDataReturnedPayload>;
|
|
98
|
+
|
|
99
|
+
/** Closed-captions cue events. */
|
|
100
|
+
onHlsPlayerCuesEvent?: DirectEventHandler<OnHlsPlayerCuesEventPayload>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
104
|
+
// Imperative commands (13)
|
|
105
|
+
//
|
|
106
|
+
// `requestId`-bearing commands deliver their response via the
|
|
107
|
+
// `onDataReturned` event (see {@link OnDataReturnedPayload}). The JS
|
|
108
|
+
// wrapper in `src/components/HMSHLSPlayer/HMSHLSPlayer.tsx` currently
|
|
109
|
+
// allocates the requestId and resolves a promise on response; Phase 1
|
|
110
|
+
// keeps that pattern.
|
|
111
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
112
|
+
|
|
113
|
+
export interface NativeCommands {
|
|
114
|
+
/** Start playing. Pass `''` (empty string) to reuse the URL prop. */
|
|
115
|
+
play: (viewRef: React.ElementRef<HostComponent<NativeProps>>, url: string) => void;
|
|
116
|
+
|
|
117
|
+
/** Stop playback (releases the player). */
|
|
118
|
+
stop: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
119
|
+
|
|
120
|
+
/** Pause playback (player remains allocated). */
|
|
121
|
+
pause: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
122
|
+
|
|
123
|
+
/** Resume from paused state. */
|
|
124
|
+
resume: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
125
|
+
|
|
126
|
+
/** Jump to the live edge (DVR HLS only). */
|
|
127
|
+
seekToLivePosition: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
128
|
+
|
|
129
|
+
/** Seek `seconds` ahead from current position. */
|
|
130
|
+
seekForward: (
|
|
131
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
132
|
+
seconds: Double
|
|
133
|
+
) => void;
|
|
134
|
+
|
|
135
|
+
/** Seek `seconds` back from current position. */
|
|
136
|
+
seekBackward: (
|
|
137
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
138
|
+
seconds: Double
|
|
139
|
+
) => void;
|
|
140
|
+
|
|
141
|
+
/** Set volume `0–100` (integer). */
|
|
142
|
+
setVolume: (
|
|
143
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
144
|
+
level: Int32
|
|
145
|
+
) => void;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Query whether the stream supports closed captions. Response via
|
|
149
|
+
* `onDataReturned` matched by `requestId`.
|
|
150
|
+
*/
|
|
151
|
+
areClosedCaptionSupported: (
|
|
152
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
153
|
+
requestId: Int32
|
|
154
|
+
) => void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Query whether closed captions are currently enabled. Response via
|
|
158
|
+
* `onDataReturned` matched by `requestId`.
|
|
159
|
+
*/
|
|
160
|
+
isClosedCaptionEnabled: (
|
|
161
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
162
|
+
requestId: Int32
|
|
163
|
+
) => void;
|
|
164
|
+
|
|
165
|
+
/** Enable closed captions display. */
|
|
166
|
+
enableClosedCaption: (
|
|
167
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
168
|
+
) => void;
|
|
169
|
+
|
|
170
|
+
/** Disable closed captions display. */
|
|
171
|
+
disableClosedCaption: (
|
|
172
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
173
|
+
) => void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get current player duration details (currentTime, duration, live).
|
|
177
|
+
* Response via `onDataReturned` matched by `requestId`.
|
|
178
|
+
*/
|
|
179
|
+
getPlayerDurationDetails: (
|
|
180
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
181
|
+
requestId: Int32
|
|
182
|
+
) => void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
186
|
+
supportedCommands: [
|
|
187
|
+
'play',
|
|
188
|
+
'stop',
|
|
189
|
+
'pause',
|
|
190
|
+
'resume',
|
|
191
|
+
'seekToLivePosition',
|
|
192
|
+
'seekForward',
|
|
193
|
+
'seekBackward',
|
|
194
|
+
'setVolume',
|
|
195
|
+
'areClosedCaptionSupported',
|
|
196
|
+
'isClosedCaptionEnabled',
|
|
197
|
+
'enableClosedCaption',
|
|
198
|
+
'disableClosedCaption',
|
|
199
|
+
'getPlayerDurationDetails',
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export default codegenNativeComponent<NativeProps>('HMSHLSPlayer');
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fabric component spec for `<HMSView />` — the native video tile.
|
|
3
|
+
*
|
|
4
|
+
* Used to render an `HMSVideoTrack` inside a React Native view tree.
|
|
5
|
+
* Today's implementation lives in `ios/HMSView.swift` (paper) and
|
|
6
|
+
* `android/.../HMSSDKViewManager.kt` + `HMSView.kt` (paper). Phase 1
|
|
7
|
+
* adds Fabric counterparts (`ios/HMSViewComponentView.mm`,
|
|
8
|
+
* `android/.../HMSSDKViewManager.kt` reworked to implement the generated
|
|
9
|
+
* `HMSViewManagerInterface`).
|
|
10
|
+
*
|
|
11
|
+
* Note: Fabric component specs require explicit prop and event payload
|
|
12
|
+
* shapes — Codegen does NOT accept `Object` for view props/events the
|
|
13
|
+
* way it does for TurboModule method payloads. The shapes below are
|
|
14
|
+
* narrow and well-known, so this isn't the same scaling problem as the
|
|
15
|
+
* TurboModule's 99-method surface.
|
|
16
|
+
*
|
|
17
|
+
* Surface authored: 4 props + 1 imperative command (`capture`) +
|
|
18
|
+
* 2 events (`onChange` for resolution updates, `onDataReturned` for
|
|
19
|
+
* capture command responses).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type * as React from 'react';
|
|
23
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
24
|
+
import type {
|
|
25
|
+
DirectEventHandler,
|
|
26
|
+
Int32,
|
|
27
|
+
WithDefault,
|
|
28
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
29
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
30
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Bag of identifiers passed to the native view to wire it up to a track.
|
|
34
|
+
* Mirrors the shape constructed in `src/classes/HmsView.tsx`.
|
|
35
|
+
*/
|
|
36
|
+
type DataProp = Readonly<{
|
|
37
|
+
trackId: string;
|
|
38
|
+
id: string;
|
|
39
|
+
mirror: boolean;
|
|
40
|
+
scaleType: string;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Emitted when the video stream's resolution changes (e.g. simulcast
|
|
45
|
+
* layer switch). Native fires `topChange`; the JS-side dispatches as
|
|
46
|
+
* `onChange`. Used to drive Android view-sizing in `HmsView.tsx`.
|
|
47
|
+
*/
|
|
48
|
+
type OnChangeEvent = Readonly<{
|
|
49
|
+
event: string;
|
|
50
|
+
data: Readonly<{
|
|
51
|
+
height: Int32;
|
|
52
|
+
width: Int32;
|
|
53
|
+
}>;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Emitted in response to the `capture` imperative command. Carries the
|
|
58
|
+
* requestId from JS and either a base64 result or an error tuple.
|
|
59
|
+
*/
|
|
60
|
+
type OnDataReturnedEvent = Readonly<{
|
|
61
|
+
requestId: Int32;
|
|
62
|
+
result?: string;
|
|
63
|
+
error?: string;
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
export interface NativeProps extends ViewProps {
|
|
67
|
+
/** Track identifier bag. See {@link DataProp}. */
|
|
68
|
+
data?: DataProp;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Enable automatic simulcast layer switching based on network
|
|
72
|
+
* conditions. iOS-side default in `HMSView.swift` is true.
|
|
73
|
+
*/
|
|
74
|
+
autoSimulcast?: WithDefault<boolean, true>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* How the video fits within the view. Values defined in
|
|
78
|
+
* `src/classes/HMSVideoViewMode.ts` (ASPECT_FIT, ASPECT_FILL,
|
|
79
|
+
* ASPECT_BALANCED).
|
|
80
|
+
*/
|
|
81
|
+
scaleType?: WithDefault<string, 'ASPECT_FILL'>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Render the video above the regular view hierarchy.
|
|
85
|
+
* Platform: Android only — iOS view manager does not implement this.
|
|
86
|
+
*/
|
|
87
|
+
setZOrderMediaOverlay?: WithDefault<boolean, false>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Resolution-change events. Renamed from `onChange` to avoid colliding with
|
|
91
|
+
* RN's built-in `topChange` internal event (registered as bubbling on every
|
|
92
|
+
* RCTView), which triggers "Event cannot be both direct and bubbling".
|
|
93
|
+
*/
|
|
94
|
+
onResolutionChange?: DirectEventHandler<OnChangeEvent>;
|
|
95
|
+
|
|
96
|
+
/** Capture command response (success or error). */
|
|
97
|
+
onDataReturned?: DirectEventHandler<OnDataReturnedEvent>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Imperative commands callable on a `<HMSView />` ref.
|
|
102
|
+
*/
|
|
103
|
+
export interface NativeCommands {
|
|
104
|
+
/**
|
|
105
|
+
* Capture a snapshot of the current video frame. The result (or
|
|
106
|
+
* error) is delivered asynchronously via the `onDataReturned` event,
|
|
107
|
+
* matched to this call by `requestId`.
|
|
108
|
+
*/
|
|
109
|
+
capture: (
|
|
110
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
111
|
+
requestId: Int32
|
|
112
|
+
) => void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
116
|
+
supportedCommands: ['capture'],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export default codegenNativeComponent<NativeProps>('HMSView');
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @100mslive/react-native-hms — TurboModule spec for HMSManager.
|
|
3
|
+
*
|
|
4
|
+
* This file is the source of truth for the JS↔native contract under
|
|
5
|
+
* React Native's New Architecture. At build time, RN's Codegen reads
|
|
6
|
+
* this spec and produces:
|
|
7
|
+
*
|
|
8
|
+
* - iOS: ios/build/.../NativeHMSManagerSpec.h (Obj-C++ protocol)
|
|
9
|
+
* - Android: android/build/.../NativeHMSManagerSpec.java (abstract class)
|
|
10
|
+
* - JS: typed wrappers + JSI fast-path bindings
|
|
11
|
+
*
|
|
12
|
+
* Phase 1 of the New Architecture migration uses **Object-typed** payloads
|
|
13
|
+
* (every dictionary in/out is just `Object`) to preserve today's runtime
|
|
14
|
+
* behavior without designing 99 typed payload schemas upfront. Phase 2 will
|
|
15
|
+
* tighten types per API surface area (room/peer/track core first, then
|
|
16
|
+
* chat, polls, recording, etc.).
|
|
17
|
+
*
|
|
18
|
+
* Method count: 99 iOS (96 async + 3 sync), 98 Android (93 async + 5 sync).
|
|
19
|
+
* Event count: 28 unique events (24 cross-platform + 4 platform-specific).
|
|
20
|
+
*
|
|
21
|
+
* Cross-platform asymmetries are noted inline. See
|
|
22
|
+
* NEW_ARCHITECTURE_MIGRATION.md / 100ms-rn-new-arch-migration-plan.md.md
|
|
23
|
+
* for the full migration plan.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { TurboModule } from 'react-native';
|
|
27
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
28
|
+
import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
29
|
+
|
|
30
|
+
export interface Spec extends TurboModule {
|
|
31
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
32
|
+
// 0. NativeEventEmitter convention methods
|
|
33
|
+
//
|
|
34
|
+
// RN's NativeEventEmitter on the JS side calls these on the native module
|
|
35
|
+
// when listeners are added/removed. Required by the eventing infrastructure
|
|
36
|
+
// even though our impl uses them as no-ops (we route events via a separate
|
|
37
|
+
// DeviceEventManagerModule.RCTDeviceEventEmitter).
|
|
38
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
addListener(eventName: string): void;
|
|
41
|
+
removeListeners(count: Int32): void;
|
|
42
|
+
|
|
43
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
44
|
+
// 1. Lifecycle
|
|
45
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
build(data: Object): Promise<Object>;
|
|
48
|
+
destroy(data: Object): Promise<Object>;
|
|
49
|
+
preview(credentials: Object): void; // fire-and-forget on iOS
|
|
50
|
+
previewForRole(data: Object): Promise<Object>;
|
|
51
|
+
cancelPreview(data: Object): Promise<Object>;
|
|
52
|
+
join(credentials: Object): void; // fire-and-forget on iOS
|
|
53
|
+
leave(data: Object): Promise<Object>;
|
|
54
|
+
endRoom(data: Object): Promise<Object>;
|
|
55
|
+
|
|
56
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
57
|
+
// 2. Track operations
|
|
58
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
setLocalMute(data: Object): void; // fire-and-forget (impl is sync)
|
|
61
|
+
setLocalVideoMute(data: Object): void; // fire-and-forget (impl is sync)
|
|
62
|
+
switchCamera(data: Object): void; // fire-and-forget
|
|
63
|
+
isMute(data: Object): Promise<Object>;
|
|
64
|
+
changeTrackState(data: Object): Promise<Object>;
|
|
65
|
+
changeTrackStateForRoles(data: Object): Promise<Object>;
|
|
66
|
+
setVolume(data: Object): Promise<Object>;
|
|
67
|
+
remoteMuteAllAudio(data: Object): Promise<Object>;
|
|
68
|
+
setPlaybackAllowed(data: Object): Promise<Object>;
|
|
69
|
+
isPlaybackAllowed(data: Object): Promise<Object>;
|
|
70
|
+
setPlaybackForAllAudio(mute: Object): Promise<Object>;
|
|
71
|
+
getRemoteVideoTrackFromTrackId(data: Object): Promise<Object>;
|
|
72
|
+
getRemoteAudioTrackFromTrackId(data: Object): Promise<Object>;
|
|
73
|
+
getVideoTrackLayer(data: Object): Promise<Object>;
|
|
74
|
+
getVideoTrackLayerDefinition(data: Object): Promise<Object>;
|
|
75
|
+
setVideoTrackLayer(data: Object): Promise<Object>;
|
|
76
|
+
captureImageAtMaxSupportedResolution(data: Object): Promise<Object>;
|
|
77
|
+
|
|
78
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
79
|
+
// 3. Peer operations
|
|
80
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
getLocalPeer(data: Object): Promise<Object>;
|
|
83
|
+
getRemotePeers(data: Object): Promise<Object>;
|
|
84
|
+
getRoles(data: Object): Promise<Object>;
|
|
85
|
+
getRoom(data: Object): Promise<Object>;
|
|
86
|
+
changeName(data: Object): Promise<Object>;
|
|
87
|
+
changeMetadata(data: Object): Promise<Object>;
|
|
88
|
+
changeRole(data: Object): Promise<Object>;
|
|
89
|
+
changeRoleOfPeer(data: Object): Promise<Object>;
|
|
90
|
+
changeRoleOfPeersWithRoles(data: Object): Promise<Object>;
|
|
91
|
+
acceptRoleChange(data: Object): Promise<Object>;
|
|
92
|
+
removePeer(data: Object): Promise<Object>;
|
|
93
|
+
raiseLocalPeerHand(data: Object): Promise<Object>;
|
|
94
|
+
lowerLocalPeerHand(data: Object): Promise<Object>;
|
|
95
|
+
lowerRemotePeerHand(data: Object): Promise<Object>;
|
|
96
|
+
|
|
97
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
98
|
+
// 4. Peer list iterator (large-room support)
|
|
99
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
// getPeerListIterator is sync — see "Synchronous methods" section below.
|
|
102
|
+
peerListIteratorHasNext(data: Object): Promise<Object>;
|
|
103
|
+
peerListIteratorNext(data: Object): Promise<Object>;
|
|
104
|
+
|
|
105
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
106
|
+
// 5. Messaging
|
|
107
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
sendBroadcastMessage(data: Object): Promise<Object>;
|
|
110
|
+
sendGroupMessage(data: Object): Promise<Object>;
|
|
111
|
+
sendDirectMessage(data: Object): Promise<Object>;
|
|
112
|
+
|
|
113
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
114
|
+
// 6. RTMP / Recording / HLS streaming
|
|
115
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
startRTMPOrRecording(data: Object): Promise<Object>;
|
|
118
|
+
stopRtmpAndRecording(data: Object): Promise<Object>;
|
|
119
|
+
startHLSStreaming(data: Object): Promise<Object>;
|
|
120
|
+
stopHLSStreaming(data: Object): Promise<Object>;
|
|
121
|
+
sendHLSTimedMetadata(data: Object): Promise<Object>;
|
|
122
|
+
|
|
123
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
124
|
+
// 7. Screen share
|
|
125
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
startScreenshare(data: Object): Promise<Object>;
|
|
128
|
+
stopScreenshare(data: Object): Promise<Object>;
|
|
129
|
+
isScreenShared(data: Object): Promise<Object>;
|
|
130
|
+
|
|
131
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
132
|
+
// 8. Audio share — iOS API
|
|
133
|
+
// Platform: iOS only. Android uses the startAudioshare/stopAudioshare
|
|
134
|
+
// pair below.
|
|
135
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
playAudioShare(data: Object): Promise<Object>; // iOS only
|
|
138
|
+
pauseAudioShare(data: Object): Promise<Object>; // iOS only
|
|
139
|
+
resumeAudioShare(data: Object): Promise<Object>; // iOS only
|
|
140
|
+
stopAudioShare(data: Object): Promise<Object>; // iOS only
|
|
141
|
+
setAudioShareVolume(data: Object): Promise<Object>; // iOS only
|
|
142
|
+
audioShareCurrentTime(data: Object): Promise<Object>; // iOS only
|
|
143
|
+
audioShareDuration(data: Object): Promise<Object>; // iOS only
|
|
144
|
+
audioShareIsPlaying(data: Object): Promise<Object>; // iOS only
|
|
145
|
+
|
|
146
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
147
|
+
// 9. Audio share — Android API
|
|
148
|
+
// Platform: Android only. iOS uses the playAudioShare/... family above.
|
|
149
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
startAudioshare(data: Object): Promise<Object>; // Android only — note lowercase 's'
|
|
152
|
+
stopAudioshare(data: Object): Promise<Object>; // Android only — note lowercase 's'
|
|
153
|
+
isAudioShared(data: Object): Promise<Object>; // Android only
|
|
154
|
+
|
|
155
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
156
|
+
// 10. Audio output / devices
|
|
157
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
158
|
+
|
|
159
|
+
switchAudioOutput(data: Object): Promise<Object>;
|
|
160
|
+
switchAudioOutputUsingIOSUI(data: Object): Promise<Object>; // iOS only
|
|
161
|
+
getAudioDevicesList(data: Object): Promise<Object>; // Android only
|
|
162
|
+
getAudioOutputRouteType(data: Object): Promise<Object>; // Android only
|
|
163
|
+
setAudioDeviceChangeListener(data: Object): void; // Android only
|
|
164
|
+
setAudioMode(data: Object): Promise<Object>; // Android only
|
|
165
|
+
setAudioMixingMode(data: Object): Promise<Object>; // Android only
|
|
166
|
+
getAudioMixingMode(data: Object): Promise<Object>; // Android only
|
|
167
|
+
getVolume(data: Object): Promise<Object>; // Android only
|
|
168
|
+
|
|
169
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
170
|
+
// 11. Picture-in-Picture
|
|
171
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
172
|
+
|
|
173
|
+
// handlePipActions is the only multi-argument method on the bridge. The
|
|
174
|
+
// first argument is the action name (string), the second is the payload.
|
|
175
|
+
handlePipActions(action: string, data: Object): Promise<Object>;
|
|
176
|
+
setupPIP(data: Object): Promise<Object>; // iOS only
|
|
177
|
+
stopPIP(data: Object): Promise<Object>; // iOS only
|
|
178
|
+
disposePIP(data: Object): Promise<Object>; // iOS only
|
|
179
|
+
isPIPActive(data: Object): Promise<Object>; // iOS only
|
|
180
|
+
changeIOSPIPVideoTrack(data: Object): Promise<Object>; // iOS only
|
|
181
|
+
setActiveSpeakerInIOSPIP(data: Object): Promise<Object>; // iOS only
|
|
182
|
+
|
|
183
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
184
|
+
// 12. Network quality
|
|
185
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
186
|
+
|
|
187
|
+
enableNetworkQualityUpdates(data: Object): void;
|
|
188
|
+
disableNetworkQualityUpdates(data: Object): void;
|
|
189
|
+
|
|
190
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
191
|
+
// 13. Session store / metadata
|
|
192
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
193
|
+
|
|
194
|
+
getSessionMetadataForKey(data: Object): Promise<Object>;
|
|
195
|
+
setSessionMetadataForKey(data: Object): Promise<Object>;
|
|
196
|
+
addKeyChangeListener(data: Object): Promise<Object>;
|
|
197
|
+
removeKeyChangeListener(data: Object): Promise<Object>;
|
|
198
|
+
|
|
199
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
200
|
+
// 14. Polls / Quiz
|
|
201
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
202
|
+
|
|
203
|
+
quickStartPoll(data: Object): Promise<Object>;
|
|
204
|
+
addResponseOnPollQuestion(data: Object): Promise<Object>;
|
|
205
|
+
stopPoll(data: Object): Promise<Object>;
|
|
206
|
+
fetchLeaderboard(data: Object): Promise<Object>;
|
|
207
|
+
|
|
208
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
209
|
+
// 15. Whiteboard
|
|
210
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
startWhiteboard(data: Object): Promise<Object>;
|
|
213
|
+
stopWhiteboard(data: Object): Promise<Object>;
|
|
214
|
+
|
|
215
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
216
|
+
// 16. Transcripts
|
|
217
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
handleRealTimeTranscription(data: Object): Promise<Object>;
|
|
220
|
+
|
|
221
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
222
|
+
// 17. Noise cancellation
|
|
223
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
enableNoiseCancellationPlugin(data: Object): Promise<Object>;
|
|
226
|
+
disableNoiseCancellationPlugin(data: Object): Promise<Object>;
|
|
227
|
+
isNoiseCancellationPluginEnabled(data: Object): Promise<Object>;
|
|
228
|
+
isNoiseCancellationPluginAvailable(data: Object): Promise<Object>;
|
|
229
|
+
|
|
230
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
231
|
+
// 18. Video plugin (virtual background, filters)
|
|
232
|
+
// Platform: iOS only. Android delegates to the separate
|
|
233
|
+
// @100mslive/react-native-video-plugin package.
|
|
234
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
enableVideoPlugin(data: Object): Promise<Object>; // iOS only
|
|
237
|
+
disableVideoPlugin(data: Object): Promise<Object>; // iOS only
|
|
238
|
+
changeVirtualBackground(data: Object): Promise<Object>; // iOS only
|
|
239
|
+
setVideoFilterParameter(data: Object): Promise<Object>; // iOS only
|
|
240
|
+
|
|
241
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
242
|
+
// 19. Misc / system / config
|
|
243
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
244
|
+
|
|
245
|
+
enableEvent(data: Object): Promise<Object>;
|
|
246
|
+
disableEvent(data: Object): Promise<Object>;
|
|
247
|
+
restrictData(data: Object): Promise<Object>;
|
|
248
|
+
getAuthTokenByRoomCode(data: Object): Promise<Object>;
|
|
249
|
+
getRoomLayout(data: Object): Promise<Object>;
|
|
250
|
+
setAlwaysScreenOn(data: Object): Promise<Object>;
|
|
251
|
+
hideSystemBars(): void; // Android only
|
|
252
|
+
showSystemBars(): void; // Android only
|
|
253
|
+
setPermissionsAccepted(data: Object): Promise<Object>; // Android only
|
|
254
|
+
checkNotifications(): Promise<Object>; // Android only
|
|
255
|
+
|
|
256
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
257
|
+
// 20. Synchronous methods
|
|
258
|
+
// These bypass the Promise queue and run on the JS thread directly.
|
|
259
|
+
// Codegen syntax: non-Promise return type signals sync.
|
|
260
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
261
|
+
|
|
262
|
+
// Cross-platform sync methods (iOS + Android)
|
|
263
|
+
getPeerProperty(data: Object): Object;
|
|
264
|
+
getRoomProperty(data: Object): Object;
|
|
265
|
+
getPeerListIterator(data: Object): Object;
|
|
266
|
+
|
|
267
|
+
// Android-only sync methods
|
|
268
|
+
setSoftInputMode(inputMode: number): number; // Android only
|
|
269
|
+
getSoftInputMode(): number; // Android only
|
|
270
|
+
|
|
271
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
272
|
+
// 21. Events — DEFERRED TO PHASE 2
|
|
273
|
+
//
|
|
274
|
+
// RN 0.77 (our current peer-dep floor) does NOT export the typed
|
|
275
|
+
// `EventEmitter<TPayload>` symbol from
|
|
276
|
+
// `react-native/Libraries/Types/CodegenTypes`; that's a 0.82+ feature.
|
|
277
|
+
//
|
|
278
|
+
// For Phase 1, events continue to flow through legacy `RCTEventEmitter`
|
|
279
|
+
// (iOS) / `DeviceEventEmitter` (Android) exactly as they do today —
|
|
280
|
+
// unchanged at runtime. They are NOT declared in this spec.
|
|
281
|
+
//
|
|
282
|
+
// When we bump the RN peer-dep floor to 0.82+ (likely as part of the
|
|
283
|
+
// Phase 4 legacy-paper drop), Phase 2 will add typed event
|
|
284
|
+
// declarations here. The 28-event inventory has been catalogued
|
|
285
|
+
// separately in the migration plan doc — no information is lost by
|
|
286
|
+
// not declaring them here today.
|
|
287
|
+
//
|
|
288
|
+
// The 28 events to add later (24 cross-platform + 4 platform-specific):
|
|
289
|
+
// onPreview, onJoin, onRoomUpdate, onPeerUpdate (string value '3'),
|
|
290
|
+
// onPeerListUpdated, onTrackUpdate, onRoleChangeRequest,
|
|
291
|
+
// onChangeTrackStateRequest, onRemovedFromRoom, onError, onMessage,
|
|
292
|
+
// onSpeaker, onReconnecting, onReconnected, onRtcStats,
|
|
293
|
+
// onLocalAudioStats, onLocalVideoStats, onRemoteAudioStats,
|
|
294
|
+
// onRemoteVideoStats, onSessionStoreAvailable,
|
|
295
|
+
// onSessionStoreChanged, onTranscripts, onPollUpdate,
|
|
296
|
+
// onWhiteboardUpdate, onAudioDeviceChanged (Android),
|
|
297
|
+
// onPermissionsRequested (Android), onPipModeChanged,
|
|
298
|
+
// onPipRoomLeave (Android).
|
|
299
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// DO NOT DELETE this default export even if it appears unused at JS runtime.
|
|
303
|
+
// React Native's Codegen statically parses this exact call shape at build time
|
|
304
|
+
// to extract the module name ('HMSManager') and emit the matching native
|
|
305
|
+
// abstract class (NativeHMSManagerSpec). Removing it fails Codegen with
|
|
306
|
+
// `UnusedModuleInterfaceParserError`.
|
|
307
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('HMSManager');
|