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.
Files changed (156) hide show
  1. package/README.md +52 -0
  2. package/USAGE.md +417 -0
  3. package/bin/tirtc-devtool.js +2 -0
  4. package/dist/app-server/protocol-client/index.d.ts +25 -0
  5. package/dist/app-server/protocol-client/index.js +114 -0
  6. package/dist/devtools/cli/src/config.d.ts +46 -0
  7. package/dist/devtools/cli/src/config.js +98 -0
  8. package/dist/devtools/cli/src/dummy.d.ts +0 -0
  9. package/dist/devtools/cli/src/dummy.js +1 -0
  10. package/dist/devtools/cli/src/embedded_paths.d.ts +7 -0
  11. package/dist/devtools/cli/src/embedded_paths.js +85 -0
  12. package/dist/devtools/cli/src/facade.d.ts +723 -0
  13. package/dist/devtools/cli/src/facade.js +194 -0
  14. package/dist/devtools/cli/src/ffmpeg_tool.d.ts +6 -0
  15. package/dist/devtools/cli/src/ffmpeg_tool.js +146 -0
  16. package/dist/devtools/cli/src/guide.d.ts +1 -0
  17. package/dist/devtools/cli/src/guide.js +49 -0
  18. package/dist/devtools/cli/src/index.d.ts +1 -0
  19. package/dist/devtools/cli/src/index.js +753 -0
  20. package/dist/devtools/cli/src/media_assets.d.ts +25 -0
  21. package/dist/devtools/cli/src/media_assets.js +121 -0
  22. package/dist/devtools/cli/src/session_manager.d.ts +25 -0
  23. package/dist/devtools/cli/src/session_manager.js +393 -0
  24. package/dist/devtools/cli/src/token_tool.d.ts +33 -0
  25. package/dist/devtools/cli/src/token_tool.js +217 -0
  26. package/dist/devtools/cli/src/transport.d.ts +30 -0
  27. package/dist/devtools/cli/src/transport.js +84 -0
  28. package/dist/dummy.d.ts +0 -0
  29. package/dist/dummy.js +1 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +48 -0
  32. package/package.json +54 -0
  33. package/script/ensure_ffmpeg.sh +22 -0
  34. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  35. package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
  36. package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
  37. package/vendor/app-server/bin/native/macos-arm64/libtgrtc.dylib +0 -0
  38. package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
  39. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
  40. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
  41. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +56 -0
  42. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
  43. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
  44. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
  45. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
  46. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
  47. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
  48. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +20 -0
  49. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +53 -0
  50. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
  51. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +89 -0
  52. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +115 -0
  53. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +236 -0
  54. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +57 -0
  55. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
  56. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +46 -0
  57. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +32 -0
  58. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +34 -0
  59. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
  60. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
  61. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
  62. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
  63. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
  64. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  65. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
  66. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
  67. package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
  68. package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
  69. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +34 -0
  70. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +398 -0
  71. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_codec.h +23 -0
  72. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_frame.h +36 -0
  73. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io.h +56 -0
  74. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_android.h +19 -0
  75. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_apple.h +19 -0
  76. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_harmony.h +19 -0
  77. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_windows.h +19 -0
  78. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_processing.h +56 -0
  79. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_sample_rate.h +18 -0
  80. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +452 -0
  81. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +34 -0
  82. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +30 -0
  83. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +27 -0
  84. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +57 -0
  85. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +55 -0
  86. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_codec.h +21 -0
  87. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +95 -0
  88. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +61 -0
  89. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +77 -0
  90. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +71 -0
  91. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_uplink.h +116 -0
  92. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +481 -0
  93. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +541 -0
  94. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_codec.h +58 -0
  95. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_frame.h +55 -0
  96. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io.h +46 -0
  97. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_android.h +32 -0
  98. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_apple.h +47 -0
  99. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_harmony.h +32 -0
  100. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_windows.h +26 -0
  101. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_processing.h +34 -0
  102. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.a +0 -0
  103. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.dylib +0 -0
  104. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  105. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  106. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  107. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  108. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  109. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  110. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  111. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  112. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.a +0 -0
  113. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.dylib +0 -0
  114. package/vendor/app-server/bin/runtime/macos-arm64/lib/libwebrtc_apm.a +0 -0
  115. package/vendor/app-server/bin/runtime/macos-arm64/lib/libxlog.a +0 -0
  116. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +50 -0
  117. package/vendor/app-server/bin/tirtc-devtool-host.js +2 -0
  118. package/vendor/app-server/dist/host/ArtifactManager.d.ts +18 -0
  119. package/vendor/app-server/dist/host/ArtifactManager.js +83 -0
  120. package/vendor/app-server/dist/host/HostProtocol.d.ts +107 -0
  121. package/vendor/app-server/dist/host/HostProtocol.js +256 -0
  122. package/vendor/app-server/dist/host/HostServer.d.ts +49 -0
  123. package/vendor/app-server/dist/host/HostServer.js +635 -0
  124. package/vendor/app-server/dist/host/HostState.d.ts +60 -0
  125. package/vendor/app-server/dist/host/HostState.js +19 -0
  126. package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +81 -0
  127. package/vendor/app-server/dist/host/RuntimeAdapter.js +559 -0
  128. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +30 -0
  129. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +224 -0
  130. package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +37 -0
  131. package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +186 -0
  132. package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +42 -0
  133. package/vendor/app-server/dist/host/RuntimeSendWorker.js +274 -0
  134. package/vendor/app-server/dist/host/TokenTool.d.ts +15 -0
  135. package/vendor/app-server/dist/host/TokenTool.js +84 -0
  136. package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +28 -0
  137. package/vendor/app-server/dist/host/WebPreviewGateway.js +815 -0
  138. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +26 -0
  139. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +118 -0
  140. package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +19 -0
  141. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +141 -0
  142. package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +10 -0
  143. package/vendor/app-server/dist/host/runtime_backed_preflight.js +78 -0
  144. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +28 -0
  145. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +85 -0
  146. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +10 -0
  147. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +41 -0
  148. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +11 -0
  149. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +32 -0
  150. package/vendor/app-server/dist/protocol/contract.d.ts +983 -0
  151. package/vendor/app-server/dist/protocol/contract.js +198 -0
  152. package/vendor/app-server/dist/protocol-client/index.d.ts +25 -0
  153. package/vendor/app-server/dist/protocol-client/index.js +114 -0
  154. package/vendor/app-server/dist/src/index.d.ts +1 -0
  155. package/vendor/app-server/dist/src/index.js +294 -0
  156. package/vendor/runtime/script/prepare_runtime_media_dataset.sh +427 -0
