tirtc-devtools-cli 0.0.10 → 0.0.12
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 +17 -11
- package/USAGE.md +148 -41
- package/bin/tirtc-devtools-cli.js +1 -1
- package/dist/cli/src/bootstrap_flows.d.ts +46 -0
- package/dist/cli/src/bootstrap_flows.js +249 -0
- package/dist/{devtools/cli → cli}/src/config.d.ts +4 -15
- package/dist/{devtools/cli → cli}/src/config.js +8 -8
- package/dist/cli/src/default_paths.d.ts +3 -0
- package/dist/cli/src/default_paths.js +23 -0
- package/dist/{devtools/cli → cli}/src/embedded_paths.d.ts +1 -0
- package/dist/{devtools/cli → cli}/src/embedded_paths.js +18 -1
- package/dist/{devtools/cli → cli}/src/facade.d.ts +41 -235
- package/dist/{devtools/cli → cli}/src/facade.js +8 -27
- package/dist/cli/src/guide.js +47 -0
- package/dist/{devtools/cli → cli}/src/index.js +67 -153
- package/dist/{devtools/cli → cli}/src/session_manager.js +9 -11
- package/dist/{devtools/cli → cli}/src/token_command.js +80 -16
- package/dist/cli/src/token_tool.d.ts +55 -0
- package/dist/{devtools/cli → cli}/src/token_tool.js +143 -47
- package/dist/{devtools/cli → cli}/src/transport.d.ts +1 -1
- package/package.json +6 -2
- package/script/ensure_ffmpeg.sh +1 -1
- package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
- package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +34 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +13 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/foundation/build_info.h +27 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/http.h +57 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +3 -1
- package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.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/libssl.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +2 -32
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +44 -305
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +52 -372
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +2 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +6 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +58 -133
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +56 -511
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libTGTRP.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libTiRTC.a +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/manifest.txt +19 -15
- package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +19 -0
- package/vendor/app-server/dist/host/HostCommandCoordinator.js +196 -0
- package/vendor/app-server/dist/host/HostProtocol.d.ts +1 -11
- package/vendor/app-server/dist/host/HostProtocol.js +3 -37
- package/vendor/app-server/dist/host/HostServer.d.ts +1 -4
- package/vendor/app-server/dist/host/HostServer.js +16 -152
- package/vendor/app-server/dist/host/RuntimeAdapter.js +2 -2
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +3 -3
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +4 -4
- package/vendor/app-server/dist/host/runtime_backed_preflight.js +2 -2
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +1 -1
- package/vendor/app-server/dist/protocol/contract.d.ts +5 -64
- package/vendor/app-server/dist/protocol/contract.js +3 -12
- package/dist/devtools/cli/src/guide.js +0 -50
- package/dist/devtools/cli/src/token_tool.d.ts +0 -38
- package/dist/dummy.d.ts +0 -0
- package/dist/dummy.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -48
- 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/runtime_host_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +0 -23
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +0 -36
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +0 -56
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +0 -19
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +0 -19
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +0 -19
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +0 -19
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +0 -56
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +0 -18
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +0 -21
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +0 -89
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +0 -115
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +0 -236
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +0 -57
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +0 -55
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +0 -46
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +0 -32
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +0 -34
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +0 -32
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +0 -26
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +0 -34
- 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_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/dist/host/RuntimeCredentialTokenIssuer.d.ts +0 -30
- package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +0 -224
- /package/dist/{devtools/cli → cli}/src/dummy.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/dummy.js +0 -0
- /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.js +0 -0
- /package/dist/{devtools/cli → cli}/src/guide.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/index.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/media_assets.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/media_assets.js +0 -0
- /package/dist/{devtools/cli → cli}/src/progress.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/progress.js +0 -0
- /package/dist/{devtools/cli → cli}/src/session_manager.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/token_command.d.ts +0 -0
- /package/dist/{devtools/cli → cli}/src/transport.js +0 -0
- /package/vendor/app-server/bin/{native/macos-arm64 → runtime/macos-arm64/lib}/libtgrtc.dylib +0 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** @file trp.h
|
|
2
|
+
* @brief Facade transport-facing public C API.
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
#ifndef TIRTC_FACADE_TRP_H_
|
|
2
6
|
#define TIRTC_FACADE_TRP_H_
|
|
3
7
|
|
|
@@ -10,621 +14,162 @@
|
|
|
10
14
|
extern "C" {
|
|
11
15
|
#endif
|
|
12
16
|
|
|
13
|
-
/**
|
|
14
|
-
* @file tirtc/trp.h
|
|
15
|
-
* @brief Base transport-facing facade API for TiRTC.
|
|
16
|
-
*
|
|
17
|
-
* This header defines the public control-plane contract that every higher
|
|
18
|
-
* facade layer builds on.
|
|
19
|
-
*
|
|
20
|
-
* Typical usage:
|
|
21
|
-
* 1. Call ::tirtc_init once for the process.
|
|
22
|
-
* 2. Either start a service with ::tirtc_conn_service_start, or create a
|
|
23
|
-
* standalone connection with ::tirtc_conn_create and then connect it with
|
|
24
|
-
* ::tirtc_conn_connect.
|
|
25
|
-
* 3. Install observers if the caller needs connection, command, or stream
|
|
26
|
-
* callbacks.
|
|
27
|
-
* 4. Exchange stream messages and commands while the connection is alive.
|
|
28
|
-
* 5. Explicitly close resources with the matching stop, disconnect, destroy,
|
|
29
|
-
* and uninit calls.
|
|
30
|
-
*
|
|
31
|
-
* Higher-level headers extend this contract rather than replace it:
|
|
32
|
-
* - `tirtc/audio.h` adds audio input and audio output objects.
|
|
33
|
-
* - `tirtc/av.h` adds video input and video output objects.
|
|
34
|
-
*
|
|
35
|
-
* Ownership model:
|
|
36
|
-
* - The caller owns every public handle returned by this facade.
|
|
37
|
-
* - The runtime owns internal transport and media pipelines.
|
|
38
|
-
* - Public handles must be released with their documented matching API.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @brief Global runtime options passed to ::tirtc_init.
|
|
43
|
-
*
|
|
44
|
-
* The runtime resolves the effective endpoint during initialization and copies
|
|
45
|
-
* the values it needs. String pointers only need to remain valid for the
|
|
46
|
-
* duration of the ::tirtc_init call.
|
|
47
|
-
*/
|
|
48
17
|
typedef struct TirtcOptions {
|
|
49
|
-
/**
|
|
50
|
-
* @brief Optional explicit service endpoint.
|
|
51
|
-
*
|
|
52
|
-
* When non-NULL and not empty, this value overrides the built-in endpoint
|
|
53
|
-
* selected by ::environment.
|
|
54
|
-
*/
|
|
55
18
|
const char* endpoint;
|
|
56
19
|
|
|
57
|
-
/**
|
|
58
|
-
* @brief Optional directory used to initialize file logging.
|
|
59
|
-
*
|
|
60
|
-
* Pass NULL or an empty string to disable file logging.
|
|
61
|
-
*/
|
|
62
20
|
const char* log_root_dir;
|
|
63
21
|
|
|
64
|
-
/**
|
|
65
|
-
* @brief Non-zero to enable console logging; zero to disable it.
|
|
66
|
-
*/
|
|
67
22
|
int enable_console_log;
|
|
68
23
|
|
|
69
|
-
/**
|
|
70
|
-
* @brief Built-in environment selector used when ::endpoint is not supplied.
|
|
71
|
-
*
|
|
72
|
-
* The current implementation recognizes these values:
|
|
73
|
-
* - `0`: test
|
|
74
|
-
* - `1`: pre-production
|
|
75
|
-
* - `2`: production
|
|
76
|
-
*
|
|
77
|
-
* Any other value currently falls back to the production endpoint.
|
|
78
|
-
*/
|
|
79
|
-
int environment;
|
|
80
24
|
} TirtcOptions;
|
|
81
25
|
|
|
82
|
-
/**
|
|
83
|
-
* @brief Default media send policy applied by the facade.
|
|
84
|
-
*
|
|
85
|
-
* The effective send gate still uses `connection + stream_id + media_kind` as
|
|
86
|
-
* the smallest scope. The policy only decides how those gates become open.
|
|
87
|
-
*/
|
|
88
26
|
typedef enum TirtcMediaSendPolicy {
|
|
89
|
-
|
|
90
|
-
* @brief Keep send gates closed until the consumer explicitly opens them.
|
|
91
|
-
*/
|
|
27
|
+
|
|
92
28
|
TIRTC_MEDIA_SEND_POLICY_ON_REQUEST = 0,
|
|
93
29
|
|
|
94
|
-
/**
|
|
95
|
-
* @brief Open send gates automatically once the accepted connection exists.
|
|
96
|
-
*
|
|
97
|
-
* When the bound input is ready, the facade may start sending without first
|
|
98
|
-
* waiting for an explicit remote request.
|
|
99
|
-
*/
|
|
100
30
|
TIRTC_MEDIA_SEND_POLICY_AUTO_ON_CONNECTED = 1,
|
|
101
31
|
} TirtcMediaSendPolicy;
|
|
102
32
|
|
|
103
|
-
/**
|
|
104
|
-
* @brief Options for starting a service-side connection listener.
|
|
105
|
-
*
|
|
106
|
-
* A service accepts inbound transport connections and exposes them through
|
|
107
|
-
* ::TirtcConnServiceObserver.on_connected.
|
|
108
|
-
*/
|
|
109
33
|
typedef struct TirtcConnServiceStartOptions {
|
|
110
|
-
/**
|
|
111
|
-
* @brief Non-empty service license string.
|
|
112
|
-
*
|
|
113
|
-
* This field is required.
|
|
114
|
-
*/
|
|
115
34
|
const char* license;
|
|
116
35
|
|
|
117
|
-
/**
|
|
118
|
-
* @brief Maximum number of concurrently accepted connections.
|
|
119
|
-
*
|
|
120
|
-
* This is a service-level capacity contract. It applies to the listener as a
|
|
121
|
-
* whole, not to any single connection and not to any individual stream.
|
|
122
|
-
*
|
|
123
|
-
* This field is required and must be non-zero.
|
|
124
|
-
*/
|
|
125
36
|
uint32_t max_connections;
|
|
126
37
|
|
|
127
|
-
/**
|
|
128
|
-
* @brief Service-level media send policy applied to accepted connections.
|
|
129
|
-
*
|
|
130
|
-
* This policy controls how the facade opens per-connection send gates after
|
|
131
|
-
* a connection becomes available. It does not change the underlying
|
|
132
|
-
* transport request/release primitives.
|
|
133
|
-
*/
|
|
134
38
|
TirtcMediaSendPolicy media_send_policy;
|
|
135
39
|
} TirtcConnServiceStartOptions;
|
|
136
40
|
|
|
137
|
-
/**
|
|
138
|
-
* @brief Options for connecting an outbound connection object.
|
|
139
|
-
*/
|
|
140
41
|
typedef struct TirtcConnConnectOptions {
|
|
141
|
-
/**
|
|
142
|
-
* @brief Remote peer identifier.
|
|
143
|
-
*
|
|
144
|
-
* This field is required and must be non-empty.
|
|
145
|
-
*/
|
|
146
42
|
const char* peer_id;
|
|
147
43
|
|
|
148
|
-
/**
|
|
149
|
-
* @brief Authentication or session token embedded into the transport
|
|
150
|
-
* descriptor.
|
|
151
|
-
*
|
|
152
|
-
* This field is required and must be non-empty.
|
|
153
|
-
*/
|
|
154
44
|
const char* token;
|
|
155
45
|
} TirtcConnConnectOptions;
|
|
156
46
|
|
|
157
|
-
/**
|
|
158
|
-
* @brief Optional observer bound when a connection object is created.
|
|
159
|
-
*
|
|
160
|
-
* The implementation copies the observer structure and stores the supplied
|
|
161
|
-
* user_data pointer with the created connection handle.
|
|
162
|
-
*/
|
|
163
47
|
typedef struct TirtcConnCreateOptions {
|
|
164
|
-
|
|
165
|
-
const struct TirtcConnObserver* observer;
|
|
48
|
+
const struct TirtcConnCallbacks* callbacks;
|
|
166
49
|
|
|
167
|
-
/** @brief Opaque pointer returned to observer callbacks. */
|
|
168
50
|
void* user_data;
|
|
169
51
|
} TirtcConnCreateOptions;
|
|
170
52
|
|
|
171
|
-
/** @brief Opaque handle returned by ::tirtc_conn_service_start. */
|
|
172
53
|
typedef struct TirtcConnService TirtcConnService;
|
|
173
54
|
|
|
174
|
-
/**
|
|
175
|
-
* @brief Opaque connection handle.
|
|
176
|
-
*
|
|
177
|
-
* A handle may come from either ::tirtc_conn_create or a service observer's
|
|
178
|
-
* ::TirtcConnServiceObserver.on_connected callback.
|
|
179
|
-
*/
|
|
180
55
|
typedef struct TirtcConn TirtcConn;
|
|
181
56
|
|
|
182
|
-
/**
|
|
183
|
-
* @brief High-level connection state reported through ::TirtcConnObserver.
|
|
184
|
-
*/
|
|
185
57
|
typedef enum TirtcConnState {
|
|
186
|
-
|
|
58
|
+
|
|
187
59
|
TIRTC_CONN_STATE_IDLE = 0,
|
|
188
60
|
|
|
189
|
-
/** Connection establishment is in progress. */
|
|
190
61
|
TIRTC_CONN_STATE_CONNECTING = 1,
|
|
191
62
|
|
|
192
|
-
/** Transport is connected and ready for control or media attachment. */
|
|
193
63
|
TIRTC_CONN_STATE_CONNECTED = 2,
|
|
194
64
|
|
|
195
|
-
/** Connection has entered its terminal disconnected state. */
|
|
196
65
|
TIRTC_CONN_STATE_DISCONNECTED = 3,
|
|
197
66
|
} TirtcConnState;
|
|
198
67
|
|
|
199
|
-
/**
|
|
200
|
-
* @brief Reason associated with a disconnected connection.
|
|
201
|
-
*/
|
|
202
|
-
typedef enum TirtcConnDisconnectReason {
|
|
203
|
-
/** The implementation could not determine a more specific reason. */
|
|
204
|
-
TIRTC_CONN_DISCONNECT_REASON_UNKNOWN = 0,
|
|
205
|
-
|
|
206
|
-
/** The local side closed the connection intentionally. */
|
|
207
|
-
TIRTC_CONN_DISCONNECT_REASON_LOCAL_CLOSED = 1,
|
|
208
|
-
|
|
209
|
-
/** The remote side closed the connection. */
|
|
210
|
-
TIRTC_CONN_DISCONNECT_REASON_REMOTE_CLOSED = 2,
|
|
211
|
-
|
|
212
|
-
/** Initial connection setup failed. */
|
|
213
|
-
TIRTC_CONN_DISCONNECT_REASON_CONNECT_FAILED = 3,
|
|
214
|
-
|
|
215
|
-
/** Descriptor exchange or validation failed. */
|
|
216
|
-
TIRTC_CONN_DISCONNECT_REASON_INVALID_DESCRIPTOR = 4,
|
|
217
|
-
|
|
218
|
-
/** The underlying transport backend reported an internal failure. */
|
|
219
|
-
TIRTC_CONN_DISCONNECT_REASON_BACKEND_ERROR = 5,
|
|
220
|
-
} TirtcConnDisconnectReason;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @brief Binary stream-message payload.
|
|
224
|
-
*
|
|
225
|
-
* Stream messages are intended for lightweight application-defined payloads on
|
|
226
|
-
* stream identifiers that are not currently reserved by attached audio or video
|
|
227
|
-
* routes.
|
|
228
|
-
*/
|
|
229
68
|
typedef struct TirtcStreamMessage {
|
|
230
|
-
/** @brief Sender-defined timestamp in milliseconds. */
|
|
231
69
|
uint32_t timestamp_ms;
|
|
232
70
|
|
|
233
|
-
/**
|
|
234
|
-
* @brief Pointer to payload bytes.
|
|
235
|
-
*
|
|
236
|
-
* The pointer may be NULL only when ::length is zero.
|
|
237
|
-
*/
|
|
238
71
|
const void* data;
|
|
239
72
|
|
|
240
|
-
/** @brief Payload size in bytes. */
|
|
241
73
|
size_t length;
|
|
242
74
|
} TirtcStreamMessage;
|
|
243
75
|
|
|
244
|
-
/**
|
|
245
|
-
* @brief Fire-and-forget command payload.
|
|
246
|
-
*
|
|
247
|
-
* Command identifiers are application-defined and must be agreed with the
|
|
248
|
-
* remote peer.
|
|
249
|
-
*
|
|
250
|
-
* The current runtime accepts application command ids in the range
|
|
251
|
-
* `[0x1000, 0x7FFF]`. Values below `0x1000` are reserved for
|
|
252
|
-
* runtime-internal commands and must not be used by consumers.
|
|
253
|
-
*/
|
|
254
76
|
typedef struct TirtcConnCommand {
|
|
255
|
-
|
|
256
|
-
* @brief Application-defined command identifier agreed with the remote peer.
|
|
257
|
-
*
|
|
258
|
-
* A request and its reply typically reuse the same ::command_id, while the
|
|
259
|
-
* per-request correlation is carried separately by ::remote_request_id.
|
|
260
|
-
*/
|
|
261
|
-
uint16_t command_id;
|
|
262
|
-
|
|
263
|
-
/** @brief Payload bytes, or NULL when ::length is zero. */
|
|
264
|
-
const void* data;
|
|
265
|
-
|
|
266
|
-
/** @brief Payload size in bytes. */
|
|
267
|
-
size_t length;
|
|
268
|
-
} TirtcConnCommand;
|
|
77
|
+
uint32_t command;
|
|
269
78
|
|
|
270
|
-
/**
|
|
271
|
-
* @brief Request payload for an asynchronous command round-trip.
|
|
272
|
-
*
|
|
273
|
-
* Command identifiers are application-defined and must be agreed with the
|
|
274
|
-
* remote peer.
|
|
275
|
-
*
|
|
276
|
-
* The current runtime accepts application command ids in the range
|
|
277
|
-
* `[0x1000, 0x7FFF]`. Values below `0x1000` are reserved for
|
|
278
|
-
* runtime-internal commands and must not be used by consumers.
|
|
279
|
-
*/
|
|
280
|
-
typedef struct TirtcConnCommandRequest {
|
|
281
|
-
/**
|
|
282
|
-
* @brief Application-defined command identifier agreed with the remote peer.
|
|
283
|
-
*
|
|
284
|
-
* In the common request-response pattern, the responder echoes the same
|
|
285
|
-
* ::command_id back in ::TirtcConnCommandResponse.
|
|
286
|
-
*/
|
|
287
|
-
uint16_t command_id;
|
|
288
|
-
|
|
289
|
-
/** @brief Payload bytes, or NULL when ::length is zero. */
|
|
290
79
|
const void* data;
|
|
291
80
|
|
|
292
|
-
/** @brief Payload size in bytes. */
|
|
293
81
|
size_t length;
|
|
82
|
+
} TirtcConnCommand;
|
|
294
83
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* than an infinite wait.
|
|
300
|
-
*/
|
|
301
|
-
uint32_t timeout_ms;
|
|
302
|
-
} TirtcConnCommandRequest;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @brief Response payload returned by a remote peer or local reply logic.
|
|
306
|
-
*
|
|
307
|
-
* Command identifiers are application-defined and must be agreed with the
|
|
308
|
-
* remote peer.
|
|
309
|
-
*
|
|
310
|
-
* The current runtime accepts application command ids in the range
|
|
311
|
-
* `[0x1000, 0x7FFF]`. Values below `0x1000` are reserved for
|
|
312
|
-
* runtime-internal commands and must not be used by consumers.
|
|
313
|
-
*/
|
|
314
|
-
typedef struct TirtcConnCommandResponse {
|
|
315
|
-
/**
|
|
316
|
-
* @brief Application-defined command identifier agreed with the remote peer.
|
|
317
|
-
*
|
|
318
|
-
* This usually matches the original request's ::command_id.
|
|
319
|
-
*/
|
|
320
|
-
uint16_t command_id;
|
|
321
|
-
|
|
322
|
-
/** @brief Payload bytes, or NULL when ::length is zero. */
|
|
323
|
-
const void* data;
|
|
84
|
+
/** Heap-owned byte payload allocated by facade callback dispatch. */
|
|
85
|
+
typedef struct TirtcOwnedBytes {
|
|
86
|
+
/** Payload buffer allocated by facade, or `NULL` for zero-length payloads. */
|
|
87
|
+
void* data;
|
|
324
88
|
|
|
325
|
-
/**
|
|
89
|
+
/** Number of bytes stored in `data`. */
|
|
326
90
|
size_t length;
|
|
327
|
-
}
|
|
91
|
+
} TirtcOwnedBytes;
|
|
328
92
|
|
|
329
|
-
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
* has been destroyed.
|
|
335
|
-
*
|
|
336
|
-
* Delivery may be synchronous or asynchronous:
|
|
337
|
-
* - If request submission fails immediately, the callback may run before
|
|
338
|
-
* ::tirtc_conn_request_command returns.
|
|
339
|
-
* - After request submission succeeds, completion is reported later from the
|
|
340
|
-
* transport or timeout path.
|
|
341
|
-
*
|
|
342
|
-
* Callers must not assume a fixed callback thread, and must write callback
|
|
343
|
-
* logic so it is safe for reentrant delivery relative to
|
|
344
|
-
* ::tirtc_conn_request_command and other connection callbacks.
|
|
345
|
-
*
|
|
346
|
-
* @param connection Connection that owns the request.
|
|
347
|
-
* @param error Completion status.
|
|
348
|
-
* @param response Non-NULL only when a response payload is available.
|
|
349
|
-
* @param user_data Opaque pointer originally passed to
|
|
350
|
-
* ::tirtc_conn_request_command.
|
|
351
|
-
*/
|
|
352
|
-
typedef void (*TirtcConnCommandResponseFn)(TirtcConn* connection, TirtcError error,
|
|
353
|
-
const TirtcConnCommandResponse* response,
|
|
354
|
-
void* user_data);
|
|
93
|
+
/** Heap-owned UTF-8 string allocated by facade callback dispatch. */
|
|
94
|
+
typedef struct TirtcOwnedString {
|
|
95
|
+
/** Null-terminated UTF-8 buffer allocated by facade, or `NULL` when no message is available. */
|
|
96
|
+
char* data;
|
|
97
|
+
} TirtcOwnedString;
|
|
355
98
|
|
|
356
|
-
|
|
357
|
-
* @brief Optional observer for service lifecycle and accepted connections.
|
|
358
|
-
*
|
|
359
|
-
* The implementation copies this structure when the service starts. The
|
|
360
|
-
* structure itself does not need to remain alive after
|
|
361
|
-
* ::tirtc_conn_service_start returns.
|
|
362
|
-
*/
|
|
363
|
-
typedef struct TirtcConnServiceObserver {
|
|
364
|
-
/** @brief Called after the service has started successfully. */
|
|
99
|
+
typedef struct TirtcConnServiceCallbacks {
|
|
365
100
|
void (*on_started)(TirtcConnService* service, void* user_data);
|
|
366
101
|
|
|
367
|
-
/** @brief Called after the service has stopped successfully. */
|
|
368
102
|
void (*on_stopped)(TirtcConnService* service, void* user_data);
|
|
369
103
|
|
|
370
|
-
/**
|
|
371
|
-
* @brief Called for each inbound connection accepted by the service.
|
|
372
|
-
*
|
|
373
|
-
* Ownership of the returned ::TirtcConn handle belongs to the caller. The
|
|
374
|
-
* caller must eventually disconnect and destroy that connection.
|
|
375
|
-
*
|
|
376
|
-
* The runtime will not dispatch other user-facing callbacks for that
|
|
377
|
-
* accepted connection until this callback returns. Callers that need full
|
|
378
|
-
* callback coverage should install the connection observer synchronously
|
|
379
|
-
* inside this callback before returning.
|
|
380
|
-
*/
|
|
381
104
|
void (*on_connected)(TirtcConnService* service, TirtcConn* connection, void* user_data);
|
|
382
105
|
|
|
383
|
-
/**
|
|
384
|
-
* @brief Called when the service reports an error or a promoted system event.
|
|
385
|
-
*/
|
|
386
106
|
void (*on_error)(TirtcConnService* service, TirtcError error, const char* message,
|
|
387
107
|
void* user_data);
|
|
388
|
-
}
|
|
108
|
+
} TirtcConnServiceCallbacks;
|
|
389
109
|
|
|
390
110
|
/**
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* The implementation stores a copy of this structure inside the owning
|
|
394
|
-
* connection object.
|
|
111
|
+
* Connection observer installed through `tirtc_conn_create()` or `tirtc_conn_set_callbacks()`.
|
|
395
112
|
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
113
|
+
* For `on_command()` and `on_stream_message()`, facade copies the variable-length payload to heap
|
|
114
|
+
* memory before dispatch. The callback receives ownership of that payload and must release it with
|
|
115
|
+
* `tirtc_owned_bytes_release()` after converting or copying the bytes it needs. The release API is
|
|
116
|
+
* NULL-safe. If facade cannot allocate an owned copy for a non-empty payload, it drops that
|
|
117
|
+
* callback delivery rather than dispatching a borrowed pointer.
|
|
400
118
|
*/
|
|
401
|
-
typedef struct
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* @brief Called for an inbound command request that expects a reply.
|
|
413
|
-
*
|
|
414
|
-
* The supplied ::remote_request_id remains valid only while the request is
|
|
415
|
-
* still pending on this connection. In the common case, reply exactly once
|
|
416
|
-
* with ::tirtc_conn_reply_remote_command.
|
|
417
|
-
*/
|
|
418
|
-
void (*on_remote_command_request)(TirtcConn* connection, uint64_t remote_request_id,
|
|
419
|
-
const TirtcConnCommand* command, void* user_data);
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* @brief Called when an application-defined stream message is received.
|
|
423
|
-
*/
|
|
424
|
-
void (*on_stream_message)(TirtcConn* connection, uint8_t stream_id,
|
|
425
|
-
const TirtcStreamMessage* message, void* user_data);
|
|
426
|
-
|
|
427
|
-
/** @brief Called when the transport reports an error for this connection. */
|
|
428
|
-
void (*on_error)(TirtcConn* connection, TirtcError error, const char* message, void* user_data);
|
|
429
|
-
} TirtcConnObserver;
|
|
119
|
+
typedef struct TirtcConnCallbacks {
|
|
120
|
+
void (*on_state_changed)(TirtcConn* connection, TirtcConnState state, TirtcError error,
|
|
121
|
+
void* user_data);
|
|
122
|
+
|
|
123
|
+
void (*on_command)(TirtcConn* connection, uint32_t command, TirtcOwnedBytes* owned_payload,
|
|
124
|
+
void* user_data);
|
|
125
|
+
|
|
126
|
+
void (*on_stream_message)(TirtcConn* connection, uint8_t stream_id, uint32_t timestamp_ms,
|
|
127
|
+
TirtcOwnedBytes* owned_payload, void* user_data);
|
|
128
|
+
} TirtcConnCallbacks;
|
|
430
129
|
|
|
431
|
-
/**
|
|
432
|
-
* @brief Initialize the global runtime.
|
|
433
|
-
*
|
|
434
|
-
* Call this exactly once before creating services, connections, audio objects,
|
|
435
|
-
* or video objects.
|
|
436
|
-
*
|
|
437
|
-
* @param options Non-NULL runtime options.
|
|
438
|
-
* @return ::TIRTC_ERROR_OK on success, or an error code when initialization
|
|
439
|
-
* fails or the runtime is already initialized.
|
|
440
|
-
*/
|
|
441
130
|
TirtcError tirtc_init(const TirtcOptions* options);
|
|
442
131
|
|
|
443
|
-
/**
|
|
444
|
-
* @brief Shut down the global runtime.
|
|
445
|
-
*
|
|
446
|
-
* This function is intentionally conservative. If any public handles are still
|
|
447
|
-
* alive, the current implementation leaves the runtime initialized and returns
|
|
448
|
-
* without tearing it down. Destroy every connection, stop every service, and
|
|
449
|
-
* destroy every media object before calling this function.
|
|
450
|
-
*/
|
|
451
132
|
void tirtc_uninit(void);
|
|
452
133
|
|
|
453
|
-
/**
|
|
454
|
-
* @brief Start a service-side listener.
|
|
455
|
-
*
|
|
456
|
-
* Only one live service is supported at a time.
|
|
457
|
-
*
|
|
458
|
-
* @param options Non-NULL start options with a non-empty license and a non-zero
|
|
459
|
-
* max_connections.
|
|
460
|
-
* @param observer Optional observer copied by value.
|
|
461
|
-
* @param user_data Opaque pointer returned to observer callbacks.
|
|
462
|
-
* @param out_service Receives the created service handle on success.
|
|
463
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
464
|
-
*/
|
|
465
134
|
TirtcError tirtc_conn_service_start(const TirtcConnServiceStartOptions* options,
|
|
466
|
-
const
|
|
135
|
+
const TirtcConnServiceCallbacks* observer, void* user_data,
|
|
467
136
|
TirtcConnService** out_service);
|
|
468
137
|
|
|
469
|
-
/**
|
|
470
|
-
* @brief Stop a service handle.
|
|
471
|
-
*
|
|
472
|
-
* Accepted connections are separate resources and are not destroyed by stopping
|
|
473
|
-
* the service. Each accepted ::TirtcConn remains the caller's responsibility.
|
|
474
|
-
* On success, the service handle is released and must not be used again.
|
|
475
|
-
*
|
|
476
|
-
* @param service Service handle to stop.
|
|
477
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
478
|
-
*/
|
|
479
138
|
TirtcError tirtc_conn_service_stop(TirtcConnService* service);
|
|
480
139
|
|
|
481
|
-
/**
|
|
482
|
-
* @brief Allocate a standalone connection handle.
|
|
483
|
-
*
|
|
484
|
-
* The runtime must already be initialized. The returned handle starts in
|
|
485
|
-
* ::TIRTC_CONN_STATE_IDLE and must be released with ::tirtc_conn_destroy.
|
|
486
|
-
*
|
|
487
|
-
* The observer, when provided, becomes part of the connection object's stable
|
|
488
|
-
* lifecycle contract. After creation succeeds, reconnects on the same handle
|
|
489
|
-
* keep using that observer.
|
|
490
|
-
*
|
|
491
|
-
* @param options Optional creation options. Pass NULL to create a connection
|
|
492
|
-
* without an observer.
|
|
493
|
-
* @param out_connection Receives the created connection handle on success.
|
|
494
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
495
|
-
*/
|
|
496
140
|
TirtcError tirtc_conn_create(const TirtcConnCreateOptions* options, TirtcConn** out_connection);
|
|
497
141
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*
|
|
501
|
-
* This legacy API remains available for accepted service connections and
|
|
502
|
-
* existing consumers that still bind observers after handle creation.
|
|
503
|
-
* New standalone-connection callers should prefer binding the observer through
|
|
504
|
-
* ::TirtcConnCreateOptions.
|
|
505
|
-
*
|
|
506
|
-
* Passing NULL for ::observer clears the current observer and its user data.
|
|
507
|
-
* After a non-NULL observer is installed, the implementation immediately
|
|
508
|
-
* replays the current state and, when applicable, the terminal disconnected
|
|
509
|
-
* callback.
|
|
510
|
-
*/
|
|
511
|
-
TirtcError tirtc_conn_set_observer(TirtcConn* connection, const TirtcConnObserver* observer,
|
|
512
|
-
void* user_data);
|
|
142
|
+
TirtcError tirtc_conn_set_callbacks(TirtcConn* connection, const TirtcConnCallbacks* callbacks,
|
|
143
|
+
void* user_data);
|
|
513
144
|
|
|
514
|
-
/**
|
|
515
|
-
* @brief Connect a standalone connection handle to a remote peer.
|
|
516
|
-
*
|
|
517
|
-
* This function is valid only for handles created by ::tirtc_conn_create.
|
|
518
|
-
* Connections accepted from a service are already transport-owned and cannot be
|
|
519
|
-
* manually connected again.
|
|
520
|
-
*
|
|
521
|
-
* After a disconnect, the same handle may be connected again.
|
|
522
|
-
*
|
|
523
|
-
* @param connection Target connection created by ::tirtc_conn_create.
|
|
524
|
-
* @param options Non-NULL connect options with non-empty peer and token values.
|
|
525
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
526
|
-
*/
|
|
527
145
|
TirtcError tirtc_conn_connect(TirtcConn* connection, const TirtcConnConnectOptions* options);
|
|
528
146
|
|
|
529
|
-
/**
|
|
530
|
-
* @brief Disconnect a connection.
|
|
531
|
-
*
|
|
532
|
-
* This call is idempotent once the connection is already idle or disconnected.
|
|
533
|
-
* Disconnecting does not destroy the handle.
|
|
534
|
-
*
|
|
535
|
-
* @param connection Target connection.
|
|
536
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
537
|
-
*/
|
|
538
147
|
TirtcError tirtc_conn_disconnect(TirtcConn* connection);
|
|
539
148
|
|
|
540
|
-
/**
|
|
541
|
-
* @brief Destroy a connection handle and release its internal transport state.
|
|
542
|
-
*
|
|
543
|
-
* Destroying a connection also detaches any currently attached audio or video
|
|
544
|
-
* objects. Those media objects are not destroyed; they return to an unbound
|
|
545
|
-
* state and remain owned by the caller.
|
|
546
|
-
*
|
|
547
|
-
* After this call returns, the connection handle is invalid and must not be
|
|
548
|
-
* reused.
|
|
549
|
-
*
|
|
550
|
-
* @param connection Connection handle to destroy.
|
|
551
|
-
*/
|
|
552
149
|
void tirtc_conn_destroy(TirtcConn* connection);
|
|
553
150
|
|
|
554
|
-
/**
|
|
555
|
-
* @brief Send an application-defined stream message.
|
|
556
|
-
*
|
|
557
|
-
* Use a stream identifier that is not currently occupied by an attached audio
|
|
558
|
-
* input, video input, or video output on the same connection.
|
|
559
|
-
*
|
|
560
|
-
* @param connection Target connection.
|
|
561
|
-
* @param stream_id Application-defined stream identifier for this message.
|
|
562
|
-
* @param message Non-NULL payload descriptor.
|
|
563
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
564
|
-
*/
|
|
565
151
|
TirtcError tirtc_conn_send_stream_message(TirtcConn* connection, uint8_t stream_id,
|
|
566
152
|
const TirtcStreamMessage* message);
|
|
567
153
|
|
|
568
|
-
/**
|
|
569
|
-
|
|
570
|
-
*
|
|
571
|
-
* Choose ::TirtcConnCommand.command_id from the command ids agreed with the
|
|
572
|
-
* remote peer. The current runtime accepts application command ids in
|
|
573
|
-
* `[0x1000, 0x7FFF]`; values below `0x1000` are reserved for
|
|
574
|
-
* runtime-internal commands.
|
|
575
|
-
*
|
|
576
|
-
* @param connection Target connection.
|
|
577
|
-
* @param command Non-NULL command payload.
|
|
578
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
579
|
-
*/
|
|
580
|
-
TirtcError tirtc_conn_send_command(TirtcConn* connection, const TirtcConnCommand* command);
|
|
154
|
+
/** Copies a stream-message payload into a releasable owned buffer. */
|
|
155
|
+
TirtcOwnedBytes* tirtc_stream_message_copy_payload(const TirtcStreamMessage* message);
|
|
581
156
|
|
|
582
|
-
/**
|
|
583
|
-
|
|
584
|
-
* asynchronously.
|
|
585
|
-
*
|
|
586
|
-
* Choose ::TirtcConnCommandRequest.command_id from the command ids agreed
|
|
587
|
-
* with the remote peer. The current runtime accepts application command
|
|
588
|
-
* ids in `[0x1000, 0x7FFF]`; values below `0x1000` are reserved for
|
|
589
|
-
* runtime-internal commands.
|
|
590
|
-
*
|
|
591
|
-
* Callback delivery is mixed synchronous/asynchronous. If request submission
|
|
592
|
-
* fails immediately after the facade has accepted the request, ::callback may
|
|
593
|
-
* run before this function returns. After request submission succeeds,
|
|
594
|
-
* completion is reported later from the response, timeout, or disconnect path.
|
|
595
|
-
*
|
|
596
|
-
* Once this call returns ::TIRTC_ERROR_OK, expect exactly one completion
|
|
597
|
-
* callback unless the connection is destroyed first.
|
|
598
|
-
*
|
|
599
|
-
* @param connection Target connection.
|
|
600
|
-
* @param request Non-NULL request payload.
|
|
601
|
-
* @param callback Completion callback invoked for response, timeout, send
|
|
602
|
-
* failure, or disconnect.
|
|
603
|
-
* @param user_data Opaque pointer returned to ::callback.
|
|
604
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
605
|
-
*/
|
|
606
|
-
TirtcError tirtc_conn_request_command(TirtcConn* connection, const TirtcConnCommandRequest* request,
|
|
607
|
-
TirtcConnCommandResponseFn callback, void* user_data);
|
|
157
|
+
/** Copies a command payload into a releasable owned buffer. */
|
|
158
|
+
TirtcOwnedBytes* tirtc_conn_command_copy_payload(const TirtcConnCommand* command);
|
|
608
159
|
|
|
609
|
-
/**
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
*
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
*
|
|
617
|
-
|
|
618
|
-
*
|
|
619
|
-
* @param remote_request_id Request id supplied by the observer callback.
|
|
620
|
-
* @param response Non-NULL response payload.
|
|
621
|
-
* @return ::TIRTC_ERROR_OK on success.
|
|
622
|
-
*/
|
|
623
|
-
TirtcError tirtc_conn_reply_remote_command(TirtcConn* connection, uint64_t remote_request_id,
|
|
624
|
-
const TirtcConnCommandResponse* response);
|
|
160
|
+
/** Copies a UTF-8 string into a releasable owned buffer. */
|
|
161
|
+
TirtcOwnedString* tirtc_string_copy_owned(const char* message);
|
|
162
|
+
|
|
163
|
+
/** Releases a payload received from facade owned-memory callback APIs. Safe to call with `NULL`. */
|
|
164
|
+
void tirtc_owned_bytes_release(TirtcOwnedBytes* owned);
|
|
165
|
+
|
|
166
|
+
/** Releases a string received from facade owned-memory callback APIs. Safe to call with `NULL`. */
|
|
167
|
+
void tirtc_owned_string_release(TirtcOwnedString* owned);
|
|
168
|
+
|
|
169
|
+
TirtcError tirtc_conn_send_command(TirtcConn* connection, const TirtcConnCommand* command);
|
|
625
170
|
|
|
626
171
|
#ifdef __cplusplus
|
|
627
172
|
}
|
|
628
173
|
#endif
|
|
629
174
|
|
|
630
|
-
#endif
|
|
175
|
+
#endif
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|