tirtc-devtools-cli 0.0.11 → 0.0.13

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 (31) hide show
  1. package/README.md +1 -1
  2. package/USAGE.md +85 -13
  3. package/dist/cli/src/guide.js +4 -3
  4. package/dist/cli/src/index.js +13 -13
  5. package/dist/cli/src/token_command.js +39 -31
  6. package/dist/cli/src/token_tool.d.ts +10 -17
  7. package/dist/cli/src/token_tool.js +84 -31
  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/include/tirtc/error.h +36 -17
  12. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
  13. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
  14. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  15. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +1 -1
  16. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +39 -316
  17. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +33 -372
  18. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +36 -17
  19. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +47 -0
  20. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +57 -325
  21. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  22. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  23. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  24. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  25. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  26. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  27. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  28. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  29. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +14 -14
  30. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +2 -5
  31. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +2 -5
@@ -1,4 +1,4 @@
1
1
  platform=linux-x64
2
2
  profile=credential
3
- staged_at_utc=2026-04-21T05:02:38Z
3
+ staged_at_utc=2026-04-23T07:10:15Z
4
4
  source_sdk=/workspace/.build/sdk/linux-x64
@@ -11,429 +11,152 @@
11
11
  extern "C" {
12
12
  #endif
13
13
 
14
- /**
15
- * @file tirtc/audio.h
16
- * @brief Audio facade layer built on top of `tirtc/trp.h`.
17
- *
18
- * This header adds media-object owned audio producer and consumer contracts to
19
- * the base transport facade.
20
- *
21
- * Typical uplink flow:
22
- * 1. Create a ::TirtcAudioInput.
23
- * 2. Bind a concrete capture backend with ::tirtc_audio_input_set_ain.
24
- * 3. Optionally configure processing options and an observer.
25
- * 4. Start or stop the local producer lifecycle with
26
- * ::tirtc_audio_input_start and ::tirtc_audio_input_stop.
27
- * 5. Attach or detach the input to individual connections with
28
- * ::tirtc_audio_input_attach and ::tirtc_audio_input_detach.
29
- * 6. Destroy the input when the object is no longer needed.
30
- *
31
- * Typical downlink flow:
32
- * 1. Create a ::TirtcAudioOutput.
33
- * 2. Bind a concrete playback backend with ::tirtc_audio_output_set_aout.
34
- * 3. Optionally configure playback options and an observer.
35
- * 4. Attach or detach the output to select which remote stream it consumes.
36
- * 5. Destroy the output when the object is no longer needed.
37
- *
38
- * Ownership model:
39
- * - The caller owns all audio input and output handles.
40
- * - Input and output attach relationships are non-owning binds.
41
- * - Destroying a connection clears the binds that reference that connection but
42
- * does not destroy media objects.
43
- * - Destroying a media object is strong cleanup: it releases its own
44
- * attach-state, observer state, and internal pipeline state.
45
- */
46
-
47
- /** @brief Opaque audio uplink handle. */
48
14
  typedef struct TirtcAudioInput TirtcAudioInput;
49
15
 
50
- /** @brief Opaque audio downlink handle. */
51
16
  typedef struct TirtcAudioOutput TirtcAudioOutput;
52
17
 
53
- /**
54
- * @brief Generic input lifecycle state used by audio and video inputs.
55
- */
56
18
  typedef enum TirtcInputState {
57
- /** Input exists but has not started running yet. */
19
+
58
20
  TIRTC_INPUT_STATE_IDLE = 0,
59
21
 
60
- /** Input is actively capturing or producing data. */
61
22
  TIRTC_INPUT_STATE_RUNNING = 1,
62
23
 
63
- /** Input has been explicitly stopped. */
64
24
  TIRTC_INPUT_STATE_STOPPED = 2,
65
25
 
66
- /** Input encountered a producer-side failure. */
67
26
  TIRTC_INPUT_STATE_FAILED = 3,
68
27
  } TirtcInputState;
69
28
 
70
- /**
71
- * @brief Audio output state reported through ::TirtcAudioOutputObserver.
72
- */
73
29
  typedef enum TirtcAudioOutputState {
74
- /** Output currently is not consuming or rendering a remote route. */
30
+
75
31
  TIRTC_AUDIO_OUTPUT_STATE_IDLE = 0,
76
32
 
77
- /** Output is waiting for enough decoded audio to continue playback. */
78
33
  TIRTC_AUDIO_OUTPUT_STATE_BUFFERING = 1,
79
34
 
80
- /** Output is actively playing remote audio. */
81
35
  TIRTC_AUDIO_OUTPUT_STATE_PLAYING = 2,
82
36
 
83
- /** Output encountered repeated playback failures. */
84
37
  TIRTC_AUDIO_OUTPUT_STATE_FAILED = 3,
85
38
  } TirtcAudioOutputState;
86
39
 
87
- /**
88
- * @brief Audio input processing options.
89
- *
90
- * These options are consumed when the internal uplink pipeline is created or
91
- * restarted. Configure them before the next ::tirtc_audio_input_start when
92
- * predictable start behavior matters.
93
- */
94
40
  typedef struct TirtcAudioInputOptions {
95
- /**
96
- * @brief Capture sample rate.
97
- *
98
- * The current implementation defaults to 16 kHz when this field is
99
- * ::TIRTC_AUDIO_SAMPLE_RATE_NONE.
100
- */
101
41
  TirtcAudioSampleRate sample_rate;
102
42
 
103
- /** @brief Acoustic echo cancellation mode. */
104
43
  TirtcAudioAecMode aec_mode;
105
44
 
106
- /** @brief Automatic gain control level. */
107
45
  TirtcAudioAgcLevel agc_level;
108
46
 
109
- /** @brief Acoustic noise suppression level. */
110
47
  TirtcAudioAnsLevel ans_level;
111
48
  } TirtcAudioInputOptions;
112
49
 
113
- /**
114
- * @brief Audio output playback options.
115
- *
116
- * Configure these options before attaching the output to a connection. The
117
- * current API does not support updating them while the output remains bound.
118
- */
119
50
  typedef struct TirtcAudioOutputOptions {
120
- /**
121
- * @brief Playback volume in percent.
122
- *
123
- * The current implementation treats `0` as the default `100` percent.
124
- */
125
51
  uint32_t volume_percent;
126
52
 
127
- /** @brief Additional gain level forwarded to the downlink pipeline. */
128
53
  int gain_level;
129
54
 
130
- /** @brief Additional noise-reduction level forwarded to the downlink pipeline. */
131
55
  int noise_reduction_level;
132
56
  } TirtcAudioOutputOptions;
133
57
 
58
+ typedef struct TirtcOutputStutterMetrics {
59
+ int session_started;
60
+ uint64_t session_duration_ms;
61
+ uint64_t session_stutter_total_ms;
62
+ uint32_t session_stutter_count;
63
+ uint64_t session_stutter_peak_ms;
64
+ double session_stutter_ratio;
65
+ uint32_t recent_window_duration_ms;
66
+ uint64_t recent_window_stutter_total_ms;
67
+ uint32_t recent_window_stutter_count;
68
+ uint64_t recent_window_stutter_peak_ms;
69
+ double recent_window_stutter_ratio;
70
+ } TirtcOutputStutterMetrics;
71
+
72
+ typedef struct TirtcPendingDurationMetrics {
73
+ uint64_t undecoded_duration_ms;
74
+ uint64_t decoded_duration_ms;
75
+ } TirtcPendingDurationMetrics;
76
+
77
+ typedef struct TirtcAudioOutputMetricsSnapshot {
78
+ TirtcOutputStutterMetrics stutter;
79
+ TirtcPendingDurationMetrics pending;
80
+ } TirtcAudioOutputMetricsSnapshot;
81
+
134
82
  /**
135
- * @brief Optional observer for an audio input object.
136
- *
137
- * The implementation stores a copy of this structure. Installing or replacing
138
- * an observer does not replay prior state; callbacks describe subsequent input
139
- * lifecycle transitions and failures.
83
+ * Audio input observer.
140
84
  *
141
- * Callback delivery is not guaranteed to be on a fixed thread. Callers must
142
- * therefore make callback logic safe for reentrant delivery and perform their
143
- * own thread handoff when thread affinity is required.
85
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
86
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
144
87
  */
145
88
  typedef struct TirtcAudioInputObserver {
146
- /**
147
- * @brief Called when the input lifecycle state changes.
148
- */
149
89
  void (*on_state_changed)(TirtcAudioInput* input, TirtcInputState state, void* user_data);
150
90
 
151
- /**
152
- * @brief Called when the input encounters an error.
153
- */
154
- void (*on_error)(TirtcAudioInput* input, TirtcError error, const char* message, void* user_data);
91
+ void (*on_error)(TirtcAudioInput* input, TirtcError error, TirtcOwnedString* owned_message,
92
+ void* user_data);
155
93
  } TirtcAudioInputObserver;
156
94
 
157
95
  /**
158
- * @brief Optional observer for an audio output object.
159
- *
160
- * The implementation stores a copy of this structure. Installing or replacing
161
- * an observer does not replay the current output state.
96
+ * Audio output observer.
162
97
  *
163
- * Callback delivery is not guaranteed to be on a fixed thread. State changes
164
- * may be reported synchronously by attach or detach paths, or asynchronously
165
- * from the internal downlink pipeline. Callers must therefore make callback
166
- * logic safe for reentrant delivery and perform their own thread handoff when
167
- * thread affinity is required.
98
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
99
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
168
100
  */
169
101
  typedef struct TirtcAudioOutputObserver {
170
- /**
171
- * @brief Called when the output state changes.
172
- */
173
102
  void (*on_state_changed)(TirtcAudioOutput* output, TirtcAudioOutputState state, void* user_data);
174
103
 
175
- /**
176
- * @brief Called when the output encounters an error.
177
- */
178
- void (*on_error)(TirtcAudioOutput* output, TirtcError error, const char* message,
104
+ void (*on_error)(TirtcAudioOutput* output, TirtcError error, TirtcOwnedString* owned_message,
179
105
  void* user_data);
180
106
  } TirtcAudioOutputObserver;
181
107
 
182
- /**
183
- * @brief Request the remote sender to start sending an audio stream.
184
- *
185
- * @param connection Target connection.
186
- * @param stream_id Remote audio stream identifier.
187
- * @return ::TIRTC_ERROR_OK on success.
188
- */
189
108
  TirtcError tirtc_conn_subscribe_audio(TirtcConn* connection, uint8_t stream_id);
190
109
 
191
- /**
192
- * @brief Request the remote sender to stop sending an audio stream.
193
- *
194
- * @param connection Target connection.
195
- * @param stream_id Remote audio stream identifier.
196
- * @return ::TIRTC_ERROR_OK on success.
197
- */
198
110
  TirtcError tirtc_conn_unsubscribe_audio(TirtcConn* connection, uint8_t stream_id);
199
111
 
200
- /**
201
- * @brief Create an audio input object.
202
- *
203
- * The runtime must already be initialized.
204
- *
205
- * @param out_input Receives the created input handle on success.
206
- * @return ::TIRTC_ERROR_OK on success.
207
- */
208
112
  TirtcError tirtc_audio_input_create(TirtcAudioInput** out_input);
209
113
 
210
- /**
211
- * @brief Bind a concrete audio capture backend to an input object.
212
- *
213
- * This must be done before the backend is needed by the producer pipeline. The
214
- * backend pointer is non-owning and must remain valid while the input may still
215
- * use it.
216
- *
217
- * @param input Target audio input.
218
- * @param ain Capture backend to bind.
219
- * @return ::TIRTC_ERROR_OK on success.
220
- */
221
114
  TirtcError tirtc_audio_input_set_ain(TirtcAudioInput* input, TirtcAudioAin* ain);
222
115
 
223
- /**
224
- * @brief Store audio input processing options.
225
- *
226
- * Best practice is to call this before the next ::tirtc_audio_input_start.
227
- * Updating options after the internal uplink pipeline has already been created
228
- * does not retroactively rebuild that running pipeline.
229
- *
230
- * @param input Target audio input.
231
- * @param options Options to copy into the facade object.
232
- * @return ::TIRTC_ERROR_OK on success.
233
- */
234
116
  TirtcError tirtc_audio_input_set_options(TirtcAudioInput* input,
235
117
  const TirtcAudioInputOptions* options);
236
118
 
237
- /**
238
- * @brief Install, replace, or clear the audio input observer.
239
- *
240
- * Passing NULL for ::observer clears the current observer. The implementation
241
- * stores a copy of the observer structure and does not require it to outlive
242
- * this call.
243
- *
244
- * @param input Target audio input.
245
- * @param observer Observer to install, or NULL to clear.
246
- * @param user_data Opaque pointer returned to observer callbacks.
247
- * @return ::TIRTC_ERROR_OK on success.
248
- */
249
119
  TirtcError tirtc_audio_input_set_observer(TirtcAudioInput* input,
250
120
  const TirtcAudioInputObserver* observer, void* user_data);
251
121
 
252
- /**
253
- * @brief Start the local audio producer lifecycle.
254
- *
255
- * This only manages the producer pipeline. It does not create, remove, or
256
- * replace any connection binding relationship.
257
- *
258
- * Calling start on an already-running input is idempotent.
259
- *
260
- * @param input Target audio input.
261
- * @return ::TIRTC_ERROR_OK on success.
262
- */
263
122
  TirtcError tirtc_audio_input_start(TirtcAudioInput* input);
264
123
 
265
- /**
266
- * @brief Stop the local audio producer lifecycle.
267
- *
268
- * This stops capture, processing, and encoding for the input but keeps all
269
- * existing attach relationships intact. Future ::tirtc_audio_input_start calls
270
- * may resume the same attach set.
271
- *
272
- * Calling stop on an already-stopped input is idempotent.
273
- *
274
- * @param input Target audio input.
275
- * @return ::TIRTC_ERROR_OK on success.
276
- */
277
124
  TirtcError tirtc_audio_input_stop(TirtcAudioInput* input);
278
125
 
279
- /**
280
- * @brief Attach an audio input to a connection stream.
281
- *
282
- * This bind is non-owning. The same input may be attached to multiple
283
- * connections at the same time, but only one stream id per connection is kept.
284
- * Re-attaching the same input to the same connection replaces the prior stream
285
- * id without requiring an explicit detach first.
286
- *
287
- * Attach only manages the binding relationship. It does not implicitly start
288
- * the producer lifecycle.
289
- *
290
- * @param input Audio input to bind.
291
- * @param connection Target connection.
292
- * @param stream_id Stream identifier that will carry this audio route.
293
- * @return ::TIRTC_ERROR_OK on success.
294
- */
295
126
  TirtcError tirtc_audio_input_attach(TirtcAudioInput* input, TirtcConn* connection,
296
127
  uint8_t stream_id);
297
128
 
298
- /**
299
- * @brief Detach an audio input from one connection.
300
- *
301
- * This call is idempotent. It only removes the binding for the specified
302
- * connection and does not implicitly stop the input lifecycle.
303
- *
304
- * @param input Audio input to unbind.
305
- * @param connection Connection whose audio route should be removed.
306
- * @return ::TIRTC_ERROR_OK on success.
307
- */
308
129
  TirtcError tirtc_audio_input_detach(TirtcAudioInput* input, TirtcConn* connection);
309
130
 
310
- /**
311
- * @brief Destroy an audio input object.
312
- *
313
- * Destroy is strong cleanup. The runtime stops the input lifecycle and clears
314
- * every attach relationship owned by this input before releasing the object.
315
- *
316
- * @param input Input handle to destroy.
317
- */
318
131
  void tirtc_audio_input_destroy(TirtcAudioInput* input);
319
132
 
320
- /**
321
- * @brief Create an audio output object.
322
- *
323
- * The runtime must already be initialized.
324
- *
325
- * @param out_output Receives the created output handle on success.
326
- * @return ::TIRTC_ERROR_OK on success.
327
- */
328
133
  TirtcError tirtc_audio_output_create(TirtcAudioOutput** out_output);
329
134
 
330
- /**
331
- * @brief Bind a concrete audio playback backend to an output object.
332
- *
333
- * The backend pointer is non-owning and should remain valid until the output
334
- * has been detached and destroyed. Passing NULL is not supported by this API.
335
- *
336
- * @param output Target audio output.
337
- * @param aout Playback backend to bind.
338
- * @return ::TIRTC_ERROR_OK on success.
339
- */
340
135
  TirtcError tirtc_audio_output_set_aout(TirtcAudioOutput* output, TirtcAudioAout* aout);
341
136
 
342
- /**
343
- * @brief Store audio output playback options.
344
- *
345
- * This call is intended for the pre-attach configuration phase. The current
346
- * implementation rejects option changes while the output is attached.
347
- *
348
- * @param output Target audio output.
349
- * @param options Options to copy into the facade object.
350
- * @return ::TIRTC_ERROR_OK on success.
351
- */
352
137
  TirtcError tirtc_audio_output_set_options(TirtcAudioOutput* output,
353
138
  const TirtcAudioOutputOptions* options);
354
139
 
355
- /**
356
- * @brief Install, replace, or clear the audio output observer.
357
- *
358
- * Passing NULL for ::observer clears the current observer. The implementation
359
- * stores a copy of the observer structure and does not require it to outlive
360
- * this call.
361
- *
362
- * @param output Target audio output.
363
- * @param observer Observer to install, or NULL to clear.
364
- * @param user_data Opaque pointer returned to observer callbacks.
365
- * @return ::TIRTC_ERROR_OK on success.
366
- */
367
140
  TirtcError tirtc_audio_output_set_observer(TirtcAudioOutput* output,
368
141
  const TirtcAudioOutputObserver* observer,
369
142
  void* user_data);
370
143
 
371
- /**
372
- * @brief Attach an audio output to a remote connection stream.
373
- *
374
- * This bind is non-owning. The same output can consume only one remote route at
375
- * a time. Re-attaching replaces the prior route without requiring an explicit
376
- * detach first.
377
- *
378
- * Attach only manages the remote consume route. It does not change connection
379
- * lifecycle or local sink ownership.
380
- *
381
- * @param output Audio output to bind.
382
- * @param connection Target connection.
383
- * @param stream_id Remote audio stream identifier to render.
384
- * @return ::TIRTC_ERROR_OK on success.
385
- */
386
144
  TirtcError tirtc_audio_output_attach(TirtcAudioOutput* output, TirtcConn* connection,
387
145
  uint8_t stream_id);
388
146
 
389
- /**
390
- * @brief Detach the current remote route from an audio output.
391
- *
392
- * This call is idempotent. Detach only stops consuming the current remote
393
- * route. It does not destroy the output object or its local sink.
394
- *
395
- * @param output Target audio output.
396
- * @return ::TIRTC_ERROR_OK on success.
397
- */
398
147
  TirtcError tirtc_audio_output_detach(TirtcAudioOutput* output);
399
148
 
400
- /**
401
- * @brief Destroy an audio output object.
402
- *
403
- * Destroy is strong cleanup. The runtime detaches the current route, clears
404
- * observer state, and releases internal playback pipeline state before the
405
- * object is destroyed.
406
- *
407
- * @param output Output handle to destroy.
408
- */
409
149
  void tirtc_audio_output_destroy(TirtcAudioOutput* output);
410
150
 
411
- /**
412
- * @brief Start encoded raw dump for the media downlink currently owned by this output.
413
- *
414
- * The output must already be attached to a connection stream and have an active
415
- * media downlink. The runtime records received encoded payload into the fixed
416
- * logging-owned media raw dump directory and derives the dump prefix from the
417
- * bound route as `<peer_id>-<stream_id>`.
418
- *
419
- * @param output Target audio output.
420
- * @return ::TIRTC_ERROR_OK on success.
421
- */
422
151
  TirtcError tirtc_audio_output_start_raw_dump(TirtcAudioOutput* output);
423
152
 
424
- /**
425
- * @brief Stop encoded raw dump for the media downlink currently owned by this output.
426
- *
427
- * This call is idempotent. Stopping seals the current dump directory and keeps
428
- * collected raw data on disk.
429
- *
430
- * @param output Target audio output.
431
- * @return ::TIRTC_ERROR_OK on success.
432
- */
433
153
  TirtcError tirtc_audio_output_stop_raw_dump(TirtcAudioOutput* output);
434
154
 
155
+ TirtcError tirtc_metrics_audio_output_get_snapshot(TirtcAudioOutput* output,
156
+ TirtcAudioOutputMetricsSnapshot* out_snapshot);
157
+
435
158
  #ifdef __cplusplus
436
159
  }
437
160
  #endif
438
161
 
439
- #endif // TIRTC_FACADE_AUDIO_H_
162
+ #endif