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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { TiRtcOutputBufferStrategy, TiRtcConnState, TiRtcInputState, TiRtcAudioCodec, TiRtcAudioSampleRate, TiRtcAudioChannelCount, TiRtcAudioAecMode, TiRtcAudioAgcLevel, TiRtcAudioAnsLevel, TiRtcVideoCodec, TiRtcVideoEncoderCodec, TiRtcVideoFrameRate, TiRtcCameraFacing, TiRtcVideoDecoderPreference, TiRtcVideoDecoderBackend, TiRtcVideoBitstreamFormat, TiRtcAudioOutputState, TiRtcVideoOutputState, } from './types';
|
|
2
|
+
export { TiRtc } from './runtime';
|
|
3
|
+
export { TiRtcConn } from './conn';
|
|
4
|
+
export { TiRtcAudioOutput } from './audio_output';
|
|
5
|
+
export { TiRtcVideoOutput, TiRtcVideoOutputView } from './video_output';
|
|
6
|
+
export { TiRtcAudioInput } from './audio_input';
|
|
7
|
+
export { TiRtcVideoInput, TiRtcVideoInputPreview } from './video_input';
|
|
8
|
+
export { TiRtcLogging } from './logging';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAmCjB,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NativeTiRtc } from './native';
|
|
2
|
+
const LogLevel = {
|
|
3
|
+
debug: 0,
|
|
4
|
+
info: 1,
|
|
5
|
+
warn: 2,
|
|
6
|
+
error: 3,
|
|
7
|
+
};
|
|
8
|
+
export class TiRtcLogging {
|
|
9
|
+
constructor() { }
|
|
10
|
+
static d(tag, message) {
|
|
11
|
+
NativeTiRtc.writeLog(LogLevel.debug, tag, message);
|
|
12
|
+
}
|
|
13
|
+
static i(tag, message) {
|
|
14
|
+
NativeTiRtc.writeLog(LogLevel.info, tag, message);
|
|
15
|
+
}
|
|
16
|
+
static w(tag, message) {
|
|
17
|
+
NativeTiRtc.writeLog(LogLevel.warn, tag, message);
|
|
18
|
+
}
|
|
19
|
+
static e(tag, message) {
|
|
20
|
+
NativeTiRtc.writeLog(LogLevel.error, tag, message);
|
|
21
|
+
}
|
|
22
|
+
static upload() {
|
|
23
|
+
return NativeTiRtc.uploadLogs();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAGrC,MAAM,QAAQ,GAAG;IACf,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACA,CAAC;AAEX,MAAM,OAAO,YAAY;IACvB,gBAAuB,CAAC;IAExB,MAAM,CAAC,CAAC,CAAC,GAAW,EAAE,OAAe;QACnC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,GAAW,EAAE,OAAe;QACnC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,GAAW,EAAE,OAAe;QACnC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,GAAW,EAAE,OAAe;QACnC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import NativeTiRtc from './specs/NativeTiRtc';
|
|
2
|
+
import NativeTiRtcVideoInputPreview from './specs/TiRtcVideoInputPreviewNativeComponent';
|
|
3
|
+
import NativeTiRtcVideoOutputView from './specs/TiRtcVideoOutputViewNativeComponent';
|
|
4
|
+
export { NativeTiRtc, NativeTiRtcVideoOutputView, NativeTiRtcVideoInputPreview };
|
|
5
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,+CAA+C,CAAC;AACzF,OAAO,0BAA0B,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAC,WAAW,EAAE,0BAA0B,EAAE,4BAA4B,EAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isPositiveInt32 } from './errors';
|
|
2
|
+
const nativeIdentities = new WeakMap();
|
|
3
|
+
const identityListeners = new WeakMap();
|
|
4
|
+
export function isNativeIdentity(value) {
|
|
5
|
+
return (typeof value === 'object'
|
|
6
|
+
&& value !== null
|
|
7
|
+
&& isPositiveInt32(value.objectId)
|
|
8
|
+
&& isPositiveInt32(value.generation));
|
|
9
|
+
}
|
|
10
|
+
export function setNativeIdentity(owner, identity) {
|
|
11
|
+
nativeIdentities.set(owner, identity);
|
|
12
|
+
emitNativeIdentityChanged(owner);
|
|
13
|
+
}
|
|
14
|
+
export function clearNativeIdentity(owner) {
|
|
15
|
+
nativeIdentities.delete(owner);
|
|
16
|
+
emitNativeIdentityChanged(owner);
|
|
17
|
+
}
|
|
18
|
+
export function readNativeIdentity(owner) {
|
|
19
|
+
if (typeof owner !== 'object' || owner === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return nativeIdentities.get(owner) ?? null;
|
|
23
|
+
}
|
|
24
|
+
export function readNativeObjectId(owner) {
|
|
25
|
+
return readNativeIdentity(owner)?.objectId ?? null;
|
|
26
|
+
}
|
|
27
|
+
export function subscribeNativeIdentity(owner, listener) {
|
|
28
|
+
let listeners = identityListeners.get(owner);
|
|
29
|
+
if (listeners === undefined) {
|
|
30
|
+
listeners = new Set();
|
|
31
|
+
identityListeners.set(owner, listeners);
|
|
32
|
+
}
|
|
33
|
+
listeners.add(listener);
|
|
34
|
+
return () => {
|
|
35
|
+
listeners?.delete(listener);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function emitNativeIdentityChanged(owner) {
|
|
39
|
+
const listeners = identityListeners.get(owner);
|
|
40
|
+
if (listeners === undefined) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
for (const listener of Array.from(listeners)) {
|
|
44
|
+
listener();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=native_object_id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native_object_id.js","sourceRoot":"","sources":["../../src/native_object_id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AASzC,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA0B,CAAC;AAC/D,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAuC,CAAC;AAE7E,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;WAC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AAyB,CAAC,KAAa;IAC9C,MAAM,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IACD,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isPlainObject, TIRTC_ERROR_INVALID_ARGUMENT } from './errors';
|
|
2
|
+
import { NativeTiRtc } from './native';
|
|
3
|
+
export class TiRtc {
|
|
4
|
+
constructor() { }
|
|
5
|
+
static initialize(config) {
|
|
6
|
+
if (!isPlainObject(config)) {
|
|
7
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
8
|
+
}
|
|
9
|
+
return NativeTiRtc.initialize({
|
|
10
|
+
appId: typeof config.appId === 'string' ? config.appId : '',
|
|
11
|
+
endpoint: typeof config.endpoint === 'string' ? config.endpoint : '',
|
|
12
|
+
consoleLogEnabled: typeof config.consoleLogEnabled === 'boolean'
|
|
13
|
+
? config.consoleLogEnabled
|
|
14
|
+
: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static shutdown() {
|
|
18
|
+
return NativeTiRtc.shutdown();
|
|
19
|
+
}
|
|
20
|
+
static errorToString(code) {
|
|
21
|
+
return NativeTiRtc.errorToString(code);
|
|
22
|
+
}
|
|
23
|
+
static formatError(code) {
|
|
24
|
+
return `error ${TiRtc.errorToString(code)} (${code})`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,4BAA4B,EAAC,MAAM,UAA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|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated after TypeScript emit so React Native Metro can parse Fabric props
|
|
3
|
+
* from the npm package's compiled NativeComponent.js files.
|
|
4
|
+
*
|
|
5
|
+
* @flow strict-local
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
10
|
+
import type {Int32, WithDefault} from 'react-native/Libraries/Types/CodegenTypes';
|
|
11
|
+
import type {HostComponent} from 'react-native/src/private/types/HostComponent';
|
|
12
|
+
|
|
13
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
14
|
+
|
|
15
|
+
type NativeTiRtcVideoInputPreviewProps = Readonly<{
|
|
16
|
+
...ViewProps,
|
|
17
|
+
nativeObjectId: Int32,
|
|
18
|
+
generation: Int32,
|
|
19
|
+
resizeMode?: WithDefault<'contain' | 'cover' | 'stretch', 'contain'>,
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export default codegenNativeComponent<NativeTiRtcVideoInputPreviewProps>(
|
|
23
|
+
'TiRtcVideoInputPreview',
|
|
24
|
+
) as HostComponent<NativeTiRtcVideoInputPreviewProps>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated after TypeScript emit so React Native Metro can parse Fabric props
|
|
3
|
+
* from the npm package's compiled NativeComponent.js files.
|
|
4
|
+
*
|
|
5
|
+
* @flow strict-local
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
10
|
+
import type {Int32, WithDefault} from 'react-native/Libraries/Types/CodegenTypes';
|
|
11
|
+
import type {HostComponent} from 'react-native/src/private/types/HostComponent';
|
|
12
|
+
|
|
13
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
14
|
+
|
|
15
|
+
type NativeTiRtcVideoOutputViewProps = Readonly<{
|
|
16
|
+
...ViewProps,
|
|
17
|
+
nativeObjectId: Int32,
|
|
18
|
+
generation: Int32,
|
|
19
|
+
resizeMode?: WithDefault<'contain' | 'cover' | 'stretch', 'contain'>,
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export default codegenNativeComponent<NativeTiRtcVideoOutputViewProps>(
|
|
23
|
+
'TiRtcVideoOutputView',
|
|
24
|
+
) as HostComponent<NativeTiRtcVideoOutputViewProps>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const TiRtcOutputBufferStrategy = {
|
|
2
|
+
automatic: 'automatic',
|
|
3
|
+
noBuffer: 'noBuffer',
|
|
4
|
+
};
|
|
5
|
+
export const TiRtcConnState = {
|
|
6
|
+
idle: 'idle',
|
|
7
|
+
connecting: 'connecting',
|
|
8
|
+
connected: 'connected',
|
|
9
|
+
disconnected: 'disconnected',
|
|
10
|
+
};
|
|
11
|
+
export const TiRtcInputState = {
|
|
12
|
+
idle: 'idle',
|
|
13
|
+
running: 'running',
|
|
14
|
+
stopped: 'stopped',
|
|
15
|
+
failed: 'failed',
|
|
16
|
+
};
|
|
17
|
+
export const TiRtcAudioCodec = {
|
|
18
|
+
g711a: 'g711a',
|
|
19
|
+
aac: 'aac',
|
|
20
|
+
pcm: 'pcm',
|
|
21
|
+
opus: 'opus',
|
|
22
|
+
amr: 'amr',
|
|
23
|
+
};
|
|
24
|
+
export const TiRtcAudioSampleRate = {
|
|
25
|
+
rate8k: 'rate8k',
|
|
26
|
+
rate16k: 'rate16k',
|
|
27
|
+
};
|
|
28
|
+
export const TiRtcAudioChannelCount = {
|
|
29
|
+
mono: 'mono',
|
|
30
|
+
};
|
|
31
|
+
export const TiRtcAudioAecMode = {
|
|
32
|
+
disabled: 'disabled',
|
|
33
|
+
enabled: 'enabled',
|
|
34
|
+
};
|
|
35
|
+
export const TiRtcAudioAgcLevel = {
|
|
36
|
+
disabled: 'disabled',
|
|
37
|
+
low: 'low',
|
|
38
|
+
medium: 'medium',
|
|
39
|
+
high: 'high',
|
|
40
|
+
};
|
|
41
|
+
export const TiRtcAudioAnsLevel = {
|
|
42
|
+
disabled: 'disabled',
|
|
43
|
+
low: 'low',
|
|
44
|
+
medium: 'medium',
|
|
45
|
+
high: 'high',
|
|
46
|
+
};
|
|
47
|
+
export const TiRtcVideoCodec = {
|
|
48
|
+
h264: 'h264',
|
|
49
|
+
h265: 'h265',
|
|
50
|
+
mjpeg: 'mjpeg',
|
|
51
|
+
};
|
|
52
|
+
export const TiRtcVideoEncoderCodec = {
|
|
53
|
+
h264: 'h264',
|
|
54
|
+
mjpeg: 'mjpeg',
|
|
55
|
+
};
|
|
56
|
+
export const TiRtcVideoFrameRate = {
|
|
57
|
+
fps10: 'fps10',
|
|
58
|
+
fps15: 'fps15',
|
|
59
|
+
fps30: 'fps30',
|
|
60
|
+
};
|
|
61
|
+
export const TiRtcCameraFacing = {
|
|
62
|
+
front: 'front',
|
|
63
|
+
back: 'back',
|
|
64
|
+
};
|
|
65
|
+
export const TiRtcVideoDecoderPreference = {
|
|
66
|
+
auto: 'auto',
|
|
67
|
+
software: 'software',
|
|
68
|
+
hardware: 'hardware',
|
|
69
|
+
};
|
|
70
|
+
export const TiRtcVideoDecoderBackend = {
|
|
71
|
+
unknown: 'unknown',
|
|
72
|
+
software: 'software',
|
|
73
|
+
hardware: 'hardware',
|
|
74
|
+
};
|
|
75
|
+
export const TiRtcVideoBitstreamFormat = {
|
|
76
|
+
unknown: 'unknown',
|
|
77
|
+
h264AnnexB: 'h264AnnexB',
|
|
78
|
+
h265AnnexB: 'h265AnnexB',
|
|
79
|
+
mjpegJfif: 'mjpegJfif',
|
|
80
|
+
};
|
|
81
|
+
export const TiRtcAudioOutputState = {
|
|
82
|
+
idle: 'idle',
|
|
83
|
+
buffering: 'buffering',
|
|
84
|
+
playing: 'playing',
|
|
85
|
+
failed: 'failed',
|
|
86
|
+
};
|
|
87
|
+
export const TiRtcVideoOutputState = {
|
|
88
|
+
idle: 'idle',
|
|
89
|
+
buffering: 'buffering',
|
|
90
|
+
rendering: 'rendering',
|
|
91
|
+
failed: 'failed',
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,YAAY;IACxB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;CACpB,CAAC;AAGX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACR,CAAC;AAGX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC;AAGX,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;CACJ,CAAC;AAIX,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC;AAGX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACJ,CAAC;AAI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;IACtB,MAAM,EAAE,QAAQ;CACR,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { isPlainObject, isPositiveInt32Size, isUInt8, normalizeCreateResult, returnReleasedIfDisposed, TIRTC_ERROR_INVALID_ARGUMENT, TIRTC_ERROR_OK, TIRTC_HOST_ERROR_OBJECT_RELEASED, } from './errors';
|
|
4
|
+
import { registerNativeEventHandler, unregisterNativeEventHandler } from './events';
|
|
5
|
+
import { clearNativeIdentity, readNativeIdentity, setNativeIdentity, subscribeNativeIdentity, } from './native_object_id';
|
|
6
|
+
import { NativeTiRtc, NativeTiRtcVideoInputPreview } from './native';
|
|
7
|
+
export class TiRtcVideoInput {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.identity = null;
|
|
10
|
+
this.disposed = false;
|
|
11
|
+
this.createCode = TIRTC_ERROR_OK;
|
|
12
|
+
this.queue = Promise.resolve();
|
|
13
|
+
this.currentState = 'idle';
|
|
14
|
+
this.currentOutputSize = null;
|
|
15
|
+
this.currentOutputFps = null;
|
|
16
|
+
this.options = {
|
|
17
|
+
codec: 'h264',
|
|
18
|
+
width: 640,
|
|
19
|
+
height: 480,
|
|
20
|
+
frameRate: 'fps15',
|
|
21
|
+
bitrateKbps: 0,
|
|
22
|
+
cameraFacing: 'front',
|
|
23
|
+
};
|
|
24
|
+
this.onStateChanged = null;
|
|
25
|
+
this.onActualConfigChanged = null;
|
|
26
|
+
this.onError = null;
|
|
27
|
+
const result = normalizeCreateResult(NativeTiRtc.createVideoInput());
|
|
28
|
+
this.createCode = result.code;
|
|
29
|
+
if (result.code === TIRTC_ERROR_OK) {
|
|
30
|
+
this.adoptIdentity({ objectId: result.objectId, generation: result.generation });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
get state() {
|
|
34
|
+
if (this.identity !== null && !this.disposed) {
|
|
35
|
+
const result = NativeTiRtc.videoInputGetState(this.identity.objectId);
|
|
36
|
+
if (result.state !== null) {
|
|
37
|
+
this.currentState = result.state;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return this.currentState;
|
|
41
|
+
}
|
|
42
|
+
get outputSize() {
|
|
43
|
+
this.refreshActualConfig();
|
|
44
|
+
return this.currentOutputSize;
|
|
45
|
+
}
|
|
46
|
+
get outputFps() {
|
|
47
|
+
this.refreshActualConfig();
|
|
48
|
+
return this.currentOutputFps;
|
|
49
|
+
}
|
|
50
|
+
setOptions(options) {
|
|
51
|
+
if (!isPlainObject(options)) {
|
|
52
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
53
|
+
}
|
|
54
|
+
const normalized = {
|
|
55
|
+
codec: options.codec ?? 'h264',
|
|
56
|
+
width: options.width ?? 640,
|
|
57
|
+
height: options.height ?? 480,
|
|
58
|
+
frameRate: options.frameRate ?? 'fps15',
|
|
59
|
+
bitrateKbps: options.bitrateKbps ?? 0,
|
|
60
|
+
cameraFacing: options.cameraFacing ?? 'front',
|
|
61
|
+
};
|
|
62
|
+
if (!isPositiveInt32Size(normalized.width)
|
|
63
|
+
|| !isPositiveInt32Size(normalized.height)
|
|
64
|
+
|| !Number.isSafeInteger(normalized.bitrateKbps)
|
|
65
|
+
|| normalized.bitrateKbps < 0
|
|
66
|
+
|| normalized.bitrateKbps > 4294967295) {
|
|
67
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
68
|
+
}
|
|
69
|
+
return this.enqueue(async () => {
|
|
70
|
+
const identity = this.ensureIdentity();
|
|
71
|
+
if (typeof identity === 'number') {
|
|
72
|
+
return identity;
|
|
73
|
+
}
|
|
74
|
+
const code = await NativeTiRtc.videoInputSetOptions(identity.objectId, normalized);
|
|
75
|
+
if (code === TIRTC_ERROR_OK) {
|
|
76
|
+
this.options = normalized;
|
|
77
|
+
}
|
|
78
|
+
return code;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
start() {
|
|
82
|
+
return this.enqueue(async () => {
|
|
83
|
+
const identity = this.ensureIdentity();
|
|
84
|
+
if (typeof identity === 'number') {
|
|
85
|
+
return identity;
|
|
86
|
+
}
|
|
87
|
+
return NativeTiRtc.videoInputStart(identity.objectId);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
attach(connection, streamId) {
|
|
91
|
+
const connIdentity = readNativeIdentity(connection);
|
|
92
|
+
if (!isUInt8(streamId)) {
|
|
93
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
94
|
+
}
|
|
95
|
+
if (connIdentity === null) {
|
|
96
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
97
|
+
}
|
|
98
|
+
return this.enqueue(async () => {
|
|
99
|
+
const identity = this.ensureIdentity();
|
|
100
|
+
if (typeof identity === 'number') {
|
|
101
|
+
return identity;
|
|
102
|
+
}
|
|
103
|
+
return NativeTiRtc.videoInputAttach(identity.objectId, connIdentity.objectId, streamId);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
detach(connection) {
|
|
107
|
+
const connIdentity = readNativeIdentity(connection);
|
|
108
|
+
if (connIdentity === null) {
|
|
109
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
110
|
+
}
|
|
111
|
+
return this.enqueue(async () => {
|
|
112
|
+
if (this.identity === null) {
|
|
113
|
+
return TIRTC_ERROR_OK;
|
|
114
|
+
}
|
|
115
|
+
return NativeTiRtc.videoInputDetach(this.identity.objectId, connIdentity.objectId);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
stop() {
|
|
119
|
+
return this.enqueue(async () => {
|
|
120
|
+
if (this.identity === null) {
|
|
121
|
+
return TIRTC_ERROR_OK;
|
|
122
|
+
}
|
|
123
|
+
return NativeTiRtc.videoInputStop(this.identity.objectId);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a React element bound to this input owner.
|
|
128
|
+
*
|
|
129
|
+
* The returned element renders a placeholder until this input has a live
|
|
130
|
+
* native identity. Configure and start the input before expecting camera
|
|
131
|
+
* frames, and dispose the input when capture is no longer needed.
|
|
132
|
+
*/
|
|
133
|
+
preview(props = {}) {
|
|
134
|
+
return React.createElement(TiRtcVideoInputPreview, {
|
|
135
|
+
...props,
|
|
136
|
+
input: this,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
dispose() {
|
|
140
|
+
if (this.disposed) {
|
|
141
|
+
return Promise.resolve(TIRTC_ERROR_OK);
|
|
142
|
+
}
|
|
143
|
+
return this.enqueue(async () => {
|
|
144
|
+
if (this.identity === null) {
|
|
145
|
+
this.disposed = true;
|
|
146
|
+
this.clearCallbacks();
|
|
147
|
+
this.currentState = 'stopped';
|
|
148
|
+
this.currentOutputSize = null;
|
|
149
|
+
this.currentOutputFps = null;
|
|
150
|
+
return TIRTC_ERROR_OK;
|
|
151
|
+
}
|
|
152
|
+
const identity = this.identity;
|
|
153
|
+
const code = await NativeTiRtc.videoInputDispose(identity.objectId);
|
|
154
|
+
if (code === TIRTC_ERROR_OK) {
|
|
155
|
+
this.disposed = true;
|
|
156
|
+
this.identity = null;
|
|
157
|
+
unregisterNativeEventHandler(identity);
|
|
158
|
+
clearNativeIdentity(this);
|
|
159
|
+
this.clearCallbacks();
|
|
160
|
+
this.currentState = 'stopped';
|
|
161
|
+
this.currentOutputSize = null;
|
|
162
|
+
this.currentOutputFps = null;
|
|
163
|
+
}
|
|
164
|
+
return code;
|
|
165
|
+
}, true);
|
|
166
|
+
}
|
|
167
|
+
enqueue(operation, allowDisposed = false) {
|
|
168
|
+
const released = returnReleasedIfDisposed(this.disposed);
|
|
169
|
+
if (released !== null && !allowDisposed) {
|
|
170
|
+
return Promise.resolve(released);
|
|
171
|
+
}
|
|
172
|
+
const next = this.queue.then(async () => {
|
|
173
|
+
if (this.disposed && !allowDisposed) {
|
|
174
|
+
return TIRTC_HOST_ERROR_OBJECT_RELEASED;
|
|
175
|
+
}
|
|
176
|
+
return operation();
|
|
177
|
+
});
|
|
178
|
+
this.queue = next.catch(() => undefined);
|
|
179
|
+
return next;
|
|
180
|
+
}
|
|
181
|
+
ensureIdentity() {
|
|
182
|
+
const released = returnReleasedIfDisposed(this.disposed);
|
|
183
|
+
if (released !== null) {
|
|
184
|
+
return released;
|
|
185
|
+
}
|
|
186
|
+
if (this.identity !== null) {
|
|
187
|
+
return this.identity;
|
|
188
|
+
}
|
|
189
|
+
return this.createCode;
|
|
190
|
+
}
|
|
191
|
+
adoptIdentity(identity) {
|
|
192
|
+
this.identity = identity;
|
|
193
|
+
setNativeIdentity(this, identity);
|
|
194
|
+
registerNativeEventHandler(identity, (event) => this.handleEvent(event));
|
|
195
|
+
void NativeTiRtc.videoInputSetOptions(identity.objectId, this.options);
|
|
196
|
+
}
|
|
197
|
+
refreshActualConfig() {
|
|
198
|
+
if (this.disposed || this.identity === null) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const result = NativeTiRtc.videoInputGetActualConfig(this.identity.objectId);
|
|
202
|
+
this.currentOutputSize = result.size;
|
|
203
|
+
this.currentOutputFps = result.fps;
|
|
204
|
+
}
|
|
205
|
+
clearCallbacks() {
|
|
206
|
+
this.onStateChanged = null;
|
|
207
|
+
this.onActualConfigChanged = null;
|
|
208
|
+
this.onError = null;
|
|
209
|
+
}
|
|
210
|
+
handleEvent(event) {
|
|
211
|
+
if (this.disposed) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
switch (event.type) {
|
|
215
|
+
case 'videoInputStateChanged':
|
|
216
|
+
if (event.state !== undefined) {
|
|
217
|
+
this.currentState = event.state;
|
|
218
|
+
this.onStateChanged?.(this.currentState);
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
case 'videoInputActualConfigChanged':
|
|
222
|
+
if (event.size !== undefined && event.fps !== undefined) {
|
|
223
|
+
this.currentOutputSize = event.size;
|
|
224
|
+
this.currentOutputFps = event.fps;
|
|
225
|
+
this.onActualConfigChanged?.(event.size, event.fps);
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
case 'videoInputError':
|
|
229
|
+
this.onError?.(event.code ?? TIRTC_ERROR_INVALID_ARGUMENT, event.message ?? null);
|
|
230
|
+
break;
|
|
231
|
+
default:
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Renders the local preview surface for a `TiRtcVideoInput`.
|
|
238
|
+
*
|
|
239
|
+
* The component observes the owner identity and never accepts raw native ids.
|
|
240
|
+
* If the owner is not created, has been disposed, or is not a `TiRtcVideoInput`,
|
|
241
|
+
* it renders a regular `View` with the remaining props.
|
|
242
|
+
*/
|
|
243
|
+
export function TiRtcVideoInputPreview(props) {
|
|
244
|
+
const { input, resizeMode = 'contain', ...viewProps } = props;
|
|
245
|
+
const identity = useOwnerIdentity(input instanceof TiRtcVideoInput ? input : null);
|
|
246
|
+
if (identity === null) {
|
|
247
|
+
return React.createElement(View, viewProps);
|
|
248
|
+
}
|
|
249
|
+
return React.createElement(NativeTiRtcVideoInputPreview, {
|
|
250
|
+
...viewProps,
|
|
251
|
+
nativeObjectId: identity.objectId,
|
|
252
|
+
generation: identity.generation,
|
|
253
|
+
resizeMode,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function useOwnerIdentity(owner) {
|
|
257
|
+
const [, forceUpdate] = React.useReducer((value) => value + 1, 0);
|
|
258
|
+
React.useEffect(() => {
|
|
259
|
+
if (owner === null) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
return subscribeNativeIdentity(owner, forceUpdate);
|
|
263
|
+
}, [owner]);
|
|
264
|
+
return owner === null ? null : readNativeIdentity(owner);
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=video_input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video_input.js","sourceRoot":"","sources":["../../src/video_input.ts"],"names":[],"mappings":"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