summaryrefslogtreecommitdiff
path: root/toxav
diff options
context:
space:
mode:
Diffstat (limited to 'toxav')
-rw-r--r--toxav/toxav.c4
-rw-r--r--toxav/video.c32
-rw-r--r--toxav/video.h3
3 files changed, 8 insertions, 31 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c
index 58e08376..aaad2f14 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -897,7 +897,7 @@ bool toxav_video_send_frame(ToxAV* av, uint32_t friend_number, uint16_t width, u
897 goto END; 897 goto END;
898 } 898 }
899 899
900 if ( vc_reconfigure_encoder(call->video.second, call->video_bit_rate * 1000, width, height) != 0 ) { 900 if ( vc_reconfigure_encoder(call->video.second->encoder, call->video_bit_rate * 1000, width, height) != 0 ) {
901 pthread_mutex_unlock(call->mutex_video); 901 pthread_mutex_unlock(call->mutex_video);
902 rc = TOXAV_ERR_SEND_FRAME_INVALID; 902 rc = TOXAV_ERR_SEND_FRAME_INVALID;
903 goto END; 903 goto END;
@@ -962,7 +962,7 @@ bool toxav_video_send_frame(ToxAV* av, uint32_t friend_number, uint16_t width, u
962 } 962 }
963 963
964 if (ba_shoud_send_dummy(&call->vba)) { 964 if (ba_shoud_send_dummy(&call->vba)) {
965 if ( vc_reconfigure_test_encoder(call->video.second, call->vba.bit_rate * 1000, width, height) != 0 ) { 965 if ( vc_reconfigure_encoder(call->video.second->test_encoder, call->vba.bit_rate * 1000, width, height) != 0 ) {
966 pthread_mutex_unlock(call->mutex_video); 966 pthread_mutex_unlock(call->mutex_video);
967 rc = TOXAV_ERR_SEND_FRAME_INVALID; 967 rc = TOXAV_ERR_SEND_FRAME_INVALID;
968 goto END; 968 goto END;
diff --git a/toxav/video.c b/toxav/video.c
index ee49c0a1..f5f9f513 100644
--- a/toxav/video.c
+++ b/toxav/video.c
@@ -289,20 +289,20 @@ end:
289 rtp_free_msg(msg); 289 rtp_free_msg(msg);
290 return 0; 290 return 0;
291} 291}
292int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height) 292int vc_reconfigure_encoder(vpx_codec_ctx_t* vccdc, uint32_t bit_rate, uint16_t width, uint16_t height)
293{ 293{
294 if (!vc) 294 if (!vccdc)
295 return -1; 295 return -1;
296 296
297 vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; 297 vpx_codec_enc_cfg_t cfg = *vccdc->config.enc;
298 if (cfg.rc_target_bitrate == (uint32_t) bit_rate && cfg.g_w == width && cfg.g_h == height) 298 if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height)
299 return 0; /* Nothing changed */ 299 return 0; /* Nothing changed */
300 300
301 cfg.rc_target_bitrate = bit_rate; 301 cfg.rc_target_bitrate = bit_rate;
302 cfg.g_w = width; 302 cfg.g_w = width;
303 cfg.g_h = height; 303 cfg.g_h = height;
304 304
305 int rc = vpx_codec_enc_config_set(vc->encoder, &cfg); 305 int rc = vpx_codec_enc_config_set(vccdc, &cfg);
306 if ( rc != VPX_CODEC_OK) { 306 if ( rc != VPX_CODEC_OK) {
307 LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); 307 LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
308 return -1; 308 return -1;
@@ -310,28 +310,6 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint
310 310
311 return 0; 311 return 0;
312} 312}
313int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height)
314{
315 if (!vc)
316 return -1;
317
318 vpx_codec_enc_cfg_t cfg = *vc->test_encoder->config.enc;
319 if (cfg.rc_target_bitrate == (uint32_t) bit_rate && cfg.g_w == width && cfg.g_h == height)
320 return 0; /* Nothing changed */
321
322 cfg.rc_target_bitrate = bit_rate;
323 cfg.g_w = width;
324 cfg.g_h = height;
325
326 int rc = vpx_codec_enc_config_set(vc->test_encoder, &cfg);
327 if ( rc != VPX_CODEC_OK) {
328 LOGGER_ERROR("Failed to set test encoder control setting: %s", vpx_codec_err_to_string(rc));
329 return -1;
330 }
331
332 return 0;
333}
334
335 313
336 314
337bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bit_rate) 315bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bit_rate)
diff --git a/toxav/video.h b/toxav/video.h
index 96d3205d..ac165df6 100644
--- a/toxav/video.h
+++ b/toxav/video.h
@@ -107,7 +107,6 @@ int vc_queue_message(void *vcp, struct RTPMessage_s *msg);
107/* 107/*
108 * Set new values to the encoders. 108 * Set new values to the encoders.
109 */ 109 */
110int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height); 110int vc_reconfigure_encoder(vpx_codec_ctx_t* vccdc, uint32_t bit_rate, uint16_t width, uint16_t height);
111int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height);
112 111
113#endif /* VIDEO_H */ \ No newline at end of file 112#endif /* VIDEO_H */ \ No newline at end of file