Skip to content

Commit 4c90295

Browse files
committed
docs: Public headers, 80 column width comments
1 parent be8a82a commit 4c90295

File tree

5 files changed

+625
-450
lines changed

5 files changed

+625
-450
lines changed

toxav/toxav.h

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
* @brief Public audio/video API for Tox clients.
88
*
99
* This API can handle multiple calls. Each call has its state, in very rare
10-
* occasions the library can change the state of the call without apps knowledge.
10+
* occasions the library can change the state of the call without apps
11+
* knowledge.
1112
*
1213
* @section av_events Events and callbacks
1314
*
1415
* As in Core API, events are handled by callbacks. One callback can be
1516
* registered per event. All events have a callback function type named
16-
* `toxav_{event}_cb` and a function to register it named `toxav_callback_{event}`.
17-
* Passing a NULL callback will result in no callback being registered for that
18-
* event. Only one callback per event can be registered, so if a client needs
19-
* multiple event listeners, it needs to implement the dispatch functionality
20-
* itself. Unlike Core API, lack of some event handlers will cause the the
21-
* library to drop calls before they are started. Hanging up call from a
22-
* callback causes undefined behaviour.
17+
* `toxav_{event}_cb` and a function to register it named
18+
* `toxav_callback_{event}`. Passing a NULL callback will result in no callback
19+
* being registered for that event. Only one callback per event can be
20+
* registered, so if a client needs multiple event listeners, it needs to
21+
* implement the dispatch functionality itself. Unlike Core API, lack of some
22+
* event handlers will cause the the library to drop calls before they are
23+
* started. Hanging up call from a callback causes undefined behaviour.
2324
*
2425
* @section av_threading Threading implications
2526
*
@@ -77,9 +78,9 @@ typedef struct Tox Tox;
7778
*
7879
* Each ToxAV instance can be bound to only one Tox instance, and Tox instance
7980
* can have only one ToxAV instance. One must make sure to close ToxAV instance
80-
* prior closing Tox instance otherwise undefined behaviour occurs. Upon
81-
* closing of ToxAV instance, all active calls will be forcibly terminated
82-
* without notifying peers.
81+
* prior closing Tox instance otherwise undefined behaviour occurs. Upon closing
82+
* of ToxAV instance, all active calls will be forcibly terminated without
83+
* notifying peers.
8384
*/
8485
typedef struct ToxAV ToxAV;
8586

