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
@@ -11,485 +11,146 @@
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
- */
29
+ typedef struct TirtcVideoOutputStartupMetrics {
30
+ int has_connect_start;
31
+ int has_connected;
32
+ int has_first_video_input;
33
+ int has_first_video_decoded;
34
+ int has_first_video_rendered;
35
+ uint64_t connect_start_monotonic_ms;
36
+ uint64_t connected_monotonic_ms;
37
+ uint64_t first_video_input_monotonic_ms;
38
+ uint64_t first_video_decoded_monotonic_ms;
39
+ uint64_t first_video_rendered_monotonic_ms;
40
+ } TirtcVideoOutputStartupMetrics;
41
+
42
+ typedef struct TirtcVideoOutputMetricsSnapshot {
43
+ TirtcVideoOutputStartupMetrics startup;
44
+ TirtcOutputStutterMetrics stutter;
45
+ TirtcPendingDurationMetrics pending;
46
+ } TirtcVideoOutputMetricsSnapshot;
47
+
78
48
  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
49
  TirtcMediaCodec codec;
86
50
 
87
- /**
88
- * @brief Target encoded width in pixels.
89
- *
90
- * The current implementation defaults to 320 when this field is zero.
91
- */
92
51
  uint32_t width;
93
52
 
94
- /**
95
- * @brief Target encoded height in pixels.
96
- *
97
- * The current implementation defaults to 180 when this field is zero.
98
- */
99
53
  uint32_t height;
100
54
 
101
- /**
102
- * @brief Target frame rate.
103
- *
104
- * The current implementation defaults to 15 when this field is zero.
105
- */
106
55
  uint32_t fps;
107
56
 
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
57
  uint32_t bitrate_kbps;
115
58
  } TirtcVideoInputOptions;
116
59
 
117
60
  /**
118
- * @brief Optional observer for a video input object.
61
+ * Video input observer.
119
62
  *
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.
123
- *
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.
63
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
64
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
127
65
  */
128
66
  typedef struct TirtcVideoInputObserver {
129
- /**
130
- * @brief Called when the input lifecycle state changes.
131
- */
132
67
  void (*on_state_changed)(TirtcVideoInput* input, TirtcInputState state, void* user_data);
133
68
 
134
- /**
135
- * @brief Called when the effective encoded output size changes.
136
- */
137
69
  void (*on_output_size_changed)(TirtcVideoInput* input, uint32_t width, uint32_t height,
138
70
  void* user_data);
139
71
 
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);
72
+ void (*on_error)(TirtcVideoInput* input, TirtcError error, TirtcOwnedString* owned_message,
73
+ void* user_data);
144
74
  } TirtcVideoInputObserver;
145
75
 
146
76
  /**
147
- * @brief Optional observer for a video output object.
77
+ * Video output observer.
148
78
  *
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.
79
+ * `owned_message` is allocated by facade for this callback dispatch. Consumers must release it
80
+ * with `tirtc_owned_string_release()` after copying or converting the string they need.
157
81
  */
