tirtc-devtools-cli 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/README.md +1 -1
  2. package/USAGE.md +79 -11
  3. package/dist/cli/src/guide.js +1 -1
  4. package/dist/cli/src/index.js +13 -13
  5. package/dist/cli/src/token_command.js +15 -20
  6. package/dist/cli/src/token_tool.d.ts +8 -17
  7. package/dist/cli/src/token_tool.js +24 -29
  8. package/package.json +1 -1
  9. package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
  10. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  11. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  12. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +1 -1
  13. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +12 -316
  14. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +11 -372
  15. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +47 -325
  16. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  17. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  18. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  19. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  20. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  21. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  22. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  23. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  24. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +12 -12
@@ -11,485 +11,124 @@
11
11
  extern "C" {
12
12
  #endif
13
13
 
14
- /**
15
- * @file tirtc/av.h
16
- * @brief Audio-video facade layer built on top of `tirtc/audio.h`.
17
- *
18
- * This header adds media-object owned video producer, preview, view, and
19
- * remote-consumer contracts to the transport-plus-audio facade.
20
- *
21
- * Typical uplink flow:
22
- * 1. Create a ::TirtcVideoInput.
23
- * 2. Bind a concrete capture backend with ::tirtc_video_input_set_vin.
24
- * 3. Optionally configure encoding options and observers.
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.
31
- *
32
- * Typical downlink flow:
33
- * 1. Create a ::TirtcVideoOutput.
34
- * 2. Bind a local render backend with ::tirtc_video_output_attach_view.
35
- * 3. Optionally install an observer.
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.
38
- *
39
- * Ownership model:
40
- * - The caller owns all video input and output handles.
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.
46
- */
47
-
48
- /** @brief Opaque video uplink handle. */
49
14
  typedef struct TirtcVideoInput TirtcVideoInput;
50
15
 
51
- /** @brief Opaque video downlink or preview output handle. */
52
16
  typedef struct TirtcVideoOutput TirtcVideoOutput;
53
17
 
54
- /**
55
- * @brief Video output state reported through ::TirtcVideoOutputObserver.
56
- */
57
18
  typedef enum TirtcVideoOutputState {
58
- /** Output currently is not consuming or rendering a remote route. */
19
+
59
20
  TIRTC_VIDEO_OUTPUT_STATE_IDLE = 0,
60
21
 
61
- /** Output is waiting for frames or sink readiness. */
62
22
  TIRTC_VIDEO_OUTPUT_STATE_BUFFERING = 1,
63
23
 
64
- /** Output is actively rendering frames. */
65
24
  TIRTC_VIDEO_OUTPUT_STATE_RENDERING = 2,
66
25
 
67
- /** Output encountered repeated rendering failures. */
68
26
  TIRTC_VIDEO_OUTPUT_STATE_FAILED = 3,
69
27
  } TirtcVideoOutputState;
70
28
 
71
- /**
72
- * @brief Video input encoding options.
73
- *
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.
77
- */
78
29
  typedef struct TirtcVideoInputOptions {
79
- /**
80
- * @brief Encoded video codec.
81
- *
82
- * The current implementation defaults to ::TIRTC_MEDIA_CODEC_VIDEO_H264 when
83
- * this field is ::TIRTC_MEDIA_CODEC_NONE.
84
- */
85
30
  TirtcMediaCodec codec;
86
31
 
87
- /**
88
- * @brief Target encoded width in pixels.
89
- *
90
- * The current implementation defaults to 320 when this field is zero.
91
- */
92
32
  uint32_t width;
93
33
 
94
- /**
95
- * @brief Target encoded height in pixels.
96
- *
97
- * The current implementation defaults to 180 when this field is zero.
98
- */
99
34
  uint32_t height;
100
35
 
101
- /**
102
- * @brief Target frame rate.
103
- *
104
- * The current implementation defaults to 15 when this field is zero.
105
- */
106
36
  uint32_t fps;
107
37
 
108
- /**
109
- * @brief Target encoded bitrate in kilobits per second.
110
- *
111
- * The current implementation passes zero through to the underlying encoder,
112
- * allowing the codec backend to choose its default rate-control behavior.
113
- */
114
38
  uint32_t bitrate_kbps;
115
39
  } TirtcVideoInputOptions;
116
40
 
117
41
  /**
118
- * @brief Optional observer for a video input object.
119
- *
120
- * The implementation stores a copy of this structure. Installing or replacing
121
- * an observer does not replay prior state; callbacks describe subsequent input
122
- * lifecycle transitions, output-size changes, and failures.
42
+ * Video input observer.
123
43
  *
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.
44
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
45
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
127
46
  */
128
47
  typedef struct TirtcVideoInputObserver {
129
- /**
130
- * @brief Called when the input lifecycle state changes.
131
- */
132
48
  void (*on_state_changed)(TirtcVideoInput* input, TirtcInputState state, void* user_data);
133
49
 
134
- /**
135
- * @brief Called when the effective encoded output size changes.
136
- */
137
50
  void (*on_output_size_changed)(TirtcVideoInput* input, uint32_t width, uint32_t height,
138
51
  void* user_data);
139
52
 
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);
53
+ void (*on_error)(TirtcVideoInput* input, TirtcError error, TirtcOwnedString* owned_message,
54
+ void* user_data);
144
55
  } TirtcVideoInputObserver;
