diff options
Diffstat (limited to 'toxav/codec.h')
-rw-r--r-- | toxav/codec.h | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/toxav/codec.h b/toxav/codec.h index 6018e5df..92262ef8 100644 --- a/toxav/codec.h +++ b/toxav/codec.h | |||
@@ -75,18 +75,16 @@ typedef struct _CSSession { | |||
75 | * | 75 | * |
76 | * | 76 | * |
77 | */ | 77 | */ |
78 | int support_video; | ||
79 | 78 | ||
80 | /* video encoding */ | 79 | /* video encoding */ |
81 | vpx_codec_ctx_t v_encoder; | 80 | vpx_codec_ctx_t v_encoder[1]; |
81 | bool v_encoding; | ||
82 | uint32_t frame_counter; | 82 | uint32_t frame_counter; |
83 | 83 | ||
84 | /* video decoding */ | 84 | /* video decoding */ |
85 | vpx_codec_ctx_t v_decoder; | 85 | vpx_codec_ctx_t v_decoder[1]; |
86 | int max_width; | 86 | bool v_decoding; |
87 | int max_height; | 87 | void *vbuf_raw; /* Un-decoded data */ |
88 | unsigned int video_bitrate; | ||
89 | |||
90 | 88 | ||
91 | /* Data handling */ | 89 | /* Data handling */ |
92 | uint8_t *frame_buf; /* buffer for split video payloads */ | 90 | uint8_t *frame_buf; /* buffer for split video payloads */ |
@@ -112,18 +110,10 @@ typedef struct _CSSession { | |||
112 | 110 | ||
113 | /* audio encoding */ | 111 | /* audio encoding */ |
114 | OpusEncoder *audio_encoder; | 112 | OpusEncoder *audio_encoder; |
115 | int audio_encoder_bitrate; | 113 | int32_t channels; |
116 | int audio_encoder_sample_rate; | 114 | |
117 | int audio_encoder_frame_duration; | ||
118 | int audio_encoder_channels; | ||
119 | |||
120 | /* audio decoding */ | 115 | /* audio decoding */ |
121 | OpusDecoder *audio_decoder; | 116 | OpusDecoder *audio_decoder; |
122 | int audio_decoder_bitrate; | ||
123 | int audio_decoder_sample_rate; | ||
124 | int audio_decoder_frame_duration; | ||
125 | int audio_decoder_channels; | ||
126 | |||
127 | struct _JitterBuffer *j_buf; | 117 | struct _JitterBuffer *j_buf; |
128 | 118 | ||
129 | 119 | ||
@@ -138,25 +128,16 @@ typedef struct _CSSession { | |||
138 | * | 128 | * |
139 | */ | 129 | */ |
140 | 130 | ||
141 | uint64_t capabilities; /* supports*/ | ||
142 | |||
143 | /* Callbacks */ | 131 | /* Callbacks */ |
144 | PAIR(CSAudioCallback, void *) acb; | 132 | PAIR(CSAudioCallback, void *) acb; |
145 | PAIR(CSVideoCallback, void *) vcb; | 133 | PAIR(CSVideoCallback, void *) vcb; |
146 | 134 | ||
147 | /* Buffering */ | ||
148 | void *vbuf_raw; /* Un-decoded data */ | ||
149 | pthread_mutex_t queue_mutex[1]; | ||
150 | |||
151 | void *agent; /* Pointer to ToxAv */ | 135 | void *agent; /* Pointer to ToxAv */ |
152 | int32_t call_idx; | 136 | int32_t call_idx; |
137 | |||
138 | pthread_mutex_t queue_mutex[1]; | ||
153 | } CSSession; | 139 | } CSSession; |
154 | 140 | ||
155 | /* Make sure to be called BEFORE corresponding rtp_new */ | ||
156 | CSSession *cs_new(const ToxAvCSettings *cs_self, const ToxAvCSettings *cs_peer, uint32_t jbuf_size, int has_video); | ||
157 | /* Make sure to be called AFTER corresponding rtp_kill */ | ||
158 | void cs_kill(CSSession *cs); | ||
159 | |||
160 | int cs_split_video_payload(CSSession *cs, const uint8_t *payload, uint16_t length); | 141 | int cs_split_video_payload(CSSession *cs, const uint8_t *payload, uint16_t length); |
161 | const uint8_t *cs_get_split_video_frame(CSSession *cs, uint16_t *size); | 142 | const uint8_t *cs_get_split_video_frame(CSSession *cs, uint16_t *size); |
162 | 143 | ||
@@ -165,11 +146,35 @@ const uint8_t *cs_get_split_video_frame(CSSession *cs, uint16_t *size); | |||
165 | */ | 146 | */ |
166 | void cs_do(CSSession *cs); | 147 | void cs_do(CSSession *cs); |
167 | 148 | ||
149 | /** | ||
150 | * Reconfigure video settings; return 0 on success or -1 on failure. | ||
151 | */ | ||
152 | int cs_set_sending_video_resolution(CSSession *cs, uint16_t width, uint16_t height); | ||
153 | int cs_set_sending_video_bitrate(CSSession *cs, uint32_t bitrate); | ||
154 | |||
155 | int cs_set_sending_audio_bitrate(CSSession* cs, int32_t rate); | ||
156 | /* NOTE: Try not to call these a lot */ | ||
157 | int cs_set_sending_audio_sampling_rate(CSSession* cs, int32_t rate); | ||
158 | int cs_set_sending_audio_channels(CSSession* cs, int32_t count); | ||
159 | |||
160 | /** | ||
161 | * Make sure to be called BEFORE corresponding rtp_new | ||
162 | */ | ||
163 | CSSession *cs_new(uint32_t s_audio_b, uint32_t p_audio_b, uint32_t s_video_b, uint32_t p_video_b); | ||
164 | /** | ||
165 | * Make sure to be called AFTER corresponding rtp_kill | ||
166 | */ | ||
167 | void cs_kill(CSSession *cs); | ||
168 | 168 | ||
169 | /* Reconfigure video encoder; return 0 on success or -1 on failure. */ | 169 | int cs_enable_audio_sending(CSSession* cs, uint32_t bitrate); |
170 | int cs_set_video_encoder_resolution(CSSession *cs, uint16_t width, uint16_t height); | 170 | int cs_enable_audio_receiving(CSSession* cs); |
171 | int cs_set_video_encoder_bitrate(CSSession *cs, uint32_t video_bitrate); | 171 | int cs_enable_video_sending(CSSession* cs, uint32_t bitrate); |
172 | int cs_enable_video_receiving(CSSession* cs); | ||
172 | 173 | ||
174 | void cs_disable_audio_sending(CSSession* cs); | ||
175 | void cs_disable_audio_receiving(CSSession* cs); | ||
176 | void cs_disable_video_sending(CSSession* cs); | ||
177 | void cs_disable_video_receiving(CSSession* cs); | ||
173 | 178 | ||
174 | /* Internal. Called from rtp_handle_message */ | 179 | /* Internal. Called from rtp_handle_message */ |
175 | void queue_message(RTPSession *session, RTPMessage *msg); | 180 | void queue_message(RTPSession *session, RTPMessage *msg); |