diff options
-rw-r--r-- | toxav/rtp.c | 2 | ||||
-rw-r--r-- | toxav/toxav.c | 24 | ||||
-rw-r--r-- | toxav/toxav.h | 25 |
3 files changed, 28 insertions, 23 deletions
diff --git a/toxav/rtp.c b/toxav/rtp.c index 8f6f0be7..8eca46d4 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -517,7 +517,7 @@ int rtp_handle_packet ( void *object, IP_Port ip_port, uint8_t *data, uint32_t l | |||
517 | RTPSession *_session = object; | 517 | RTPSession *_session = object; |
518 | RTPMessage *_msg; | 518 | RTPMessage *_msg; |
519 | 519 | ||
520 | if ( !_session || length < 13 ) /* 12 is the minimum length for rtp + desc. byte */ | 520 | if ( !_session || length < 13 + crypto_secretbox_MACBYTES) /* 12 is the minimum length for rtp + desc. byte */ |
521 | return -1; | 521 | return -1; |
522 | 522 | ||
523 | uint8_t _plain[MAX_UDP_PACKET_SIZE]; | 523 | uint8_t _plain[MAX_UDP_PACKET_SIZE]; |
diff --git a/toxav/toxav.c b/toxav/toxav.c index f704bc6b..e0ddc731 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -35,6 +35,16 @@ | |||
35 | 35 | ||
36 | #include "toxav.h" | 36 | #include "toxav.h" |
37 | 37 | ||
38 | /* Default video bitrate in bytes/s */ | ||
39 | #define VIDEO_BITRATE (10*1000*100) | ||
40 | |||
41 | /* Default audio bitrate in bits/s */ | ||
42 | #define AUDIO_BITRATE 64000 | ||
43 | |||
44 | /* Assume 60 fps*/ | ||
45 | #define MAX_ENCODE_TIME_US ((1000 / 60) * 1000) | ||
46 | |||
47 | |||
38 | #define inline__ inline __attribute__((always_inline)) | 48 | #define inline__ inline __attribute__((always_inline)) |
39 | 49 | ||
40 | static const uint8_t audio_index = 0, video_index = 1; | 50 | static const uint8_t audio_index = 0, video_index = 1; |
@@ -474,11 +484,12 @@ inline__ int toxav_send_video ( ToxAv *av, vpx_image_t *input) | |||
474 | * @brief Receive decoded audio frame. | 484 | * @brief Receive decoded audio frame. |
475 | * | 485 | * |
476 | * @param av Handler. | 486 | * @param av Handler. |
477 | * @param frame_size ... | 487 | * @param frame_size The size of dest in frames/samples (one frame/sample is 16 bits or 2 bytes |
478 | * @param dest Destination of the packet. Make sure it has enough space for | 488 | * and corresponds to one sample of audio.) |
479 | * RTP_PAYLOAD_SIZE bytes. | 489 | * @param dest Destination of the raw audio (16 bit signed pcm with AUDIO_CHANNELS channels). |
490 | * Make sure it has enough space for frame_size frames/samples. | ||
480 | * @return int | 491 | * @return int |
481 | * @retval >=0 Size of received packet. | 492 | * @retval >=0 Size of received data in frames/samples. |
482 | * @retval ToxAvError On error. | 493 | * @retval ToxAvError On error. |
483 | */ | 494 | */ |
484 | inline__ int toxav_recv_audio ( ToxAv *av, int frame_size, int16_t *dest ) | 495 | inline__ int toxav_recv_audio ( ToxAv *av, int frame_size, int16_t *dest ) |
@@ -503,8 +514,9 @@ inline__ int toxav_recv_audio ( ToxAv *av, int frame_size, int16_t *dest ) | |||
503 | * @brief Encode and send audio frame. | 514 | * @brief Encode and send audio frame. |
504 | * | 515 | * |
505 | * @param av Handler. | 516 | * @param av Handler. |
506 | * @param frame The frame. | 517 | * @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.) |
507 | * @param frame_size It's size. | 518 | * @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes) |
519 | * frame size should be AUDIO_FRAME_SIZE. | ||
508 | * @return int | 520 | * @return int |
509 | * @retval 0 Success. | 521 | * @retval 0 Success. |
510 | * @retval ToxAvError On error. | 522 | * @retval ToxAvError On error. |
diff --git a/toxav/toxav.h b/toxav/toxav.h index be7a2950..40cd90db 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -39,12 +39,6 @@ typedef struct Tox Tox; | |||
39 | 39 | ||
40 | #define RTP_PAYLOAD_SIZE 65535 | 40 | #define RTP_PAYLOAD_SIZE 65535 |
41 | 41 | ||
42 | /* Default video bitrate in bytes/s */ | ||
43 | #define VIDEO_BITRATE 10*1000*100 | ||
44 | |||
45 | /* Default audio bitrate in bits/s */ | ||
46 | #define AUDIO_BITRATE 64000 | ||
47 | |||
48 | /* Number of audio channels. */ | 42 | /* Number of audio channels. */ |
49 | #define AUDIO_CHANNELS 1 | 43 | #define AUDIO_CHANNELS 1 |
50 | 44 | ||
@@ -55,10 +49,7 @@ typedef struct Tox Tox; | |||
55 | #define AUDIO_SAMPLE_RATE 48000 | 49 | #define AUDIO_SAMPLE_RATE 48000 |
56 | 50 | ||
57 | /* The amount of samples in one audio frame */ | 51 | /* The amount of samples in one audio frame */ |
58 | #define AUDIO_FRAME_SIZE AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000 | 52 | #define AUDIO_FRAME_SIZE (AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000) |
59 | |||
60 | /* Assume 60 fps*/ | ||
61 | #define MAX_ENCODE_TIME_US ((1000 / 60) * 1000) | ||
62 | 53 | ||
63 | 54 | ||
64 | /** | 55 | /** |
@@ -246,11 +237,12 @@ int toxav_recv_video ( ToxAv *av, vpx_image_t **output); | |||
246 | * @brief Receive decoded audio frame. | 237 | * @brief Receive decoded audio frame. |
247 | * | 238 | * |
248 | * @param av Handler. | 239 | * @param av Handler. |
249 | * @param frame_size ... | 240 | * @param frame_size The size of dest in frames/samples (one frame/sample is 16 bits or 2 bytes |
250 | * @param dest Destination of the packet. Make sure it has enough space for | 241 | * and corresponds to one sample of audio.) |
251 | * RTP_PAYLOAD_SIZE bytes. | 242 | * @param dest Destination of the raw audio (16 bit signed pcm with AUDIO_CHANNELS channels). |
243 | * Make sure it has enough space for frame_size frames/samples. | ||
252 | * @return int | 244 | * @return int |
253 | * @retval >=0 Size of received packet. | 245 | * @retval >=0 Size of received data in frames/samples. |
254 | * @retval ToxAvError On error. | 246 | * @retval ToxAvError On error. |
255 | */ | 247 | */ |
256 | int toxav_recv_audio( ToxAv *av, int frame_size, int16_t *dest ); | 248 | int toxav_recv_audio( ToxAv *av, int frame_size, int16_t *dest ); |
@@ -270,8 +262,9 @@ int toxav_send_video ( ToxAv *av, vpx_image_t *input); | |||
270 | * @brief Encode and send audio frame. | 262 | * @brief Encode and send audio frame. |
271 | * | 263 | * |
272 | * @param av Handler. | 264 | * @param av Handler. |
273 | * @param frame The frame. | 265 | * @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.) |
274 | * @param frame_size It's size. | 266 | * @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes) |
267 | * frame size should be AUDIO_FRAME_SIZE. | ||
275 | * @return int | 268 | * @return int |
276 | * @retval 0 Success. | 269 | * @retval 0 Success. |
277 | * @retval ToxAvError On error. | 270 | * @retval ToxAvError On error. |