tirtc-devtools-cli 0.0.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/README.md +52 -0
- package/USAGE.md +417 -0
- package/bin/tirtc-devtool.js +2 -0
- package/dist/app-server/protocol-client/index.d.ts +25 -0
- package/dist/app-server/protocol-client/index.js +114 -0
- package/dist/devtools/cli/src/config.d.ts +46 -0
- package/dist/devtools/cli/src/config.js +98 -0
- package/dist/devtools/cli/src/dummy.d.ts +0 -0
- package/dist/devtools/cli/src/dummy.js +1 -0
- package/dist/devtools/cli/src/embedded_paths.d.ts +7 -0
- package/dist/devtools/cli/src/embedded_paths.js +85 -0
- package/dist/devtools/cli/src/facade.d.ts +723 -0
- package/dist/devtools/cli/src/facade.js +194 -0
- package/dist/devtools/cli/src/ffmpeg_tool.d.ts +6 -0
- package/dist/devtools/cli/src/ffmpeg_tool.js +146 -0
- package/dist/devtools/cli/src/guide.d.ts +1 -0
- package/dist/devtools/cli/src/guide.js +49 -0
- package/dist/devtools/cli/src/index.d.ts +1 -0
- package/dist/devtools/cli/src/index.js +753 -0
- package/dist/devtools/cli/src/media_assets.d.ts +25 -0
- package/dist/devtools/cli/src/media_assets.js +121 -0
- package/dist/devtools/cli/src/session_manager.d.ts +25 -0
- package/dist/devtools/cli/src/session_manager.js +393 -0
- package/dist/devtools/cli/src/token_tool.d.ts +33 -0
- package/dist/devtools/cli/src/token_tool.js +217 -0
- package/dist/devtools/cli/src/transport.d.ts +30 -0
- package/dist/devtools/cli/src/transport.js +84 -0
- package/dist/dummy.d.ts +0 -0
- package/dist/dummy.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +48 -0
- package/package.json +54 -0
- package/script/ensure_ffmpeg.sh +22 -0
- package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libtgrtc.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +56 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +20 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +53 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +89 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +115 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +236 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +57 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +46 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +32 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +34 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +398 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_codec.h +23 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_frame.h +36 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io.h +56 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_android.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_apple.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_harmony.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_windows.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_processing.h +56 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_sample_rate.h +18 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +452 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +30 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +27 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +57 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +55 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_codec.h +21 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +95 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +61 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +77 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +71 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_uplink.h +116 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +481 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +541 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_codec.h +58 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_frame.h +55 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io.h +46 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_android.h +32 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_apple.h +47 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_harmony.h +32 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_windows.h +26 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_processing.h +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.dylib +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.dylib +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libwebrtc_apm.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libxlog.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +50 -0
- package/vendor/app-server/bin/tirtc-devtool-host.js +2 -0
- package/vendor/app-server/dist/host/ArtifactManager.d.ts +18 -0
- package/vendor/app-server/dist/host/ArtifactManager.js +83 -0
- package/vendor/app-server/dist/host/HostProtocol.d.ts +107 -0
- package/vendor/app-server/dist/host/HostProtocol.js +256 -0
- package/vendor/app-server/dist/host/HostServer.d.ts +49 -0
- package/vendor/app-server/dist/host/HostServer.js +635 -0
- package/vendor/app-server/dist/host/HostState.d.ts +60 -0
- package/vendor/app-server/dist/host/HostState.js +19 -0
- package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +81 -0
- package/vendor/app-server/dist/host/RuntimeAdapter.js +559 -0
- package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +30 -0
- package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +224 -0
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +37 -0
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +186 -0
- package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +42 -0
- package/vendor/app-server/dist/host/RuntimeSendWorker.js +274 -0
- package/vendor/app-server/dist/host/TokenTool.d.ts +15 -0
- package/vendor/app-server/dist/host/TokenTool.js +84 -0
- package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +28 -0
- package/vendor/app-server/dist/host/WebPreviewGateway.js +815 -0
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +26 -0
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +118 -0
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +19 -0
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +141 -0
- package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +10 -0
- package/vendor/app-server/dist/host/runtime_backed_preflight.js +78 -0
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +28 -0
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +85 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +10 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +41 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +11 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +32 -0
- package/vendor/app-server/dist/protocol/contract.d.ts +983 -0
- package/vendor/app-server/dist/protocol/contract.js +198 -0
- package/vendor/app-server/dist/protocol-client/index.d.ts +25 -0
- package/vendor/app-server/dist/protocol-client/index.js +114 -0
- package/vendor/app-server/dist/src/index.d.ts +1 -0
- package/vendor/app-server/dist/src/index.js +294 -0
- package/vendor/runtime/script/prepare_runtime_media_dataset.sh +427 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
#ifndef TIRTC_TRANSPORT_H_
|
|
2
|
+
#define TIRTC_TRANSPORT_H_
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
#ifdef __cplusplus
|
|
8
|
+
extern "C" {
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @brief Transport API status code.
|
|
13
|
+
*/
|
|
14
|
+
typedef enum TirtcTransportStatus {
|
|
15
|
+
/** Operation succeeded. */
|
|
16
|
+
TIRTC_TRANSPORT_STATUS_OK = 0,
|
|
17
|
+
/** Input argument is invalid. */
|
|
18
|
+
TIRTC_TRANSPORT_STATUS_INVALID_ARGUMENT = 1,
|
|
19
|
+
/** Transport runtime has not been initialized. */
|
|
20
|
+
TIRTC_TRANSPORT_STATUS_NOT_INITIALIZED = 2,
|
|
21
|
+
/** Connection is not established or already closed. */
|
|
22
|
+
TIRTC_TRANSPORT_STATUS_NOT_CONNECTED = 3,
|
|
23
|
+
/** Requested operation is not supported by current backend. */
|
|
24
|
+
TIRTC_TRANSPORT_STATUS_UNSUPPORTED = 4,
|
|
25
|
+
/** Backend returned an internal error. */
|
|
26
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_ERROR = 5,
|
|
27
|
+
/** Backend reported invalid license. */
|
|
28
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_INVALID_LICENSE = 6,
|
|
29
|
+
/** Backend reported operation timeout. */
|
|
30
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_TIMEOUT = 7,
|
|
31
|
+
/** Backend reported busy/send-buffer-full. */
|
|
32
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_BUSY = 8,
|
|
33
|
+
/** Backend reported connection timeout close. */
|
|
34
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_CONNECTION_TIMEOUT_CLOSED = 9,
|
|
35
|
+
/** Backend reported remote close. */
|
|
36
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_REMOTE_CLOSED = 10,
|
|
37
|
+
/** Backend reported other connection error. */
|
|
38
|
+
TIRTC_TRANSPORT_STATUS_BACKEND_CONNECTION_OTHER_ERROR = 11,
|
|
39
|
+
} TirtcTransportStatus;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @brief Connection state visible to user callbacks.
|
|
43
|
+
*/
|
|
44
|
+
typedef enum TirtcTransportConnState {
|
|
45
|
+
/** Invalid or unknown state. */
|
|
46
|
+
TIRTC_TRANSPORT_CONN_STATE_INVALID = 0,
|
|
47
|
+
/** Connecting is in progress. */
|
|
48
|
+
TIRTC_TRANSPORT_CONN_STATE_CONNECTING = 1,
|
|
49
|
+
/** Connection is established and usable. */
|
|
50
|
+
TIRTC_TRANSPORT_CONN_STATE_CONNECTED = 2,
|
|
51
|
+
/** Connection is disconnected and no longer usable. */
|
|
52
|
+
TIRTC_TRANSPORT_CONN_STATE_DISCONNECTED = 3,
|
|
53
|
+
} TirtcTransportConnState;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Reason for disconnected state.
|
|
57
|
+
*/
|
|
58
|
+
typedef enum TirtcTransportDisconnectReason {
|
|
59
|
+
/** Unknown reason. */
|
|
60
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_UNKNOWN = 0,
|
|
61
|
+
/** Disconnected by local side. */
|
|
62
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_LOCAL_CLOSED = 1,
|
|
63
|
+
/** Disconnected by remote side. */
|
|
64
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_REMOTE_CLOSED = 2,
|
|
65
|
+
/** Connection establishment failed. */
|
|
66
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_CONNECT_FAILED = 3,
|
|
67
|
+
/** Descriptor validation failed. */
|
|
68
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_INVALID_DESCRIPTOR = 4,
|
|
69
|
+
/** Backend reported fatal error. */
|
|
70
|
+
TIRTC_TRANSPORT_DISCONNECT_REASON_BACKEND_ERROR = 5,
|
|
71
|
+
} TirtcTransportDisconnectReason;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @brief Service-level runtime event.
|
|
75
|
+
*/
|
|
76
|
+
typedef enum TirtcTransportSystemEvent {
|
|
77
|
+
/** Service runtime started. */
|
|
78
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_STARTED = 0,
|
|
79
|
+
/** Service runtime stopped. */
|
|
80
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_STOPPED = 1,
|
|
81
|
+
/** Upstream access endpoint may be hijacked/redirected. */
|
|
82
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_ACCESS_HIJACKING = 2,
|
|
83
|
+
} TirtcTransportSystemEvent;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @brief Transport media type mapped from backend media kinds.
|
|
87
|
+
*
|
|
88
|
+
* Notes:
|
|
89
|
+
* - stream_id is global per connection.
|
|
90
|
+
* - audio and video MUST NOT share the same stream_id on one connection.
|
|
91
|
+
*/
|
|
92
|
+
typedef enum TirtcTransportMediaType {
|
|
93
|
+
/** PCM audio payload. */
|
|
94
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_PCM = 1,
|
|
95
|
+
/** G.711 A-law audio payload. */
|
|
96
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_ALAW = 2,
|
|
97
|
+
/** AAC audio payload. */
|
|
98
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_AAC = 3,
|
|
99
|
+
/** Opus audio payload. */
|
|
100
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_OPUS = 4,
|
|
101
|
+
/** JPEG video payload. */
|
|
102
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_JPEG = 65,
|
|
103
|
+
/** H.264 video payload. */
|
|
104
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_H264 = 66,
|
|
105
|
+
/** H.265 video payload. */
|
|
106
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_H265 = 67,
|
|
107
|
+
/** Stream message payload (media-channel message). */
|
|
108
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_STREAM_MESSAGE = 128,
|
|
109
|
+
} TirtcTransportMediaType;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @brief Audio sample format value used in frame flags for audio streams.
|
|
113
|
+
*/
|
|
114
|
+
typedef enum TirtcTransportAudioSample {
|
|
115
|
+
/** 8 kHz, 16-bit, mono. */
|
|
116
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_8K16B1C = 0,
|
|
117
|
+
/** 16 kHz, 16-bit, mono. */
|
|
118
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_16K16B1C = 1,
|
|
119
|
+
/** 8 kHz, 16-bit, stereo. */
|
|
120
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_8K16B2C = 2,
|
|
121
|
+
/** 16 kHz, 16-bit, stereo. */
|
|
122
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_16K16B2C = 3,
|
|
123
|
+
} TirtcTransportAudioSample;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @brief Video key-frame flag for TirtcTransportFrameHeader.flags.
|
|
127
|
+
*/
|
|
128
|
+
#define TIRTC_TRANSPORT_FRAME_FLAG_KEY_FRAME 0x01
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @brief Opaque descriptor payload passed to transport backend.
|
|
132
|
+
*/
|
|
133
|
+
typedef struct TirtcTransportDescriptor {
|
|
134
|
+
/** Pointer to descriptor bytes. */
|
|
135
|
+
const void* data;
|
|
136
|
+
/** Descriptor byte length. */
|
|
137
|
+
size_t length;
|
|
138
|
+
} TirtcTransportDescriptor;
|
|
139
|
+
|
|
140
|
+
typedef struct TirtcTransportConnService TirtcTransportConnService;
|
|
141
|
+
typedef struct TirtcTransportConn TirtcTransportConn;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @brief Options for starting service runtime.
|
|
145
|
+
*/
|
|
146
|
+
typedef struct TirtcTransportConnServiceOptions {
|
|
147
|
+
/** Required transport descriptor for service runtime. */
|
|
148
|
+
const TirtcTransportDescriptor* descriptor;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @brief Maximum number of concurrently accepted connections for this
|
|
152
|
+
* service listener.
|
|
153
|
+
*
|
|
154
|
+
* This is a service-level capacity contract. It applies to the listener as a
|
|
155
|
+
* whole, not to any single connection and not to any individual stream.
|
|
156
|
+
*
|
|
157
|
+
* The current public contract requires a non-zero value.
|
|
158
|
+
*/
|
|
159
|
+
uint32_t max_connections;
|
|
160
|
+
} TirtcTransportConnServiceOptions;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @brief Options for creating outgoing connection.
|
|
164
|
+
*/
|
|
165
|
+
typedef struct TirtcTransportConnOptions {
|
|
166
|
+
/** Target peer identifier. */
|
|
167
|
+
const char* peer_id;
|
|
168
|
+
/** Required transport descriptor for client connection. */
|
|
169
|
+
const TirtcTransportDescriptor* descriptor;
|
|
170
|
+
} TirtcTransportConnOptions;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @brief Command-channel payload.
|
|
174
|
+
*
|
|
175
|
+
* Command word semantics:
|
|
176
|
+
* - sequence_number: high 16 bits
|
|
177
|
+
* - command_id: low 15 bits
|
|
178
|
+
* - is_response: request/response bit (bit15)
|
|
179
|
+
*/
|
|
180
|
+
typedef struct TirtcTransportCommand {
|
|
181
|
+
/** 16-bit command sequence number. */
|
|
182
|
+
uint16_t sequence_number;
|
|
183
|
+
/** 15-bit command identifier. */
|
|
184
|
+
uint16_t command_id;
|
|
185
|
+
/** Non-zero for response, zero for request. */
|
|
186
|
+
uint8_t is_response;
|
|
187
|
+
/** Reserved, set to zero. */
|
|
188
|
+
uint8_t reserved0;
|
|
189
|
+
/** Reserved, set to zero. */
|
|
190
|
+
uint16_t reserved1;
|
|
191
|
+
/** Command payload pointer, can be NULL when payload_length is 0. */
|
|
192
|
+
const void* payload;
|
|
193
|
+
/** Command payload bytes. */
|
|
194
|
+
size_t payload_length;
|
|
195
|
+
} TirtcTransportCommand;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @brief Unified frame header for audio/video/stream-message.
|
|
199
|
+
*/
|
|
200
|
+
typedef struct TirtcTransportFrameHeader {
|
|
201
|
+
/** Stream identifier (global unique per connection). */
|
|
202
|
+
uint8_t stream_id;
|
|
203
|
+
/** One of TirtcTransportMediaType. */
|
|
204
|
+
uint8_t media_type;
|
|
205
|
+
/** Flags; video key-frame uses TIRTC_TRANSPORT_FRAME_FLAG_KEY_FRAME. */
|
|
206
|
+
uint8_t flags;
|
|
207
|
+
/** Reserved field (mapped from backend dummy field). */
|
|
208
|
+
uint8_t reserved0;
|
|
209
|
+
/** Frame timestamp in milliseconds. */
|
|
210
|
+
uint32_t timestamp_ms;
|
|
211
|
+
/** Payload length in bytes. */
|
|
212
|
+
uint32_t payload_length;
|
|
213
|
+
} TirtcTransportFrameHeader;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @brief Audio frame wrapper.
|
|
217
|
+
*/
|
|
218
|
+
typedef struct TirtcTransportAudioFrame {
|
|
219
|
+
/** Audio frame header. */
|
|
220
|
+
TirtcTransportFrameHeader header;
|
|
221
|
+
/** Audio payload bytes. */
|
|
222
|
+
const void* payload;
|
|
223
|
+
} TirtcTransportAudioFrame;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @brief Video frame wrapper.
|
|
227
|
+
*/
|
|
228
|
+
typedef struct TirtcTransportVideoFrame {
|
|
229
|
+
/** Video frame header. */
|
|
230
|
+
TirtcTransportFrameHeader header;
|
|
231
|
+
/** Video payload bytes. */
|
|
232
|
+
const void* payload;
|
|
233
|
+
} TirtcTransportVideoFrame;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @brief Stream-message frame wrapper.
|
|
237
|
+
*/
|
|
238
|
+
typedef struct TirtcTransportStreamMessage {
|
|
239
|
+
/** Message frame header. */
|
|
240
|
+
TirtcTransportFrameHeader header;
|
|
241
|
+
/** Message payload bytes. */
|
|
242
|
+
const void* payload;
|
|
243
|
+
} TirtcTransportStreamMessage;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @brief Service observer callbacks.
|
|
247
|
+
*/
|
|
248
|
+
typedef struct TirtcTransportConnServiceObserver {
|
|
249
|
+
/** Called when service runtime is started. */
|
|
250
|
+
void (*on_started)(TirtcTransportConnService* service, void* user_data);
|
|
251
|
+
/** Called when service runtime is stopped. */
|
|
252
|
+
void (*on_stopped)(TirtcTransportConnService* service, void* user_data);
|
|
253
|
+
/** Called on system-level service event. */
|
|
254
|
+
void (*on_event)(TirtcTransportConnService* service, TirtcTransportSystemEvent event,
|
|
255
|
+
const void* data, size_t length, void* user_data);
|
|
256
|
+
/** Called when a new incoming connection is accepted by service. */
|
|
257
|
+
void (*on_connected)(TirtcTransportConnService* service, TirtcTransportConn* connection,
|
|
258
|
+
void* user_data);
|
|
259
|
+
/** Called when service-level error happens. */
|
|
260
|
+
void (*on_error)(TirtcTransportConnService* service, TirtcTransportStatus code,
|
|
261
|
+
const char* message, void* user_data);
|
|
262
|
+
} TirtcTransportConnServiceObserver;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @brief Connection observer callbacks.
|
|
266
|
+
*
|
|
267
|
+
* Callback user_data here is observer context, independent from
|
|
268
|
+
* tirtc_transport_conn_set_user_data()/get_user_data().
|
|
269
|
+
*/
|
|
270
|
+
typedef struct TirtcTransportConnObserver {
|
|
271
|
+
/** Called when connection state changes. */
|
|
272
|
+
void (*on_state_changed)(TirtcTransportConn* connection, TirtcTransportConnState state,
|
|
273
|
+
void* user_data);
|
|
274
|
+
/** Called once connection is disconnected. */
|
|
275
|
+
void (*on_disconnected)(TirtcTransportConn* connection, TirtcTransportDisconnectReason reason,
|
|
276
|
+
void* user_data);
|
|
277
|
+
/** Called when command payload is received. */
|
|
278
|
+
void (*on_command)(TirtcTransportConn* connection, const TirtcTransportCommand* command,
|
|
279
|
+
void* user_data);
|
|
280
|
+
/** Called when remote requests a key frame. */
|
|
281
|
+
void (*on_request_iframe)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
282
|
+
/**
|
|
283
|
+
* @brief Called when remote requests video stream start.
|
|
284
|
+
* @return 0 to accept, non-zero to reject.
|
|
285
|
+
*/
|
|
286
|
+
int (*on_request_video)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
287
|
+
/** Called when remote requests video stream stop. */
|
|
288
|
+
void (*on_release_video)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
289
|
+
/**
|
|
290
|
+
* @brief Called when remote requests audio stream start.
|
|
291
|
+
* @return 0 to accept, non-zero to reject.
|
|
292
|
+
*/
|
|
293
|
+
int (*on_request_audio)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
294
|
+
/** Called when remote requests audio stream stop. */
|
|
295
|
+
void (*on_release_audio)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
296
|
+
/** Called when audio frame is received. */
|
|
297
|
+
void (*on_audio_frame)(TirtcTransportConn* connection, const TirtcTransportAudioFrame* frame,
|
|
298
|
+
void* user_data);
|
|
299
|
+
/** Called when video frame is received. */
|
|
300
|
+
void (*on_video_frame)(TirtcTransportConn* connection, const TirtcTransportVideoFrame* frame,
|
|
301
|
+
void* user_data);
|
|
302
|
+
/** Called when stream message is received. */
|
|
303
|
+
void (*on_stream_message)(TirtcTransportConn* connection,
|
|
304
|
+
const TirtcTransportStreamMessage* message, void* user_data);
|
|
305
|
+
/** Called on connection-level error. */
|
|
306
|
+
void (*on_error)(TirtcTransportConn* connection, TirtcTransportStatus code, const char* message,
|
|
307
|
+
void* user_data);
|
|
308
|
+
} TirtcTransportConnObserver;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @brief Initialize transport runtime.
|
|
312
|
+
*
|
|
313
|
+
* This function is idempotent.
|
|
314
|
+
*/
|
|
315
|
+
TirtcTransportStatus tirtc_transport_init(void);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @brief Enable/disable transport debug mode.
|
|
319
|
+
*
|
|
320
|
+
* When enabled, transport backend sets verbose vendor SDK log level during runtime init
|
|
321
|
+
* and applies it immediately if runtime is already initialized.
|
|
322
|
+
*
|
|
323
|
+
* @param enabled Non-zero to enable debug mode, zero to disable.
|
|
324
|
+
* @return Operation status.
|
|
325
|
+
*/
|
|
326
|
+
TirtcTransportStatus tirtc_transport_enable_debug(uint8_t enabled);
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @brief Allocate next 16-bit command sequence number.
|
|
330
|
+
*/
|
|
331
|
+
uint16_t tirtc_transport_command_next_sequence(void);
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @brief Uninitialize transport runtime.
|
|
335
|
+
*
|
|
336
|
+
* This function is idempotent.
|
|
337
|
+
*/
|
|
338
|
+
void tirtc_transport_uninit(void);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @brief Start service runtime with descriptor and service observer.
|
|
342
|
+
*/
|
|
343
|
+
TirtcTransportStatus tirtc_transport_conn_service_start(
|
|
344
|
+
const TirtcTransportConnServiceOptions* options,
|
|
345
|
+
const TirtcTransportConnServiceObserver* observer, void* user_data,
|
|
346
|
+
TirtcTransportConnService** out_service);
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @brief Stop service runtime.
|
|
350
|
+
*/
|
|
351
|
+
TirtcTransportStatus tirtc_transport_conn_service_stop(TirtcTransportConnService* service);
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @brief Create outgoing connection.
|
|
355
|
+
*
|
|
356
|
+
* On success, returned handle enters CONNECTING first; actual connected/disconnected
|
|
357
|
+
* transition is delivered by observer callbacks.
|
|
358
|
+
*/
|
|
359
|
+
TirtcTransportStatus tirtc_transport_connect(const TirtcTransportConnOptions* options,
|
|
360
|
+
TirtcTransportConn** out_connection);
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @brief Set or replace connection observer.
|
|
364
|
+
*
|
|
365
|
+
* The implementation may synchronously replay current state/disconnected event
|
|
366
|
+
* to the new observer according to contract.
|
|
367
|
+
*/
|
|
368
|
+
TirtcTransportStatus tirtc_transport_conn_set_observer(TirtcTransportConn* connection,
|
|
369
|
+
const TirtcTransportConnObserver* observer,
|
|
370
|
+
void* user_data);
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @brief Attach a connection-level user context pointer.
|
|
374
|
+
*
|
|
375
|
+
* This is equivalent to backend connection user data mapping and is independent
|
|
376
|
+
* from observer callback user_data.
|
|
377
|
+
*/
|
|
378
|
+
TirtcTransportStatus tirtc_transport_conn_set_user_data(TirtcTransportConn* connection,
|
|
379
|
+
void* user_data);
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @brief Get connection-level user context pointer set by set_user_data.
|
|
383
|
+
*/
|
|
384
|
+
void* tirtc_transport_conn_get_user_data(TirtcTransportConn* connection);
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @brief Get current send-buffer used bytes for this connection.
|
|
388
|
+
*/
|
|
389
|
+
TirtcTransportStatus tirtc_transport_conn_get_send_buffer_used(TirtcTransportConn* connection,
|
|
390
|
+
size_t* out_bytes);
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* @brief Request local disconnect.
|
|
394
|
+
*
|
|
395
|
+
* Disconnected completion is reported by on_disconnected callback.
|
|
396
|
+
*/
|
|
397
|
+
TirtcTransportStatus tirtc_transport_disconnect(TirtcTransportConn* connection);
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* @brief Destroy transport connection handle.
|
|
401
|
+
*
|
|
402
|
+
* This releases transport-layer resources owned by this handle.
|
|
403
|
+
*/
|
|
404
|
+
void tirtc_transport_conn_destroy(TirtcTransportConn* connection);
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @brief Send command payload over command channel.
|
|
408
|
+
*/
|
|
409
|
+
TirtcTransportStatus tirtc_transport_send_command(TirtcTransportConn* connection,
|
|
410
|
+
const TirtcTransportCommand* command);
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @brief Request remote side to send a key frame for a video stream on this
|
|
414
|
+
* connection.
|
|
415
|
+
*/
|
|
416
|
+
TirtcTransportStatus tirtc_transport_request_iframe(TirtcTransportConn* connection,
|
|
417
|
+
uint8_t stream_id);
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* @brief Request remote side to start sending a video stream on this
|
|
421
|
+
* connection.
|
|
422
|
+
*
|
|
423
|
+
* The request scope is limited to the supplied ::connection and ::stream_id.
|
|
424
|
+
* It must not affect any other connection.
|
|
425
|
+
*/
|
|
426
|
+
TirtcTransportStatus tirtc_transport_request_video(TirtcTransportConn* connection,
|
|
427
|
+
uint8_t stream_id);
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @brief Request remote side to stop sending a video stream on this
|
|
431
|
+
* connection.
|
|
432
|
+
*
|
|
433
|
+
* The release scope is limited to the supplied ::connection and ::stream_id.
|
|
434
|
+
* It must not affect any other connection.
|
|
435
|
+
*/
|
|
436
|
+
TirtcTransportStatus tirtc_transport_release_video(TirtcTransportConn* connection,
|
|
437
|
+
uint8_t stream_id);
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @brief Request remote side to start sending an audio stream on this
|
|
441
|
+
* connection.
|
|
442
|
+
*
|
|
443
|
+
* The request scope is limited to the supplied ::connection and ::stream_id.
|
|
444
|
+
* It must not affect any other connection.
|
|
445
|
+
*/
|
|
446
|
+
TirtcTransportStatus tirtc_transport_request_audio(TirtcTransportConn* connection,
|
|
447
|
+
uint8_t stream_id);
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @brief Request remote side to stop sending an audio stream on this
|
|
451
|
+
* connection.
|
|
452
|
+
*
|
|
453
|
+
* The release scope is limited to the supplied ::connection and ::stream_id.
|
|
454
|
+
* It must not affect any other connection.
|
|
455
|
+
*/
|
|
456
|
+
TirtcTransportStatus tirtc_transport_release_audio(TirtcTransportConn* connection,
|
|
457
|
+
uint8_t stream_id);
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* @brief Send typed audio frame.
|
|
461
|
+
*/
|
|
462
|
+
TirtcTransportStatus tirtc_transport_send_audio_frame(TirtcTransportConn* connection,
|
|
463
|
+
const TirtcTransportAudioFrame* frame);
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @brief Send typed video frame.
|
|
467
|
+
*/
|
|
468
|
+
TirtcTransportStatus tirtc_transport_send_video_frame(TirtcTransportConn* connection,
|
|
469
|
+
const TirtcTransportVideoFrame* frame);
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* @brief Send stream-message payload in media channel.
|
|
473
|
+
*/
|
|
474
|
+
TirtcTransportStatus tirtc_transport_send_stream_message(
|
|
475
|
+
TirtcTransportConn* connection, const TirtcTransportStreamMessage* message);
|
|
476
|
+
|
|
477
|
+
#ifdef __cplusplus
|
|
478
|
+
}
|
|
479
|
+
#endif
|
|
480
|
+
|
|
481
|
+
#endif // TIRTC_TRANSPORT_H_
|