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,452 @@
1
+ #ifndef TIRTC_FACADE_AV_H_
2
+ #define TIRTC_FACADE_AV_H_
3
+
4
+ #include "tirtc/audio.h"
5
+ #include "tirtc/media_codec.h"
6
+ #include "tirtc/video_io.h"
7
+
8
+ #ifdef __cplusplus
9
+ extern "C" {
10
+ #endif
11
+
12
+ /**
13
+ * @file tirtc/av.h
14
+ * @brief Audio-video facade layer built on top of `tirtc/audio.h`.
15
+ *
16
+ * This header adds local video input, remote video output, preview binding,
17
+ * and video-specific control helpers to the transport-plus-audio facade.
18
+ *
19
+ * Typical uplink flow:
20
+ * 1. Create a ::TirtcVideoInput.
21
+ * 2. Bind a concrete capture backend with ::tirtc_video_input_set_vin.
22
+ * 3. Optionally configure encoding options and observers.
23
+ * 4. Optionally bind a preview output with
24
+ * ::tirtc_video_input_set_preview_output.
25
+ * 5. Start the input and attach it to a connection stream.
26
+ * 6. Detach, stop, clear preview, and destroy the input during shutdown.
27
+ *
28
+ * Typical downlink flow:
29
+ * 1. Create a ::TirtcVideoOutput.
30
+ * 2. Bind a concrete render backend with ::tirtc_video_output_set_vout.
31
+ * 3. Optionally install an observer.
32
+ * 4. Attach the output to a connection stream.
33
+ * 5. Detach and destroy the output during shutdown.
34
+ *
35
+ * Important exclusivity rule:
36
+ * one ::TirtcVideoOutput can serve only one consumer at a time. It may be used
37
+ * either as a local preview target for one ::TirtcVideoInput or as a remote
38
+ * display target for one connection stream, but not both at once.
39
+ *
40
+ * Ownership model:
41
+ * - The caller owns all video input and output handles.
42
+ * - Attaching to a connection or binding a preview output is non-owning.
43
+ * - Destroying a connection detaches remote-bound video objects but does not
44
+ * destroy them.
45
+ * - Destroying a video input clears its preview binding but does not destroy
46
+ * the preview output object.
47
+ */
48
+
49
+ /** @brief Opaque video uplink handle. */
50
+ typedef struct TirtcVideoInput TirtcVideoInput;
51
+
52
+ /** @brief Opaque video downlink or preview output handle. */
53
+ typedef struct TirtcVideoOutput TirtcVideoOutput;
54
+
55
+ /**
56
+ * @brief Video output state reported through ::TirtcVideoOutputObserver.
57
+ */
58
+ typedef enum TirtcVideoOutputState {
59
+ /** Output is attached but not currently rendering frames. */
60
+ TIRTC_VIDEO_OUTPUT_STATE_IDLE = 0,
61
+
62
+ /** Output is actively rendering frames. */
63
+ TIRTC_VIDEO_OUTPUT_STATE_RENDERING = 1,
64
+
65
+ /** Output is waiting for frames or recovering from a transient failure. */
66
+ TIRTC_VIDEO_OUTPUT_STATE_BUFFERING = 2,
67
+
68
+ /** Reserved paused state. */
69
+ TIRTC_VIDEO_OUTPUT_STATE_PAUSED = 3,
70
+
71
+ /** Reserved completed state. */
72
+ TIRTC_VIDEO_OUTPUT_STATE_COMPLETED = 4,
73
+
74
+ /** Output encountered repeated rendering failures. */
75
+ TIRTC_VIDEO_OUTPUT_STATE_FAILED = 5,
76
+ } TirtcVideoOutputState;
77
+
78
+ /**
79
+ * @brief Video input encoding options.
80
+ *
81
+ * These options are consumed when the internal video uplink pipeline is first
82
+ * created. Configure them before the first successful start for predictable
83
+ * behavior.
84
+ */
85
+ typedef struct TirtcVideoInputOptions {
86
+ /**
87
+ * @brief Encoded video codec.
88
+ *
89
+ * The current implementation defaults to ::TIRTC_MEDIA_CODEC_VIDEO_H264 when
90
+ * this field is ::TIRTC_MEDIA_CODEC_NONE.
91
+ */
92
+ TirtcMediaCodec codec;
93
+
94
+ /**
95
+ * @brief Target encoded width in pixels.
96
+ *
97
+ * The current implementation defaults to 320 when this field is zero.
98
+ */
99
+ uint32_t width;
100
+
101
+ /**
102
+ * @brief Target encoded height in pixels.
103
+ *
104
+ * The current implementation defaults to 180 when this field is zero.
105
+ */
106
+ uint32_t height;
107
+
108
+ /**
109
+ * @brief Target frame rate.
110
+ *
111
+ * The current implementation defaults to 15 when this field is zero.
112
+ */
113
+ uint32_t fps;
114
+
115
+ /**
116
+ * @brief Target encoded bitrate in kilobits per second.
117
+ *
118
+ * The current implementation passes zero through to the underlying encoder,
119
+ * allowing the codec backend to choose its default rate-control behavior.
120
+ */
121
+ uint32_t bitrate_kbps;
122
+ } TirtcVideoInputOptions;
123
+
124
+ /**
125
+ * @brief Optional observer for a video input object.
126
+ *
127
+ * The implementation stores a copy of this structure. Installing or replacing
128
+ * an observer does not replay prior state; callbacks describe subsequent local
129
+ * start and stop transitions.
130
+ *
131
+ * Callback delivery is not guaranteed to be on a fixed thread. In the current
132
+ * implementation, input state notifications may be dispatched synchronously by
133
+ * API calls such as ::tirtc_video_input_start and ::tirtc_video_input_stop.
134
+ * Callers must therefore make callback logic safe for reentrant delivery.
135
+ */
136
+ typedef struct TirtcVideoInputObserver {
137
+ /**
138
+ * @brief Called when the input starts or stops.
139
+ *
140
+ * In the current implementation, a start failure is reported as STOPPED with
141
+ * a non-OK ::error value.
142
+ */
143
+ void (*on_state_changed)(TirtcVideoInput* input, TirtcInputState state, TirtcError error,
144
+ void* user_data);
145
+
146
+ /**
147
+ * @brief Reserved callback for output-size updates.
148
+ *
149
+ * The current facade implementation exposes this callback in the contract but
150
+ * does not currently emit it.
151
+ */
152
+ void (*on_output_size_changed)(TirtcVideoInput* input, uint32_t width, uint32_t height,
153
+ void* user_data);
154
+ } TirtcVideoInputObserver;
155
+
156
+ /**
157
+ * @brief Optional observer for a video output object.
158
+ *
159
+ * The implementation stores a copy of this structure. Installing or replacing
160
+ * an observer does not replay the current output state.
161
+ *
162
+ * Callback delivery is not guaranteed to be on a fixed thread. State changes
163
+ * may be reported synchronously by attach, detach, or backend-clear paths, or
164
+ * asynchronously from the internal downlink pipeline. Callers must therefore
165
+ * make callback logic safe for reentrant delivery and perform their own thread
166
+ * handoff when thread affinity is required.
167
+ */
168
+ typedef struct TirtcVideoOutputObserver {
169
+ /**
170
+ * @brief Called when the output state changes.
171
+ *
172
+ * A common sequence is IDLE after attach, then BUFFERING, then RENDERING,
173
+ * and IDLE again after detach or backend removal.
174
+ */
175
+ void (*on_state_changed)(TirtcVideoOutput* output, TirtcVideoOutputState state, TirtcError error,
176
+ void* user_data);
177
+
178
+ /**
179
+ * @brief Reserved callback for output-size updates.
180
+ *
181
+ * The current facade implementation exposes this callback in the contract but
182
+ * does not currently emit it.
183
+ */
184
+ void (*on_output_size_changed)(TirtcVideoOutput* output, uint32_t width, uint32_t height,
185
+ void* user_data);
186
+ } TirtcVideoOutputObserver;
187
+
188
+ /**
189
+ * @brief Enable or disable runtime media-trace logging.
190
+ *
191
+ * This is a process-wide runtime switch, not a per-connection setting.
192
+ *
193
+ * @param enabled Non-zero to enable tracing; zero to disable it.
194
+ * @return ::TIRTC_ERROR_OK on success.
195
+ */
196
+ TirtcError tirtc_set_media_trace_enabled(int enabled);
197
+
198
+ /**
199
+ * @brief Query whether runtime media tracing is enabled.
200
+ *
201
+ * @param out_enabled Receives `1` when enabled or `0` when disabled.
202
+ * @return ::TIRTC_ERROR_OK on success.
203
+ */
204
+ TirtcError tirtc_get_media_trace_enabled(int* out_enabled);
205
+
206
+ /**
207
+ * @brief Request an I-frame from the remote sender for a video stream.
208
+ *
209
+ * This is typically used by a receiver after join, decoder recovery, or severe
210
+ * packet loss when waiting for the next natural key frame would be too slow.
211
+ *
212
+ * @param connection Target connection.
213
+ * @param stream_id Video stream identifier.
214
+ * @return ::TIRTC_ERROR_OK on success.
215
+ */
216
+ TirtcError tirtc_conn_request_iframe(TirtcConn* connection, uint8_t stream_id);
217
+
218
+ /**
219
+ * @brief Attach a local video input to a connection stream.
220
+ *
221
+ * This bind is non-owning. The same input cannot be attached to more than one
222
+ * connection at a time. The selected ::stream_id must be unique across all
223
+ * currently attached input and output streams on the same connection.
224
+ *
225
+ * @param connection Target connection.
226
+ * @param stream_id Stream identifier that will carry this video route.
227
+ * @param input Video input to bind.
228
+ * @return ::TIRTC_ERROR_OK on success.
229
+ */
230
+ TirtcError tirtc_conn_attach_video_input(TirtcConn* connection, uint8_t stream_id,
231
+ TirtcVideoInput* input);
232
+
233
+ /**
234
+ * @brief Attach a remote video output to a connection stream.
235
+ *
236
+ * The output must not currently be used as a preview target. A video output
237
+ * can be either a preview sink or a remote sink, but never both at the same
238
+ * time.
239
+ *
240
+ * If an observer is already installed, a successful attach typically reports an
241
+ * initial IDLE state before decoded frames begin to render.
242
+ *
243
+ * @param connection Target connection.
244
+ * @param stream_id Remote video stream identifier to render.
245
+ * @param output Video output to bind.
246
+ * @return ::TIRTC_ERROR_OK on success.
247
+ */
248
+ TirtcError tirtc_conn_attach_video_output(TirtcConn* connection, uint8_t stream_id,
249
+ TirtcVideoOutput* output);
250
+
251
+ /**
252
+ * @brief Detach a video input from a connection stream.
253
+ *
254
+ * This call is idempotent.
255
+ *
256
+ * @param connection Target connection.
257
+ * @param stream_id Stream identifier to detach.
258
+ * @return ::TIRTC_ERROR_OK on success.
259
+ */
260
+ TirtcError tirtc_conn_detach_video_input(TirtcConn* connection, uint8_t stream_id);
261
+
262
+ /**
263
+ * @brief Detach a video output from a connection stream.
264
+ *
265
+ * This call is idempotent.
266
+ *
267
+ * @param connection Target connection.
268
+ * @param stream_id Stream identifier to detach.
269
+ * @return ::TIRTC_ERROR_OK on success.
270
+ */
271
+ TirtcError tirtc_conn_detach_video_output(TirtcConn* connection, uint8_t stream_id);
272
+
273
+ /**
274
+ * @brief Create a video input object.
275
+ *
276
+ * The runtime must already be initialized.
277
+ *
278
+ * @param out_input Receives the created input handle on success.
279
+ * @return ::TIRTC_ERROR_OK on success.
280
+ */
281
+ TirtcError tirtc_video_input_create(TirtcVideoInput** out_input);
282
+
283
+ /**
284
+ * @brief Destroy a video input object.
285
+ *
286
+ * The input must already be detached from any connection. Any preview binding
287
+ * is cleared during destruction.
288
+ *
289
+ * @param input Input handle to destroy.
290
+ */
291
+ void tirtc_video_input_destroy(TirtcVideoInput* input);
292
+
293
+ /**
294
+ * @brief Bind a concrete video capture backend to an input object.
295
+ *
296
+ * This must be done while the input is stopped and detached, before the next
297
+ * successful start. The backend pointer is non-owning and should remain valid
298
+ * while the input may still use it.
299
+ *
300
+ * @param input Target video input.
301
+ * @param vin Capture backend to bind.
302
+ * @return ::TIRTC_ERROR_OK on success.
303
+ */
304
+ TirtcError tirtc_video_input_set_vin(TirtcVideoInput* input, TirtcVideoVin* vin);
305
+
306
+ /**
307
+ * @brief Store video encoding options.
308
+ *
309
+ * Best practice is to call this before the first successful start. Updating
310
+ * options after the internal uplink pipeline has already been created does not
311
+ * retroactively rebuild that running pipeline.
312
+ *
313
+ * @param input Target video input.
314
+ * @param options Options to copy into the facade object.
315
+ * @return ::TIRTC_ERROR_OK on success.
316
+ */
317
+ TirtcError tirtc_video_input_set_options(TirtcVideoInput* input,
318
+ const TirtcVideoInputOptions* options);
319
+
320
+ /**
321
+ * @brief Install, replace, or clear the video input observer.
322
+ *
323
+ * Passing NULL for ::observer clears the current observer. The implementation
324
+ * stores a copy of the observer structure and does not require it to outlive
325
+ * this call.
326
+ *
327
+ * @param input Target video input.
328
+ * @param observer Observer to install, or NULL to clear.
329
+ * @param user_data Opaque pointer returned to observer callbacks.
330
+ * @return ::TIRTC_ERROR_OK on success.
331
+ */
332
+ TirtcError tirtc_video_input_set_observer(TirtcVideoInput* input,
333
+ const TirtcVideoInputObserver* observer, void* user_data);
334
+
335
+ /**
336
+ * @brief Bind a preview output to a video input.
337
+ *
338
+ * Use this when local camera frames should also be rendered locally, for
339
+ * example in a self-preview view.
340
+ *
341
+ * The supplied output must already have a non-NULL render backend configured
342
+ * by ::tirtc_video_output_set_vout, and it must not currently be attached to a
343
+ * remote connection stream or owned by another preview input.
344
+ *
345
+ * This preview relationship is non-owning and may be established before or
346
+ * after ::tirtc_video_input_start. Rebinding to a different output
347
+ * automatically releases the previous preview relationship held by this input.
348
+ * When the input is already running, the new preview sink is applied to the
349
+ * live uplink immediately.
350
+ *
351
+ * @param input Target video input.
352
+ * @param output Video output to use for preview.
353
+ * @return ::TIRTC_ERROR_OK on success.
354
+ */
355
+ TirtcError tirtc_video_input_set_preview_output(TirtcVideoInput* input, TirtcVideoOutput* output);
356
+
357
+ /**
358
+ * @brief Clear the preview output currently associated with a video input.
359
+ *
360
+ * This call is idempotent and is the normal pairing call for
361
+ * ::tirtc_video_input_set_preview_output when a preview surface is being
362
+ * released or repurposed for remote display. Clearing the preview relationship
363
+ * does not destroy the output object.
364
+ *
365
+ * @param input Target video input.
366
+ * @return ::TIRTC_ERROR_OK on success.
367
+ */
368
+ TirtcError tirtc_video_input_clear_preview_output(TirtcVideoInput* input);
369
+
370
+ /**
371
+ * @brief Start local video capture and encoding for an input object.
372
+ *
373
+ * A capture backend must already be bound with ::tirtc_video_input_set_vin.
374
+ *
375
+ * @param input Target video input.
376
+ * @return ::TIRTC_ERROR_OK on success.
377
+ */
378
+ TirtcError tirtc_video_input_start(TirtcVideoInput* input);
379
+
380
+ /**
381
+ * @brief Stop local video capture and encoding for an input object.
382
+ *
383
+ * This is the normal pairing call for ::tirtc_video_input_start. The current
384
+ * implementation also tolerates stopping an already stopped input.
385
+ *
386
+ * @param input Target video input.
387
+ * @return ::TIRTC_ERROR_OK on success.
388
+ */
389
+ TirtcError tirtc_video_input_stop(TirtcVideoInput* input);
390
+
391
+ /**
392
+ * @brief Create a video output object.
393
+ *
394
+ * The runtime must already be initialized.
395
+ *
396
+ * @param out_output Receives the created output handle on success.
397
+ * @return ::TIRTC_ERROR_OK on success.
398
+ */
399
+ TirtcError tirtc_video_output_create(TirtcVideoOutput** out_output);
400
+
401
+ /**
402
+ * @brief Destroy a video output object.
403
+ *
404
+ * The output must already be detached from any connection stream and must not
405
+ * be owned by a preview input. If it is still active, the current
406
+ * implementation keeps it alive and ignores the destroy request.
407
+ *
408
+ * @param output Output handle to destroy.
409
+ */
410
+ void tirtc_video_output_destroy(TirtcVideoOutput* output);
411
+
412
+ /**
413
+ * @brief Bind or clear a concrete video render backend for an output object.
414
+ *
415
+ * Passing a non-NULL backend is allowed only while the output is inactive.
416
+ * That means it must be neither attached to a remote stream nor serving as a
417
+ * preview output.
418
+ *
419
+ * Passing NULL clears the current backend. When a remote output is already
420
+ * attached, clearing the backend stops rendering and returns the output to the
421
+ * IDLE state. When the output is currently used for preview, clearing the
422
+ * backend stops the live preview sink but does not clear the preview
423
+ * relationship itself. The output remains owned by that preview binding until
424
+ * ::tirtc_video_input_clear_preview_output is called.
425
+ *
426
+ * @param output Target video output.
427
+ * @param vout Render backend to bind, or NULL to clear.
428
+ * @return ::TIRTC_ERROR_OK on success.
429
+ */
430
+ TirtcError tirtc_video_output_set_vout(TirtcVideoOutput* output, TirtcVideoVout* vout);
431
+
432
+ /**
433
+ * @brief Install, replace, or clear the video output observer.
434
+ *
435
+ * Passing NULL for ::observer clears the current observer. The implementation
436
+ * stores a copy of the observer structure and does not require it to outlive
437
+ * this call.
438
+ *
439
+ * @param output Target video output.
440
+ * @param observer Observer to install, or NULL to clear.
441
+ * @param user_data Opaque pointer returned to observer callbacks.
442
+ * @return ::TIRTC_ERROR_OK on success.
443
+ */
444
+ TirtcError tirtc_video_output_set_observer(TirtcVideoOutput* output,
445
+ const TirtcVideoOutputObserver* observer,
446
+ void* user_data);
447
+
448
+ #ifdef __cplusplus
449
+ }
450
+ #endif
451
+
452
+ #endif // TIRTC_FACADE_AV_H_
@@ -0,0 +1,34 @@
1
+ #ifndef TIRTC_CREDENTIAL_H_
2
+ #define TIRTC_CREDENTIAL_H_
3
+
4
+ #include "tirtc/error.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ typedef struct TirtcCredentialIssueTokenOptions {
11
+ const char* openapi_entry;
12
+ const char* access_id;
13
+ const char* secret_key;
14
+ const char* local_id;
15
+ const char* peer_id;
16
+ int user_ttl_seconds;
17
+ int channel_ttl_seconds;
18
+ } TirtcCredentialIssueTokenOptions;
19
+
20
+ typedef struct TirtcCredentialIssueTokenResult {
21
+ char* token;
22
+ int http_status_code;
23
+ } TirtcCredentialIssueTokenResult;
24
+
25
+ TirtcError tirtc_credential_issue_token(const TirtcCredentialIssueTokenOptions* options,
26
+ TirtcCredentialIssueTokenResult* out_result);
27
+
28
+ void tirtc_credential_issue_token_result_dispose(TirtcCredentialIssueTokenResult* result);
29
+
30
+ #ifdef __cplusplus
31
+ }
32
+ #endif
33
+
34
+ #endif // TIRTC_CREDENTIAL_H_
@@ -0,0 +1,30 @@
1
+ #ifndef TIRTC_FOUNDATION_ERROR_H_
2
+ #define TIRTC_FOUNDATION_ERROR_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ typedef enum TirtcError {
9
+ TIRTC_ERROR_OK = 0,
10
+ TIRTC_ERROR_INVALID_ARGUMENT = 1,
11
+ TIRTC_ERROR_NOT_INITIALIZED = 2,
12
+ TIRTC_ERROR_INTERNAL = 3,
13
+ TIRTC_ERROR_NOT_READY = 4,
14
+ TIRTC_ERROR_UNSUPPORTED_LOOP_POLICY = 5,
15
+ TIRTC_ERROR_SOURCE_HASH_MISMATCH = 6,
16
+ TIRTC_ERROR_STOPPED = 7,
17
+ TIRTC_ERROR_DESTROYED = 8,
18
+ TIRTC_ERROR_TRANSPORT_INVALID_LICENSE = 9,
19
+ TIRTC_ERROR_TRANSPORT_TIMEOUT = 10,
20
+ TIRTC_ERROR_TRANSPORT_BUSY = 11,
21
+ TIRTC_ERROR_TRANSPORT_CONNECTION_TIMEOUT_CLOSED = 12,
22
+ TIRTC_ERROR_TRANSPORT_REMOTE_CLOSED = 13,
23
+ TIRTC_ERROR_TRANSPORT_CONNECTION_OTHER_ERROR = 14,
24
+ } TirtcError;
25
+
26
+ #ifdef __cplusplus
27
+ }
28
+ #endif
29
+
30
+ #endif // TIRTC_FOUNDATION_ERROR_H_
@@ -0,0 +1,27 @@
1
+ #ifndef TIRTC_FOUNDATION_BUILD_INFO_H_
2
+ #define TIRTC_FOUNDATION_BUILD_INFO_H_
3
+
4
+ #include "tirtc/error.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ typedef struct TirtcBuildInfo {
11
+ const char* semver_base;
12
+ const char* semver_effective;
13
+ const char* commit_hash;
14
+ int commit_count;
15
+ const char* build_branch;
16
+ const char* build_time_utc;
17
+ const char* version_string;
18
+ } TirtcBuildInfo;
19
+
20
+ const TirtcBuildInfo* tirtc_build_info_get(void);
21
+ const char* tirtc_build_version_string(void);
22
+
23
+ #ifdef __cplusplus
24
+ }
25
+ #endif
26
+
27
+ #endif // TIRTC_FOUNDATION_BUILD_INFO_H_
@@ -0,0 +1,57 @@
1
+ #ifndef TIRTC_FOUNDATION_HTTP_H_
2
+ #define TIRTC_FOUNDATION_HTTP_H_
3
+
4
+ #include "tirtc/error.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ typedef enum TirtcHttpMethod {
11
+ TIRTC_HTTP_METHOD_GET = 0,
12
+ TIRTC_HTTP_METHOD_POST = 1,
13
+ TIRTC_HTTP_METHOD_PUT = 2,
14
+ TIRTC_HTTP_METHOD_PATCH = 3,
15
+ TIRTC_HTTP_METHOD_DELETE = 4,
16
+ } TirtcHttpMethod;
17
+
18
+ typedef struct TirtcHttpHeader {
19
+ const char* key;
20
+ const char* value;
21
+ } TirtcHttpHeader;
22
+
23
+ typedef struct TirtcHttpRequest {
24
+ const char* scheme;
25
+ const char* host;
26
+ int port;
27
+ const char* path;
28
+ const char* query;
29
+ const TirtcHttpHeader* headers;
30
+ int header_count;
31
+ const char* body;
32
+ int body_size;
33
+ int connect_timeout_ms;
34
+ int read_timeout_ms;
35
+ int write_timeout_ms;
36
+ } TirtcHttpRequest;
37
+
38
+ typedef struct TirtcHttpResponse {
39
+ int status_code;
40
+ const char* body;
41
+ int body_size;
42
+ } TirtcHttpResponse;
43
+
44
+ typedef TirtcError (*TirtcHttpMockHandler)(const TirtcHttpRequest* request, TirtcHttpMethod method,
45
+ TirtcHttpResponse* response, void* user_data);
46
+
47
+ TirtcError tirtc_http_request(const TirtcHttpRequest* request, TirtcHttpMethod method,
48
+ TirtcHttpResponse* response);
49
+ void tirtc_http_response_dispose(TirtcHttpResponse* response);
50
+ TirtcError tirtc_http_set_mock_handler(TirtcHttpMockHandler handler, void* user_data);
51
+ void tirtc_http_clear_mock_handler(void);
52
+
53
+ #ifdef __cplusplus
54
+ }
55
+ #endif
56
+
57
+ #endif // TIRTC_FOUNDATION_HTTP_H_
@@ -0,0 +1,55 @@
1
+ #ifndef TIRTC_FOUNDATION_LOGGING_H_
2
+ #define TIRTC_FOUNDATION_LOGGING_H_
3
+
4
+ #include <stdarg.h>
5
+
6
+ #include "tirtc/error.h"
7
+
8
+ #ifdef __cplusplus
9
+ extern "C" {
10
+ #endif
11
+
12
+ typedef enum TirtcLogLevel {
13
+ TIRTC_LOG_LEVEL_VERBOSE = 0,
14
+ TIRTC_LOG_LEVEL_DEBUG,
15
+ TIRTC_LOG_LEVEL_INFO,
16
+ TIRTC_LOG_LEVEL_WARN,
17
+ TIRTC_LOG_LEVEL_ERROR,
18
+ TIRTC_LOG_LEVEL_FATAL,
19
+ } TirtcLogLevel;
20
+
21
+ typedef void (*TirtcLoggingPrintFunction)(const char* prefix, TirtcLogLevel level, const char* tag,
22
+ const char* fmt, va_list args);
23
+
24
+ #define TIRTC_LOG_PREFIX_DEFAULT "TIRTC_"
25
+
26
+ TirtcError tirtc_logging_set_print_function(TirtcLoggingPrintFunction function);
27
+ TirtcError tirtc_logging_set_level(TirtcLogLevel level);
28
+ TirtcError tirtc_logging_set_console_enabled(int enabled);
29
+
30
+ TirtcError tirtc_logging_initialize(const char* root_dir);
31
+ TirtcError tirtc_logging_write(TirtcLogLevel level, const char* tag, const char* message);
32
+ TirtcError tirtc_logging_print(const char* prefix, TirtcLogLevel level, const char* tag,
33
+ const char* fmt, ...);
34
+ TirtcError tirtc_logging_flush(void);
35
+ TirtcError tirtc_logging_export(const char* output_zip_path);
36
+ TirtcError tirtc_logging_upload(char* log_id, int log_id_capacity);
37
+
38
+ #define TIRTC_LOGV(tag, fmt, ...) \
39
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_VERBOSE, tag, fmt, ##__VA_ARGS__)
40
+ #define TIRTC_LOGD(tag, fmt, ...) \
41
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_DEBUG, tag, fmt, ##__VA_ARGS__)
42
+ #define TIRTC_LOGI(tag, fmt, ...) \
43
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_INFO, tag, fmt, ##__VA_ARGS__)
44
+ #define TIRTC_LOGW(tag, fmt, ...) \
45
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_WARN, tag, fmt, ##__VA_ARGS__)
46
+ #define TIRTC_LOGE(tag, fmt, ...) \
47
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_ERROR, tag, fmt, ##__VA_ARGS__)
48
+ #define TIRTC_LOGF(tag, fmt, ...) \
49
+ tirtc_logging_print(TIRTC_LOG_PREFIX_DEFAULT, TIRTC_LOG_LEVEL_FATAL, tag, fmt, ##__VA_ARGS__)
50
+
51
+ #ifdef __cplusplus
52
+ }
53
+ #endif
54
+
55
+ #endif // TIRTC_FOUNDATION_LOGGING_H_
@@ -0,0 +1,21 @@
1
+ #ifndef TIRTC_MEDIA_CONTRACT_MEDIA_CODEC_H_
2
+ #define TIRTC_MEDIA_CONTRACT_MEDIA_CODEC_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ typedef enum TirtcMediaCodec {
9
+ TIRTC_MEDIA_CODEC_NONE = 0,
10
+ TIRTC_MEDIA_CODEC_AUDIO_G711A = 1,
11
+ /* Reserved shared identifiers; concrete video implementations live outside media-contract. */
12
+ TIRTC_MEDIA_CODEC_VIDEO_H264 = 65,
13
+ TIRTC_MEDIA_CODEC_VIDEO_H265 = 66,
14
+ TIRTC_MEDIA_CODEC_VIDEO_MJPEG = 67,
15
+ } TirtcMediaCodec;
16
+
17
+ #ifdef __cplusplus
18
+ }
19
+ #endif
20
+
21
+ #endif // TIRTC_MEDIA_CONTRACT_MEDIA_CODEC_H_