summaryrefslogtreecommitdiff
path: root/toxav/codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxav/codec.c')
-rw-r--r--toxav/codec.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/toxav/codec.c b/toxav/codec.c
index 3e6de803..3664ddd0 100644
--- a/toxav/codec.c
+++ b/toxav/codec.c
@@ -206,6 +206,44 @@ int init_audio_decoder(CodecState *cs, uint32_t audio_channels)
206 return 0; 206 return 0;
207} 207}
208 208
209int reconfigure_video_encoder_resolution(CodecState *cs, uint16_t width, uint16_t height)
210{
211 vpx_codec_enc_cfg_t cfg = *cs->v_encoder.config.enc;
212
213 if (cfg.g_w == width && cfg.g_h == height)
214 return 0;
215
216 LOGGER_DEBUG("New video resolution: %u %u", width, height);
217 cfg.g_w = width;
218 cfg.g_h = height;
219 int rc = vpx_codec_enc_config_set(&cs->v_encoder, &cfg);
220
221 if ( rc != VPX_CODEC_OK) {
222 LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
223 return -1;
224 }
225
226 return 0;
227}
228
229int reconfigure_video_encoder_bitrate(CodecState *cs, uint32_t video_bitrate)
230{
231 vpx_codec_enc_cfg_t cfg = *cs->v_encoder.config.enc;
232
233 if (cfg.rc_target_bitrate == video_bitrate)
234 return 0;
235
236 LOGGER_DEBUG("New video bitrate: %u", video_bitrate);
237 cfg.rc_target_bitrate = video_bitrate;
238 int rc = vpx_codec_enc_config_set(&cs->v_encoder, &cfg);
239
240 if ( rc != VPX_CODEC_OK) {
241 LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
242 return -1;
243 }
244
245 return 0;
246}
209 247
210int init_video_encoder(CodecState *cs, uint16_t width, uint16_t height, uint32_t video_bitrate) 248int init_video_encoder(CodecState *cs, uint16_t width, uint16_t height, uint32_t video_bitrate)
211{ 249{