158
82
  typedef struct TirtcVideoOutputObserver {
159
- /**
160
- * @brief Called when the output state changes.
161
- */
162
83
  void (*on_state_changed)(TirtcVideoOutput* output, TirtcVideoOutputState state, void* user_data);
163
84
 
164
- /**
165
- * @brief Called when the effective rendered output size changes.
166
- */
167
85
  void (*on_output_size_changed)(TirtcVideoOutput* output, uint32_t width, uint32_t height,
168
86
  void* user_data);
169
87
 
170
- /**
171
- * @brief Called when the output encounters an error.
172
- */
173
- void (*on_error)(TirtcVideoOutput* output, TirtcError error, const char* message,
88
+ void (*on_error)(TirtcVideoOutput* output, TirtcError error, TirtcOwnedString* owned_message,
174
89
  void* user_data);
175
90
  } TirtcVideoOutputObserver;
176
91
 
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
92
  TirtcError tirtc_set_media_trace_enabled(int enabled);
186
93
 
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
94
  TirtcError tirtc_get_media_trace_enabled(int* out_enabled);
194
95
 
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
96
  TirtcError tirtc_conn_subscribe_video(TirtcConn* connection, uint8_t stream_id);
203
97
 
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
98
  TirtcError tirtc_conn_unsubscribe_video(TirtcConn* connection, uint8_t stream_id);
212
99
 
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
100
  TirtcError tirtc_conn_request_key_frame(TirtcConn* connection, uint8_t stream_id);
224
101
 
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
102
  TirtcError tirtc_video_input_create(TirtcVideoInput** out_input);
234
103
 
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
104
  TirtcError tirtc_video_input_set_vin(TirtcVideoInput* input, TirtcVideoVin* vin);
247
105
 
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
106
  TirtcError tirtc_video_input_set_options(TirtcVideoInput* input,
260
107
  const TirtcVideoInputOptions* options);
261
108
 
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
109
  TirtcError tirtc_video_input_set_observer(TirtcVideoInput* input,
275
110
  const TirtcVideoInputObserver* observer, void* user_data);
276
111
 
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
112
  TirtcError tirtc_video_input_start(TirtcVideoInput* input);
289
113
 
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
114
  TirtcError tirtc_video_input_stop(TirtcVideoInput* input);
303
115
 
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
116
  TirtcError tirtc_video_input_attach(TirtcVideoInput* input, TirtcConn* connection,
321
117
  uint8_t stream_id);
322
118
 
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
119
  TirtcError tirtc_video_input_detach(TirtcVideoInput* input, TirtcConn* connection);
334
120
 
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
121
  TirtcError tirtc_video_input_attach_preview(TirtcVideoInput* input,
352
122
  TirtcVideoOutput* preview_output);
353
123
 
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
124
  TirtcError tirtc_video_input_detach_preview(TirtcVideoInput* input);
365
125
 
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
126
  void tirtc_video_input_destroy(TirtcVideoInput* input);
376
127
 
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
128
  TirtcError tirtc_video_output_create(TirtcVideoOutput** out_output);
386
129
 
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
130
  TirtcError tirtc_video_output_set_observer(TirtcVideoOutput* output,
400
131
  const TirtcVideoOutputObserver* observer,
401
132
  void* user_data);
402
133
 
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
134
  TirtcError tirtc_video_output_attach_view(TirtcVideoOutput* output, TirtcVideoVout* view_sink);
415
135
 
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
136
  TirtcError tirtc_video_output_detach_view(TirtcVideoOutput* output);
426
137
 
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
138
  TirtcError tirtc_video_output_attach(TirtcVideoOutput* output, TirtcConn* connection,
443
139
  uint8_t stream_id);
444
140
 
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
141
  TirtcError tirtc_video_output_detach(TirtcVideoOutput* output);
455
142
 
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
143
  void tirtc_video_output_destroy(TirtcVideoOutput* output);
466
144
 
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
145
  TirtcError tirtc_video_output_start_raw_dump(TirtcVideoOutput* output);
479
146
 
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
147
  TirtcError tirtc_video_output_stop_raw_dump(TirtcVideoOutput* output);
490
148
 
149
+ TirtcError tirtc_metrics_video_output_get_snapshot(TirtcVideoOutput* output,
150
+ TirtcVideoOutputMetricsSnapshot* out_snapshot);
151
+
491
152
  #ifdef __cplusplus
492
153
  }
493
154
  #endif
494
155
 
495
- #endif // TIRTC_FACADE_AV_H_
156
+ #endif
@@ -7,25 +7,44 @@ extern "C" {
7
7
 
8
8
  typedef enum TirtcError {
9
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
- TIRTC_ERROR_TRANSPORT_TOKEN_EXPIRED = 15,
25
- TIRTC_ERROR_DUMP_ROOT_UNAVAILABLE = 16,
26
- TIRTC_ERROR_DUMP_ALREADY_ACTIVE = 17,
10
+ TIRTC_ERROR_INVALID_ARGUMENT = 6000,
11
+ TIRTC_ERROR_NOT_INITIALIZED = 6001,
12
+ TIRTC_ERROR_INTERNAL = 6002,
13
+ TIRTC_ERROR_NOT_READY = 6003,
14
+ TIRTC_ERROR_UNSUPPORTED_LOOP_POLICY = 6004,
15
+ TIRTC_ERROR_SOURCE_HASH_MISMATCH = 6005,
16
+ TIRTC_ERROR_ALREADY_STOPPED = 6006,
17
+ TIRTC_ERROR_STOPPED = TIRTC_ERROR_ALREADY_STOPPED,
18
+ TIRTC_ERROR_ALREADY_DESTROYED = 6007,
19
+ TIRTC_ERROR_DESTROYED = TIRTC_ERROR_ALREADY_DESTROYED,
20
+ TIRTC_ERROR_TRANSPORT_INVALID_LICENSE = 6008,
21
+ TIRTC_ERROR_TRANSPORT_TIMEOUT = 6009,
22
+ TIRTC_ERROR_TRANSPORT_BUSY = 6010,
23
+ TIRTC_ERROR_TRANSPORT_CONNECTION_TIMEOUT_CLOSED = 6011,
24
+ TIRTC_ERROR_TRANSPORT_REMOTE_CLOSED = 6012,
25
+ TIRTC_ERROR_TRANSPORT_CONNECTION_OTHER_ERROR = 6013,
26
+ TIRTC_ERROR_TRANSPORT_TOKEN_EXPIRED = 6014,
27
+ TIRTC_ERROR_DUMP_ROOT_UNAVAILABLE = 6015,
28
+ TIRTC_ERROR_DUMP_ALREADY_ACTIVE = 6016,
29
+ TIRTC_ERROR_TRANSPORT_RESOURCE_EXHAUSTED = 6017,
30
+ TIRTC_ERROR_TRANSPORT_SERVER_ERROR = 6018,
31
+ TIRTC_ERROR_TRANSPORT_BACKEND_INTERNAL_ERROR = 6019,
32
+ TIRTC_ERROR_TRANSPORT_NO_SECRET_KEY = 6020,
33
+ TIRTC_ERROR_TRANSPORT_UNEXPECTED_RESPONSE = 6021,
34
+ TIRTC_ERROR_ALREADY_INITIALIZED = 6022,
35
+ TIRTC_ERROR_INVALID_THREAD = 6023,
36
+ TIRTC_ERROR_PERMISSION_DENIED = 6024,
37
+ TIRTC_ERROR_ALREADY_BOUND = 6025,
38
+ TIRTC_ERROR_IN_USE = 6026,
39
+ TIRTC_ERROR_NOT_STARTED = 6027,
40
+ TIRTC_ERROR_NOT_CONNECTED = 6028,
41
+ TIRTC_ERROR_NOT_BOUND = 6029,
42
+ TIRTC_ERROR_NOT_CONFIGURED = 6030,
43
+ TIRTC_ERROR_NOT_OPEN = 6031,
27
44
  } TirtcError;
28
45
 
46
+ const char* tirtc_error_to_string(TirtcError error);
47
+
29
48
  #ifdef __cplusplus
30
49
  }