145
56
 
146
57
  /**
147
- * @brief Optional observer for a video output object.
58
+ * Video output observer.
148
59
  *
149
- * The implementation stores a copy of this structure. Installing or replacing
150
- * an observer does not replay the current output state.
151
- *
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.
60
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
61
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
157
62
  */
158
63
  typedef struct TirtcVideoOutputObserver {
159
- /**
160
- * @brief Called when the output state changes.
161
- */
162
64
  void (*on_state_changed)(TirtcVideoOutput* output, TirtcVideoOutputState state, void* user_data);
163
65
 
164
- /**
165
- * @brief Called when the effective rendered output size changes.
166
- */
167
66
  void (*on_output_size_changed)(TirtcVideoOutput* output, uint32_t width, uint32_t height,
168
67
  void* user_data);
169
68
 
170
- /**
171
- * @brief Called when the output encounters an error.
172
- */
173
- void (*on_error)(TirtcVideoOutput* output, TirtcError error, const char* message,
69
+ void (*on_error)(TirtcVideoOutput* output, TirtcError error, TirtcOwnedString* owned_message,
174
70
  void* user_data);
175
71
  } TirtcVideoOutputObserver;
176
72
 
177
- /**
178
- * @brief Enable or disable runtime media-trace logging.
179
- *
180
- * This is a process-wide runtime switch, not a per-connection setting.
181
- *
182
- * @param enabled Non-zero to enable tracing; zero to disable it.
183
- * @return ::TIRTC_ERROR_OK on success.
184
- */
185
73
  TirtcError tirtc_set_media_trace_enabled(int enabled);
186
74
 
187
- /**
188
- * @brief Query whether runtime media tracing is enabled.
189
- *
190
- * @param out_enabled Receives `1` when enabled or `0` when disabled.
191
- * @return ::TIRTC_ERROR_OK on success.
192
- */
193
75
  TirtcError tirtc_get_media_trace_enabled(int* out_enabled);
194
76
 
195
- /**
196
- * @brief Request the remote sender to start sending a video stream.
197
- *
198
- * @param connection Target connection.
199
- * @param stream_id Remote video stream identifier.
200
- * @return ::TIRTC_ERROR_OK on success.
201
- */
202
77
  TirtcError tirtc_conn_subscribe_video(TirtcConn* connection, uint8_t stream_id);
203
78
 
204
- /**
205
- * @brief Request the remote sender to stop sending a video stream.
206
- *
207
- * @param connection Target connection.
208
- * @param stream_id Remote video stream identifier.
209
- * @return ::TIRTC_ERROR_OK on success.
210
- */
211
79
  TirtcError tirtc_conn_unsubscribe_video(TirtcConn* connection, uint8_t stream_id);
212
80
 
213
- /**
214
- * @brief Request a key frame from the remote sender for a video stream.
215
- *
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.
218
- *
219
- * @param connection Target connection.
220
- * @param stream_id Video stream identifier.
221
- * @return ::TIRTC_ERROR_OK on success.
222
- */
223
81
  TirtcError tirtc_conn_request_key_frame(TirtcConn* connection, uint8_t stream_id);
224
82
 
225
- /**
226
- * @brief Create a video input object.
227
- *
228
- * The runtime must already be initialized.
229
- *
230
- * @param out_input Receives the created input handle on success.
231
- * @return ::TIRTC_ERROR_OK on success.
232
- */
233
83
  TirtcError tirtc_video_input_create(TirtcVideoInput** out_input);
234
84
 
235
- /**
236
- * @brief Bind a concrete video capture backend to an input object.
237
- *
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.
241
- *
242
- * @param input Target video input.
243
- * @param vin Capture backend to bind.
244
- * @return ::TIRTC_ERROR_OK on success.
245
- */
246
85
  TirtcError tirtc_video_input_set_vin(TirtcVideoInput* input, TirtcVideoVin* vin);
247
86
 
248
- /**
249
- * @brief Store video encoding options.
250
- *
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.
254
- *
255
- * @param input Target video input.
256
- * @param options Options to copy into the facade object.
257
- * @return ::TIRTC_ERROR_OK on success.
258
- */
259
87
  TirtcError tirtc_video_input_set_options(TirtcVideoInput* input,
260
88
  const TirtcVideoInputOptions* options);
261
89
 
262
- /**
263
- * @brief Install, replace, or clear the video input observer.
264
- *
265
- * Passing NULL for ::observer clears the current observer. The implementation
266
- * stores a copy of the observer structure and does not require it to outlive
267
- * this call.
268
- *
269
- * @param input Target video input.
270
- * @param observer Observer to install, or NULL to clear.
271
- * @param user_data Opaque pointer returned to observer callbacks.
272
- * @return ::TIRTC_ERROR_OK on success.
273
- */
274
90
  TirtcError tirtc_video_input_set_observer(TirtcVideoInput* input,
275
91
  const TirtcVideoInputObserver* observer, void* user_data);
276
92
 
277
- /**
278
- * @brief Start the local video producer lifecycle.
279
- *
280
- * This only manages the producer pipeline. It does not create, remove, or
281
- * replace any connection binding relationship.
282
- *
283
- * Calling start on an already-running input is idempotent.
284
- *
285
- * @param input Target video input.
286
- * @return ::TIRTC_ERROR_OK on success.
287
- */
288
93
  TirtcError tirtc_video_input_start(TirtcVideoInput* input);
289
94
 
290
- /**
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.
296
- *
297
- * Calling stop on an already-stopped input is idempotent.
298
- *
299
- * @param input Target video input.
300
- * @return ::TIRTC_ERROR_OK on success.
301
- */
302
95
  TirtcError tirtc_video_input_stop(TirtcVideoInput* input);
303
96
 
304
- /**
305
- * @brief Attach a video input to a connection stream.
306
- *
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.
311
- *
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.
318
- * @return ::TIRTC_ERROR_OK on success.
319
- */
320
97
  TirtcError tirtc_video_input_attach(TirtcVideoInput* input, TirtcConn* connection,
321
98
  uint8_t stream_id);
322
99
 
323
- /**
324
- * @brief Detach a video input from one connection.
325
- *
326
- * This call is idempotent. It only removes the binding for the specified
327
- * connection and does not implicitly stop the input lifecycle.
328
- *
329
- * @param input Video input to unbind.
330
- * @param connection Connection whose video route should be removed.
331
- * @return ::TIRTC_ERROR_OK on success.
332
- */
333
100
  TirtcError tirtc_video_input_detach(TirtcVideoInput* input, TirtcConn* connection);
334
101
 
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 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.
349
- * @return ::TIRTC_ERROR_OK on success.
350
- */
351
102
  TirtcError tirtc_video_input_attach_preview(TirtcVideoInput* input,
352
103
  TirtcVideoOutput* preview_output);
353
104
 
354
- /**
355
- * @brief Clear the preview output currently associated with a video input.
356
- *
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.
360
- *
361
- * @param input Target video input.
362
- * @return ::TIRTC_ERROR_OK on success.
363
- */
364
105
  TirtcError tirtc_video_input_detach_preview(TirtcVideoInput* input);
365
106
 
366
- /**
367
- * @brief Destroy a video input object.
368
- *
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.
372
- *
373
- * @param input Input handle to destroy.
374
- */
375
107
  void tirtc_video_input_destroy(TirtcVideoInput* input);
376
108
 
377
- /**
378
- * @brief Create a video output object.
379
- *
380
- * The runtime must already be initialized.
381
- *
382
- * @param out_output Receives the created output handle on success.
383
- * @return ::TIRTC_ERROR_OK on success.
384
- */
385
109
  TirtcError tirtc_video_output_create(TirtcVideoOutput** out_output);
386
110
 
387
- /**
388
- * @brief Install, replace, or clear the video output observer.
389
- *
390
- * Passing NULL for ::observer clears the current observer. The implementation
391
- * stores a copy of the observer structure and does not require it to outlive
392
- * this call.
393
- *
394
- * @param output Target video output.
395
- * @param observer Observer to install, or NULL to clear.
396
- * @param user_data Opaque pointer returned to observer callbacks.
397
- * @return ::TIRTC_ERROR_OK on success.
398
- */
399
111
  TirtcError tirtc_video_output_set_observer(TirtcVideoOutput* output,
400
112
  const TirtcVideoOutputObserver* observer,
401
113
  void* user_data);
402
114
 
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
115
  TirtcError tirtc_video_output_attach_view(TirtcVideoOutput* output, TirtcVideoVout* view_sink);
415
116
 
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
117
  TirtcError tirtc_video_output_detach_view(TirtcVideoOutput* output);
426
118
 
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
119
  TirtcError tirtc_video_output_attach(TirtcVideoOutput* output, TirtcConn* connection,
443
120
  uint8_t stream_id);
444
121
 
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
122
  TirtcError tirtc_video_output_detach(TirtcVideoOutput* output);
455
123
 
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
124
  void tirtc_video_output_destroy(TirtcVideoOutput* output);
466
125
 
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
126
  TirtcError tirtc_video_output_start_raw_dump(TirtcVideoOutput* output);
479
127
 
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
128
  TirtcError tirtc_video_output_stop_raw_dump(TirtcVideoOutput* output);
490
129
 
491
130
  #ifdef __cplusplus
492
131
  }
493
132
  #endif
494
133
 
495
- #endif // TIRTC_FACADE_AV_H_
134
+ #endif