tirtc-devtools-cli 0.0.9 → 0.0.11

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 (115) hide show
  1. package/README.md +17 -11
  2. package/USAGE.md +72 -33
  3. package/bin/tirtc-devtools-cli.js +1 -1
  4. package/dist/cli/src/bootstrap_flows.d.ts +46 -0
  5. package/dist/cli/src/bootstrap_flows.js +249 -0
  6. package/dist/{devtools/cli → cli}/src/config.d.ts +4 -15
  7. package/dist/{devtools/cli → cli}/src/config.js +7 -31
  8. package/dist/cli/src/default_paths.d.ts +3 -0
  9. package/dist/cli/src/default_paths.js +23 -0
  10. package/dist/{devtools/cli → cli}/src/embedded_paths.d.ts +1 -0
  11. package/dist/{devtools/cli → cli}/src/embedded_paths.js +18 -1
  12. package/dist/{devtools/cli → cli}/src/facade.d.ts +41 -235
  13. package/dist/{devtools/cli → cli}/src/facade.js +8 -27
  14. package/dist/cli/src/guide.js +47 -0
  15. package/dist/{devtools/cli → cli}/src/index.js +55 -141
  16. package/dist/{devtools/cli → cli}/src/session_manager.js +9 -11
  17. package/dist/{devtools/cli → cli}/src/token_command.js +69 -0
  18. package/dist/{devtools/cli → cli}/src/token_tool.d.ts +26 -0
  19. package/dist/{devtools/cli → cli}/src/token_tool.js +123 -22
  20. package/dist/{devtools/cli → cli}/src/transport.d.ts +1 -1
  21. package/package.json +6 -2
  22. package/script/ensure_ffmpeg.sh +1 -1
  23. package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
  24. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  25. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +34 -0
  26. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +13 -0
  27. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/foundation/build_info.h +27 -0
  28. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/http.h +57 -0
  29. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +3 -1
  30. package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
  31. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
  32. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
  33. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  34. package/vendor/app-server/bin/runtime/linux-x64/lib/libssl.a +0 -0
  35. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +2 -32
  36. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +176 -133
  37. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +223 -182
  38. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +2 -0
  39. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +6 -0
  40. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +58 -133
  41. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +47 -224
  42. package/vendor/app-server/bin/runtime/macos-arm64/lib/libTGTRP.a +0 -0
  43. package/vendor/app-server/bin/runtime/macos-arm64/lib/libTiRTC.a +0 -0
  44. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  45. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  46. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  47. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  48. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  49. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  50. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  51. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  52. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +19 -15
  53. package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +19 -0
  54. package/vendor/app-server/dist/host/HostCommandCoordinator.js +196 -0
  55. package/vendor/app-server/dist/host/HostProtocol.d.ts +1 -11
  56. package/vendor/app-server/dist/host/HostProtocol.js +3 -37
  57. package/vendor/app-server/dist/host/HostServer.d.ts +1 -4
  58. package/vendor/app-server/dist/host/HostServer.js +16 -152
  59. package/vendor/app-server/dist/host/RuntimeAdapter.js +2 -2
  60. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +3 -3
  61. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +4 -4
  62. package/vendor/app-server/dist/host/runtime_backed_preflight.js +2 -2
  63. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +1 -1
  64. package/vendor/app-server/dist/protocol/contract.d.ts +5 -64
  65. package/vendor/app-server/dist/protocol/contract.js +3 -12
  66. package/dist/devtools/cli/src/guide.js +0 -50
  67. package/dist/dummy.d.ts +0 -0
  68. package/dist/dummy.js +0 -1
  69. package/dist/index.d.ts +0 -1
  70. package/dist/index.js +0 -48
  71. package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
  72. package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
  73. package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
  74. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +0 -23
  75. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +0 -36
  76. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +0 -56
  77. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +0 -19
  78. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +0 -19
  79. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +0 -19
  80. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +0 -19
  81. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +0 -56
  82. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +0 -18
  83. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +0 -21
  84. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +0 -89
  85. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +0 -115
  86. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +0 -236
  87. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +0 -57
  88. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +0 -55
  89. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +0 -46
  90. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +0 -32
  91. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +0 -34
  92. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +0 -32
  93. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +0 -26
  94. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +0 -34
  95. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
  96. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
  97. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
  98. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
  99. package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
  100. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +0 -30
  101. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +0 -224
  102. /package/dist/{devtools/cli → cli}/src/dummy.d.ts +0 -0
  103. /package/dist/{devtools/cli → cli}/src/dummy.js +0 -0
  104. /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.d.ts +0 -0
  105. /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.js +0 -0
  106. /package/dist/{devtools/cli → cli}/src/guide.d.ts +0 -0
  107. /package/dist/{devtools/cli → cli}/src/index.d.ts +0 -0
  108. /package/dist/{devtools/cli → cli}/src/media_assets.d.ts +0 -0
  109. /package/dist/{devtools/cli → cli}/src/media_assets.js +0 -0
  110. /package/dist/{devtools/cli → cli}/src/progress.d.ts +0 -0
  111. /package/dist/{devtools/cli → cli}/src/progress.js +0 -0
  112. /package/dist/{devtools/cli → cli}/src/session_manager.d.ts +0 -0
  113. /package/dist/{devtools/cli → cli}/src/token_command.d.ts +0 -0
  114. /package/dist/{devtools/cli → cli}/src/transport.js +0 -0
  115. /package/vendor/app-server/bin/{native/macos-arm64 → runtime/macos-arm64/lib}/libtgrtc.dylib +0 -0
