tirtc-devtools-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +52 -0
  2. package/USAGE.md +417 -0
  3. package/bin/tirtc-devtool.js +2 -0
  4. package/dist/app-server/protocol-client/index.d.ts +25 -0
  5. package/dist/app-server/protocol-client/index.js +114 -0
  6. package/dist/devtools/cli/src/config.d.ts +46 -0
  7. package/dist/devtools/cli/src/config.js +98 -0
  8. package/dist/devtools/cli/src/dummy.d.ts +0 -0
  9. package/dist/devtools/cli/src/dummy.js +1 -0
  10. package/dist/devtools/cli/src/embedded_paths.d.ts +7 -0
  11. package/dist/devtools/cli/src/embedded_paths.js +85 -0
  12. package/dist/devtools/cli/src/facade.d.ts +723 -0
  13. package/dist/devtools/cli/src/facade.js +194 -0
  14. package/dist/devtools/cli/src/ffmpeg_tool.d.ts +6 -0
  15. package/dist/devtools/cli/src/ffmpeg_tool.js +146 -0
  16. package/dist/devtools/cli/src/guide.d.ts +1 -0
  17. package/dist/devtools/cli/src/guide.js +49 -0
  18. package/dist/devtools/cli/src/index.d.ts +1 -0
  19. package/dist/devtools/cli/src/index.js +753 -0
  20. package/dist/devtools/cli/src/media_assets.d.ts +25 -0
  21. package/dist/devtools/cli/src/media_assets.js +121 -0
  22. package/dist/devtools/cli/src/session_manager.d.ts +25 -0
  23. package/dist/devtools/cli/src/session_manager.js +393 -0
  24. package/dist/devtools/cli/src/token_tool.d.ts +33 -0
  25. package/dist/devtools/cli/src/token_tool.js +217 -0
  26. package/dist/devtools/cli/src/transport.d.ts +30 -0
  27. package/dist/devtools/cli/src/transport.js +84 -0
  28. package/dist/dummy.d.ts +0 -0
  29. package/dist/dummy.js +1 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +48 -0
  32. package/package.json +54 -0
  33. package/script/ensure_ffmpeg.sh +22 -0
  34. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  35. package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
  36. package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
  37. package/vendor/app-server/bin/native/macos-arm64/libtgrtc.dylib +0 -0
  38. package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
  39. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
  40. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
  41. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +56 -0
  42. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
  43. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
  44. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
  45. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
  46. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
  47. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
  48. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +20 -0
  49. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +53 -0
  50. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
  51. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +89 -0
  52. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +115 -0
  53. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +236 -0
  54. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +57 -0
  55. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
  56. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +46 -0
  57. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +32 -0
  58. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +34 -0
  59. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
  60. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
  61. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
  62. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
  63. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
  64. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  65. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
  66. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
  67. package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
  68. package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
  69. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +34 -0
  70. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +398 -0
  71. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_codec.h +23 -0
  72. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_frame.h +36 -0
  73. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io.h +56 -0
  74. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_android.h +19 -0
  75. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_apple.h +19 -0
  76. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_harmony.h +19 -0
  77. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_windows.h +19 -0
  78. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_processing.h +56 -0
  79. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_sample_rate.h +18 -0
  80. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +452 -0
  81. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +34 -0
  82. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +30 -0
  83. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +27 -0
  84. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +57 -0
  85. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +55 -0
  86. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_codec.h +21 -0
  87. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +95 -0
  88. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +61 -0
  89. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +77 -0
  90. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +71 -0
  91. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_uplink.h +116 -0
  92. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +481 -0
  93. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +541 -0
  94. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_codec.h +58 -0
  95. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_frame.h +55 -0
  96. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io.h +46 -0
  97. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_android.h +32 -0
  98. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_apple.h +47 -0
  99. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_harmony.h +32 -0
  100. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_windows.h +26 -0
  101. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_processing.h +34 -0
  102. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.a +0 -0
  103. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.dylib +0 -0
  104. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  105. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  106. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  107. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  108. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  109. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  110. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  111. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  112. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.a +0 -0
  113. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.dylib +0 -0
  114. package/vendor/app-server/bin/runtime/macos-arm64/lib/libwebrtc_apm.a +0 -0
  115. package/vendor/app-server/bin/runtime/macos-arm64/lib/libxlog.a +0 -0
  116. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +50 -0
  117. package/vendor/app-server/bin/tirtc-devtool-host.js +2 -0
  118. package/vendor/app-server/dist/host/ArtifactManager.d.ts +18 -0
  119. package/vendor/app-server/dist/host/ArtifactManager.js +83 -0
  120. package/vendor/app-server/dist/host/HostProtocol.d.ts +107 -0
  121. package/vendor/app-server/dist/host/HostProtocol.js +256 -0
  122. package/vendor/app-server/dist/host/HostServer.d.ts +49 -0
  123. package/vendor/app-server/dist/host/HostServer.js +635 -0
  124. package/vendor/app-server/dist/host/HostState.d.ts +60 -0
  125. package/vendor/app-server/dist/host/HostState.js +19 -0
  126. package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +81 -0
  127. package/vendor/app-server/dist/host/RuntimeAdapter.js +559 -0
  128. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +30 -0
  129. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +224 -0
  130. package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +37 -0
  131. package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +186 -0
  132. package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +42 -0
  133. package/vendor/app-server/dist/host/RuntimeSendWorker.js +274 -0
  134. package/vendor/app-server/dist/host/TokenTool.d.ts +15 -0
  135. package/vendor/app-server/dist/host/TokenTool.js +84 -0
  136. package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +28 -0
  137. package/vendor/app-server/dist/host/WebPreviewGateway.js +815 -0
  138. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +26 -0
  139. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +118 -0
  140. package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +19 -0
  141. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +141 -0
  142. package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +10 -0
  143. package/vendor/app-server/dist/host/runtime_backed_preflight.js +78 -0
  144. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +28 -0
  145. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +85 -0
  146. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +10 -0
  147. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +41 -0
  148. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +11 -0
  149. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +32 -0
  150. package/vendor/app-server/dist/protocol/contract.d.ts +983 -0
  151. package/vendor/app-server/dist/protocol/contract.js +198 -0
  152. package/vendor/app-server/dist/protocol-client/index.d.ts +25 -0
  153. package/vendor/app-server/dist/protocol-client/index.js +114 -0
  154. package/vendor/app-server/dist/src/index.d.ts +1 -0
  155. package/vendor/app-server/dist/src/index.js +294 -0
  156. package/vendor/runtime/script/prepare_runtime_media_dataset.sh +427 -0