@@ -0,0 +1,541 @@
1
+ #ifndef TIRTC_FACADE_TRP_H_
2
+ #define TIRTC_FACADE_TRP_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
+ * @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
+ 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
+ const char* endpoint;
56
+
57
+ /**
58
+ * @brief Optional directory used to initialize file logging.
59
+ *
60
+ * Pass NULL or an empty string to disable file logging.
61
+ */
62
+ const char* log_root_dir;
63
+
64
+ /**
65
+ * @brief Non-zero to enable console logging; zero to disable it.
66
+ */
67
+ int enable_console_log;
68
+
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
+ } TirtcOptions;
81
+
82
+ /**
83
+ * @brief Options for starting a service-side connection listener.
84
+ *
85
+ * A service accepts inbound transport connections and exposes them through
86
+ * ::TirtcConnServiceObserver.on_connected.
87
+ */
88
+ typedef struct TirtcConnServiceStartOptions {
89
+ /**
90
+ * @brief Non-empty service license string.
91
+ *
92
+ * This field is required.
93
+ */
94
+ const char* license;
95
+
96
+ /**
97
+ * @brief Maximum number of concurrently accepted connections.
98
+ *
99
+ * This is a service-level capacity contract. It applies to the listener as a
100
+ * whole, not to any single connection and not to any individual stream.
101
+ *
102
+ * This field is required and must be non-zero.
103
+ */
104
+ uint32_t max_connections;
105
+ } TirtcConnServiceStartOptions;
106
+
107
+ /**
108
+ * @brief Options for connecting an outbound connection object.
109
+ */
110
+ typedef struct TirtcConnConnectOptions {
111
+ /**
112
+ * @brief Remote peer identifier.
113
+ *
114
+ * This field is required and must be non-empty.
115
+ */
116
+ const char* peer_id;
117
+
118
+ /**
119
+ * @brief Authentication or session token embedded into the transport
120
+ * descriptor.
121
+ *
122
+ * This field is required and must be non-empty.
123
+ */
124
+ const char* token;
125
+ } TirtcConnConnectOptions;
126
+
127
+ /** @brief Opaque handle returned by ::tirtc_conn_service_start. */
128
+ typedef struct TirtcConnService TirtcConnService;
129
+
130
+ /**
131
+ * @brief Opaque connection handle.
132
+ *
133
+ * A handle may come from either ::tirtc_conn_create or a service observer's
134
+ * ::TirtcConnServiceObserver.on_connected callback.
135
+ */
136
+ typedef struct TirtcConn TirtcConn;
137
+
138
+ /**
139
+ * @brief High-level connection state reported through ::TirtcConnObserver.
140
+ */
141
+ typedef enum TirtcConnState {
142
+ /** Connection exists but has not started connecting yet. */
143
+ TIRTC_CONN_STATE_IDLE = 0,
144
+
145
+ /** Connection establishment is in progress. */
146
+ TIRTC_CONN_STATE_CONNECTING = 1,
147
+
148
+ /** Transport is connected and ready for control or media attachment. */
149
+ TIRTC_CONN_STATE_CONNECTED = 2,
150
+
151
+ /** Connection has entered its terminal disconnected state. */
152
+ TIRTC_CONN_STATE_DISCONNECTED = 3,
153
+ } TirtcConnState;
154
+
155
+ /**
156
+ * @brief Reason associated with a disconnected connection.
157
+ */
158
+ typedef enum TirtcConnDisconnectReason {
159
+ /** The implementation could not determine a more specific reason. */
160
+ TIRTC_CONN_DISCONNECT_REASON_UNKNOWN = 0,
161
+
162
+ /** The local side closed the connection intentionally. */
163
+ TIRTC_CONN_DISCONNECT_REASON_LOCAL_CLOSED = 1,
164
+
165
+ /** The remote side closed the connection. */
166
+ TIRTC_CONN_DISCONNECT_REASON_REMOTE_CLOSED = 2,
167
+
168
+ /** Initial connection setup failed. */
169
+ TIRTC_CONN_DISCONNECT_REASON_CONNECT_FAILED = 3,
170
+
171
+ /** Descriptor exchange or validation failed. */
172
+ TIRTC_CONN_DISCONNECT_REASON_INVALID_DESCRIPTOR = 4,
173
+
174
+ /** The underlying transport backend reported an internal failure. */
175
+ TIRTC_CONN_DISCONNECT_REASON_BACKEND_ERROR = 5,
176
+ } TirtcConnDisconnectReason;
177
+
178
+ /**
179
+ * @brief Binary stream-message payload.
180
+ *
181
+ * Stream messages are intended for lightweight application-defined payloads on
182
+ * stream identifiers that are not currently reserved by attached audio or video
183
+ * routes.
184
+ */
185
+ typedef struct TirtcStreamMessage {
186
+ /** @brief Sender-defined timestamp in milliseconds. */
187
+ uint32_t timestamp_ms;
188
+
189
+ /**
190
+ * @brief Pointer to payload bytes.
191
+ *
192
+ * The pointer may be NULL only when ::length is zero.
193
+ */
194
+ const void* data;
195
+
196
+ /** @brief Payload size in bytes. */
197
+ size_t length;
198
+ } TirtcStreamMessage;
199
+
200
+ /**
201
+ * @brief Fire-and-forget command payload.
202
+ */
203
+ typedef struct TirtcConnCommand {
204
+ /** @brief Application-defined command identifier. */
205
+ uint16_t command_id;
206
+
207
+ /** @brief Payload bytes, or NULL when ::length is zero. */
208
+ const void* data;
209
+
210
+ /** @brief Payload size in bytes. */
211
+ size_t length;
212
+ } TirtcConnCommand;
213
+
214
+ /**
215
+ * @brief Request payload for an asynchronous command round-trip.
216
+ */
217
+ typedef struct TirtcConnCommandRequest {
218
+ /** @brief Application-defined command identifier. */
219
+ uint16_t command_id;
220
+
221
+ /** @brief Payload bytes, or NULL when ::length is zero. */
222
+ const void* data;
223
+
224
+ /** @brief Payload size in bytes. */
225
+ size_t length;
226
+
227
+ /**
228
+ * @brief Response timeout in milliseconds.
229
+ *
230
+ * A value of zero is currently treated as a minimal non-zero timeout rather
231
+ * than an infinite wait.
232
+ */
233
+ uint32_t timeout_ms;
234
+ } TirtcConnCommandRequest;
235
+
236
+ /**
237
+ * @brief Response payload returned by a remote peer or local reply logic.
238
+ */
239
+ typedef struct TirtcConnCommandResponse {
240
+ /** @brief Application-defined command identifier. */
241
+ uint16_t command_id;
242
+
243
+ /** @brief Payload bytes, or NULL when ::length is zero. */
244
+ const void* data;
245
+
246
+ /** @brief Payload size in bytes. */
247
+ size_t length;
248
+ } TirtcConnCommandResponse;
249
+
250
+ /**
251
+ * @brief Completion callback used by ::tirtc_conn_request_command.
252
+ *
253
+ * The callback may complete because of a successful response, a send failure,
254
+ * a timeout, or a disconnect. The callback is not invoked after the connection
255
+ * has been destroyed.
256
+ *
257
+ * Delivery may be synchronous or asynchronous:
258
+ * - If request submission fails immediately, the callback may run before
259
+ * ::tirtc_conn_request_command returns.
260
+ * - After request submission succeeds, completion is reported later from the
261
+ * transport or timeout path.
262
+ *
263
+ * Callers must not assume a fixed callback thread, and must write callback
264
+ * logic so it is safe for reentrant delivery relative to
265
+ * ::tirtc_conn_request_command and other connection callbacks.
266
+ *
267
+ * @param connection Connection that owns the request.
268
+ * @param error Completion status.
269
+ * @param response Non-NULL only when a response payload is available.
270
+ * @param user_data Opaque pointer originally passed to
271
+ * ::tirtc_conn_request_command.
272
+ */
273
+ typedef void (*TirtcConnCommandResponseFn)(TirtcConn* connection, TirtcError error,
274
+ const TirtcConnCommandResponse* response,
275
+ void* user_data);
276
+
277
+ /**
278
+ * @brief Optional observer for service lifecycle and accepted connections.
279
+ *
280
+ * The implementation copies this structure when the service starts. The
281
+ * structure itself does not need to remain alive after
282
+ * ::tirtc_conn_service_start returns.
283
+ */
284
+ typedef struct TirtcConnServiceObserver {
285
+ /** @brief Called after the service has started successfully. */
286
+ void (*on_started)(TirtcConnService* service, void* user_data);
287
+
288
+ /** @brief Called after the service has stopped successfully. */
289
+ void (*on_stopped)(TirtcConnService* service, void* user_data);
290
+
291
+ /**
292
+ * @brief Called for each inbound connection accepted by the service.
293
+ *
294
+ * Ownership of the returned ::TirtcConn handle belongs to the caller. The
295
+ * caller must eventually disconnect and destroy that connection.
296
+ *
297
+ * The runtime will not dispatch other user-facing callbacks for that
298
+ * accepted connection until this callback returns. Callers that need full
299
+ * callback coverage should install the connection observer synchronously
300
+ * inside this callback before returning.
301
+ */
302
+ void (*on_connected)(TirtcConnService* service, TirtcConn* connection, void* user_data);
303
+
304
+ /**
305
+ * @brief Called when the service reports an error or a promoted system event.
306
+ */
307
+ void (*on_error)(TirtcConnService* service, TirtcError error, const char* message,
308
+ void* user_data);
309
+ } TirtcConnServiceObserver;
310
+
311
+ /**
312
+ * @brief Optional observer for connection lifecycle and control-plane events.
313
+ *
314
+ * The implementation stores a copy of this structure. Passing NULL to
315
+ * ::tirtc_conn_set_observer clears the current observer.
316
+ *
317
+ * Replay contract:
318
+ * - Installing or replacing an observer immediately replays the current state.
319
+ * - If the connection has already disconnected, the terminal disconnected
320
+ * callback is replayed as part of observer installation.
321
+ *
322
+ * Callback threading is not restricted to a single caller thread. Some
323
+ * callbacks may be replayed synchronously by API calls such as
324
+ * ::tirtc_conn_set_observer, while others may arrive asynchronously from the
325
+ * internal transport layer.
326
+ */
327
+ typedef struct TirtcConnObserver {
328
+ /** @brief Called when the connection state changes or is replayed. */
329
+ void (*on_state_changed)(TirtcConn* connection, TirtcConnState state, void* user_data);
330
+
331
+ /**
332
+ * @brief Called when the connection enters DISCONNECTED, or when that
333
+ * terminal state is replayed to a newly installed observer.
334
+ */
335
+ void (*on_disconnected)(TirtcConn* connection, TirtcConnDisconnectReason reason, void* user_data);
336
+
337
+ /**
338
+ * @brief Called for an inbound command request that expects a reply.
339
+ *
340
+ * The supplied ::remote_request_id remains valid only while the request is
341
+ * still pending on this connection. In the common case, reply exactly once
342
+ * with ::tirtc_conn_reply_remote_command.
343
+ */
344
+ void (*on_remote_command_request)(TirtcConn* connection, uint64_t remote_request_id,
345
+ const TirtcConnCommand* command, void* user_data);
346
+
347
+ /**
348
+ * @brief Called when an application-defined stream message is received.
349
+ */
350
+ void (*on_stream_message)(TirtcConn* connection, uint8_t stream_id,
351
+ const TirtcStreamMessage* message, void* user_data);
352
+
353
+ /** @brief Called when the transport reports an error for this connection. */
354
+ void (*on_error)(TirtcConn* connection, TirtcError error, const char* message, void* user_data);
355
+ } TirtcConnObserver;
356
+
357
+ /**
358
+ * @brief Initialize the global runtime.
359
+ *
360
+ * Call this exactly once before creating services, connections, audio objects,
361
+ * or video objects.
362
+ *
363
+ * @param options Non-NULL runtime options.
364
+ * @return ::TIRTC_ERROR_OK on success, or an error code when initialization
365
+ * fails or the runtime is already initialized.
366
+ */
367
+ TirtcError tirtc_init(const TirtcOptions* options);
368
+
369
+ /**
370
+ * @brief Shut down the global runtime.
371
+ *
372
+ * This function is intentionally conservative. If any public handles are still
373
+ * alive, the current implementation leaves the runtime initialized and returns
374
+ * without tearing it down. Destroy every connection, stop every service, and
375
+ * destroy every media object before calling this function.
376
+ */
377
+ void tirtc_uninit(void);
378
+
379
+ /**
380
+ * @brief Start a service-side listener.
381
+ *
382
+ * Only one live service is supported at a time.
383
+ *
384
+ * @param options Non-NULL start options with a non-empty license and a non-zero
385
+ * max_connections.
386
+ * @param observer Optional observer copied by value.
387
+ * @param user_data Opaque pointer returned to observer callbacks.
388
+ * @param out_service Receives the created service handle on success.
389
+ * @return ::TIRTC_ERROR_OK on success.
390
+ */
391
+ TirtcError tirtc_conn_service_start(const TirtcConnServiceStartOptions* options,
392
+ const TirtcConnServiceObserver* observer, void* user_data,
393
+ TirtcConnService** out_service);
394
+
395
+ /**
396
+ * @brief Stop a service handle.
397
+ *
398
+ * Accepted connections are separate resources and are not destroyed by stopping
399
+ * the service. Each accepted ::TirtcConn remains the caller's responsibility.
400
+ * On success, the service handle is released and must not be used again.
401
+ *
402
+ * @param service Service handle to stop.
403
+ * @return ::TIRTC_ERROR_OK on success.
404
+ */
405
+ TirtcError tirtc_conn_service_stop(TirtcConnService* service);
406
+
407
+ /**
408
+ * @brief Allocate a standalone connection handle.
409
+ *
410
+ * The runtime must already be initialized. The returned handle starts in
411
+ * ::TIRTC_CONN_STATE_IDLE and must be released with ::tirtc_conn_destroy.
412
+ *
413
+ * @param out_connection Receives the created connection handle on success.
414
+ * @return ::TIRTC_ERROR_OK on success.
415
+ */
416
+ TirtcError tirtc_conn_create(TirtcConn** out_connection);
417
+
418
+ /**
419
+ * @brief Install, replace, or clear the connection observer.
420
+ *
421
+ * Passing NULL for ::observer clears the current observer and its user data.
422
+ * The implementation stores a copy of the observer structure and does not
423
+ * require it to outlive this call.
424
+ * After a non-NULL observer is installed, the implementation immediately
425
+ * replays the current state and, when applicable, the terminal disconnected
426
+ * callback.
427
+ *
428
+ * @param connection Target connection.
429
+ * @param observer Observer to install, or NULL to clear.
430
+ * @param user_data Opaque pointer returned to observer callbacks.
431
+ * @return ::TIRTC_ERROR_OK on success.
432
+ */
433
+ TirtcError tirtc_conn_set_observer(TirtcConn* connection, const TirtcConnObserver* observer,
434
+ void* user_data);
435
+
436
+ /**
437
+ * @brief Connect a standalone connection handle to a remote peer.
438
+ *
439
+ * This function is valid only for handles created by ::tirtc_conn_create.
440
+ * Connections accepted from a service are already transport-owned and cannot be
441
+ * manually connected again.
442
+ *
443
+ * After a disconnect, the same handle may be connected again.
444
+ *
445
+ * @param connection Target connection created by ::tirtc_conn_create.
446
+ * @param options Non-NULL connect options with non-empty peer and token values.
447
+ * @return ::TIRTC_ERROR_OK on success.
448
+ */
449
+ TirtcError tirtc_conn_connect(TirtcConn* connection, const TirtcConnConnectOptions* options);
450
+
451
+ /**
452
+ * @brief Disconnect a connection.
453
+ *
454
+ * This call is idempotent once the connection is already idle or disconnected.
455
+ * Disconnecting does not destroy the handle.
456
+ *
457
+ * @param connection Target connection.
458
+ * @return ::TIRTC_ERROR_OK on success.
459
+ */
460
+ TirtcError tirtc_conn_disconnect(TirtcConn* connection);
461
+
462
+ /**
463
+ * @brief Destroy a connection handle and release its internal transport state.
464
+ *
465
+ * Destroying a connection also detaches any currently attached audio or video
466
+ * objects. Those media objects are not destroyed; they return to an unbound
467
+ * state and remain owned by the caller.
468
+ *
469
+ * After this call returns, the connection handle is invalid and must not be
470
+ * reused.
471
+ *
472
+ * @param connection Connection handle to destroy.
473
+ */
474
+ void tirtc_conn_destroy(TirtcConn* connection);
475
+
476
+ /**
477
+ * @brief Send an application-defined stream message.
478
+ *
479
+ * Use a stream identifier that is not currently occupied by an attached audio
480
+ * input, video input, or video output on the same connection.
481
+ *
482
+ * @param connection Target connection.
483
+ * @param stream_id Application-defined stream identifier for this message.
484
+ * @param message Non-NULL payload descriptor.
485
+ * @return ::TIRTC_ERROR_OK on success.
486
+ */
487
+ TirtcError tirtc_conn_send_stream_message(TirtcConn* connection, uint8_t stream_id,
488
+ const TirtcStreamMessage* message);
489
+
490
+ /**
491
+ * @brief Send an application-defined command without waiting for a response.
492
+ *
493
+ * @param connection Target connection.
494
+ * @param command Non-NULL command payload.
495
+ * @return ::TIRTC_ERROR_OK on success.
496
+ */
497
+ TirtcError tirtc_conn_send_command(TirtcConn* connection, const TirtcConnCommand* command);
498
+
499
+ /**
500
+ * @brief Send an application-defined request command and complete it
501
+ * asynchronously.
502
+ *
503
+ * Callback delivery is mixed synchronous/asynchronous. If request submission
504
+ * fails immediately after the facade has accepted the request, ::callback may
505
+ * run before this function returns. After request submission succeeds,
506
+ * completion is reported later from the response, timeout, or disconnect path.
507
+ *
508
+ * Once this call returns ::TIRTC_ERROR_OK, expect exactly one completion
509
+ * callback unless the connection is destroyed first.
510
+ *
511
+ * @param connection Target connection.
512
+ * @param request Non-NULL request payload.
513
+ * @param callback Completion callback invoked for response, timeout, send
514
+ * failure, or disconnect.
515
+ * @param user_data Opaque pointer returned to ::callback.
516
+ * @return ::TIRTC_ERROR_OK on success.
517
+ */
518
+ TirtcError tirtc_conn_request_command(TirtcConn* connection, const TirtcConnCommandRequest* request,
519
+ TirtcConnCommandResponseFn callback, void* user_data);
520
+
521
+ /**
522
+ * @brief Reply to an inbound remote command request.
523
+ *
524
+ * Use the ::remote_request_id delivered by
525
+ * ::TirtcConnObserver.on_remote_command_request on the same connection. If the
526
+ * request is no longer pending, this function returns a not-ready error.
527
+ * In the normal case, reply at most once for each delivered request id.
528
+ *
529
+ * @param connection Target connection.
530
+ * @param remote_request_id Request id supplied by the observer callback.
531
+ * @param response Non-NULL response payload.
532
+ * @return ::TIRTC_ERROR_OK on success.
533
+ */
534
+ TirtcError tirtc_conn_reply_remote_command(TirtcConn* connection, uint64_t remote_request_id,
535
+ const TirtcConnCommandResponse* response);
536
+
537
+ #ifdef __cplusplus
538
+ }
539
+ #endif
540
+
541
+ #endif // TIRTC_FACADE_TRP_H_
@@ -0,0 +1,58 @@
1
+ #ifndef TIRTC_VIDEO_CODEC_H_
2
+ #define TIRTC_VIDEO_CODEC_H_
3
+
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+
7
+ #include "tirtc/error.h"
8
+ #include "tirtc/video_frame.h"
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ typedef struct TirtcVideoEncoder TirtcVideoEncoder;
15
+ typedef struct TirtcVideoDecoder TirtcVideoDecoder;
16
+
17
+ typedef struct TirtcVideoEncoderConfig {
18
+ TirtcMediaCodec codec;
19
+ TirtcVideoBitstreamFormat bitstream_format;
20
+ uint32_t width;
21
+ uint32_t height;
22
+ uint32_t fps;
23
+ uint32_t bitrate_kbps;
24
+ TirtcVideoPixelFormat input_pixel_format;
25
+ } TirtcVideoEncoderConfig;
26
+
27
+ typedef struct TirtcVideoDecoderConfig {
28
+ TirtcMediaCodec codec;
29
+ TirtcVideoBitstreamFormat bitstream_format;
30
+ TirtcVideoPixelFormat output_pixel_format;
31
+ } TirtcVideoDecoderConfig;
32
+
33
+ TirtcError tirtc_video_encoder_create(const TirtcVideoEncoderConfig* config,
34
+ TirtcVideoEncoder** out_encoder);
35
+ void tirtc_video_encoder_destroy(TirtcVideoEncoder* encoder);
36
+ TirtcError tirtc_video_encoder_reset(TirtcVideoEncoder* encoder);
37
+ TirtcError tirtc_video_encoder_request_key_frame(TirtcVideoEncoder* encoder);
38
+ TirtcError tirtc_video_encoder_encode(TirtcVideoEncoder* encoder,
39
+ const TirtcVideoPixelFrame* in_frame, void* out_buffer,
40
+ size_t out_buffer_capacity,
41
+ TirtcVideoEncodedFrame* out_frame);
42
+
43
+ TirtcError tirtc_video_decoder_create(const TirtcVideoDecoderConfig* config,
44
+ TirtcVideoDecoder** out_decoder);
45
+ void tirtc_video_decoder_destroy(TirtcVideoDecoder* decoder);
46
+ TirtcError tirtc_video_decoder_reset(TirtcVideoDecoder* decoder);
47
+ TirtcError tirtc_video_decoder_decode(TirtcVideoDecoder* decoder,
48
+ const TirtcVideoEncodedFrame* in_frame,
49
+ TirtcVideoPixelFrame* out_frame);
50
+
51
+ TirtcError tirtc_video_snapshot_export_jpeg(const TirtcVideoPixelFrame* frame,
52
+ const char* output_path);
53
+
54
+ #ifdef __cplusplus
55
+ }
56
+ #endif
57
+
58
+ #endif // TIRTC_VIDEO_CODEC_H_
@@ -0,0 +1,55 @@
1
+ #ifndef TIRTC_VIDEO_FRAME_H_
2
+ #define TIRTC_VIDEO_FRAME_H_
3
+
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+
7
+ #include "tirtc/media_codec.h"
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ #define TIRTC_VIDEO_MAX_PLANES 4
14
+
15
+ typedef enum TirtcVideoPixelFormat {
16
+ TIRTC_VIDEO_PIXEL_FORMAT_NONE = 0,
17
+ TIRTC_VIDEO_PIXEL_FORMAT_I420 = 1,
18
+ TIRTC_VIDEO_PIXEL_FORMAT_NV12 = 2,
19
+ TIRTC_VIDEO_PIXEL_FORMAT_RGBA8888 = 3,
20
+ } TirtcVideoPixelFormat;
21
+
22
+ typedef enum TirtcVideoBitstreamFormat {
23
+ TIRTC_VIDEO_BITSTREAM_FORMAT_NONE = 0,
24
+ TIRTC_VIDEO_BITSTREAM_FORMAT_H264_ANNEXB = 1,
25
+ TIRTC_VIDEO_BITSTREAM_FORMAT_H265_ANNEXB = 2,
26
+ TIRTC_VIDEO_BITSTREAM_FORMAT_MJPEG_JFIF = 3,
27
+ } TirtcVideoBitstreamFormat;
28
+
29
+ typedef struct TirtcVideoPixelFrame {
30
+ uint32_t width;
31
+ uint32_t height;
32
+ TirtcVideoPixelFormat pixel_format;
33
+ int64_t pts_us;
34
+ uint32_t plane_count;
35
+ void* planes[TIRTC_VIDEO_MAX_PLANES];
36
+ uint32_t strides[TIRTC_VIDEO_MAX_PLANES];
37
+ size_t plane_bytes[TIRTC_VIDEO_MAX_PLANES];
38
+ } TirtcVideoPixelFrame;
39
+
40
+ typedef struct TirtcVideoEncodedFrame {
41
+ TirtcMediaCodec codec;
42
+ TirtcVideoBitstreamFormat bitstream_format;
43
+ uint32_t width;
44
+ uint32_t height;
45
+ int64_t pts_us;
46
+ int is_key_frame;
47
+ const void* data;
48
+ size_t data_bytes;
49
+ } TirtcVideoEncodedFrame;
50
+
51
+ #ifdef __cplusplus
52
+ }
53
+ #endif
54
+
55
+ #endif // TIRTC_VIDEO_FRAME_H_
@@ -0,0 +1,46 @@
1
+ #ifndef TIRTC_VIDEO_IO_H_
2
+ #define TIRTC_VIDEO_IO_H_
3
+
4
+ #include <stdint.h>
5
+
6
+ #include "tirtc/error.h"
7
+ #include "tirtc/video_frame.h"
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ typedef struct TirtcVideoVin TirtcVideoVin;
14
+ typedef struct TirtcVideoVout TirtcVideoVout;
15
+
16
+ typedef struct TirtcVideoIoConfig {
17
+ uint32_t width;
18
+ uint32_t height;
19
+ uint32_t fps;
20
+ /* Preferred pixel format; actual format resolution is backend-specific. */
21
+ TirtcVideoPixelFormat pixel_format;
22
+ } TirtcVideoIoConfig;
23
+
24
+ typedef void (*TirtcVideoVinOnFrameFn)(TirtcVideoVin* vin, const TirtcVideoPixelFrame* frame,
25
+ void* user_data);
26
+
27
+ TirtcError tirtc_video_vin_open(TirtcVideoVin* vin, const TirtcVideoIoConfig* config,
28
+ TirtcVideoVinOnFrameFn on_frame, void* user_data);
29
+ TirtcError tirtc_video_vin_get_actual_config(TirtcVideoVin* vin, TirtcVideoIoConfig* out_config);
30
+ TirtcError tirtc_video_vin_start(TirtcVideoVin* vin);
31
+ TirtcError tirtc_video_vin_stop(TirtcVideoVin* vin);
32
+ TirtcError tirtc_video_vin_close(TirtcVideoVin* vin);
33
+ void tirtc_video_vin_destroy(TirtcVideoVin* vin);
34
+
35
+ TirtcError tirtc_video_vout_open(TirtcVideoVout* vout, const TirtcVideoIoConfig* config);
36
+ TirtcError tirtc_video_vout_get_actual_config(TirtcVideoVout* vout, TirtcVideoIoConfig* out_config);
37
+ TirtcError tirtc_video_vout_render_frame(TirtcVideoVout* vout, const TirtcVideoPixelFrame* frame);
38
+ TirtcError tirtc_video_vout_flush(TirtcVideoVout* vout);
39
+ TirtcError tirtc_video_vout_close(TirtcVideoVout* vout);
40
+ void tirtc_video_vout_destroy(TirtcVideoVout* vout);
41
+
42
+ #ifdef __cplusplus
43
+ }
44
+ #endif
45
+
46
+ #endif // TIRTC_VIDEO_IO_H_