@@ -1,6 +1,8 @@
1
1
  #ifndef TIRTC_FACADE_AV_H_
2
2
  #define TIRTC_FACADE_AV_H_
3
3
 
4
+ #include <stdint.h>
5
+
4
6
  #include "tirtc/audio.h"
5
7
  #include "tirtc/media_codec.h"
6
8
  #include "tirtc/video_io.h"
@@ -13,37 +15,34 @@ extern "C" {
13
15
  * @file tirtc/av.h
14
16
  * @brief Audio-video facade layer built on top of `tirtc/audio.h`.
15
17
  *
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
+ * This header adds media-object owned video producer, preview, view, and
19
+ * remote-consumer contracts to the transport-plus-audio facade.
18
20
  *
19
21
  * Typical uplink flow:
20
22
  * 1. Create a ::TirtcVideoInput.
21
23
  * 2. Bind a concrete capture backend with ::tirtc_video_input_set_vin.
22
24
  * 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.
25
+ * 4. Optionally bind a preview output with ::tirtc_video_input_attach_preview.
26
+ * 5. Start or stop the local producer lifecycle with
27
+ * ::tirtc_video_input_start and ::tirtc_video_input_stop.
28
+ * 6. Attach or detach the input to individual connections with
29
+ * ::tirtc_video_input_attach and ::tirtc_video_input_detach.
30
+ * 7. Destroy the input when the object is no longer needed.
27
31
  *
28
32
  * Typical downlink flow:
29
33
  * 1. Create a ::TirtcVideoOutput.
30
- * 2. Bind a concrete render backend with ::tirtc_video_output_set_vout.
34
+ * 2. Bind a local render backend with ::tirtc_video_output_attach_view.
31
35
  * 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.
36
+ * 4. Attach or detach the output to select which remote stream it consumes.
37
+ * 5. Destroy the output when the object is no longer needed.
39
38
  *
40
39
  * Ownership model:
41
40
  * - 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.
41
+ * - Remote attach relationships and preview/view relationships are non-owning.
42
+ * - Destroying a connection clears the binds that reference that connection but
43
+ * does not destroy media objects.
44
+ * - Destroying a media object is strong cleanup: it releases attach-state,
45
+ * preview-state, view-state, observer state, and internal pipeline state.
47
46
  */
48
47
 
49
48
  /** @brief Opaque video uplink handle. */
@@ -56,31 +55,25 @@ typedef struct TirtcVideoOutput TirtcVideoOutput;
56
55
  * @brief Video output state reported through ::TirtcVideoOutputObserver.
57
56
  */
58
57
  typedef enum TirtcVideoOutputState {
59
- /** Output is attached but not currently rendering frames. */
58
+ /** Output currently is not consuming or rendering a remote route. */
60
59
  TIRTC_VIDEO_OUTPUT_STATE_IDLE = 0,
61
60
 
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,
61
+ /** Output is waiting for frames or sink readiness. */
62
+ TIRTC_VIDEO_OUTPUT_STATE_BUFFERING = 1,
70
63
 
71
- /** Reserved completed state. */
72
- TIRTC_VIDEO_OUTPUT_STATE_COMPLETED = 4,
64
+ /** Output is actively rendering frames. */
65
+ TIRTC_VIDEO_OUTPUT_STATE_RENDERING = 2,
73
66
 
74
67
  /** Output encountered repeated rendering failures. */
75
- TIRTC_VIDEO_OUTPUT_STATE_FAILED = 5,
68
+ TIRTC_VIDEO_OUTPUT_STATE_FAILED = 3,
76
69
  } TirtcVideoOutputState;
77
70
 
78
71
  /**
79
72
  * @brief Video input encoding options.
80
73
  *
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.
74
+ * These options are consumed when the internal video uplink pipeline is
75
+ * created or restarted. Configure them before the next
76
+ * ::tirtc_video_input_start when predictable start behavior matters.
84
77
  */
85
78
  typedef struct TirtcVideoInputOptions {
86
79
  /**
@@ -125,32 +118,29 @@ typedef struct TirtcVideoInputOptions {
125
118
  * @brief Optional observer for a video input object.
126
119
  *
127
120
  * 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.
121
+ * an observer does not replay prior state; callbacks describe subsequent input
122
+ * lifecycle transitions, output-size changes, and failures.
130
123
  *
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.
124
+ * Callback delivery is not guaranteed to be on a fixed thread. Callers must
125
+ * therefore make callback logic safe for reentrant delivery and perform their
126
+ * own thread handoff when thread affinity is required.
135
127
  */
136
128
  typedef struct TirtcVideoInputObserver {
137
129
  /**
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.
130
+ * @brief Called when the input lifecycle state changes.
142
131
  */
143
- void (*on_state_changed)(TirtcVideoInput* input, TirtcInputState state, TirtcError error,
144
- void* user_data);
132
+ void (*on_state_changed)(TirtcVideoInput* input, TirtcInputState state, void* user_data);
145
133
 
146
134
  /**
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.
135
+ * @brief Called when the effective encoded output size changes.
151
136
  */
152
137
  void (*on_output_size_changed)(TirtcVideoInput* input, uint32_t width, uint32_t height,
153
138
  void* user_data);
139
+
140
+ /**
141
+ * @brief Called when the input encounters an error.
142
+ */
143
+ void (*on_error)(TirtcVideoInput* input, TirtcError error, const char* message, void* user_data);
154
144
  } TirtcVideoInputObserver;
155
145
 
156
146
  /**
@@ -159,30 +149,29 @@ typedef struct TirtcVideoInputObserver {
159
149
  * The implementation stores a copy of this structure. Installing or replacing
160
150
  * an observer does not replay the current output state.
161
151
  *
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.
152
+ * Callback delivery is not guaranteed to be on a fixed thread. State changes,
153
+ * output-size changes, and failures may be reported synchronously by local API
154
+ * paths or asynchronously from the internal downlink pipeline. Callers must
155
+ * therefore make callback logic safe for reentrant delivery and perform their
156
+ * own thread handoff when thread affinity is required.
167
157
  */
168
158
  typedef struct TirtcVideoOutputObserver {
169
159
  /**
170
160
  * @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
161
  */
175
- void (*on_state_changed)(TirtcVideoOutput* output, TirtcVideoOutputState state, TirtcError error,
176
- void* user_data);
162
+ void (*on_state_changed)(TirtcVideoOutput* output, TirtcVideoOutputState state, void* user_data);
177
163
 
178
164
  /**
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.
165
+ * @brief Called when the effective rendered output size changes.
183
166
  */
184
167
  void (*on_output_size_changed)(TirtcVideoOutput* output, uint32_t width, uint32_t height,
185
168
  void* user_data);
169
+
170
+ /**
171
+ * @brief Called when the output encounters an error.
172
+ */
173
+ void (*on_error)(TirtcVideoOutput* output, TirtcError error, const char* message,
174
+ void* user_data);
186
175
  } TirtcVideoOutputObserver;
187
176
 
188
177
  /**
@@ -204,73 +193,34 @@ TirtcError tirtc_set_media_trace_enabled(int enabled);
204
193
  TirtcError tirtc_get_media_trace_enabled(int* out_enabled);
205
194
 
206
195
  /**
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
- * Attach is a local bind only; it does not send a remote request for this
243
- * stream.
196
+ * @brief Request the remote sender to start sending a video stream.
244
197
  *
245
198
  * @param connection Target connection.
246
- * @param stream_id Remote video stream identifier to render.
247
- * @param output Video output to bind.
199
+ * @param stream_id Remote video stream identifier.
248
200
  * @return ::TIRTC_ERROR_OK on success.
249
201
  */
250
- TirtcError tirtc_conn_attach_video_output(TirtcConn* connection, uint8_t stream_id,
251
- TirtcVideoOutput* output);
202
+ TirtcError tirtc_conn_subscribe_video(TirtcConn* connection, uint8_t stream_id);
252
203
 
253
204
  /**
254
- * @brief Detach a video input from a connection stream.
255
- *
256
- * This call is idempotent.
205
+ * @brief Request the remote sender to stop sending a video stream.
257
206
  *
258
207
  * @param connection Target connection.
259
- * @param stream_id Stream identifier to detach.
208
+ * @param stream_id Remote video stream identifier.
260
209
  * @return ::TIRTC_ERROR_OK on success.
261
210
  */
262
- TirtcError tirtc_conn_detach_video_input(TirtcConn* connection, uint8_t stream_id);
211
+ TirtcError tirtc_conn_unsubscribe_video(TirtcConn* connection, uint8_t stream_id);
263
212
 
264
213
  /**
265
- * @brief Detach a video output from a connection stream.
214
+ * @brief Request a key frame from the remote sender for a video stream.
266
215
  *
267
- * This call is idempotent.
216
+ * This is typically used by a receiver after join, decoder recovery, or severe
217
+ * packet loss when waiting for the next natural key frame would be too slow.
268
218
  *
269
219
  * @param connection Target connection.
270
- * @param stream_id Stream identifier to detach.
220
+ * @param stream_id Video stream identifier.
271
221
  * @return ::TIRTC_ERROR_OK on success.
272
222
  */
273
- TirtcError tirtc_conn_detach_video_output(TirtcConn* connection, uint8_t stream_id);
223
+ TirtcError tirtc_conn_request_key_frame(TirtcConn* connection, uint8_t stream_id);
274
224
 
275
225
  /**
276
226
  * @brief Create a video input object.
@@ -282,22 +232,12 @@ TirtcError tirtc_conn_detach_video_output(TirtcConn* connection, uint8_t stream_
282
232
  */
283
233
  TirtcError tirtc_video_input_create(TirtcVideoInput** out_input);
284
234
 
285
- /**
286
- * @brief Destroy a video input object.
287
- *
288
- * The input must already be detached from any connection. Any preview binding
289
- * is cleared during destruction.
290
- *
291
- * @param input Input handle to destroy.
292
- */
293
- void tirtc_video_input_destroy(TirtcVideoInput* input);
294
-
295
235
  /**
296
236
  * @brief Bind a concrete video capture backend to an input object.
297
237
  *
298
- * This must be done while the input is stopped and detached, before the next
299
- * successful start. The backend pointer is non-owning and should remain valid
300
- * while the input may still use it.
238
+ * This must be done before the backend is needed by the producer pipeline. The
239
+ * backend pointer is non-owning and should remain valid while the input may
240
+ * still use it.
301
241
  *
302
242
  * @param input Target video input.
303
243
  * @param vin Capture backend to bind.
@@ -308,9 +248,9 @@ TirtcError tirtc_video_input_set_vin(TirtcVideoInput* input, TirtcVideoVin* vin)
308
248
  /**
309
249
  * @brief Store video encoding options.
310
250
  *
311
- * Best practice is to call this before the first successful start. Updating
312
- * options after the internal uplink pipeline has already been created does not
313
- * retroactively rebuild that running pipeline.
251
+ * Best practice is to call this before the next ::tirtc_video_input_start.
252
+ * Updating options after the internal uplink pipeline has already been created
253
+ * does not retroactively rebuild that running pipeline.
314
254
  *
315
255
  * @param input Target video input.
316
256
  * @param options Options to copy into the facade object.
@@ -335,101 +275,114 @@ TirtcError tirtc_video_input_set_observer(TirtcVideoInput* input,
335
275
  const TirtcVideoInputObserver* observer, void* user_data);
336
276
 
337
277
  /**
338
- * @brief Bind a preview output to a video input.
278
+ * @brief Start the local video producer lifecycle.
339
279
  *
340
- * Use this when local camera frames should also be rendered locally, for
341
- * example in a self-preview view.
280
+ * This only manages the producer pipeline. It does not create, remove, or
281
+ * replace any connection binding relationship.
342
282
  *
343
- * The supplied output must already have a non-NULL render backend configured
344
- * by ::tirtc_video_output_set_vout, and it must not currently be attached to a
345
- * remote connection stream or owned by another preview input.
346
- *
347
- * This preview relationship is non-owning and may be established before or
348
- * after ::tirtc_video_input_start. Rebinding to a different output
349
- * automatically releases the previous preview relationship held by this input.
350
- * When the input is already running, the new preview sink is applied to the
351
- * live uplink immediately.
283
+ * Calling start on an already-running input is idempotent.
352
284
  *
353
285
  * @param input Target video input.
354
- * @param output Video output to use for preview.
355
286
  * @return ::TIRTC_ERROR_OK on success.
356
287
  */
357
- TirtcError tirtc_video_input_set_preview_output(TirtcVideoInput* input, TirtcVideoOutput* output);
288
+ TirtcError tirtc_video_input_start(TirtcVideoInput* input);
358
289
 
359
290
  /**
360
- * @brief Clear the preview output currently associated with a video input.
291
+ * @brief Stop the local video producer lifecycle.
292
+ *
293
+ * This stops capture, processing, and encoding for the input but keeps all
294
+ * existing attach relationships intact. Future ::tirtc_video_input_start calls
295
+ * may resume the same attach set.
361
296
  *
362
- * This call is idempotent and is the normal pairing call for
363
- * ::tirtc_video_input_set_preview_output when a preview surface is being
364
- * released or repurposed for remote display. Clearing the preview relationship
365
- * does not destroy the output object.
297
+ * Calling stop on an already-stopped input is idempotent.
366
298
  *
367
299
  * @param input Target video input.
368
300
  * @return ::TIRTC_ERROR_OK on success.
369
301
  */
370
- TirtcError tirtc_video_input_clear_preview_output(TirtcVideoInput* input);
302
+ TirtcError tirtc_video_input_stop(TirtcVideoInput* input);
371
303
 
372
304
  /**
373
- * @brief Start local video capture and encoding for an input object.
305
+ * @brief Attach a video input to a connection stream.
374
306
  *
375
- * A capture backend must already be bound with ::tirtc_video_input_set_vin.
307
+ * This bind is non-owning. The same input may be attached to multiple
308
+ * connections at the same time, but only one stream id per connection is kept.
309
+ * Re-attaching the same input to the same connection replaces the prior stream
310
+ * id without requiring an explicit detach first.
376
311
  *
377
- * @param input Target video input.
312
+ * Attach only manages the binding relationship. It does not implicitly start
313
+ * the producer lifecycle.
314
+ *
315
+ * @param input Video input to bind.
316
+ * @param connection Target connection.
317
+ * @param stream_id Stream identifier that will carry this video route.
378
318
  * @return ::TIRTC_ERROR_OK on success.
379
319
  */
380
- TirtcError tirtc_video_input_start(TirtcVideoInput* input);
320
+ TirtcError tirtc_video_input_attach(TirtcVideoInput* input, TirtcConn* connection,
321
+ uint8_t stream_id);
381
322
 
382
323
  /**
383
- * @brief Stop local video capture and encoding for an input object.
324
+ * @brief Detach a video input from one connection.
384
325
  *
385
- * This is the normal pairing call for ::tirtc_video_input_start. The current
386
- * implementation also tolerates stopping an already stopped input.
326
+ * This call is idempotent. It only removes the binding for the specified
327
+ * connection and does not implicitly stop the input lifecycle.
387
328
  *
388
- * @param input Target video input.
329
+ * @param input Video input to unbind.
330
+ * @param connection Connection whose video route should be removed.
389
331
  * @return ::TIRTC_ERROR_OK on success.
390
332
  */
391
- TirtcError tirtc_video_input_stop(TirtcVideoInput* input);
333
+ TirtcError tirtc_video_input_detach(TirtcVideoInput* input, TirtcConn* connection);
392
334
 
393
335
  /**
394
- * @brief Create a video output object.
336
+ * @brief Bind a preview output to a video input.
395
337
  *
396
- * The runtime must already be initialized.
338
+ * Use this when local camera frames should also be rendered locally, for
339
+ * example in a self-preview view.
397
340
  *
398
- * @param out_output Receives the created output handle on success.
341
+ * The supplied output must not currently be attached to a remote connection
342
+ * stream or owned by another preview input. This preview relationship is
343
+ * non-owning and may be established before or after ::tirtc_video_input_start.
344
+ * Rebinding to a different output automatically releases the previous preview
345
+ * relationship held by this input.
346
+ *
347
+ * @param input Target video input.
348
+ * @param preview_output Video output to use for preview.
399
349
  * @return ::TIRTC_ERROR_OK on success.
400
350
  */
401
- TirtcError tirtc_video_output_create(TirtcVideoOutput** out_output);
351
+ TirtcError tirtc_video_input_attach_preview(TirtcVideoInput* input,
352
+ TirtcVideoOutput* preview_output);
402
353
 
403
354
  /**
404
- * @brief Destroy a video output object.
355
+ * @brief Clear the preview output currently associated with a video input.
405
356
  *
406
- * The output must already be detached from any connection stream and must not
407
- * be owned by a preview input. If it is still active, the current
408
- * implementation keeps it alive and ignores the destroy request.
357
+ * This call is idempotent. Clearing the preview relationship does not destroy
358
+ * the output object and does not affect remote connection binds owned by the
359
+ * input.
409
360
  *
410
- * @param output Output handle to destroy.
361
+ * @param input Target video input.
362
+ * @return ::TIRTC_ERROR_OK on success.
411
363
  */
412
- void tirtc_video_output_destroy(TirtcVideoOutput* output);
364
+ TirtcError tirtc_video_input_detach_preview(TirtcVideoInput* input);
413
365
 
414
366
  /**
415
- * @brief Bind or clear a concrete video render backend for an output object.
367
+ * @brief Destroy a video input object.
416
368
  *
417
- * Passing a non-NULL backend is allowed only while the output is inactive.
418
- * That means it must be neither attached to a remote stream nor serving as a
419
- * preview output.
369
+ * Destroy is strong cleanup. The runtime stops the input lifecycle, clears
370
+ * every connection bind and preview relationship owned by this input, and then
371
+ * releases the object.
420
372
  *
421
- * Passing NULL clears the current backend. When a remote output is already
422
- * attached, clearing the backend stops rendering and returns the output to the
423
- * IDLE state. When the output is currently used for preview, clearing the
424
- * backend stops the live preview sink but does not clear the preview
425
- * relationship itself. The output remains owned by that preview binding until
426
- * ::tirtc_video_input_clear_preview_output is called.
373
+ * @param input Input handle to destroy.
374
+ */
375
+ void tirtc_video_input_destroy(TirtcVideoInput* input);
376
+
377
+ /**
378
+ * @brief Create a video output object.
427
379
  *
428
- * @param output Target video output.
429
- * @param vout Render backend to bind, or NULL to clear.
380
+ * The runtime must already be initialized.
381
+ *
382
+ * @param out_output Receives the created output handle on success.
430
383
  * @return ::TIRTC_ERROR_OK on success.
431
384
  */
432
- TirtcError tirtc_video_output_set_vout(TirtcVideoOutput* output, TirtcVideoVout* vout);
385
+ TirtcError tirtc_video_output_create(TirtcVideoOutput** out_output);
433
386
 
434
387
  /**
435
388
  * @brief Install, replace, or clear the video output observer.
@@ -447,6 +400,94 @@ TirtcError tirtc_video_output_set_observer(TirtcVideoOutput* output,
447
400
  const TirtcVideoOutputObserver* observer,
448
401
  void* user_data);
449
402
 
403
+ /**
404
+ * @brief Attach a local render backend to a video output.
405
+ *
406
+ * This establishes the local view/render sink relationship. It is independent
407
+ * from the remote route relationship managed by ::tirtc_video_output_attach.
408
+ * Re-attaching replaces the current local view relationship.
409
+ *
410
+ * @param output Target video output.
411
+ * @param view_sink Render backend to bind.
412
+ * @return ::TIRTC_ERROR_OK on success.
413
+ */
414
+ TirtcError tirtc_video_output_attach_view(TirtcVideoOutput* output, TirtcVideoVout* view_sink);
415
+
416
+ /**
417
+ * @brief Detach the local render backend from a video output.
418
+ *
419
+ * This call is idempotent and does not implicitly detach the current remote
420
+ * route.
421
+ *
422
+ * @param output Target video output.
423
+ * @return ::TIRTC_ERROR_OK on success.
424
+ */
425
+ TirtcError tirtc_video_output_detach_view(TirtcVideoOutput* output);
426
+
427
+ /**
428
+ * @brief Attach a video output to a remote connection stream.
429
+ *
430
+ * This bind is non-owning. The same output can consume only one remote route at
431
+ * a time. Re-attaching replaces the prior route without requiring an explicit
432
+ * detach first.
433
+ *
434
+ * Attach only manages the remote consume route. It does not change local view
435
+ * ownership.
436
+ *
437
+ * @param output Video output to bind.
438
+ * @param connection Target connection.
439
+ * @param stream_id Remote video stream identifier to render.
440
+ * @return ::TIRTC_ERROR_OK on success.
441
+ */
442
+ TirtcError tirtc_video_output_attach(TirtcVideoOutput* output, TirtcConn* connection,
443
+ uint8_t stream_id);
444
+
445
+ /**
446
+ * @brief Detach the current remote route from a video output.
447
+ *
448
+ * This call is idempotent. Detach only stops consuming the current remote
449
+ * route. It does not clear the current local view relationship.
450
+ *
451
+ * @param output Target video output.
452
+ * @return ::TIRTC_ERROR_OK on success.
453
+ */
454
+ TirtcError tirtc_video_output_detach(TirtcVideoOutput* output);
455
+
456
+ /**
457
+ * @brief Destroy a video output object.
458
+ *
459
+ * Destroy is strong cleanup. The runtime detaches the current remote route,
460
+ * clears the local view relationship, clears observer state, and releases
461
+ * internal render pipeline state before the object is destroyed.
462
+ *
463
+ * @param output Output handle to destroy.
464
+ */
465
+ void tirtc_video_output_destroy(TirtcVideoOutput* output);
466
+
467
+ /**
468
+ * @brief Start encoded raw dump for the media downlink currently owned by this output.
469
+ *
470
+ * The output must already be attached to a connection stream and have an active
471
+ * media downlink. The runtime records received encoded payload into the fixed
472
+ * logging-owned media raw dump directory and derives the dump prefix from the
473
+ * bound route as `<peer_id>-<stream_id>`.
474
+ *
475
+ * @param output Target video output.
476
+ * @return ::TIRTC_ERROR_OK on success.
477
+ */
478
+ TirtcError tirtc_video_output_start_raw_dump(TirtcVideoOutput* output);
479
+
480
+ /**
481
+ * @brief Stop encoded raw dump for the media downlink currently owned by this output.
482
+ *
483
+ * This call is idempotent. Stopping seals the current dump directory and keeps
484
+ * collected raw data on disk.
485
+ *
486
+ * @param output Target video output.
487
+ * @return ::TIRTC_ERROR_OK on success.
488
+ */
489
+ TirtcError tirtc_video_output_stop_raw_dump(TirtcVideoOutput* output);
490
+
450
491
  #ifdef __cplusplus
451
492
  }
452
493
  #endif
@@ -22,6 +22,8 @@ typedef enum TirtcError {
22
22
  TIRTC_ERROR_TRANSPORT_REMOTE_CLOSED = 13,
23
23
  TIRTC_ERROR_TRANSPORT_CONNECTION_OTHER_ERROR = 14,
24
24
  TIRTC_ERROR_TRANSPORT_TOKEN_EXPIRED = 15,
25
+ TIRTC_ERROR_DUMP_ROOT_UNAVAILABLE = 16,
26
+ TIRTC_ERROR_DUMP_ALREADY_ACTIVE = 17,
25
27
  } TirtcError;
26
28
 
27
29
  #ifdef __cplusplus
@@ -62,6 +62,9 @@ TirtcError tirtc_media_downlink_audio_get_current_pts(TirtcMediaDownlinkAudio* d
62
62
  int64_t* out_pts_us);
63
63
  TirtcError tirtc_media_downlink_audio_start(TirtcMediaDownlinkAudio* downlink);
64
64
  TirtcError tirtc_media_downlink_audio_stop(TirtcMediaDownlinkAudio* downlink);
65
+ TirtcError tirtc_media_downlink_audio_start_raw_dump(TirtcMediaDownlinkAudio* downlink,
66
+ const char* prefix);
67
+ TirtcError tirtc_media_downlink_audio_stop_raw_dump(TirtcMediaDownlinkAudio* downlink);
65
68
 
66
69
  TirtcError tirtc_media_downlink_video_create(TirtcMediaDownlinkVideo** out_downlink);
67
70
  void tirtc_media_downlink_video_retain(TirtcMediaDownlinkVideo* downlink);
@@ -87,6 +90,9 @@ TirtcError tirtc_media_downlink_video_follow_video(TirtcMediaDownlinkVideo* foll
87
90
  TirtcError tirtc_media_downlink_video_use_self_timing(TirtcMediaDownlinkVideo* downlink);
88
91
  TirtcError tirtc_media_downlink_video_start(TirtcMediaDownlinkVideo* downlink);
89
92
  TirtcError tirtc_media_downlink_video_stop(TirtcMediaDownlinkVideo* downlink);
93
+ TirtcError tirtc_media_downlink_video_start_raw_dump(TirtcMediaDownlinkVideo* downlink,
94
+ const char* prefix);
95
+ TirtcError tirtc_media_downlink_video_stop_raw_dump(TirtcMediaDownlinkVideo* downlink);
90
96
 
91
97
  #ifdef __cplusplus
92
98
  }