diff options
Diffstat (limited to 'other/apidsl/toxav.in.h')
-rw-r--r-- | other/apidsl/toxav.in.h | 615 |
1 files changed, 615 insertions, 0 deletions
diff --git a/other/apidsl/toxav.in.h b/other/apidsl/toxav.in.h new file mode 100644 index 00000000..ab89b0ea --- /dev/null +++ b/other/apidsl/toxav.in.h | |||
@@ -0,0 +1,615 @@ | |||
1 | %{ | ||
2 | /* toxav.h | ||
3 | * | ||
4 | * Copyright (C) 2013-2015 Tox project All Rights Reserved. | ||
5 | * | ||
6 | * This file is part of Tox. | ||
7 | * | ||
8 | * Tox is free software: you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation, either version 3 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * Tox is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef TOXAV_H | ||
24 | #define TOXAV_H | ||
25 | |||
26 | #include <stdbool.h> | ||
27 | #include <stddef.h> | ||
28 | #include <stdint.h> | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" { | ||
32 | #endif | ||
33 | %} | ||
34 | |||
35 | /** \page av Public audio/video API for Tox clients. | ||
36 | * | ||
37 | * This API can handle multiple calls. Each call has its state, in very rare | ||
38 | * occasions the library can change the state of the call without apps knowledge. | ||
39 | * | ||
40 | */ | ||
41 | |||
42 | /** \subsection events Events and callbacks | ||
43 | * | ||
44 | * As in Core API, events are handled by callbacks. One callback can be | ||
45 | * registered per event. All events have a callback function type named | ||
46 | * `toxav_{event}_cb` and a function to register it named `tox_callback_{event}`. | ||
47 | * Passing a NULL callback will result in no callback being registered for that | ||
48 | * event. Only one callback per event can be registered, so if a client needs | ||
49 | * multiple event listeners, it needs to implement the dispatch functionality | ||
50 | * itself. Unlike Core API, lack of some event handlers will cause the the | ||
51 | * library to drop calls before they are started. Hanging up call from a | ||
52 | * callback causes undefined behaviour. | ||
53 | * | ||
54 | */ | ||
55 | |||
56 | /** \subsection threading Threading implications | ||
57 | * | ||
58 | * Unlike the Core API, this API is fully thread-safe. The library will ensure | ||
59 | * the proper synchronization of parallel calls. | ||
60 | * | ||
61 | * A common way to run ToxAV (multiple or single instance) is to have a thread, | ||
62 | * separate from tox instance thread, running a simple ${toxAV.iterate} loop, | ||
63 | * sleeping for ${toxAV.iteration_interval} * milliseconds on each iteration. | ||
64 | * | ||
65 | * An important thing to note is that events are triggered from both tox and | ||
66 | * toxav thread (see above). audio and video receive frame events are triggered | ||
67 | * from toxav thread while all the other events are triggered from tox thread. | ||
68 | * | ||
69 | * Tox thread has priority with mutex mechanisms. Any api function can | ||
70 | * fail if mutexes are held by tox thread in which case they will set SYNC | ||
71 | * error code. | ||
72 | */ | ||
73 | |||
74 | /** | ||
75 | * External Tox type. | ||
76 | */ | ||
77 | class tox { | ||
78 | struct this; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * ToxAV. | ||
83 | */ | ||
84 | class toxAV { | ||
85 | |||
86 | /** | ||
87 | * The ToxAV instance type. Each ToxAV instance can be bound to only one Tox | ||
88 | * instance, and Tox instance can have only one ToxAV instance. One must make | ||
89 | * sure to close ToxAV instance prior closing Tox instance otherwise undefined | ||
90 | * behaviour occurs. Upon closing of ToxAV instance, all active calls will be | ||
91 | * forcibly terminated without notifying peers. | ||
92 | * | ||
93 | */ | ||
94 | struct this; | ||
95 | /******************************************************************************* | ||
96 | * | ||
97 | * :: API version | ||
98 | * | ||
99 | ******************************************************************************/ | ||
100 | /** | ||
101 | * The major version number. Incremented when the API or ABI changes in an | ||
102 | * incompatible way. | ||
103 | */ | ||
104 | #define TOXAV_VERSION_MAJOR 0u | ||
105 | /** | ||
106 | * The minor version number. Incremented when functionality is added without | ||
107 | * breaking the API or ABI. Set to 0 when the major version number is | ||
108 | * incremented. | ||
109 | */ | ||
110 | #define TOXAV_VERSION_MINOR 0u | ||
111 | /** | ||
112 | * The patch or revision number. Incremented when bugfixes are applied without | ||
113 | * changing any functionality or API or ABI. | ||
114 | */ | ||
115 | #define TOXAV_VERSION_PATCH 0u | ||
116 | |||
117 | /** | ||
118 | * A macro to check at preprocessing time whether the client code is compatible | ||
119 | * with the installed version of ToxAV. | ||
120 | */ | ||
121 | #define TOXAV_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \ | ||
122 | (TOXAV_VERSION_MAJOR == MAJOR && \ | ||
123 | (TOXAV_VERSION_MINOR > MINOR || \ | ||
124 | (TOXAV_VERSION_MINOR == MINOR && \ | ||
125 | TOXAV_VERSION_PATCH >= PATCH))) | ||
126 | |||
127 | /** | ||
128 | * A macro to make compilation fail if the client code is not compatible with | ||
129 | * the installed version of ToxAV. | ||
130 | */ | ||
131 | #define TOXAV_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \ | ||
132 | typedef char toxav_required_version[TOXAV_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1] | ||
133 | |||
134 | /** | ||
135 | * A convenience macro to call ${version.is_compatible} with the currently | ||
136 | * compiling API version. | ||
137 | */ | ||
138 | #define TOXAV_VERSION_IS_ABI_COMPATIBLE() \ | ||
139 | toxav_version_is_compatible(TOXAV_VERSION_MAJOR, TOXAV_VERSION_MINOR, TOXAV_VERSION_PATCH) | ||
140 | |||
141 | |||
142 | static namespace version { | ||
143 | |||
144 | /** | ||
145 | * Return the major version number of the library. Can be used to display the | ||
146 | * ToxAV library version or to check whether the client is compatible with the | ||
147 | * dynamically linked version of ToxAV. | ||
148 | */ | ||
149 | uint32_t major(); | ||
150 | |||
151 | /** | ||
152 | * Return the minor version number of the library. | ||
153 | */ | ||
154 | uint32_t minor(); | ||
155 | |||
156 | /** | ||
157 | * Return the patch number of the library. | ||
158 | */ | ||
159 | uint32_t patch(); | ||
160 | |||
161 | /** | ||
162 | * Return whether the compiled library version is compatible with the passed | ||
163 | * version numbers. | ||
164 | */ | ||
165 | bool is_compatible(uint32_t major, uint32_t minor, uint32_t patch); | ||
166 | |||
167 | } | ||
168 | /******************************************************************************* | ||
169 | * | ||
170 | * :: Creation and destruction | ||
171 | * | ||
172 | ******************************************************************************/ | ||
173 | /** | ||
174 | * Start new A/V session. There can only be only one session per Tox instance. | ||
175 | */ | ||
176 | static this new (tox::this *tox) { | ||
177 | NULL, | ||
178 | /** | ||
179 | * Memory allocation failure while trying to allocate structures required for | ||
180 | * the A/V session. | ||
181 | */ | ||
182 | MALLOC, | ||
183 | /** | ||
184 | * Attempted to create a second session for the same Tox instance. | ||
185 | */ | ||
186 | MULTIPLE, | ||
187 | } | ||
188 | /** | ||
189 | * Releases all resources associated with the A/V session. | ||
190 | * | ||
191 | * If any calls were ongoing, these will be forcibly terminated without | ||
192 | * notifying peers. After calling this function, no other functions may be | ||
193 | * called and the av pointer becomes invalid. | ||
194 | */ | ||
195 | void kill(); | ||
196 | /** | ||
197 | * Returns the Tox instance the A/V object was created for. | ||
198 | */ | ||
199 | tox::this *tox { get(); } | ||
200 | /******************************************************************************* | ||
201 | * | ||
202 | * :: A/V event loop | ||
203 | * | ||
204 | ******************************************************************************/ | ||
205 | /** | ||
206 | * Returns the interval in milliseconds when the next toxav_iterate call should | ||
207 | * be. If no call is active at the moment, this function returns 200. | ||
208 | */ | ||
209 | const uint32_t iteration_interval(); | ||
210 | /** | ||
211 | * Main loop for the session. This function needs to be called in intervals of | ||
212 | * toxav_iteration_interval() milliseconds. It is best called in the separate | ||
213 | * thread from tox_iterate. | ||
214 | */ | ||
215 | void iterate(); | ||
216 | /******************************************************************************* | ||
217 | * | ||
218 | * :: Call setup | ||
219 | * | ||
220 | ******************************************************************************/ | ||
221 | /** | ||
222 | * Call a friend. This will start ringing the friend. | ||
223 | * | ||
224 | * It is the client's responsibility to stop ringing after a certain timeout, | ||
225 | * if such behaviour is desired. If the client does not stop ringing, the | ||
226 | * library will not stop until the friend is disconnected. Audio and video | ||
227 | * receiving are both enabled by default. | ||
228 | * | ||
229 | * @param friend_number The friend number of the friend that should be called. | ||
230 | * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable | ||
231 | * audio sending. | ||
232 | * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable | ||
233 | * video sending. | ||
234 | */ | ||
235 | bool call(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate) { | ||
236 | /** | ||
237 | * A resource allocation error occurred while trying to create the structures | ||
238 | * required for the call. | ||
239 | */ | ||
240 | MALLOC, | ||
241 | /** | ||
242 | * Synchronization error occurred. | ||
243 | */ | ||
244 | SYNC, | ||
245 | /** | ||
246 | * The friend number did not designate a valid friend. | ||
247 | */ | ||
248 | FRIEND_NOT_FOUND, | ||
249 | /** | ||
250 | * The friend was valid, but not currently connected. | ||
251 | */ | ||
252 | FRIEND_NOT_CONNECTED, | ||
253 | /** | ||
254 | * Attempted to call a friend while already in an audio or video call with | ||
255 | * them. | ||
256 | */ | ||
257 | FRIEND_ALREADY_IN_CALL, | ||
258 | /** | ||
259 | * Audio or video bit rate is invalid. | ||
260 | */ | ||
261 | INVALID_BIT_RATE, | ||
262 | } | ||
263 | event call { | ||
264 | /** | ||
265 | * The function type for the ${event call} callback. | ||
266 | * | ||
267 | * @param friend_number The friend number from which the call is incoming. | ||
268 | * @param audio_enabled True if friend is sending audio. | ||
269 | * @param video_enabled True if friend is sending video. | ||
270 | */ | ||
271 | typedef void(uint32_t friend_number, bool audio_enabled, bool video_enabled); | ||
272 | } | ||
273 | /** | ||
274 | * Accept an incoming call. | ||
275 | * | ||
276 | * If answering fails for any reason, the call will still be pending and it is | ||
277 | * possible to try and answer it later. Audio and video receiving are both | ||
278 | * enabled by default. | ||
279 | * | ||
280 | * @param friend_number The friend number of the friend that is calling. | ||
281 | * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable | ||
282 | * audio sending. | ||
283 | * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable | ||
284 | * video sending. | ||
285 | */ | ||
286 | bool answer(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate) { | ||
287 | /** | ||
288 | * Synchronization error occurred. | ||
289 | */ | ||
290 | SYNC, | ||
291 | /** | ||
292 | * Failed to initialize codecs for call session. Note that codec initiation | ||
293 | * will fail if there is no receive callback registered for either audio or | ||
294 | * video. | ||
295 | */ | ||
296 | CODEC_INITIALIZATION, | ||
297 | /** | ||
298 | * The friend number did not designate a valid friend. | ||
299 | */ | ||
300 | FRIEND_NOT_FOUND, | ||
301 | /** | ||
302 | * The friend was valid, but they are not currently trying to initiate a call. | ||
303 | * This is also returned if this client is already in a call with the friend. | ||
304 | */ | ||
305 | FRIEND_NOT_CALLING, | ||
306 | /** | ||
307 | * Audio or video bit rate is invalid. | ||
308 | */ | ||
309 | INVALID_BIT_RATE, | ||
310 | } | ||
311 | /******************************************************************************* | ||
312 | * | ||
313 | * :: Call state graph | ||
314 | * | ||
315 | ******************************************************************************/ | ||
316 | bitmask FRIEND_CALL_STATE { | ||
317 | /** | ||
318 | * Set by the AV core if an error occurred on the remote end or if friend | ||
319 | * timed out. This is the final state after which no more state | ||
320 | * transitions can occur for the call. This call state will never be triggered | ||
321 | * in combination with other call states. | ||
322 | */ | ||
323 | ERROR, | ||
324 | /** | ||
325 | * The call has finished. This is the final state after which no more state | ||
326 | * transitions can occur for the call. This call state will never be | ||
327 | * triggered in combination with other call states. | ||
328 | */ | ||
329 | FINISHED, | ||
330 | /** | ||
331 | * The flag that marks that friend is sending audio. | ||
332 | */ | ||
333 | SENDING_A, | ||
334 | /** | ||
335 | * The flag that marks that friend is sending video. | ||
336 | */ | ||
337 | SENDING_V, | ||
338 | /** | ||
339 | * The flag that marks that friend is receiving audio. | ||
340 | */ | ||
341 | ACCEPTING_A, | ||
342 | /** | ||
343 | * The flag that marks that friend is receiving video. | ||
344 | */ | ||
345 | ACCEPTING_V, | ||
346 | } | ||
347 | event call_state { | ||
348 | /** | ||
349 | * The function type for the ${event call_state} callback. | ||
350 | * | ||
351 | * @param friend_number The friend number for which the call state changed. | ||
352 | * @param state The bitmask of the new call state which is guaranteed to be | ||
353 | * different than the previous state. The state is set to 0 when the call is | ||
354 | * paused. The bitmask represents all the activities currently performed by the | ||
355 | * friend. | ||
356 | */ | ||
357 | typedef void(uint32_t friend_number, uint32_t state); | ||
358 | } | ||
359 | /******************************************************************************* | ||
360 | * | ||
361 | * :: Call control | ||
362 | * | ||
363 | ******************************************************************************/ | ||
364 | enum class CALL_CONTROL { | ||
365 | /** | ||
366 | * Resume a previously paused call. Only valid if the pause was caused by this | ||
367 | * client, if not, this control is ignored. Not valid before the call is accepted. | ||
368 | */ | ||
369 | RESUME, | ||
370 | /** | ||
371 | * Put a call on hold. Not valid before the call is accepted. | ||
372 | */ | ||
373 | PAUSE, | ||
374 | /** | ||
375 | * Reject a call if it was not answered, yet. Cancel a call after it was | ||
376 | * answered. | ||
377 | */ | ||
378 | CANCEL, | ||
379 | /** | ||
380 | * Request that the friend stops sending audio. Regardless of the friend's | ||
381 | * compliance, this will cause the ${event audio.receive_frame} event to stop being | ||
382 | * triggered on receiving an audio frame from the friend. | ||
383 | */ | ||
384 | MUTE_AUDIO, | ||
385 | /** | ||
386 | * Calling this control will notify client to start sending audio again. | ||
387 | */ | ||
388 | UNMUTE_AUDIO, | ||
389 | /** | ||
390 | * Request that the friend stops sending video. Regardless of the friend's | ||
391 | * compliance, this will cause the ${event video.receive_frame} event to stop being | ||
392 | * triggered on receiving a video frame from the friend. | ||
393 | */ | ||
394 | HIDE_VIDEO, | ||
395 | /** | ||
396 | * Calling this control will notify client to start sending video again. | ||
397 | */ | ||
398 | SHOW_VIDEO, | ||
399 | } | ||
400 | /** | ||
401 | * Sends a call control command to a friend. | ||
402 | * | ||
403 | * @param friend_number The friend number of the friend this client is in a call | ||
404 | * with. | ||
405 | * @param control The control command to send. | ||
406 | * | ||
407 | * @return true on success. | ||
408 | */ | ||
409 | bool call_control (uint32_t friend_number, CALL_CONTROL control) { | ||
410 | /** | ||
411 | * Synchronization error occurred. | ||
412 | */ | ||
413 | SYNC, | ||
414 | /** | ||
415 | * The friend_number passed did not designate a valid friend. | ||
416 | */ | ||
417 | FRIEND_NOT_FOUND, | ||
418 | /** | ||
419 | * This client is currently not in a call with the friend. Before the call is | ||
420 | * answered, only CANCEL is a valid control. | ||
421 | */ | ||
422 | FRIEND_NOT_IN_CALL, | ||
423 | /** | ||
424 | * Happens if user tried to pause an already paused call or if trying to | ||
425 | * resume a call that is not paused. | ||
426 | */ | ||
427 | INVALID_TRANSITION, | ||
428 | } | ||
429 | /******************************************************************************* | ||
430 | * | ||
431 | * :: Controlling bit rates | ||
432 | * | ||
433 | ******************************************************************************/ | ||
434 | namespace bit_rate { | ||
435 | /** | ||
436 | * Set the audio bit rate to be used in subsequent audio/video frames. | ||
437 | * | ||
438 | * @param friend_number The friend number. | ||
439 | * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable | ||
440 | * audio sending. Set to -1 to leave unchanged. | ||
441 | * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable | ||
442 | * video sending. Set to -1 to leave unchanged. | ||
443 | * | ||
444 | */ | ||
445 | bool set(uint32_t friend_number, int32_t audio_bit_rate, int32_t video_bit_rate) { | ||
446 | /** | ||
447 | * Synchronization error occurred. | ||
448 | */ | ||
449 | SYNC, | ||
450 | /** | ||
451 | * The bit rate passed was not one of the supported values. | ||
452 | */ | ||
453 | INVALID, | ||
454 | /** | ||
455 | * The friend_number passed did not designate a valid friend. | ||
456 | */ | ||
457 | FRIEND_NOT_FOUND, | ||
458 | /** | ||
459 | * This client is currently not in a call with the friend. | ||
460 | */ | ||
461 | FRIEND_NOT_IN_CALL, | ||
462 | } | ||
463 | event status { | ||
464 | /** | ||
465 | * The function type for the ${event status} callback. The event is triggered | ||
466 | * when the network becomes too saturated for current bit rates at which | ||
467 | * point core suggests new bit rates. | ||
468 | * | ||
469 | * @param friend_number The friend number. | ||
470 | * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. | ||
471 | * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. | ||
472 | */ | ||
473 | typedef void(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate); | ||
474 | } | ||
475 | } | ||
476 | /******************************************************************************* | ||
477 | * | ||
478 | * :: A/V sending | ||
479 | * | ||
480 | ******************************************************************************/ | ||
481 | error for send_frame { | ||
482 | /** | ||
483 | * In case of video, one of Y, U, or V was NULL. In case of audio, the samples | ||
484 | * data pointer was NULL. | ||
485 | */ | ||
486 | NULL, | ||
487 | /** | ||
488 | * The friend_number passed did not designate a valid friend. | ||
489 | */ | ||
490 | FRIEND_NOT_FOUND, | ||
491 | /** | ||
492 | * This client is currently not in a call with the friend. | ||
493 | */ | ||
494 | FRIEND_NOT_IN_CALL, | ||
495 | /** | ||
496 | * Synchronization error occurred. | ||
497 | */ | ||
498 | SYNC, | ||
499 | /** | ||
500 | * One of the frame parameters was invalid. E.g. the resolution may be too | ||
501 | * small or too large, or the audio sampling rate may be unsupported. | ||
502 | */ | ||
503 | INVALID, | ||
504 | /** | ||
505 | * Either friend turned off audio or video receiving or we turned off sending | ||
506 | * for the said payload. | ||
507 | */ | ||
508 | PAYLOAD_TYPE_DISABLED, | ||
509 | /** | ||
510 | * Failed to push frame through rtp interface. | ||
511 | */ | ||
512 | RTP_FAILED, | ||
513 | } | ||
514 | namespace audio { | ||
515 | /** | ||
516 | * Send an audio frame to a friend. | ||
517 | * | ||
518 | * The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... | ||
519 | * Meaning: sample 1 for channel 1, sample 1 for channel 2, ... | ||
520 | * For mono audio, this has no meaning, every sample is subsequent. For stereo, | ||
521 | * this means the expected format is LRLRLR... with samples for left and right | ||
522 | * alternating. | ||
523 | * | ||
524 | * @param friend_number The friend number of the friend to which to send an | ||
525 | * audio frame. | ||
526 | * @param pcm An array of audio samples. The size of this array must be | ||
527 | * sample_count * channels. | ||
528 | * @param sample_count Number of samples in this frame. Valid numbers here are | ||
529 | * ((sample rate) * (audio length) / 1000), where audio length can be | ||
530 | * 2.5, 5, 10, 20, 40 or 60 millseconds. | ||
531 | * @param channels Number of audio channels. Supported values are 1 and 2. | ||
532 | * @param sampling_rate Audio sampling rate used in this frame. Valid sampling | ||
533 | * rates are 8000, 12000, 16000, 24000, or 48000. | ||
534 | */ | ||
535 | bool send_frame(uint32_t friend_number, const int16_t *pcm, size_t sample_count, | ||
536 | uint8_t channels, uint32_t sampling_rate) with error for send_frame; | ||
537 | } | ||
538 | namespace video { | ||
539 | /** | ||
540 | * Send a video frame to a friend. | ||
541 | * | ||
542 | * Y - plane should be of size: height * width | ||
543 | * U - plane should be of size: (height/2) * (width/2) | ||
544 | * V - plane should be of size: (height/2) * (width/2) | ||
545 | * | ||
546 | * @param friend_number The friend number of the friend to which to send a video | ||
547 | * frame. | ||
548 | * @param width Width of the frame in pixels. | ||
549 | * @param height Height of the frame in pixels. | ||
550 | * @param y Y (Luminance) plane data. | ||
551 | * @param u U (Chroma) plane data. | ||
552 | * @param v V (Chroma) plane data. | ||
553 | */ | ||
554 | bool send_frame(uint32_t friend_number, uint16_t width, uint16_t height, | ||
555 | const uint8_t *y, const uint8_t *u, const uint8_t *v) with error for send_frame; | ||
556 | } | ||
557 | /******************************************************************************* | ||
558 | * | ||
559 | * :: A/V receiving | ||
560 | * | ||
561 | ******************************************************************************/ | ||
562 | namespace audio { | ||
563 | event receive_frame { | ||
564 | /** | ||
565 | * The function type for the ${event receive_frame} callback. The callback can be | ||
566 | * called multiple times per single iteration depending on the amount of queued | ||
567 | * frames in the buffer. The received format is the same as in send function. | ||
568 | * | ||
569 | * @param friend_number The friend number of the friend who sent an audio frame. | ||
570 | * @param pcm An array of audio samples (sample_count * channels elements). | ||
571 | * @param sample_count The number of audio samples per channel in the PCM array. | ||
572 | * @param channels Number of audio channels. | ||
573 | * @param sampling_rate Sampling rate used in this frame. | ||
574 | * | ||
575 | */ | ||
576 | typedef void(uint32_t friend_number, const int16_t *pcm, size_t sample_count, | ||
577 | uint8_t channels, uint32_t sampling_rate); | ||
578 | } | ||
579 | } | ||
580 | namespace video { | ||
581 | event receive_frame { | ||
582 | /** | ||
583 | * The function type for the ${event receive_frame} callback. | ||
584 | * | ||
585 | * @param friend_number The friend number of the friend who sent a video frame. | ||
586 | * @param width Width of the frame in pixels. | ||
587 | * @param height Height of the frame in pixels. | ||
588 | * @param y | ||
589 | * @param u | ||
590 | * @param v Plane data. | ||
591 | * The size of plane data is derived from width and height where | ||
592 | * Y = MAX(width, abs(ystride)) * height, | ||
593 | * U = MAX(width/2, abs(ustride)) * (height/2) and | ||
594 | * V = MAX(width/2, abs(vstride)) * (height/2). | ||
595 | * @param ystride | ||
596 | * @param ustride | ||
597 | * @param vstride Strides data. Strides represent padding for each plane | ||
598 | * that may or may not be present. You must handle strides in | ||
599 | * your image processing code. Strides are negative if the | ||
600 | * image is bottom-up hence why you MUST abs() it when | ||
601 | * calculating plane buffer size. | ||
602 | */ | ||
603 | typedef void(uint32_t friend_number, uint16_t width, uint16_t height, | ||
604 | const uint8_t *y, const uint8_t *u, const uint8_t *v, | ||
605 | int32_t ystride, int32_t ustride, int32_t vstride); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | } | ||
610 | %{ | ||
611 | #ifdef __cplusplus | ||
612 | } | ||
613 | #endif | ||
614 | #endif /* TOXAV_H */ | ||
615 | %} | ||