Added better documentation to the api, move some defines, fixed a possible issue.

This commit is contained in:
irungentoo 2014-02-19 08:08:55 -05:00
parent a3904932bf
commit 354a392d69
3 changed files with 28 additions and 23 deletions

View File

@ -517,7 +517,7 @@ int rtp_handle_packet ( void *object, IP_Port ip_port, uint8_t *data, uint32_t l
RTPSession *_session = object;
RTPMessage *_msg;
if ( !_session || length < 13 ) /* 12 is the minimum length for rtp + desc. byte */
if ( !_session || length < 13 + crypto_secretbox_MACBYTES) /* 12 is the minimum length for rtp + desc. byte */
return -1;
uint8_t _plain[MAX_UDP_PACKET_SIZE];

View File

@ -35,6 +35,16 @@
#include "toxav.h"
/* Default video bitrate in bytes/s */
#define VIDEO_BITRATE (10*1000*100)
/* Default audio bitrate in bits/s */
#define AUDIO_BITRATE 64000
/* Assume 60 fps*/
#define MAX_ENCODE_TIME_US ((1000 / 60) * 1000)
#define inline__ inline __attribute__((always_inline))
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)
* @brief Receive decoded audio frame.
*
* @param av Handler.
* @param frame_size ...
* @param dest Destination of the packet. Make sure it has enough space for
* RTP_PAYLOAD_SIZE bytes.
* @param frame_size The size of dest in frames/samples (one frame/sample is 16 bits or 2 bytes
* and corresponds to one sample of audio.)
* @param dest Destination of the raw audio (16 bit signed pcm with AUDIO_CHANNELS channels).
* Make sure it has enough space for frame_size frames/samples.
* @return int
* @retval >=0 Size of received packet.
* @retval >=0 Size of received data in frames/samples.
* @retval ToxAvError On error.
*/
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 )
* @brief Encode and send audio frame.
*
* @param av Handler.
* @param frame The frame.
* @param frame_size It's size.
* @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.)
* @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes)
* frame size should be AUDIO_FRAME_SIZE.
* @return int
* @retval 0 Success.
* @retval ToxAvError On error.

View File

@ -39,12 +39,6 @@ typedef struct Tox Tox;
#define RTP_PAYLOAD_SIZE 65535
/* Default video bitrate in bytes/s */
#define VIDEO_BITRATE 10*1000*100
/* Default audio bitrate in bits/s */
#define AUDIO_BITRATE 64000
/* Number of audio channels. */
#define AUDIO_CHANNELS 1
@ -55,10 +49,7 @@ typedef struct Tox Tox;
#define AUDIO_SAMPLE_RATE 48000
/* The amount of samples in one audio frame */
#define AUDIO_FRAME_SIZE AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000
/* Assume 60 fps*/
#define MAX_ENCODE_TIME_US ((1000 / 60) * 1000)
#define AUDIO_FRAME_SIZE (AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000)
/**
@ -246,11 +237,12 @@ int toxav_recv_video ( ToxAv *av, vpx_image_t **output);
* @brief Receive decoded audio frame.
*
* @param av Handler.
* @param frame_size ...
* @param dest Destination of the packet. Make sure it has enough space for
* RTP_PAYLOAD_SIZE bytes.
* @param frame_size The size of dest in frames/samples (one frame/sample is 16 bits or 2 bytes
* and corresponds to one sample of audio.)
* @param dest Destination of the raw audio (16 bit signed pcm with AUDIO_CHANNELS channels).
* Make sure it has enough space for frame_size frames/samples.
* @return int
* @retval >=0 Size of received packet.
* @retval >=0 Size of received data in frames/samples.
* @retval ToxAvError On error.
*/
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);
* @brief Encode and send audio frame.
*
* @param av Handler.
* @param frame The frame.
* @param frame_size It's size.
* @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.)
* @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes)
* frame size should be AUDIO_FRAME_SIZE.
* @return int
* @retval 0 Success.
* @retval ToxAvError On error.