diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-12 21:53:59 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-12 23:32:59 +0000 |
commit | df9033dcb9d2b5ee8ef521b75abc32cda6498827 (patch) | |
tree | 5a83e9e3cba33b934e27b5f1105d0cafd5f2a6b8 /toxav/rtp.h | |
parent | f1eee021855c8ab7d21fddbdf3a08a072699e708 (diff) |
Fix coding style in rtp module.
* Named callback types only.
* No anonymous enums or structs.
* `++i` instead of `i++`.
* Don't use enums to specify integer constants. Enums should be
enumerations. All values of an enum type should be listed[1].
[1] I don't know what to do about bit masks yet, but given that enums by
C standard can only go up to 32767 portably and 2^31 in reality, they are
probably not useful for 64 bit bit masks.
Diffstat (limited to 'toxav/rtp.h')
-rw-r--r-- | toxav/rtp.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/toxav/rtp.h b/toxav/rtp.h index e1cf7950..225f4c03 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h | |||
@@ -45,16 +45,16 @@ extern "C" { | |||
45 | /** | 45 | /** |
46 | * Payload type identifier. Also used as rtp callback prefix. | 46 | * Payload type identifier. Also used as rtp callback prefix. |
47 | */ | 47 | */ |
48 | enum { | 48 | typedef enum RTP_Type { |
49 | RTP_TYPE_AUDIO = 192, | 49 | RTP_TYPE_AUDIO = 192, |
50 | RTP_TYPE_VIDEO = 193, | 50 | RTP_TYPE_VIDEO = 193, |
51 | }; | 51 | } RTP_Type; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * A bit mask (up to 64 bits) specifying features of the current frame affecting | 54 | * A bit mask (up to 64 bits) specifying features of the current frame affecting |
55 | * the behaviour of the decoder. | 55 | * the behaviour of the decoder. |
56 | */ | 56 | */ |
57 | enum RTPFlags { | 57 | typedef enum RTPFlags { |
58 | /** | 58 | /** |
59 | * Support frames larger than 64KiB. The full 32 bit length and offset are | 59 | * Support frames larger than 64KiB. The full 32 bit length and offset are |
60 | * set in \ref RTPHeader::data_length_full and \ref RTPHeader::offset_full. | 60 | * set in \ref RTPHeader::data_length_full and \ref RTPHeader::offset_full. |
@@ -64,7 +64,7 @@ enum RTPFlags { | |||
64 | * Whether the packet is part of a key frame. | 64 | * Whether the packet is part of a key frame. |
65 | */ | 65 | */ |
66 | RTP_KEY_FRAME = 1 << 1, | 66 | RTP_KEY_FRAME = 1 << 1, |
67 | }; | 67 | } RTPFlags; |
68 | 68 | ||
69 | 69 | ||
70 | struct RTPHeader { | 70 | struct RTPHeader { |
@@ -159,6 +159,8 @@ struct RTPWorkBufferList { | |||
159 | 159 | ||
160 | #define DISMISS_FIRST_LOST_VIDEO_PACKET_COUNT 10 | 160 | #define DISMISS_FIRST_LOST_VIDEO_PACKET_COUNT 10 |
161 | 161 | ||
162 | typedef int rtp_m_cb(void *cs, struct RTPMessage *msg); | ||
163 | |||
162 | /** | 164 | /** |
163 | * RTP control session. | 165 | * RTP control session. |
164 | */ | 166 | */ |
@@ -175,7 +177,7 @@ typedef struct RTPSession { | |||
175 | uint32_t friend_number; | 177 | uint32_t friend_number; |
176 | BWController *bwc; | 178 | BWController *bwc; |
177 | void *cs; | 179 | void *cs; |
178 | int (*mcb)(void *, struct RTPMessage *msg); | 180 | rtp_m_cb *mcb; |
179 | } RTPSession; | 181 | } RTPSession; |
180 | 182 | ||
181 | 183 | ||
@@ -198,8 +200,7 @@ size_t rtp_header_pack(uint8_t *rdata, const struct RTPHeader *header); | |||
198 | size_t rtp_header_unpack(const uint8_t *data, struct RTPHeader *header); | 200 | size_t rtp_header_unpack(const uint8_t *data, struct RTPHeader *header); |
199 | 201 | ||
200 | RTPSession *rtp_new(int payload_type, Messenger *m, uint32_t friendnumber, | 202 | RTPSession *rtp_new(int payload_type, Messenger *m, uint32_t friendnumber, |
201 | BWController *bwc, void *cs, | 203 | BWController *bwc, void *cs, rtp_m_cb *mcb); |
202 | int (*mcb)(void *, struct RTPMessage *)); | ||
203 | void rtp_kill(RTPSession *session); | 204 | void rtp_kill(RTPSession *session); |
204 | int rtp_allow_receiving(RTPSession *session); | 205 | int rtp_allow_receiving(RTPSession *session); |
205 | int rtp_stop_receiving(RTPSession *session); | 206 | int rtp_stop_receiving(RTPSession *session); |