@@ -100,8 +101,8 @@ typedef enum Toxav_Err_New {
100101
TOXAV_ERR_NEW_NULL,
101102

102103
/**
103-
* Memory allocation failure while trying to allocate structures required for
104-
* the A/V session.
104+
* Memory allocation failure while trying to allocate structures required
105+
* for the A/V session.
105106
*/
106107
TOXAV_ERR_NEW_MALLOC,
107108

@@ -203,8 +204,8 @@ typedef enum Toxav_Err_Call {
203204
TOXAV_ERR_CALL_OK,
204205

205206
/**
206-
* A resource allocation error occurred while trying to create the structures
207-
* required for the call.
207+
* A resource allocation error occurred while trying to create the
208+
* structures required for the call.
208209
*/
209210
TOXAV_ERR_CALL_MALLOC,
210211

@@ -246,9 +247,9 @@ typedef enum Toxav_Err_Call {
246247
*
247248
* @param friend_number The friend number of the friend that should be called.
248249
* @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable
249-
* audio sending.
250+
* audio sending.
250251
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
251-
* video sending.
252+
* video sending.
252253
*/
253254
bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
254255
Toxav_Err_Call *error);
@@ -293,8 +294,9 @@ typedef enum Toxav_Err_Answer {
293294
TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND,
294295

295296
/**
296-
* The friend was valid, but they are not currently trying to initiate a call.
297-
* This is also returned if this client is already in a call with the friend.
297+
* The friend was valid, but they are not currently trying to initiate a
298+
* call. This is also returned if this client is already in a call with the
299+
* friend.
298300
*/
299301
TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING,
300302

@@ -314,9 +316,9 @@ typedef enum Toxav_Err_Answer {
314316
*
315317
* @param friend_number The friend number of the friend that is calling.
316318
* @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable
317-
* audio sending.
319+
* audio sending.
318320
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
319-
* video sending.
321+
* video sending.
320322
*/
321323
bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
322324
Toxav_Err_Answer *error);
@@ -337,8 +339,8 @@ enum Toxav_Friend_Call_State {
337339
/**
338340
* Set by the AV core if an error occurred on the remote end or if friend
339341
* timed out. This is the final state after which no more state
340-
* transitions can occur for the call. This call state will never be triggered
341-
* in combination with other call states.
342+
* transitions can occur for the call. This call state will never be
343+
* triggered in combination with other call states.
342344
*/
343345
TOXAV_FRIEND_CALL_STATE_ERROR = 1,
344346

@@ -376,9 +378,9 @@ enum Toxav_Friend_Call_State {
376378
*
377379
* @param friend_number The friend number for which the call state changed.
378380
* @param state The bitmask of the new call state which is guaranteed to be
379-
* different than the previous state. The state is set to 0 when the call is
380-
* paused. The bitmask represents all the activities currently performed by the
381-
* friend.
381+
* different than the previous state. The state is set to 0 when the call is
382+
* paused. The bitmask represents all the activities currently performed by
383+
* the friend.
382384
*/
383385
typedef void toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data);
384386

@@ -397,8 +399,9 @@ void toxav_callback_call_state(ToxAV *av, toxav_call_state_cb *callback, void *u
397399
typedef enum Toxav_Call_Control {
398400

399401
/**
400-
* Resume a previously paused call. Only valid if the pause was caused by this
401-
* client, if not, this control is ignored. Not valid before the call is accepted.
402+
* Resume a previously paused call. Only valid if the pause was caused by
403+
* this client, if not, this control is ignored. Not valid before the call
404+
* is accepted.
402405
*/
403406
TOXAV_CALL_CONTROL_RESUME,
404407

@@ -457,8 +460,8 @@ typedef enum Toxav_Err_Call_Control {
457460
TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND,
458461

459462
/**
460-
* This client is currently not in a call with the friend. Before the call is
461-
* answered, only CANCEL is a valid control.
463+
* This client is currently not in a call with the friend. Before the call
464+
* is answered, only CANCEL is a valid control.
462465
*/
463466
TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL,
464467

@@ -474,7 +477,7 @@ typedef enum Toxav_Err_Call_Control {
474477
* Sends a call control command to a friend.
475478
*
476479
* @param friend_number The friend number of the friend this client is in a call
477-
* with.
480+
* with.
478481
* @param control The control command to send.
479482
*
480483
* @return true on success.
@@ -530,8 +533,8 @@ typedef enum Toxav_Err_Send_Frame {
530533
TOXAV_ERR_SEND_FRAME_OK,
531534

532535
/**
533-
* In case of video, one of Y, U, or V was NULL. In case of audio, the samples
534-
* data pointer was NULL.
536+
* In case of video, one of Y, U, or V was NULL. In case of audio, the
537+
* samples data pointer was NULL.
535538
*/
536539
TOXAV_ERR_SEND_FRAME_NULL,
537540

@@ -557,8 +560,8 @@ typedef enum Toxav_Err_Send_Frame {
557560
TOXAV_ERR_SEND_FRAME_INVALID,
558561

559562
/**
560-
* Either friend turned off audio or video receiving or we turned off sending
561-
* for the said payload.
563+
* Either friend turned off audio or video receiving or we turned off
564+
* sending for the said payload.
562565
*/
563566
TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED,
564567

@@ -572,7 +575,8 @@ typedef enum Toxav_Err_Send_Frame {
572575
/**
573576
* Send an audio frame to a friend.
574577
*
575-
* The expected format of the PCM data is: `[s1c1][s1c2][...][s2c1][s2c2][...]...`
578+
* The expected format of the PCM data is:
579+
* `[s1c1][s1c2][...][s2c1][s2c2][...]...`
576580
* Meaning: sample 1 for channel 1, sample 1 for channel 2, ...
577581
* For mono audio, this has no meaning, every sample is subsequent. For stereo,
578582
* this means the expected format is LRLRLR... with samples for left and right
@@ -587,7 +591,7 @@ typedef enum Toxav_Err_Send_Frame {
587591
* 2.5, 5, 10, 20, 40 or 60 millseconds.
588592
* @param channels Number of audio channels. Supported values are 1 and 2.
589593
* @param sampling_rate Audio sampling rate used in this frame. Valid sampling
590-
* rates are 8000, 12000, 16000, 24000, or 48000.
594+
* rates are 8000, 12000, 16000, 24000, or 48000.
591595
*/
592596
bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t pcm[], size_t sample_count,
593597
uint8_t channels, uint32_t sampling_rate, Toxav_Err_Send_Frame *error);
@@ -596,7 +600,7 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t pcm
596600
* Set the bit rate to be used in subsequent video frames.
597601
*
598602
* @param friend_number The friend number of the friend for which to set the
599-
* bit rate.
603+
* bit rate.
600604
* @param bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable.
601605
*
602606
* @return true on success.
@@ -609,7 +613,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_ra
609613
* point core suggests new bit rates.
610614
*
611615
* @param friend_number The friend number of the friend for which to set the
612-
* bit rate.
616+
* bit rate.
613617
* @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec.
614618
*/
615619
typedef void toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, void *user_data);
@@ -628,7 +632,7 @@ void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback,
628632
* V - plane should be of size: `(height/2) * (width/2)`
629633
*
630634
* @param friend_number The friend number of the friend to which to send a video
631-
* frame.
635+
* frame.
632636
* @param width Width of the frame in pixels.
633637
* @param height Height of the frame in pixels.
634638
* @param y Y (Luminance) plane data.
@@ -646,7 +650,7 @@ bool toxav_video_send_frame(
646650
* Set the bit rate to be used in subsequent video frames.
647651
*
648652
* @param friend_number The friend number of the friend for which to set the
649-
* bit rate.
653+
* bit rate.
650654
* @param bit_rate The new video bit rate in Kb/sec. Set to 0 to disable.
651655
*
652656
* @return true on success.
@@ -659,7 +663,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_ra
659663
* point core suggests new bit rates.
660664
*
661665
* @param friend_number The friend number of the friend for which to set the
662-
* bit rate.
666+
* bit rate.
663667
* @param video_bit_rate Suggested maximum video bit rate in Kb/sec.
664668
*/
665669
typedef void toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, void *user_data);
@@ -714,7 +718,6 @@ void toxav_callback_audio_receive_frame(ToxAV *av, toxav_audio_receive_frame_cb
714718
* @param y Luminosity plane. `Size = MAX(width, abs(ystride)) * height`.
715719
* @param u U chroma plane. `Size = MAX(width/2, abs(ustride)) * (height/2)`.
716720
* @param v V chroma plane. `Size = MAX(width/2, abs(vstride)) * (height/2)`.
717-
*
718721
* @param ystride Luminosity plane stride.
719722
* @param ustride U chroma plane stride.
720723
* @param vstride V chroma plane stride.
@@ -744,7 +747,8 @@ void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb
744747
* userdata per group.
745748
*/
746749

747-
// TODO(iphydf): Use this better typed one instead of the void-pointer one below.
750+
// TODO(iphydf): Use this better typed one instead of the void-pointer one
751+
// below.
748752
typedef void toxav_group_audio_cb(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t pcm[],
749753
uint32_t samples, uint8_t channels, uint32_t sample_rate, void *user_data);
750754

@@ -756,7 +760,8 @@ typedef void toxav_audio_data_cb(void *tox, uint32_t groupnumber, uint32_t peern
756760
* @return group number on success.
757761
* @retval -1 on failure.
758762
*
759-
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
763+
* Note that total size of pcm in bytes is equal to
764+
* `samples * channels * sizeof(int16_t)`.
760765
*/
761766
int32_t toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, void *userdata);
762767

@@ -765,7 +770,8 @@ int32_t toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, vo
765770
* @return group number on success.
766771
* @retval -1 on failure.
767772
*
768-
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
773+
* Note that total size of pcm in bytes is equal to
774+
* `samples * channels * sizeof(int16_t)`.
769775
*/
770776
int32_t toxav_join_av_groupchat(
771777
Tox *tox, uint32_t friendnumber, const uint8_t data[], uint16_t length,
@@ -776,7 +782,8 @@ int32_t toxav_join_av_groupchat(
776782
* @retval 0 on success.
777783
* @retval -1 on failure.
778784
*
779-
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
785+
* Note that total size of pcm in bytes is equal to
786+
* `samples * channels * sizeof(int16_t)`.
780787
*
781788
* Valid number of samples are `(sample rate) * (audio length) / 1000`
782789
* (Valid values for audio length are: 2.5, 5, 10, 20, 40 or 60 ms)
@@ -794,15 +801,16 @@ int32_t toxav_group_send_audio(
794801
* A/V must be enabled on a groupchat for audio to be sent to it and for
795802
* received audio to be handled.
796803
*
797-
* An A/V group created with `toxav_add_av_groupchat` or `toxav_join_av_groupchat`
798-
* will start with A/V enabled.
804+
* An A/V group created with `toxav_add_av_groupchat` or
805+
* `toxav_join_av_groupchat` will start with A/V enabled.
799806
*
800807
* An A/V group loaded from a savefile will start with A/V disabled.
801808
*
802809
* @retval 0 on success.
803810
* @retval -1 on failure.
804811
*
805-
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
812+
* Note that total size of pcm in bytes is equal to
813+
* `samples * channels * sizeof(int16_t)`.
806814
*/
807815
int32_t toxav_groupchat_enable_av(
808816
Tox *tox, uint32_t groupnumber,

0 commit comments

Comments
 (0)