summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/av_test.c10
-rw-r--r--toxav/toxav.c4
-rw-r--r--toxav/video.c32
-rw-r--r--toxav/video.h3
4 files changed, 13 insertions, 36 deletions
diff --git a/testing/av_test.c b/testing/av_test.c
index 8e048d02..1c13ebad 100644
--- a/testing/av_test.c
+++ b/testing/av_test.c
@@ -70,8 +70,8 @@
70#define YUV2B(Y, U, V) CLIP(( 298 * C(Y) + 516 * D(U) + 128) >> 8) 70#define YUV2B(Y, U, V) CLIP(( 298 * C(Y) + 516 * D(U) + 128) >> 8)
71 71
72 72
73#define TEST_TRANSFER_A 1 73#define TEST_TRANSFER_A 0
74#define TEST_TRANSFER_V 0 74#define TEST_TRANSFER_V 1
75 75
76 76
77typedef struct { 77typedef struct {
@@ -650,7 +650,7 @@ int main (int argc, char** argv)
650 650
651 { /* Call */ 651 { /* Call */
652 TOXAV_ERR_CALL rc; 652 TOXAV_ERR_CALL rc;
653 toxav_call(AliceAV, 0, 0, 3000, &rc); 653 toxav_call(AliceAV, 0, 0, 2000, &rc);
654 654
655 if (rc != TOXAV_ERR_CALL_OK) { 655 if (rc != TOXAV_ERR_CALL_OK) {
656 printf("toxav_call failed: %d\n", rc); 656 printf("toxav_call failed: %d\n", rc);
@@ -663,7 +663,7 @@ int main (int argc, char** argv)
663 663
664 { /* Answer */ 664 { /* Answer */
665 TOXAV_ERR_ANSWER rc; 665 TOXAV_ERR_ANSWER rc;
666 toxav_answer(BobAV, 0, 0, 500, &rc); 666 toxav_answer(BobAV, 0, 0, 5000, &rc);
667 667
668 if (rc != TOXAV_ERR_ANSWER_OK) { 668 if (rc != TOXAV_ERR_ANSWER_OK) {
669 printf("toxav_answer failed: %d\n", rc); 669 printf("toxav_answer failed: %d\n", rc);
@@ -690,7 +690,7 @@ int main (int argc, char** argv)
690 exit(1); 690 exit(1);
691 } 691 }
692 692
693 toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); 693// toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL);
694 694
695 time_t start_time = time(NULL); 695 time_t start_time = time(NULL);
696 while(start_time + 90 > time(NULL)) { 696 while(start_time + 90 > time(NULL)) {
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