@@ -0,0 +1,398 @@
1
+ #ifndef TIRTC_FACADE_AUDIO_H_
2
+ #define TIRTC_FACADE_AUDIO_H_
3
+
4
+ #include "tirtc/audio_io.h"
5
+ #include "tirtc/audio_processing.h"
6
+ #include "tirtc/trp.h"
7
+
8
+ #ifdef __cplusplus
9
+ extern "C" {
10
+ #endif
11
+
12
+ /**
13
+ * @file tirtc/audio.h
14
+ * @brief Audio facade layer built on top of `tirtc/trp.h`.
15
+ *
16
+ * This header adds local audio capture and remote audio playback objects to the
17
+ * transport-facing facade.
18
+ *
19
+ * Typical uplink flow:
20
+ * 1. Create a ::TirtcAudioInput.
21
+ * 2. Bind a concrete capture backend with ::tirtc_audio_input_set_ain.
22
+ * 3. Optionally configure processing options and an observer.
23
+ * 4. Start the input and attach it to a connection stream.
24
+ * 5. Detach, stop, and destroy the input during shutdown.
25
+ *
26
+ * Typical downlink flow:
27
+ * 1. Create a ::TirtcAudioOutput.
28
+ * 2. Bind a concrete playback backend with ::tirtc_audio_output_set_aout.
29
+ * 3. Optionally configure playback options and an observer.
30
+ * 4. Attach the output to a connected ::TirtcConn.
31
+ * 5. Detach and destroy the output during shutdown.
32
+ *
33
+ * Ownership model:
34
+ * - The caller owns all audio input and output handles.
35
+ * - Attaching an object to a connection is a non-owning bind.
36
+ * - Destroying a connection detaches bound audio objects but does not destroy
37
+ * them.
38
+ */
39
+
40
+ /** @brief Opaque audio uplink handle. */
41
+ typedef struct TirtcAudioInput TirtcAudioInput;
42
+
43
+ /** @brief Opaque audio downlink handle. */
44
+ typedef struct TirtcAudioOutput TirtcAudioOutput;
45
+
46
+ /**
47
+ * @brief Generic input state used by audio and video input observers.
48
+ *
49
+ * The current facade implementation primarily reports RUNNING and STOPPED.
50
+ * Callers should still handle the full enum for forward compatibility.
51
+ */
52
+ typedef enum TirtcInputState {
53
+ /** Input exists but has not started running yet. */
54
+ TIRTC_INPUT_STATE_IDLE = 0,
55
+
56
+ /** Input is actively capturing or producing data. */
57
+ TIRTC_INPUT_STATE_RUNNING = 1,
58
+
59
+ /** Reserved paused state. */
60
+ TIRTC_INPUT_STATE_PAUSED = 2,
61
+
62
+ /** Input is stopped. */
63
+ TIRTC_INPUT_STATE_STOPPED = 3,
64
+
65
+ /** Reserved terminal failure state. */
66
+ TIRTC_INPUT_STATE_FAILED = 4,
67
+ } TirtcInputState;
68
+
69
+ /**
70
+ * @brief Audio output state reported through ::TirtcAudioOutputObserver.
71
+ */
72
+ typedef enum TirtcAudioOutputState {
73
+ /** Output is attached but not currently rendering audio. */
74
+ TIRTC_AUDIO_OUTPUT_STATE_IDLE = 0,
75
+
76
+ /** Output is actively playing remote audio. */
77
+ TIRTC_AUDIO_OUTPUT_STATE_PLAYING = 1,
78
+
79
+ /** Output is waiting for enough decoded audio to continue playback. */
80
+ TIRTC_AUDIO_OUTPUT_STATE_BUFFERING = 2,
81
+
82
+ /** Reserved paused state. */
83
+ TIRTC_AUDIO_OUTPUT_STATE_PAUSED = 3,
84
+
85
+ /** Reserved completed state. */
86
+ TIRTC_AUDIO_OUTPUT_STATE_COMPLETED = 4,
87
+
88
+ /** Output encountered repeated playback failures. */
89
+ TIRTC_AUDIO_OUTPUT_STATE_FAILED = 5,
90
+ } TirtcAudioOutputState;
91
+
92
+ /**
93
+ * @brief Audio input processing options.
94
+ *
95
+ * These options are consumed when the internal uplink pipeline is created.
96
+ * Configure them before the first successful start for predictable behavior.
97
+ */
98
+ typedef struct TirtcAudioInputOptions {
99
+ /**
100
+ * @brief Capture sample rate.
101
+ *
102
+ * The current implementation defaults to 16 kHz when this field is set to
103
+ * ::TIRTC_AUDIO_SAMPLE_RATE_NONE.
104
+ */
105
+ TirtcAudioSampleRate sample_rate;
106
+
107
+ /** @brief Acoustic echo cancellation mode. */
108
+ TirtcAudioAecMode aec_mode;
109
+
110
+ /** @brief Automatic gain control level. */
111
+ TirtcAudioAgcLevel agc_level;
112
+
113
+ /** @brief Acoustic noise suppression level. */
114
+ TirtcAudioAnsLevel ans_level;
115
+ } TirtcAudioInputOptions;
116
+
117
+ /**
118
+ * @brief Audio output playback options.
119
+ *
120
+ * Configure these options before attaching the output to a connection. The
121
+ * current API does not support updating them while the output remains bound.
122
+ */
123
+ typedef struct TirtcAudioOutputOptions {
124
+ /**
125
+ * @brief Playback volume in percent.
126
+ *
127
+ * The current implementation treats `0` as the default `100` percent.
128
+ */
129
+ uint32_t volume_percent;
130
+
131
+ /** @brief Additional gain level forwarded to the downlink pipeline. */
132
+ int gain_level;
133
+
134
+ /** @brief Additional noise-reduction level forwarded to the downlink pipeline. */
135
+ int noise_reduction_level;
136
+ } TirtcAudioOutputOptions;
137
+
138
+ /**
139
+ * @brief Optional observer for an audio input object.
140
+ *
141
+ * The implementation stores a copy of this structure. Installing or replacing
142
+ * an observer does not replay prior state; callbacks describe subsequent local
143
+ * start and stop transitions.
144
+ *
145
+ * Callback delivery is not guaranteed to be on a fixed thread. In the current
146
+ * implementation, input state notifications may be dispatched synchronously by
147
+ * API calls such as ::tirtc_audio_input_start and ::tirtc_audio_input_stop.
148
+ * Callers must therefore make callback logic safe for reentrant delivery.
149
+ */
150
+ typedef struct TirtcAudioInputObserver {
151
+ /**
152
+ * @brief Called when the input starts or stops.
153
+ *
154
+ * In the current implementation, a start failure is reported as STOPPED with
155
+ * a non-OK ::error value.
156
+ */
157
+ void (*on_state_changed)(TirtcAudioInput* input, TirtcInputState state, TirtcError error,
158
+ void* user_data);
159
+ } TirtcAudioInputObserver;
160
+
161
+ /**
162
+ * @brief Optional observer for an audio output object.
163
+ *
164
+ * The implementation stores a copy of this structure. Installing or replacing
165
+ * an observer does not replay the current output state.
166
+ *
167
+ * Callback delivery is not guaranteed to be on a fixed thread. State changes
168
+ * may be reported synchronously by attach or detach paths, or asynchronously
169
+ * from the internal downlink pipeline. Callers must therefore make callback
170
+ * logic safe for reentrant delivery and perform their own thread handoff when
171
+ * thread affinity is required.
172
+ */
173
+ typedef struct TirtcAudioOutputObserver {
174
+ /**
175
+ * @brief Called when the output state changes.
176
+ *
177
+ * A common sequence is IDLE after attach, then BUFFERING, then PLAYING, and
178
+ * IDLE again after detach.
179
+ * Repeated downlink failures may eventually promote the output to FAILED.
180
+ */
181
+ void (*on_state_changed)(TirtcAudioOutput* output, TirtcAudioOutputState state, TirtcError error,
182
+ void* user_data);
183
+ } TirtcAudioOutputObserver;
184
+
185
+ /**
186
+ * @brief Attach an audio input to a connection stream.
187
+ *
188
+ * This bind is non-owning. The same input cannot be attached to more than one
189
+ * connection at a time. The selected ::stream_id must be unique across all
190
+ * audio inputs, video inputs, and video outputs currently attached to the same
191
+ * connection.
192
+ *
193
+ * The input may be attached before or after ::tirtc_audio_input_start. Audio
194
+ * is actually sent only while the input is both attached and running.
195
+ *
196
+ * @param connection Target connection.
197
+ * @param stream_id Stream identifier that will carry this audio route.
198
+ * @param input Audio input to bind.
199
+ * @return ::TIRTC_ERROR_OK on success.
200
+ */
201
+ TirtcError tirtc_conn_attach_audio_input(TirtcConn* connection, uint8_t stream_id,
202
+ TirtcAudioInput* input);
203
+
204
+ /**
205
+ * @brief Attach a remote audio output to a connection stream.
206
+ *
207
+ * This bind is non-owning. The same output cannot be attached to more than
208
+ * one connection stream at a time. Configure the output with
209
+ * ::tirtc_audio_output_set_aout and any desired options before attaching it.
210
+ *
211
+ * If an observer is already installed, a successful attach typically reports an
212
+ * initial IDLE state before playback begins. A successful attach also asks the
213
+ * remote peer to start sending audio for this ::stream_id on this connection.
214
+ *
215
+ * @param connection Target connection.
216
+ * @param stream_id Remote audio stream identifier to render.
217
+ * @param output Audio output to bind.
218
+ * @return ::TIRTC_ERROR_OK on success.
219
+ */
220
+ TirtcError tirtc_conn_attach_audio_output(TirtcConn* connection, uint8_t stream_id,
221
+ TirtcAudioOutput* output);
222
+
223
+ /**
224
+ * @brief Detach an audio input from a connection stream.
225
+ *
226
+ * This call is idempotent. If the stream is attached, the internal uplink path
227
+ * for that bind is stopped and the input returns to an unbound state.
228
+ *
229
+ * @param connection Target connection.
230
+ * @param stream_id Stream identifier to detach.
231
+ * @return ::TIRTC_ERROR_OK on success.
232
+ */
233
+ TirtcError tirtc_conn_detach_audio_input(TirtcConn* connection, uint8_t stream_id);
234
+
235
+ /**
236
+ * @brief Detach an audio output from a connection stream.
237
+ *
238
+ * This call is idempotent. A successful detach also asks the remote peer to
239
+ * stop sending audio for this ::stream_id on this connection.
240
+ *
241
+ * @param connection Target connection.
242
+ * @param stream_id Stream identifier to detach.
243
+ * @return ::TIRTC_ERROR_OK on success.
244
+ */
245
+ TirtcError tirtc_conn_detach_audio_output(TirtcConn* connection, uint8_t stream_id);
246
+
247
+ /**
248
+ * @brief Create an audio input object.
249
+ *
250
+ * The runtime must already be initialized.
251
+ *
252
+ * @param out_input Receives the created input handle on success.
253
+ * @return ::TIRTC_ERROR_OK on success.
254
+ */
255
+ TirtcError tirtc_audio_input_create(TirtcAudioInput** out_input);
256
+
257
+ /**
258
+ * @brief Destroy an audio input object.
259
+ *
260
+ * The input must already be detached from any connection. If the input is
261
+ * still bound, the current implementation keeps it alive and ignores the
262
+ * destroy request.
263
+ *
264
+ * @param input Input handle to destroy.
265
+ */
266
+ void tirtc_audio_input_destroy(TirtcAudioInput* input);
267
+
268
+ /**
269
+ * @brief Bind a concrete audio capture backend to an input object.
270
+ *
271
+ * This must be done while the input is stopped and detached, before the next
272
+ * successful start. The backend pointer is non-owning and must remain valid
273
+ * while the input may still use it.
274
+ *
275
+ * @param input Target audio input.
276
+ * @param ain Capture backend to bind.
277
+ * @return ::TIRTC_ERROR_OK on success.
278
+ */
279
+ TirtcError tirtc_audio_input_set_ain(TirtcAudioInput* input, TirtcAudioAin* ain);
280
+
281
+ /**
282
+ * @brief Store audio input processing options.
283
+ *
284
+ * Best practice is to call this before the first successful start. Updating
285
+ * options after the internal uplink pipeline has already been created does not
286
+ * retroactively rebuild that running pipeline.
287
+ *
288
+ * @param input Target audio input.
289
+ * @param options Options to copy into the facade object.
290
+ * @return ::TIRTC_ERROR_OK on success.
291
+ */
292
+ TirtcError tirtc_audio_input_set_options(TirtcAudioInput* input,
293
+ const TirtcAudioInputOptions* options);
294
+
295
+ /**
296
+ * @brief Install, replace, or clear the audio input observer.
297
+ *
298
+ * Passing NULL for ::observer clears the current observer. The implementation
299
+ * stores a copy of the observer structure and does not require it to outlive
300
+ * this call.
301
+ *
302
+ * @param input Target audio input.
303
+ * @param observer Observer to install, or NULL to clear.
304
+ * @param user_data Opaque pointer returned to observer callbacks.
305
+ * @return ::TIRTC_ERROR_OK on success.
306
+ */
307
+ TirtcError tirtc_audio_input_set_observer(TirtcAudioInput* input,
308
+ const TirtcAudioInputObserver* observer, void* user_data);
309
+
310
+ /**
311
+ * @brief Start local audio capture for an input object.
312
+ *
313
+ * A capture backend must already be bound with ::tirtc_audio_input_set_ain.
314
+ * Starting twice without an intervening stop is rejected.
315
+ *
316
+ * @param input Target audio input.
317
+ * @return ::TIRTC_ERROR_OK on success.
318
+ */
319
+ TirtcError tirtc_audio_input_start(TirtcAudioInput* input);
320
+
321
+ /**
322
+ * @brief Stop local audio capture for an input object.
323
+ *
324
+ * This is the normal pairing call for ::tirtc_audio_input_start. The current
325
+ * implementation also tolerates stopping an already stopped input.
326
+ *
327
+ * @param input Target audio input.
328
+ * @return ::TIRTC_ERROR_OK on success.
329
+ */
330
+ TirtcError tirtc_audio_input_stop(TirtcAudioInput* input);
331
+
332
+ /**
333
+ * @brief Create an audio output object.
334
+ *
335
+ * The runtime must already be initialized.
336
+ *
337
+ * @param out_output Receives the created output handle on success.
338
+ * @return ::TIRTC_ERROR_OK on success.
339
+ */
340
+ TirtcError tirtc_audio_output_create(TirtcAudioOutput** out_output);
341
+
342
+ /**
343
+ * @brief Destroy an audio output object.
344
+ *
345
+ * The output must already be detached from any connection. If it is still
346
+ * bound, the current implementation keeps it alive and ignores the destroy
347
+ * request.
348
+ *
349
+ * @param output Output handle to destroy.
350
+ */
351
+ void tirtc_audio_output_destroy(TirtcAudioOutput* output);
352
+
353
+ /**
354
+ * @brief Bind a concrete audio playback backend to an output object.
355
+ *
356
+ * The backend pointer is non-owning and should remain valid until the output
357
+ * has been detached and destroyed. Passing NULL is not supported by this API.
358
+ *
359
+ * @param output Target audio output.
360
+ * @param aout Playback backend to bind.
361
+ * @return ::TIRTC_ERROR_OK on success.
362
+ */
363
+ TirtcError tirtc_audio_output_set_aout(TirtcAudioOutput* output, TirtcAudioAout* aout);
364
+
365
+ /**
366
+ * @brief Store audio output playback options.
367
+ *
368
+ * This call is intended for the pre-attach configuration phase. The current
369
+ * implementation rejects option changes while the output is attached.
370
+ *
371
+ * @param output Target audio output.
372
+ * @param options Options to copy into the facade object.
373
+ * @return ::TIRTC_ERROR_OK on success.
374
+ */
375
+ TirtcError tirtc_audio_output_set_options(TirtcAudioOutput* output,
376
+ const TirtcAudioOutputOptions* options);
377
+
378
+ /**
379
+ * @brief Install, replace, or clear the audio output observer.
380
+ *
381
+ * Passing NULL for ::observer clears the current observer. The implementation
382
+ * stores a copy of the observer structure and does not require it to outlive
383
+ * this call.
384
+ *
385
+ * @param output Target audio output.
386
+ * @param observer Observer to install, or NULL to clear.
387
+ * @param user_data Opaque pointer returned to observer callbacks.
388
+ * @return ::TIRTC_ERROR_OK on success.
389
+ */
390
+ TirtcError tirtc_audio_output_set_observer(TirtcAudioOutput* output,
391
+ const TirtcAudioOutputObserver* observer,
392
+ void* user_data);
393
+
394
+ #ifdef __cplusplus
395
+ }
396
+ #endif
397
+
398
+ #endif // TIRTC_FACADE_AUDIO_H_
@@ -0,0 +1,23 @@
1
+ #ifndef TIRTC_AUDIO_CODEC_H_
2
+ #define TIRTC_AUDIO_CODEC_H_
3
+
4
+ #include <stddef.h>
5
+
6
+ #include "tirtc/audio_frame.h"
7
+ #include "tirtc/error.h"
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ TirtcError tirtc_audio_g711a_encode(const TirtcAudioPcmFrame* pcm_frame, void* out_buffer,
14
+ size_t out_buffer_capacity, TirtcAudioEncodedFrame* out_frame);
15
+
16
+ TirtcError tirtc_audio_g711a_decode(const TirtcAudioEncodedFrame* in_frame, void* out_buffer,
17
+ size_t out_buffer_capacity, TirtcAudioPcmFrame* out_frame);
18
+
19
+ #ifdef __cplusplus
20
+ }
21
+ #endif
22
+
23
+ #endif // TIRTC_AUDIO_CODEC_H_
@@ -0,0 +1,36 @@
1
+ #ifndef TIRTC_AUDIO_FRAME_H_
2
+ #define TIRTC_AUDIO_FRAME_H_
3
+
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+
7
+ #include "tirtc/audio_sample_rate.h"
8
+ #include "tirtc/media_codec.h"
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ typedef struct TirtcAudioPcmFrame {
15
+ TirtcAudioSampleRate sample_rate;
16
+ uint32_t samples_per_channel;
17
+ int64_t pts_us;
18
+ /* Mutable PCM payload for capture, processing, and render-fill paths. */
19
+ void* data;
20
+ size_t data_bytes;
21
+ } TirtcAudioPcmFrame;
22
+
23
+ typedef struct TirtcAudioEncodedFrame {
24
+ TirtcMediaCodec codec;
25
+ TirtcAudioSampleRate sample_rate;
26
+ uint32_t samples_per_channel;
27
+ int64_t pts_us;
28
+ const void* data;
29
+ size_t data_bytes;
30
+ } TirtcAudioEncodedFrame;
31
+
32
+ #ifdef __cplusplus
33
+ }
34
+ #endif
35
+
36
+ #endif // TIRTC_AUDIO_FRAME_H_
@@ -0,0 +1,56 @@
1
+ #ifndef TIRTC_AUDIO_IO_H_
2
+ #define TIRTC_AUDIO_IO_H_
3
+
4
+ #include <stdint.h>
5
+
6
+ #include "tirtc/audio_frame.h"
7
+ #include "tirtc/error.h"
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ typedef struct TirtcAudioAin TirtcAudioAin;
14
+ typedef struct TirtcAudioAout TirtcAudioAout;
15
+
16
+ typedef struct TirtcAudioIoConfig {
17
+ TirtcAudioSampleRate sample_rate;
18
+ /* AIN uses fixed 10 ms mono blocks; AOUT may use larger callback-sized multiples. */
19
+ uint32_t samples_per_buffer;
20
+ } TirtcAudioIoConfig;
21
+
22
+ typedef void (*TirtcAudioAinOnFrameFn)(TirtcAudioAin* ain, const TirtcAudioPcmFrame* frame,
23
+ void* user_data);
24
+
25
+ /*
26
+ * AOUT pre-fills sample_rate, samples_per_channel, data, and data_bytes before
27
+ * calling render. The callback contract expects a non-negative rendered PCM
28
+ * byte count. Backends defensively clamp negative returns to zero and zero-fill
29
+ * any remaining buffer space.
30
+ *
31
+ * The render callback and user_data supplied at open-time must stay valid until
32
+ * close completes. Backends may invoke render without holding backend locks.
33
+ */
34
+ typedef int (*TirtcAudioAoutRenderFn)(TirtcAudioAout* aout, TirtcAudioPcmFrame* frame,
35
+ void* user_data);
36
+
37
+ TirtcError tirtc_audio_ain_open(TirtcAudioAin* ain, const TirtcAudioIoConfig* config,
38
+ TirtcAudioAinOnFrameFn on_frame, void* user_data);
39
+
40
+ TirtcError tirtc_audio_ain_close(TirtcAudioAin* ain);
41
+ void tirtc_audio_ain_destroy(TirtcAudioAin* ain);
42
+
43
+ TirtcError tirtc_audio_aout_open(TirtcAudioAout* aout, const TirtcAudioIoConfig* config,
44
+ TirtcAudioAoutRenderFn render, void* user_data);
45
+
46
+ TirtcError tirtc_audio_aout_set_volume(TirtcAudioAout* aout, uint32_t volume_percent);
47
+ TirtcError tirtc_audio_aout_pause(TirtcAudioAout* aout, int pause_on);
48
+ TirtcError tirtc_audio_aout_flush(TirtcAudioAout* aout);
49
+ TirtcError tirtc_audio_aout_close(TirtcAudioAout* aout);
50
+ void tirtc_audio_aout_destroy(TirtcAudioAout* aout);
51
+
52
+ #ifdef __cplusplus
53
+ }
54
+ #endif
55
+
56
+ #endif // TIRTC_AUDIO_IO_H_
@@ -0,0 +1,19 @@
1
+ #ifndef TIRTC_AUDIO_IO_ANDROID_H_
2
+ #define TIRTC_AUDIO_IO_ANDROID_H_
3
+
4
+ #include "tirtc/audio_io.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #if defined(__ANDROID__)
11
+ TirtcError tirtc_audio_android_create_open_sl_ain(TirtcAudioAin** out_ain);
12
+ TirtcError tirtc_audio_android_create_open_sl_aout(TirtcAudioAout** out_aout);
13
+ #endif
14
+
15
+ #ifdef __cplusplus
16
+ }
17
+ #endif
18
+
19
+ #endif // TIRTC_AUDIO_IO_ANDROID_H_
@@ -0,0 +1,19 @@
1
+ #ifndef TIRTC_AUDIO_IO_APPLE_H_
2
+ #define TIRTC_AUDIO_IO_APPLE_H_
3
+
4
+ #include "tirtc/audio_io.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #if defined(__APPLE__)
11
+ TirtcError tirtc_audio_apple_create_audio_toolbox_ain(TirtcAudioAin** out_ain);
12
+ TirtcError tirtc_audio_apple_create_audio_queue_aout(TirtcAudioAout** out_aout);
13
+ #endif
14
+
15
+ #ifdef __cplusplus
16
+ }
17
+ #endif
18
+
19
+ #endif // TIRTC_AUDIO_IO_APPLE_H_
@@ -0,0 +1,19 @@
1
+ #ifndef TIRTC_AUDIO_IO_HARMONY_H_
2
+ #define TIRTC_AUDIO_IO_HARMONY_H_
3
+
4
+ #include "tirtc/audio_io.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #if defined(__OHOS__)
11
+ TirtcError tirtc_audio_harmony_create_open_sl_ain(TirtcAudioAin** out_ain);
12
+ TirtcError tirtc_audio_harmony_create_audio_render_aout(TirtcAudioAout** out_aout);
13
+ #endif
14
+
15
+ #ifdef __cplusplus
16
+ }
17
+ #endif
18
+
19
+ #endif // TIRTC_AUDIO_IO_HARMONY_H_
@@ -0,0 +1,19 @@
1
+ #ifndef TIRTC_AUDIO_IO_WINDOWS_H_
2
+ #define TIRTC_AUDIO_IO_WINDOWS_H_
3
+
4
+ #include "tirtc/audio_io.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #if defined(_WIN32)
11
+ TirtcError tirtc_audio_windows_create_wasapi_ain(TirtcAudioAin** out_ain);
12
+ TirtcError tirtc_audio_windows_create_wave_out_aout(TirtcAudioAout** out_aout);
13
+ #endif
14
+
15
+ #ifdef __cplusplus
16
+ }
17
+ #endif
18
+
19
+ #endif // TIRTC_AUDIO_IO_WINDOWS_H_
@@ -0,0 +1,56 @@
1
+ #ifndef TIRTC_AUDIO_PROCESSING_H_
2
+ #define TIRTC_AUDIO_PROCESSING_H_
3
+
4
+ #include "tirtc/audio_frame.h"
5
+ #include "tirtc/error.h"
6
+
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ typedef struct TirtcAudioProcessor TirtcAudioProcessor;
12
+
13
+ typedef enum TirtcAudioAecMode {
14
+ TIRTC_AUDIO_AEC_MODE_DISABLED = 0,
15
+ TIRTC_AUDIO_AEC_MODE_ENABLED = 1,
16
+ } TirtcAudioAecMode;
17
+
18
+ typedef enum TirtcAudioAnsLevel {
19
+ TIRTC_AUDIO_ANS_LEVEL_DISABLED = 0,
20
+ TIRTC_AUDIO_ANS_LEVEL_LOW = 1,
21
+ TIRTC_AUDIO_ANS_LEVEL_MEDIUM = 2,
22
+ TIRTC_AUDIO_ANS_LEVEL_HIGH = 3,
23
+ } TirtcAudioAnsLevel;
24
+
25
+ typedef enum TirtcAudioAgcLevel {
26
+ TIRTC_AUDIO_AGC_LEVEL_DISABLED = 0,
27
+ TIRTC_AUDIO_AGC_LEVEL_LOW = 1,
28
+ TIRTC_AUDIO_AGC_LEVEL_MEDIUM = 2,
29
+ TIRTC_AUDIO_AGC_LEVEL_HIGH = 3,
30
+ } TirtcAudioAgcLevel;
31
+
32
+ typedef struct TirtcAudioProcessorConfig {
33
+ TirtcAudioSampleRate sample_rate;
34
+ TirtcAudioAecMode aec_mode;
35
+ TirtcAudioAnsLevel ans_level;
36
+ TirtcAudioAgcLevel agc_level;
37
+ } TirtcAudioProcessorConfig;
38
+
39
+ TirtcError tirtc_audio_processor_create(const TirtcAudioProcessorConfig* config,
40
+ TirtcAudioProcessor** out_processor);
41
+ void tirtc_audio_processor_destroy(TirtcAudioProcessor* processor);
42
+
43
+ TirtcError tirtc_audio_processor_set_config(TirtcAudioProcessor* processor,
44
+ const TirtcAudioProcessorConfig* config);
45
+
46
+ TirtcError tirtc_audio_processor_process(TirtcAudioProcessor* processor,
47
+ const TirtcAudioPcmFrame* in_frame,
48
+ TirtcAudioPcmFrame* out_frame);
49
+
50
+ TirtcError tirtc_audio_processor_reset(TirtcAudioProcessor* processor);
51
+
52
+ #ifdef __cplusplus
53
+ }
54
+ #endif
55
+
56
+ #endif // TIRTC_AUDIO_PROCESSING_H_
@@ -0,0 +1,18 @@
1
+ #ifndef TIRTC_MEDIA_CONTRACT_AUDIO_SAMPLE_RATE_H_
2
+ #define TIRTC_MEDIA_CONTRACT_AUDIO_SAMPLE_RATE_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ typedef enum TirtcAudioSampleRate {
9
+ TIRTC_AUDIO_SAMPLE_RATE_NONE = 0,
10
+ TIRTC_AUDIO_SAMPLE_RATE_8K = 8000,
11
+ TIRTC_AUDIO_SAMPLE_RATE_16K = 16000,
12
+ } TirtcAudioSampleRate;
13
+
14
+ #ifdef __cplusplus
15
+ }
16
+ #endif
17
+
18
+ #endif // TIRTC_MEDIA_CONTRACT_AUDIO_SAMPLE_RATE_H_