tirtc-devtools-cli 0.0.15 → 0.1.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 +5 -1
- package/USAGE.md +6 -3
- package/dist/cli/src/index.js +19 -3
- package/dist/cli/src/media_assets.js +27 -6
- package/dist/cli/src/role_driver.js +8 -3
- package/package.json +1 -1
- package/vendor/devtools/driver/linux-x64/devtools_driver_probe +0 -0
- package/vendor/devtools/driver/macos-arm64/devtools_driver_probe +0 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio.h +237 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_io.h +65 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
- package/vendor/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
- package/vendor/runtime/linux-x64/include/tirtc/av.h +236 -0
- package/vendor/runtime/linux-x64/include/tirtc/error.h +102 -0
- package/vendor/runtime/linux-x64/include/tirtc/foundation/build_info.h +27 -0
- package/vendor/runtime/linux-x64/include/tirtc/http.h +57 -0
- package/vendor/runtime/linux-x64/include/tirtc/logging.h +55 -0
- package/vendor/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
- package/vendor/runtime/linux-x64/include/tirtc/media_downlink.h +199 -0
- package/vendor/runtime/linux-x64/include/tirtc/media_uplink.h +120 -0
- package/vendor/runtime/linux-x64/include/tirtc/transport.h +445 -0
- package/vendor/runtime/linux-x64/include/tirtc/trp.h +187 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_codec.h +112 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_io.h +53 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_io_android.h +34 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_io_apple.h +47 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
- package/vendor/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
- package/vendor/runtime/linux-x64/lib/libTiRTC.a +0 -0
- package/vendor/runtime/linux-x64/lib/libcrypto.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/runtime/linux-x64/lib/libssl.a +0 -0
- package/vendor/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
- package/vendor/runtime/linux-x64/lib/libxlog.a +0 -0
- package/vendor/runtime/linux-x64/manifest.txt +45 -0
- package/vendor/runtime/macos-arm64/include/tirtc/audio.h +21 -0
- package/vendor/runtime/macos-arm64/include/tirtc/av.h +28 -0
- package/vendor/runtime/macos-arm64/include/tirtc/error.h +41 -2
- package/vendor/runtime/macos-arm64/include/tirtc/media_downlink.h +45 -0
- package/vendor/runtime/macos-arm64/include/tirtc/video_codec.h +13 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/runtime/macos-arm64/manifest.txt +13 -13
- package/vendor/runtime/script/prepare_runtime_media_dataset.sh +15 -0
- package/vendor/devtools/driver/macos-arm64/runtime_validation_client_bin +0 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
#ifndef TIRTC_TRANSPORT_H_
|
|
2
|
+
#define TIRTC_TRANSPORT_H_
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
#include "tirtc/error.h"
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @brief Connection state visible to user callbacks.
|
|
15
|
+
*/
|
|
16
|
+
typedef enum TirtcTransportConnState {
|
|
17
|
+
/** Invalid or unknown state. */
|
|
18
|
+
TIRTC_TRANSPORT_CONN_STATE_INVALID = 0,
|
|
19
|
+
/** Connecting is in progress. */
|
|
20
|
+
TIRTC_TRANSPORT_CONN_STATE_CONNECTING = 1,
|
|
21
|
+
/** Connection is established and usable. */
|
|
22
|
+
TIRTC_TRANSPORT_CONN_STATE_CONNECTED = 2,
|
|
23
|
+
/** Connection is disconnected and no longer usable. */
|
|
24
|
+
TIRTC_TRANSPORT_CONN_STATE_DISCONNECTED = 3,
|
|
25
|
+
} TirtcTransportConnState;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @brief Service-level runtime event.
|
|
29
|
+
*/
|
|
30
|
+
typedef enum TirtcTransportSystemEvent {
|
|
31
|
+
/** Service runtime started. */
|
|
32
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_STARTED = 0,
|
|
33
|
+
/** Service runtime stopped. */
|
|
34
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_STOPPED = 1,
|
|
35
|
+
/** Upstream access endpoint may be hijacked/redirected. */
|
|
36
|
+
TIRTC_TRANSPORT_SYSTEM_EVENT_ACCESS_HIJACKING = 2,
|
|
37
|
+
} TirtcTransportSystemEvent;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @brief Transport media type mapped from backend media kinds.
|
|
41
|
+
*
|
|
42
|
+
* Notes:
|
|
43
|
+
* - stream_id is global per connection.
|
|
44
|
+
* - audio and video MUST NOT share the same stream_id on one connection.
|
|
45
|
+
*/
|
|
46
|
+
typedef enum TirtcTransportMediaType {
|
|
47
|
+
/** PCM audio payload. */
|
|
48
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_PCM = 1,
|
|
49
|
+
/** G.711 A-law audio payload. */
|
|
50
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_ALAW = 2,
|
|
51
|
+
/** AAC audio payload. */
|
|
52
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_AAC = 3,
|
|
53
|
+
/** Opus audio payload. */
|
|
54
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_AUDIO_OPUS = 4,
|
|
55
|
+
/** JPEG video payload. */
|
|
56
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_JPEG = 65,
|
|
57
|
+
/** H.264 video payload. */
|
|
58
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_H264 = 66,
|
|
59
|
+
/** H.265 video payload. */
|
|
60
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_VIDEO_H265 = 67,
|
|
61
|
+
/** Stream message payload (media-channel message). */
|
|
62
|
+
TIRTC_TRANSPORT_MEDIA_TYPE_STREAM_MESSAGE = 128,
|
|
63
|
+
} TirtcTransportMediaType;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @brief Audio sample format value used in frame flags for audio streams.
|
|
67
|
+
*/
|
|
68
|
+
typedef enum TirtcTransportAudioSample {
|
|
69
|
+
/** 8 kHz, 16-bit, mono. */
|
|
70
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_8K16B1C = 0,
|
|
71
|
+
/** 16 kHz, 16-bit, mono. */
|
|
72
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_16K16B1C = 1,
|
|
73
|
+
/** 8 kHz, 16-bit, stereo. */
|
|
74
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_8K16B2C = 2,
|
|
75
|
+
/** 16 kHz, 16-bit, stereo. */
|
|
76
|
+
TIRTC_TRANSPORT_AUDIO_SAMPLE_16K16B2C = 3,
|
|
77
|
+
} TirtcTransportAudioSample;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @brief Video key-frame flag for TirtcTransportFrameHeader.flags.
|
|
81
|
+
*/
|
|
82
|
+
#define TIRTC_TRANSPORT_FRAME_FLAG_KEY_FRAME 0x01
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @brief Network type hint passed to the transport backend.
|
|
86
|
+
*/
|
|
87
|
+
typedef enum TirtcTransportNetworkType {
|
|
88
|
+
/** Use the backend default network behavior. */
|
|
89
|
+
TIRTC_TRANSPORT_NETWORK_TYPE_DEFAULT = 0,
|
|
90
|
+
/** Wi-Fi network path. */
|
|
91
|
+
TIRTC_TRANSPORT_NETWORK_TYPE_WIFI = 1,
|
|
92
|
+
/** 4G cellular network path. */
|
|
93
|
+
TIRTC_TRANSPORT_NETWORK_TYPE_4G = 2,
|
|
94
|
+
} TirtcTransportNetworkType;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @brief Transport runtime options shared by service and outgoing connection paths.
|
|
98
|
+
*/
|
|
99
|
+
typedef struct TirtcTransportRuntimeOptions {
|
|
100
|
+
/** Required service endpoint URL. */
|
|
101
|
+
const char* endpoint;
|
|
102
|
+
/** Optional network type hint. Zero-initialized options use the backend default. */
|
|
103
|
+
TirtcTransportNetworkType network_type;
|
|
104
|
+
/** Non-zero enables backend wakeup support. */
|
|
105
|
+
uint8_t wakeup_enabled;
|
|
106
|
+
/** Non-zero enables restricted-network mode. */
|
|
107
|
+
uint8_t restricted_network;
|
|
108
|
+
} TirtcTransportRuntimeOptions;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @brief Connect-parameter cache policy for outgoing connections.
|
|
112
|
+
*/
|
|
113
|
+
typedef enum TirtcTransportConnectCacheMode {
|
|
114
|
+
/** Use backend default cache policy. */
|
|
115
|
+
TIRTC_TRANSPORT_CONNECT_CACHE_DEFAULT = 0,
|
|
116
|
+
/** Disable backend connection-parameter cache. */
|
|
117
|
+
TIRTC_TRANSPORT_CONNECT_CACHE_DISABLED = 1,
|
|
118
|
+
/** Enable backend connection-parameter cache. */
|
|
119
|
+
TIRTC_TRANSPORT_CONNECT_CACHE_ENABLED = 2,
|
|
120
|
+
} TirtcTransportConnectCacheMode;
|
|
121
|
+
|
|
122
|
+
typedef struct TirtcTransportConnService TirtcTransportConnService;
|
|
123
|
+
typedef struct TirtcTransportConn TirtcTransportConn;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @brief Options for starting service runtime.
|
|
127
|
+
*/
|
|
128
|
+
typedef struct TirtcTransportConnServiceOptions {
|
|
129
|
+
/** Required service license. */
|
|
130
|
+
const char* license;
|
|
131
|
+
|
|
132
|
+
/** Required runtime options. */
|
|
133
|
+
TirtcTransportRuntimeOptions runtime_options;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @brief Maximum number of concurrently accepted connections for this
|
|
137
|
+
* service listener.
|
|
138
|
+
*
|
|
139
|
+
* This is a service-level capacity contract. It applies to the listener as a
|
|
140
|
+
* whole, not to any single connection and not to any individual stream.
|
|
141
|
+
*
|
|
142
|
+
* The current public contract requires a non-zero value.
|
|
143
|
+
*/
|
|
144
|
+
uint32_t max_connections;
|
|
145
|
+
} TirtcTransportConnServiceOptions;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @brief Options for creating outgoing connection.
|
|
149
|
+
*/
|
|
150
|
+
typedef struct TirtcTransportConnOptions {
|
|
151
|
+
/** Target remote identifier. */
|
|
152
|
+
const char* remote_id;
|
|
153
|
+
/** Required one-shot bootstrap token. */
|
|
154
|
+
const char* token;
|
|
155
|
+
/** Required runtime options. */
|
|
156
|
+
TirtcTransportRuntimeOptions runtime_options;
|
|
157
|
+
/** Backend connection-parameter cache policy. */
|
|
158
|
+
TirtcTransportConnectCacheMode connect_cache_mode;
|
|
159
|
+
/** Non-zero asks backend to try cached connect parameters before the explicit token. */
|
|
160
|
+
uint8_t prefer_cached_connect_params;
|
|
161
|
+
} TirtcTransportConnOptions;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @brief Command-channel payload.
|
|
165
|
+
*
|
|
166
|
+
* command is an opaque backend-defined 32-bit value. The transport public
|
|
167
|
+
* contract forwards it without splitting sequence or request/response bits.
|
|
168
|
+
*/
|
|
169
|
+
typedef struct TirtcTransportCommand {
|
|
170
|
+
/** Opaque raw 32-bit command word. */
|
|
171
|
+
uint32_t command;
|
|
172
|
+
/** Command payload pointer, can be NULL when payload_length is 0. */
|
|
173
|
+
const void* payload;
|
|
174
|
+
/** Command payload bytes. */
|
|
175
|
+
size_t payload_length;
|
|
176
|
+
} TirtcTransportCommand;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @brief Unified frame header for audio/video/stream-message.
|
|
180
|
+
*/
|
|
181
|
+
typedef struct TirtcTransportFrameHeader {
|
|
182
|
+
/** Stream identifier (global unique per connection). */
|
|
183
|
+
uint8_t stream_id;
|
|
184
|
+
/** One of TirtcTransportMediaType. */
|
|
185
|
+
uint8_t media_type;
|
|
186
|
+
/** Flags; video key-frame uses TIRTC_TRANSPORT_FRAME_FLAG_KEY_FRAME. */
|
|
187
|
+
uint8_t flags;
|
|
188
|
+
/** Reserved field (mapped from backend dummy field). */
|
|
189
|
+
uint8_t reserved0;
|
|
190
|
+
/** Frame timestamp in milliseconds. */
|
|
191
|
+
uint32_t timestamp_ms;
|
|
192
|
+
/** Payload length in bytes. */
|
|
193
|
+
uint32_t payload_length;
|
|
194
|
+
} TirtcTransportFrameHeader;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @brief Audio frame wrapper.
|
|
198
|
+
*/
|
|
199
|
+
typedef struct TirtcTransportAudioFrame {
|
|
200
|
+
/** Audio frame header. */
|
|
201
|
+
TirtcTransportFrameHeader header;
|
|
202
|
+
/** Audio payload bytes. */
|
|
203
|
+
const void* payload;
|
|
204
|
+
} TirtcTransportAudioFrame;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @brief Video frame wrapper.
|
|
208
|
+
*/
|
|
209
|
+
typedef struct TirtcTransportVideoFrame {
|
|
210
|
+
/** Video frame header. */
|
|
211
|
+
TirtcTransportFrameHeader header;
|
|
212
|
+
/** Video payload bytes. */
|
|
213
|
+
const void* payload;
|
|
214
|
+
} TirtcTransportVideoFrame;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @brief Stream-message frame wrapper.
|
|
218
|
+
*/
|
|
219
|
+
typedef struct TirtcTransportStreamMessage {
|
|
220
|
+
/** Message frame header. */
|
|
221
|
+
TirtcTransportFrameHeader header;
|
|
222
|
+
/** Message payload bytes. */
|
|
223
|
+
const void* payload;
|
|
224
|
+
} TirtcTransportStreamMessage;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @brief Service observer callbacks.
|
|
228
|
+
*/
|
|
229
|
+
typedef struct TirtcTransportConnServiceCallbacks {
|
|
230
|
+
/** Called when service runtime is started. */
|
|
231
|
+
void (*on_started)(TirtcTransportConnService* service, void* user_data);
|
|
232
|
+
/** Called when service runtime is stopped. */
|
|
233
|
+
void (*on_stopped)(TirtcTransportConnService* service, void* user_data);
|
|
234
|
+
/** Called on system-level service event. */
|
|
235
|
+
void (*on_event)(TirtcTransportConnService* service, TirtcTransportSystemEvent event,
|
|
236
|
+
const void* data, size_t length, void* user_data);
|
|
237
|
+
/** Called when a new incoming connection is accepted by service. */
|
|
238
|
+
void (*on_connected)(TirtcTransportConnService* service, TirtcTransportConn* connection,
|
|
239
|
+
void* user_data);
|
|
240
|
+
/** Called when service-level error happens. */
|
|
241
|
+
void (*on_error)(TirtcTransportConnService* service, TirtcError error, const char* message,
|
|
242
|
+
void* user_data);
|
|
243
|
+
} TirtcTransportConnServiceCallbacks;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @brief Connection observer callbacks.
|
|
247
|
+
*
|
|
248
|
+
* Callback user_data here is observer context, independent from
|
|
249
|
+
* tirtc_transport_conn_set_user_data()/get_user_data().
|
|
250
|
+
*/
|
|
251
|
+
typedef struct TirtcTransportConnCallbacks {
|
|
252
|
+
/** Called when connection state changes. */
|
|
253
|
+
void (*on_state_changed)(TirtcTransportConn* connection, TirtcTransportConnState state,
|
|
254
|
+
TirtcError error, void* user_data);
|
|
255
|
+
/** Called when command payload is received. */
|
|
256
|
+
void (*on_command)(TirtcTransportConn* connection, const TirtcTransportCommand* command,
|
|
257
|
+
void* user_data);
|
|
258
|
+
/** Called when remote requests a key frame. */
|
|
259
|
+
void (*on_request_key_frame)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
260
|
+
/**
|
|
261
|
+
* @brief Called when remote subscribes to video stream.
|
|
262
|
+
* @return 0 to accept, non-zero to reject.
|
|
263
|
+
*/
|
|
264
|
+
int (*on_subscribe_video)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
265
|
+
/** Called when remote unsubscribes from video stream. */
|
|
266
|
+
void (*on_unsubscribe_video)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
267
|
+
/**
|
|
268
|
+
* @brief Called when remote subscribes to audio stream.
|
|
269
|
+
* @return 0 to accept, non-zero to reject.
|
|
270
|
+
*/
|
|
271
|
+
int (*on_subscribe_audio)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
272
|
+
/** Called when remote unsubscribes from audio stream. */
|
|
273
|
+
void (*on_unsubscribe_audio)(TirtcTransportConn* connection, uint8_t stream_id, void* user_data);
|
|
274
|
+
/** Called when audio frame is received. */
|
|
275
|
+
void (*on_stream_audio)(TirtcTransportConn* connection, const TirtcTransportAudioFrame* frame,
|
|
276
|
+
void* user_data);
|
|
277
|
+
/** Called when video frame is received. */
|
|
278
|
+
void (*on_stream_video)(TirtcTransportConn* connection, const TirtcTransportVideoFrame* frame,
|
|
279
|
+
void* user_data);
|
|
280
|
+
/** Called when stream message is received. */
|
|
281
|
+
void (*on_stream_message)(TirtcTransportConn* connection,
|
|
282
|
+
const TirtcTransportStreamMessage* message, void* user_data);
|
|
283
|
+
} TirtcTransportConnCallbacks;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @brief Initialize transport runtime.
|
|
287
|
+
*
|
|
288
|
+
* This function is idempotent.
|
|
289
|
+
*/
|
|
290
|
+
TirtcError tirtc_transport_init(void);
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @brief Enable/disable transport debug mode.
|
|
294
|
+
*
|
|
295
|
+
* When enabled, transport backend sets verbose vendor SDK log level during runtime init
|
|
296
|
+
* and applies it immediately if runtime is already initialized.
|
|
297
|
+
*
|
|
298
|
+
* @param enabled Non-zero to enable debug mode, zero to disable.
|
|
299
|
+
* @return Operation status.
|
|
300
|
+
*/
|
|
301
|
+
TirtcError tirtc_transport_enable_debug(uint8_t enabled);
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @brief Uninitialize transport runtime.
|
|
305
|
+
*
|
|
306
|
+
* This function is idempotent.
|
|
307
|
+
*/
|
|
308
|
+
void tirtc_transport_uninit(void);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @brief Start service runtime with typed options and service observer.
|
|
312
|
+
*/
|
|
313
|
+
TirtcError tirtc_transport_conn_service_start(const TirtcTransportConnServiceOptions* options,
|
|
314
|
+
const TirtcTransportConnServiceCallbacks* callbacks,
|
|
315
|
+
void* user_data,
|
|
316
|
+
TirtcTransportConnService** out_service);
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @brief Stop service runtime.
|
|
320
|
+
*/
|
|
321
|
+
TirtcError tirtc_transport_conn_service_stop(TirtcTransportConnService* service);
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @brief Create outgoing connection.
|
|
325
|
+
*
|
|
326
|
+
* On success, returned handle enters CONNECTING first; actual connected/disconnected
|
|
327
|
+
* transition is delivered by observer callbacks.
|
|
328
|
+
*/
|
|
329
|
+
TirtcError tirtc_transport_connect(const TirtcTransportConnOptions* options,
|
|
330
|
+
TirtcTransportConn** out_connection);
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @brief Set or replace connection observer.
|
|
334
|
+
*
|
|
335
|
+
* The implementation may synchronously replay the current state according to
|
|
336
|
+
* contract.
|
|
337
|
+
*/
|
|
338
|
+
TirtcError tirtc_transport_conn_set_callbacks(TirtcTransportConn* connection,
|
|
339
|
+
const TirtcTransportConnCallbacks* callbacks,
|
|
340
|
+
void* user_data);
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @brief Attach a connection-level user context pointer.
|
|
344
|
+
*
|
|
345
|
+
* This is equivalent to backend connection user data mapping and is independent
|
|
346
|
+
* from observer callback user_data.
|
|
347
|
+
*/
|
|
348
|
+
TirtcError tirtc_transport_conn_set_user_data(TirtcTransportConn* connection, void* user_data);
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @brief Get connection-level user context pointer set by set_user_data.
|
|
352
|
+
*/
|
|
353
|
+
void* tirtc_transport_conn_get_user_data(TirtcTransportConn* connection);
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @brief Get current send-buffer used bytes for this connection.
|
|
357
|
+
*/
|
|
358
|
+
TirtcError tirtc_transport_conn_get_send_buffer_used(TirtcTransportConn* connection,
|
|
359
|
+
size_t* out_bytes);
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @brief Request local disconnect.
|
|
363
|
+
*
|
|
364
|
+
* Disconnected completion is reported by on_state_changed callback.
|
|
365
|
+
*/
|
|
366
|
+
TirtcError tirtc_transport_disconnect(TirtcTransportConn* connection);
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @brief Destroy transport connection handle.
|
|
370
|
+
*
|
|
371
|
+
* This releases transport-layer resources owned by this handle.
|
|
372
|
+
*/
|
|
373
|
+
void tirtc_transport_conn_destroy(TirtcTransportConn* connection);
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @brief Send command payload over command channel.
|
|
377
|
+
*/
|
|
378
|
+
TirtcError tirtc_transport_send_command(TirtcTransportConn* connection,
|
|
379
|
+
const TirtcTransportCommand* command);
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @brief Request remote side to send a key frame for a video stream on this
|
|
383
|
+
* connection.
|
|
384
|
+
*/
|
|
385
|
+
TirtcError tirtc_transport_request_key_frame(TirtcTransportConn* connection, uint8_t stream_id);
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* @brief Request remote side to start sending a video stream on this
|
|
389
|
+
* connection.
|
|
390
|
+
*
|
|
391
|
+
* The request scope is limited to the supplied ::connection and ::stream_id.
|
|
392
|
+
* It must not affect any other connection.
|
|
393
|
+
*/
|
|
394
|
+
TirtcError tirtc_transport_subscribe_video(TirtcTransportConn* connection, uint8_t stream_id);
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @brief Request remote side to stop sending a video stream on this
|
|
398
|
+
* connection.
|
|
399
|
+
*
|
|
400
|
+
* The release scope is limited to the supplied ::connection and ::stream_id.
|
|
401
|
+
* It must not affect any other connection.
|
|
402
|
+
*/
|
|
403
|
+
TirtcError tirtc_transport_unsubscribe_video(TirtcTransportConn* connection, uint8_t stream_id);
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @brief Request remote side to start sending an audio stream on this
|
|
407
|
+
* connection.
|
|
408
|
+
*
|
|
409
|
+
* The request scope is limited to the supplied ::connection and ::stream_id.
|
|
410
|
+
* It must not affect any other connection.
|
|
411
|
+
*/
|
|
412
|
+
TirtcError tirtc_transport_subscribe_audio(TirtcTransportConn* connection, uint8_t stream_id);
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @brief Request remote side to stop sending an audio stream on this
|
|
416
|
+
* connection.
|
|
417
|
+
*
|
|
418
|
+
* The release scope is limited to the supplied ::connection and ::stream_id.
|
|
419
|
+
* It must not affect any other connection.
|
|
420
|
+
*/
|
|
421
|
+
TirtcError tirtc_transport_unsubscribe_audio(TirtcTransportConn* connection, uint8_t stream_id);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @brief Send typed audio frame.
|
|
425
|
+
*/
|
|
426
|
+
TirtcError tirtc_transport_send_audio_frame(TirtcTransportConn* connection,
|
|
427
|
+
const TirtcTransportAudioFrame* frame);
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @brief Send typed video frame.
|
|
431
|
+
*/
|
|
432
|
+
TirtcError tirtc_transport_send_video_frame(TirtcTransportConn* connection,
|
|
433
|
+
const TirtcTransportVideoFrame* frame);
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @brief Send stream-message payload in media channel.
|
|
437
|
+
*/
|
|
438
|
+
TirtcError tirtc_transport_send_stream_message(TirtcTransportConn* connection,
|
|
439
|
+
const TirtcTransportStreamMessage* message);
|
|
440
|
+
|
|
441
|
+
#ifdef __cplusplus
|
|
442
|
+
}
|
|
443
|
+
#endif
|
|
444
|
+
|
|
445
|
+
#endif // TIRTC_TRANSPORT_H_
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/** @file trp.h
|
|
2
|
+
* @brief Facade transport-facing public C API.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#ifndef TIRTC_FACADE_TRP_H_
|
|
6
|
+
#define TIRTC_FACADE_TRP_H_
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
|
|
11
|
+
#include "tirtc/error.h"
|
|
12
|
+
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
extern "C" {
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
typedef struct TirtcInitOptions {
|
|
18
|
+
const char* app_id;
|
|
19
|
+
|
|
20
|
+
const char* endpoint;
|
|
21
|
+
|
|
22
|
+
const char* log_root_dir;
|
|
23
|
+
|
|
24
|
+
int console_log_enabled;
|
|
25
|
+
|
|
26
|
+
} TirtcInitOptions;
|
|
27
|
+
|
|
28
|
+
typedef enum TirtcMediaSendPolicy {
|
|
29
|
+
|
|
30
|
+
TIRTC_MEDIA_SEND_POLICY_ON_REQUEST = 0,
|
|
31
|
+
|
|
32
|
+
TIRTC_MEDIA_SEND_POLICY_AUTO_ON_CONNECTED = 1,
|
|
33
|
+
} TirtcMediaSendPolicy;
|
|
34
|
+
|
|
35
|
+
typedef struct TirtcConnServiceStartOptions {
|
|
36
|
+
const char* license;
|
|
37
|
+
|
|
38
|
+
uint32_t max_connections;
|
|
39
|
+
|
|
40
|
+
TirtcMediaSendPolicy media_send_policy;
|
|
41
|
+
} TirtcConnServiceStartOptions;
|
|
42
|
+
|
|
43
|
+
typedef struct TirtcConnConnectOptions {
|
|
44
|
+
const char* remote_id;
|
|
45
|
+
|
|
46
|
+
const char* token;
|
|
47
|
+
} TirtcConnConnectOptions;
|
|
48
|
+
|
|
49
|
+
typedef struct TirtcConnCreateOptions {
|
|
50
|
+
const struct TirtcConnCallbacks* callbacks;
|
|
51
|
+
|
|
52
|
+
void* user_data;
|
|
53
|
+
} TirtcConnCreateOptions;
|
|
54
|
+
|
|
55
|
+
typedef struct TirtcConnService TirtcConnService;
|
|
56
|
+
|
|
57
|
+
typedef struct TirtcConn TirtcConn;
|
|
58
|
+
|
|
59
|
+
typedef enum TirtcConnState {
|
|
60
|
+
|
|
61
|
+
TIRTC_CONN_STATE_IDLE = 0,
|
|
62
|
+
|
|
63
|
+
TIRTC_CONN_STATE_CONNECTING = 1,
|
|
64
|
+
|
|
65
|
+
TIRTC_CONN_STATE_CONNECTED = 2,
|
|
66
|
+
|
|
67
|
+
TIRTC_CONN_STATE_DISCONNECTED = 3,
|
|
68
|
+
} TirtcConnState;
|
|
69
|
+
|
|
70
|
+
typedef struct TirtcStreamMessage {
|
|
71
|
+
uint32_t timestamp_ms;
|
|
72
|
+
|
|
73
|
+
const void* data;
|
|
74
|
+
|
|
75
|
+
size_t length;
|
|
76
|
+
} TirtcStreamMessage;
|
|
77
|
+
|
|
78
|
+
typedef struct TirtcConnCommand {
|
|
79
|
+
uint32_t command;
|
|
80
|
+
|
|
81
|
+
const void* data;
|
|
82
|
+
|
|
83
|
+
size_t length;
|
|
84
|
+
} TirtcConnCommand;
|
|
85
|
+
|
|
86
|
+
typedef struct TirtcConnMetricsSnapshot {
|
|
87
|
+
int has_connect_start;
|
|
88
|
+
int has_connected;
|
|
89
|
+
uint64_t connect_start_monotonic_ms;
|
|
90
|
+
uint64_t connected_monotonic_ms;
|
|
91
|
+
} TirtcConnMetricsSnapshot;
|
|
92
|
+
|
|
93
|
+
/** Heap-owned byte payload allocated by facade callback dispatch. */
|
|
94
|
+
typedef struct TirtcOwnedBytes {
|
|
95
|
+
/** Payload buffer allocated by facade, or `NULL` for zero-length payloads. */
|
|
96
|
+
void* data;
|
|
97
|
+
|
|
98
|
+
/** Number of bytes stored in `data`. */
|
|
99
|
+
size_t length;
|
|
100
|
+
} TirtcOwnedBytes;
|
|
101
|
+
|
|
102
|
+
/** Heap-owned UTF-8 string allocated by facade callback dispatch. */
|
|
103
|
+
typedef struct TirtcOwnedString {
|
|
104
|
+
/** Null-terminated UTF-8 buffer allocated by facade, or `NULL` when no message is available. */
|
|
105
|
+
char* data;
|
|
106
|
+
} TirtcOwnedString;
|
|
107
|
+
|
|
108
|
+
typedef struct TirtcConnServiceCallbacks {
|
|
109
|
+
void (*on_started)(TirtcConnService* service, void* user_data);
|
|
110
|
+
|
|
111
|
+
void (*on_stopped)(TirtcConnService* service, void* user_data);
|
|
112
|
+
|
|
113
|
+
void (*on_connected)(TirtcConnService* service, TirtcConn* connection, void* user_data);
|
|
114
|
+
|
|
115
|
+
void (*on_error)(TirtcConnService* service, TirtcError error, const char* message,
|
|
116
|
+
void* user_data);
|
|
117
|
+
} TirtcConnServiceCallbacks;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Connection observer installed through `tirtc_conn_create()` or `tirtc_conn_set_callbacks()`.
|
|
121
|
+
*
|
|
122
|
+
* For `on_command()` and `on_stream_message()`, facade copies the variable-length payload to heap
|
|
123
|
+
* memory before dispatch. The callback receives ownership of that payload and must release it with
|
|
124
|
+
* `tirtc_owned_bytes_release()` after converting or copying the bytes it needs. The release API is
|
|
125
|
+
* NULL-safe. If facade cannot allocate an owned copy for a non-empty payload, it drops that
|
|
126
|
+
* callback delivery rather than dispatching a borrowed pointer.
|
|
127
|
+
*/
|
|
128
|
+
typedef struct TirtcConnCallbacks {
|
|
129
|
+
void (*on_state_changed)(TirtcConn* connection, TirtcConnState state, TirtcError error,
|
|
130
|
+
void* user_data);
|
|
131
|
+
|
|
132
|
+
void (*on_command)(TirtcConn* connection, uint32_t command, TirtcOwnedBytes* owned_payload,
|
|
133
|
+
void* user_data);
|
|
134
|
+
|
|
135
|
+
void (*on_stream_message)(TirtcConn* connection, uint8_t stream_id, uint32_t timestamp_ms,
|
|
136
|
+
TirtcOwnedBytes* owned_payload, void* user_data);
|
|
137
|
+
} TirtcConnCallbacks;
|
|
138
|
+
|
|
139
|
+
TirtcError tirtc_init(const TirtcInitOptions* options);
|
|
140
|
+
|
|
141
|
+
void tirtc_uninit(void);
|
|
142
|
+
|
|
143
|
+
TirtcError tirtc_conn_service_start(const TirtcConnServiceStartOptions* options,
|
|
144
|
+
const TirtcConnServiceCallbacks* observer, void* user_data,
|
|
145
|
+
TirtcConnService** out_service);
|
|
146
|
+
|
|
147
|
+
TirtcError tirtc_conn_service_stop(TirtcConnService* service);
|
|
148
|
+
|
|
149
|
+
TirtcError tirtc_conn_create(const TirtcConnCreateOptions* options, TirtcConn** out_connection);
|
|
150
|
+
|
|
151
|
+
TirtcError tirtc_conn_set_callbacks(TirtcConn* connection, const TirtcConnCallbacks* callbacks,
|
|
152
|
+
void* user_data);
|
|
153
|
+
|
|
154
|
+
TirtcError tirtc_conn_connect(TirtcConn* connection, const TirtcConnConnectOptions* options);
|
|
155
|
+
|
|
156
|
+
TirtcError tirtc_conn_disconnect(TirtcConn* connection);
|
|
157
|
+
|
|
158
|
+
void tirtc_conn_destroy(TirtcConn* connection);
|
|
159
|
+
|
|
160
|
+
TirtcError tirtc_conn_send_stream_message(TirtcConn* connection, uint8_t stream_id,
|
|
161
|
+
const TirtcStreamMessage* message);
|
|
162
|
+
|
|
163
|
+
/** Copies a stream-message payload into a releasable owned buffer. */
|
|
164
|
+
TirtcOwnedBytes* tirtc_stream_message_copy_payload(const TirtcStreamMessage* message);
|
|
165
|
+
|
|
166
|
+
/** Copies a command payload into a releasable owned buffer. */
|
|
167
|
+
TirtcOwnedBytes* tirtc_conn_command_copy_payload(const TirtcConnCommand* command);
|
|
168
|
+
|
|
169
|
+
/** Copies a UTF-8 string into a releasable owned buffer. */
|
|
170
|
+
TirtcOwnedString* tirtc_string_copy_owned(const char* message);
|
|
171
|
+
|
|
172
|
+
/** Releases a payload received from facade owned-memory callback APIs. Safe to call with `NULL`. */
|
|
173
|
+
void tirtc_owned_bytes_release(TirtcOwnedBytes* owned);
|
|
174
|
+
|
|
175
|
+
/** Releases a string received from facade owned-memory callback APIs. Safe to call with `NULL`. */
|
|
176
|
+
void tirtc_owned_string_release(TirtcOwnedString* owned);
|
|
177
|
+
|
|
178
|
+
TirtcError tirtc_conn_send_command(TirtcConn* connection, const TirtcConnCommand* command);
|
|
179
|
+
|
|
180
|
+
TirtcError tirtc_metrics_conn_get_snapshot(TirtcConn* connection,
|
|
181
|
+
TirtcConnMetricsSnapshot* out_snapshot);
|
|
182
|
+
|
|
183
|
+
#ifdef __cplusplus
|
|
184
|
+
}
|
|
185
|
+
#endif
|
|
186
|
+
|
|
187
|
+
#endif
|