31
50
  #endif
@@ -43,6 +43,45 @@ typedef struct TirtcMediaDownlinkVideoObserver {
43
43
  void* user_data);
44
44
  } TirtcMediaDownlinkVideoObserver;
45
45
 
46
+ typedef struct TirtcMediaDownlinkStutterMetricsSnapshot {
47
+ int session_started;
48
+ uint64_t session_duration_ms;
49
+ uint64_t session_stutter_total_ms;
50
+ uint32_t session_stutter_count;
51
+ uint64_t session_stutter_peak_ms;
52
+ double session_stutter_ratio;
53
+ uint32_t recent_window_duration_ms;
54
+ uint64_t recent_window_stutter_total_ms;
55
+ uint32_t recent_window_stutter_count;
56
+ uint64_t recent_window_stutter_peak_ms;
57
+ double recent_window_stutter_ratio;
58
+ } TirtcMediaDownlinkStutterMetricsSnapshot;
59
+
60
+ typedef struct TirtcMediaDownlinkPendingMetricsSnapshot {
61
+ uint64_t undecoded_pending_duration_ms;
62
+ uint64_t decoded_pending_duration_ms;
63
+ } TirtcMediaDownlinkPendingMetricsSnapshot;
64
+
65
+ typedef struct TirtcMediaDownlinkAudioMetricsSnapshot {
66
+ TirtcMediaDownlinkStutterMetricsSnapshot stutter;
67
+ TirtcMediaDownlinkPendingMetricsSnapshot pending;
68
+ } TirtcMediaDownlinkAudioMetricsSnapshot;
69
+
70
+ typedef struct TirtcMediaDownlinkVideoStartupMetricsSnapshot {
71
+ int has_first_video_input;
72
+ int has_first_video_decoded;
73
+ int has_first_video_rendered;
74
+ uint64_t first_video_input_monotonic_ms;
75
+ uint64_t first_video_decoded_monotonic_ms;
76
+ uint64_t first_video_rendered_monotonic_ms;
77
+ } TirtcMediaDownlinkVideoStartupMetricsSnapshot;
78
+
79
+ typedef struct TirtcMediaDownlinkVideoMetricsSnapshot {
80
+ TirtcMediaDownlinkVideoStartupMetricsSnapshot startup;
81
+ TirtcMediaDownlinkStutterMetricsSnapshot stutter;
82
+ TirtcMediaDownlinkPendingMetricsSnapshot pending;
83
+ } TirtcMediaDownlinkVideoMetricsSnapshot;
84
+
46
85
  TirtcError tirtc_media_downlink_audio_create(TirtcMediaDownlinkAudio** out_downlink);
47
86
  void tirtc_media_downlink_audio_retain(TirtcMediaDownlinkAudio* downlink);
48
87
  void tirtc_media_downlink_audio_release(TirtcMediaDownlinkAudio* downlink);
@@ -94,6 +133,14 @@ TirtcError tirtc_media_downlink_video_start_raw_dump(TirtcMediaDownlinkVideo* do
94
133
  const char* prefix);
95
134
  TirtcError tirtc_media_downlink_video_stop_raw_dump(TirtcMediaDownlinkVideo* downlink);
96
135
 
136
+ TirtcError tirtc_media_downlink_audio_get_metrics_snapshot(
137
+ TirtcMediaDownlinkAudio* downlink, TirtcMediaDownlinkAudioMetricsSnapshot* out_snapshot);
138
+ void tirtc_media_downlink_audio_reset_metrics_session(TirtcMediaDownlinkAudio* downlink);
139
+
140
+ TirtcError tirtc_media_downlink_video_get_metrics_snapshot(
141
+ TirtcMediaDownlinkVideo* downlink, TirtcMediaDownlinkVideoMetricsSnapshot* out_snapshot);
142
+ void tirtc_media_downlink_video_reset_metrics_session(TirtcMediaDownlinkVideo* downlink);
143
+
97
144
  #ifdef __cplusplus
98
145
  }
99
146
  #endif