tirtc-react-native 2.2.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.
- package/LICENSE +11 -0
- package/README.md +140 -0
- package/TiRtcReactNative.podspec +35 -0
- package/android/build.gradle +37 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +482 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcPackage.kt +43 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeErrors.kt +32 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +99 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +168 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +49 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMetricsMaps.kt +173 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeModuleSupport.kt +91 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeOptions.kt +127 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +71 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoInputPreviewManager.kt +109 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +109 -0
- package/ios/TiRtcReactNative+Conn.mm +112 -0
- package/ios/TiRtcReactNative+Input.mm +196 -0
- package/ios/TiRtcReactNative+Output.mm +172 -0
- package/ios/TiRtcReactNative+Private.h +28 -0
- package/ios/TiRtcReactNative.h +6 -0
- package/ios/TiRtcReactNative.mm +189 -0
- package/ios/TiRtcReactNativeErrors.h +18 -0
- package/ios/TiRtcReactNativeErrors.mm +105 -0
- package/ios/TiRtcReactNativeEventBinder.h +19 -0
- package/ios/TiRtcReactNativeEventBinder.mm +226 -0
- package/ios/TiRtcReactNativeEventSink.h +29 -0
- package/ios/TiRtcReactNativeEventSink.mm +125 -0
- package/ios/TiRtcReactNativeMaps.h +21 -0
- package/ios/TiRtcReactNativeMaps.mm +249 -0
- package/ios/TiRtcReactNativeNative.h +8 -0
- package/ios/TiRtcReactNativeOptions.h +11 -0
- package/ios/TiRtcReactNativeOptions.mm +123 -0
- package/ios/TiRtcReactNativeRegistry.h +20 -0
- package/ios/TiRtcReactNativeRegistry.mm +119 -0
- package/ios/TiRtcVideoInputPreview.h +5 -0
- package/ios/TiRtcVideoInputPreview.mm +149 -0
- package/ios/TiRtcVideoOutputView.h +5 -0
- package/ios/TiRtcVideoOutputView.mm +149 -0
- package/lib/module/audio_input.js +177 -0
- package/lib/module/audio_input.js.map +1 -0
- package/lib/module/audio_output.js +168 -0
- package/lib/module/audio_output.js.map +1 -0
- package/lib/module/conn.js +174 -0
- package/lib/module/conn.js.map +1 -0
- package/lib/module/errors.js +63 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/events.js +37 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/logging.js +26 -0
- package/lib/module/logging.js.map +1 -0
- package/lib/module/native.js +5 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/native_object_id.js +47 -0
- package/lib/module/native_object_id.js.map +1 -0
- package/lib/module/runtime.js +27 -0
- package/lib/module/runtime.js.map +1 -0
- package/lib/module/specs/NativeTiRtc.js +3 -0
- package/lib/module/specs/NativeTiRtc.js.map +1 -0
- package/lib/module/specs/TiRtcVideoInputPreviewNativeComponent.js +24 -0
- package/lib/module/specs/TiRtcVideoOutputViewNativeComponent.js +24 -0
- package/lib/module/types.js +93 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/video_input.js +266 -0
- package/lib/module/video_input.js.map +1 -0
- package/lib/module/video_output.js +224 -0
- package/lib/module/video_output.js.map +1 -0
- package/lib/typescript/audio_input.d.ts +25 -0
- package/lib/typescript/audio_output.d.ts +25 -0
- package/lib/typescript/conn.d.ts +28 -0
- package/lib/typescript/errors.d.ts +19 -0
- package/lib/typescript/events.d.ts +6 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/logging.d.ts +9 -0
- package/lib/typescript/native.d.ts +5 -0
- package/lib/typescript/native_object_id.d.ts +12 -0
- package/lib/typescript/runtime.d.ts +8 -0
- package/lib/typescript/specs/NativeTiRtc.d.ts +223 -0
- package/lib/typescript/specs/TiRtcVideoInputPreviewNativeComponent.d.ts +8 -0
- package/lib/typescript/specs/TiRtcVideoOutputViewNativeComponent.d.ts +8 -0
- package/lib/typescript/types.d.ts +281 -0
- package/lib/typescript/video_input.d.ts +50 -0
- package/lib/typescript/video_output.d.ts +46 -0
- package/package.json +80 -0
- package/react-native.config.js +10 -0
- package/src/audio_input.ts +205 -0
- package/src/audio_output.ts +202 -0
- package/src/conn.ts +222 -0
- package/src/errors.ts +81 -0
- package/src/events.ts +44 -0
- package/src/index.ts +61 -0
- package/src/logging.ts +33 -0
- package/src/native.ts +6 -0
- package/src/native_object_id.ts +63 -0
- package/src/runtime.ts +32 -0
- package/src/specs/NativeTiRtc.ts +256 -0
- package/src/specs/TiRtcVideoInputPreviewNativeComponent.ts +14 -0
- package/src/specs/TiRtcVideoOutputViewNativeComponent.ts +12 -0
- package/src/types.ts +340 -0
- package/src/video_input.ts +314 -0
- package/src/video_output.ts +273 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Tange AI
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
3. Neither the name of Tange AI nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# TiRTC React Native SDK
|
|
2
|
+
|
|
3
|
+
`tirtc-react-native` is the TiRTC React Native New Architecture package for Android and iOS.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install tirtc-react-native
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The package ships ESM JavaScript, TypeScript declarations, Codegen specs, Android native wrapper code and iOS native wrapper code. It requires React Native `>=0.80.0`, Android `com.tange.ai:tirtc:2.2.9`, and iOS `TiRTC` `2.2.9` with iOS minimum `15.1`.
|
|
10
|
+
|
|
11
|
+
Version `2.2.0` is a stable React Native release focused on client media output, client voice talkback and client video uplink primitives.
|
|
12
|
+
|
|
13
|
+
## Imports
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
TiRtc,
|
|
18
|
+
TiRtcConn,
|
|
19
|
+
TiRtcAudioInput,
|
|
20
|
+
TiRtcVideoInput,
|
|
21
|
+
TiRtcAudioOutput,
|
|
22
|
+
TiRtcVideoOutput,
|
|
23
|
+
TiRtcVideoOutputView,
|
|
24
|
+
TiRtcVideoInputPreview,
|
|
25
|
+
TiRtcAudioCodec,
|
|
26
|
+
TiRtcVideoCodec,
|
|
27
|
+
} from 'tirtc-react-native';
|
|
28
|
+
|
|
29
|
+
import * as TiRtc from 'tirtc-react-native';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The root export is the public API. Deep imports are not supported.
|
|
33
|
+
|
|
34
|
+
## Semantic Values
|
|
35
|
+
|
|
36
|
+
String values are exported as stable `as const` objects and matching TypeScript union types:
|
|
37
|
+
|
|
38
|
+
`TiRtcOutputBufferStrategy`, `TiRtcConnState`, `TiRtcInputState`, `TiRtcAudioCodec`, `TiRtcAudioSampleRate`, `TiRtcAudioChannelCount`, `TiRtcAudioAecMode`, `TiRtcAudioAgcLevel`, `TiRtcAudioAnsLevel`, `TiRtcVideoCodec`, `TiRtcVideoEncoderCodec`, `TiRtcVideoFrameRate`, `TiRtcCameraFacing`, `TiRtcVideoDecoderPreference`, `TiRtcVideoDecoderBackend`, `TiRtcVideoBitstreamFormat`, `TiRtcAudioOutputState`, `TiRtcVideoOutputState`.
|
|
39
|
+
|
|
40
|
+
Use the exported values instead of hard-coded strings in app code.
|
|
41
|
+
|
|
42
|
+
## Permissions
|
|
43
|
+
|
|
44
|
+
Applications own runtime permissions and platform entitlement setup before starting capture or output:
|
|
45
|
+
|
|
46
|
+
- Android: camera, microphone, network and foreground execution policy required by the host app.
|
|
47
|
+
- iOS: camera and microphone usage descriptions, user permission prompts and background behavior required by the host app.
|
|
48
|
+
|
|
49
|
+
The SDK reports platform failures through numeric TiRTC return codes and callbacks; it does not request permissions on the app's behalf.
|
|
50
|
+
|
|
51
|
+
## Minimal Client
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import React from 'react';
|
|
55
|
+
import {TiRtc, TiRtcConn, TiRtcVideoOutput, TiRtcVideoOutputView} from 'tirtc-react-native';
|
|
56
|
+
|
|
57
|
+
await TiRtc.initialize({appId, endpoint});
|
|
58
|
+
|
|
59
|
+
const conn = new TiRtcConn();
|
|
60
|
+
const videoOutput = new TiRtcVideoOutput();
|
|
61
|
+
videoOutput.attach(conn, streamId);
|
|
62
|
+
|
|
63
|
+
conn.onStateChanged = (state, errorCode) => {
|
|
64
|
+
if (errorCode !== 0) {
|
|
65
|
+
console.warn(TiRtc.formatError(errorCode));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
conn.connect(remoteDeviceId, token);
|
|
70
|
+
|
|
71
|
+
export function RemoteVideo() {
|
|
72
|
+
return <TiRtcVideoOutputView output={videoOutput} resizeMode="contain" />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Dispose in reverse ownership order:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
videoOutput.detach();
|
|
80
|
+
videoOutput.dispose();
|
|
81
|
+
conn.disconnect();
|
|
82
|
+
conn.dispose();
|
|
83
|
+
TiRtc.shutdown();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Client Voice Talkback
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import {TiRtcAudioCodec, TiRtcAudioInput} from 'tirtc-react-native';
|
|
90
|
+
|
|
91
|
+
const audioInput = new TiRtcAudioInput();
|
|
92
|
+
|
|
93
|
+
await audioInput.setOptions({
|
|
94
|
+
codec: TiRtcAudioCodec.g711a,
|
|
95
|
+
});
|
|
96
|
+
await audioInput.attach(conn, talkbackStreamId);
|
|
97
|
+
await audioInput.start();
|
|
98
|
+
|
|
99
|
+
await audioInput.stop();
|
|
100
|
+
await audioInput.detach(conn);
|
|
101
|
+
await audioInput.dispose();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Client Video Uplink Primitives
|
|
105
|
+
|
|
106
|
+
`TiRtcVideoInput`, `TiRtcVideoInputPreview` and the video input option values are exported for client-side video uplink integration.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import {TiRtcVideoInput, TiRtcVideoInputPreview} from 'tirtc-react-native';
|
|
110
|
+
|
|
111
|
+
const videoInput = new TiRtcVideoInput();
|
|
112
|
+
|
|
113
|
+
export function LocalPreview() {
|
|
114
|
+
return <TiRtcVideoInputPreview input={videoInput} resizeMode="contain" />;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Errors And Lifecycle
|
|
119
|
+
|
|
120
|
+
Public methods return numeric TiRTC codes instead of throwing for SDK failures. `0` means success. Use `TiRtc.errorToString(code)` or `TiRtc.formatError(code)` for display and logs.
|
|
121
|
+
|
|
122
|
+
Constructors create native owner identities, so outputs and inputs can attach to a `TiRtcConn` before `connect(...)`. `dispose()` releases the native object only after the underlying stop/destroy call returns success. Calling `dispose()` again after success is valid and returns success; methods called after a successful dispose return the object released code. Input/output/view ownership is tracked by native object id plus generation so stale callbacks or recycled ids do not attach to a newer object.
|
|
123
|
+
|
|
124
|
+
## Release
|
|
125
|
+
|
|
126
|
+
Version `2.2.0` is the current React Native package for TiRTC client media output and talkback. It supports React Native New Architecture apps on Android and iOS and pins Android `com.tange.ai:tirtc:2.2.9` and iOS `TiRTC` `2.2.9`.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
This npm package is licensed as BSD-3-Clause. The BSD-3-Clause license covers the React Native wrapper/source distributed in this package. Native TiRTC runtime binaries consumed by the Android and iOS dependencies are governed by their own distributed terms.
|
|
131
|
+
|
|
132
|
+
## Package Validation
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
npm run lint
|
|
136
|
+
npm test
|
|
137
|
+
npm run typecheck
|
|
138
|
+
npm run build
|
|
139
|
+
npm run codegen:check
|
|
140
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'TiRtcReactNative'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.homepage = 'https://tange.ai/'
|
|
10
|
+
s.license = { :type => 'BSD-3-Clause', :file => 'LICENSE' }
|
|
11
|
+
s.author = 'Tange AI'
|
|
12
|
+
s.platforms = { :ios => '15.1' }
|
|
13
|
+
s.source = { :git => 'https://gitlab.tange-ai.com/tirtc-nexus/tirtc.git', :tag => s.version.to_s }
|
|
14
|
+
s.source_files = 'ios/**/*.{h,m,mm,swift}'
|
|
15
|
+
s.dependency 'React-Core'
|
|
16
|
+
s.dependency 'TiRTC', '2.2.9'
|
|
17
|
+
|
|
18
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
else
|
|
21
|
+
s.dependency 'React-RCTFabric'
|
|
22
|
+
s.dependency 'React-Codegen'
|
|
23
|
+
s.dependency 'RCTRequired'
|
|
24
|
+
s.dependency 'RCTTypeSafety'
|
|
25
|
+
s.dependency 'ReactCommon/turbomodule/bridging'
|
|
26
|
+
s.dependency 'ReactCommon/turbomodule/core'
|
|
27
|
+
s.dependency 'React-NativeModulesApple'
|
|
28
|
+
s.dependency 'Yoga'
|
|
29
|
+
s.dependency 'React-Fabric'
|
|
30
|
+
s.dependency 'React-graphics'
|
|
31
|
+
s.dependency 'React-utils'
|
|
32
|
+
s.dependency 'React-featureflags'
|
|
33
|
+
s.dependency 'React-debug'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath("com.android.tools.build:gradle:8.8.2")
|
|
8
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21")
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: "com.android.library"
|
|
13
|
+
apply plugin: "com.facebook.react"
|
|
14
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
15
|
+
|
|
16
|
+
android {
|
|
17
|
+
namespace "com.tange.ai.tirtc.reactnative"
|
|
18
|
+
compileSdk 35
|
|
19
|
+
|
|
20
|
+
defaultConfig {
|
|
21
|
+
minSdk 23
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
repositories {
|
|
26
|
+
google()
|
|
27
|
+
mavenCentral()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dependencies {
|
|
31
|
+
implementation "com.facebook.react:react-android"
|
|
32
|
+
implementation "com.tange.ai:tirtc:${safeExtGet("tirtcAndroidVersion", "2.2.9")}"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def safeExtGet(prop, fallback) {
|
|
36
|
+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|