summaryrefslogtreecommitdiff
path: root/toxav/codec.h
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2014-11-29 13:42:19 +0100
committermannol <eniz_vukovic@hotmail.com>2014-11-29 13:42:19 +0100
commite62ded3a6dfc1203418e3d7a2c936794c4c9ec1c (patch)
tree74db9ab7f52295304e6079d8e90b8d5b5f3afc67 /toxav/codec.h
parent975ce25af0e469f3b2d80478695d3bbe8e79be79 (diff)
More av cleanup
Diffstat (limited to 'toxav/codec.h')
-rw-r--r--toxav/codec.h43
1 files changed, 29 insertions, 14 deletions
diff --git a/toxav/codec.h b/toxav/codec.h
index dd054338..432bb847 100644
--- a/toxav/codec.h
+++ b/toxav/codec.h
@@ -42,16 +42,33 @@
42/* Audio encoding/decoding */ 42/* Audio encoding/decoding */
43#include <opus.h> 43#include <opus.h>
44 44
45#define PAIR(TYPE1__, TYPE2__) struct { TYPE1__ first; TYPE2__ second; }
46
45typedef void (*CSAudioCallback) (void *agent, int32_t call_idx, const int16_t *PCM, uint16_t size, void *data); 47typedef void (*CSAudioCallback) (void *agent, int32_t call_idx, const int16_t *PCM, uint16_t size, void *data);
46typedef void (*CSVideoCallback) (void *agent, int32_t call_idx, const vpx_image_t *img, void *data); 48typedef void (*CSVideoCallback) (void *agent, int32_t call_idx, const vpx_image_t *img, void *data);
47 49
48typedef enum _CsCapabilities { 50/**
49 a_encoding = 1 << 0, 51 * Codec capabilities
50 a_decoding = 1 << 1, 52 */
51 v_encoding = 1 << 2, 53typedef enum {
52 v_decoding = 1 << 3 54 cs_AudioEncoding = 1 << 0,
53} CsCapabilities; 55 cs_AudioDecoding = 1 << 1,
56 cs_VideoEncoding = 1 << 2,
57 cs_VideoDecoding = 1 << 3
58} CSCapabilities;
59
60/**
61 * Codec errors.
62 */
63typedef enum {
64 cs_ErrorSettingVideoResolution = -30,
65 cs_ErrorSettingVideoBitrate = -31,
66 cs_ErrorSplittingVideoPayload = -32,
67} CSError;
54 68
69/**
70 * Codec session - controling codec
71 */
55typedef struct _CSSession { 72typedef struct _CSSession {
56 73
57 /* VIDEO 74 /* VIDEO
@@ -122,16 +139,21 @@ typedef struct _CSSession {
122 139
123 uint64_t capabilities; /* supports*/ 140 uint64_t capabilities; /* supports*/
124 141
142 /* Callbacks */
143 PAIR(CSAudioCallback, void*) acb;
144 PAIR(CSVideoCallback, void*) vcb;
145
125 /* Buffering */ 146 /* Buffering */
126 void *abuf_raw, *vbuf_raw; /* Un-decoded data */ 147 void *abuf_raw, *vbuf_raw; /* Un-decoded data */
127 _Bool active;
128 pthread_mutex_t queue_mutex[1]; 148 pthread_mutex_t queue_mutex[1];
129 149
130 void *agent; /* Pointer to ToxAv */ 150 void *agent; /* Pointer to ToxAv */
131 int32_t call_idx; 151 int32_t call_idx;
132} CSSession; 152} CSSession;
133 153
154/* Make sure to be called BEFORE corresponding rtp_new */
134CSSession *cs_new(const ToxAvCSettings *cs_self, const ToxAvCSettings *cs_peer, uint32_t jbuf_size, int has_video); 155CSSession *cs_new(const ToxAvCSettings *cs_self, const ToxAvCSettings *cs_peer, uint32_t jbuf_size, int has_video);
156/* Make sure to be called AFTER corresponding rtp_kill */
135void cs_kill(CSSession *cs); 157void cs_kill(CSSession *cs);
136 158
137int cs_split_video_payload(CSSession *cs, const uint8_t *payload, uint16_t length); 159int cs_split_video_payload(CSSession *cs, const uint8_t *payload, uint16_t length);
@@ -142,19 +164,12 @@ const uint8_t *cs_get_split_video_frame(CSSession *cs, uint16_t *size);
142 */ 164 */
143void cs_do(CSSession *cs); 165void cs_do(CSSession *cs);
144 166
145void cs_register_audio_callback(CSAudioCallback cb, void *data);
146void cs_register_video_callback(CSVideoCallback cb, void *data);
147 167
148/* Reconfigure video encoder; return 0 on success or -1 on failure. */ 168/* Reconfigure video encoder; return 0 on success or -1 on failure. */
149int cs_set_video_encoder_resolution(CSSession *cs, uint16_t width, uint16_t height); 169int cs_set_video_encoder_resolution(CSSession *cs, uint16_t width, uint16_t height);
150int cs_set_video_encoder_bitrate(CSSession *cs, uint32_t video_bitrate); 170int cs_set_video_encoder_bitrate(CSSession *cs, uint32_t video_bitrate);
151 171
152 172
153/* Calculate energy and return 1 if has voice, 0 if not */
154int cs_calculate_vad(CSSession *cs, int16_t *PCM, uint16_t frame_size, float energy);
155void cs_set_vad_treshold(CSSession *cs, uint32_t treshold, uint16_t frame_duration);
156
157
158/* Internal. Called from rtp_handle_message */ 173/* Internal. Called from rtp_handle_message */
159void queue_message(RTPSession *session, RTPMessage *msg); 174void queue_message(RTPSession *session, RTPMessage *msg);
160#endif /* _CODEC_H_ */ 175#endif /* _CODEC_H_ */