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 @@ #define YUV2B(Y, U, V) CLIP(( 298 * C(Y) + 516 * D(U) + 128) >> 8) -#define TEST_TRANSFER_A 1 -#define TEST_TRANSFER_V 0 +#define TEST_TRANSFER_A 0 +#define TEST_TRANSFER_V 1 typedef struct { @@ -650,7 +650,7 @@ int main (int argc, char** argv) { /* Call */ TOXAV_ERR_CALL rc; - toxav_call(AliceAV, 0, 0, 3000, &rc); + toxav_call(AliceAV, 0, 0, 2000, &rc); if (rc != TOXAV_ERR_CALL_OK) { printf("toxav_call failed: %d\n", rc); @@ -663,7 +663,7 @@ int main (int argc, char** argv) { /* Answer */ TOXAV_ERR_ANSWER rc; - toxav_answer(BobAV, 0, 0, 500, &rc); + toxav_answer(BobAV, 0, 0, 5000, &rc); if (rc != TOXAV_ERR_ANSWER_OK) { printf("toxav_answer failed: %d\n", rc); @@ -690,7 +690,7 @@ int main (int argc, char** argv) exit(1); } - toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); +// toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); time_t start_time = time(NULL); 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 goto END; } - if ( vc_reconfigure_encoder(call->video.second, call->video_bit_rate * 1000, width, height) != 0 ) { + if ( vc_reconfigure_encoder(call->video.second->encoder, call->video_bit_rate * 1000, width, height) != 0 ) { pthread_mutex_unlock(call->mutex_video); rc = TOXAV_ERR_SEND_FRAME_INVALID; goto END; @@ -962,7 +962,7 @@ bool toxav_video_send_frame(ToxAV* av, uint32_t friend_number, uint16_t width, u } if (ba_shoud_send_dummy(&call->vba)) { - if ( vc_reconfigure_test_encoder(call->video.second, call->vba.bit_rate * 1000, width, height) != 0 ) { + if ( vc_reconfigure_encoder(call->video.second->test_encoder, call->vba.bit_rate * 1000, width, height) != 0 ) { pthread_mutex_unlock(call->mutex_video); rc = TOXAV_ERR_SEND_FRAME_INVALID; 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: rtp_free_msg(msg); return 0; } -int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height) +int vc_reconfigure_encoder(vpx_codec_ctx_t* vccdc, uint32_t bit_rate, uint16_t width, uint16_t height) { - if (!vc) + if (!vccdc) return -1; - vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; - if (cfg.rc_target_bitrate == (uint32_t) bit_rate && cfg.g_w == width && cfg.g_h == height) + vpx_codec_enc_cfg_t cfg = *vccdc->config.enc; + if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) return 0; /* Nothing changed */ cfg.rc_target_bitrate = bit_rate; cfg.g_w = width; cfg.g_h = height; - int rc = vpx_codec_enc_config_set(vc->encoder, &cfg); + int rc = vpx_codec_enc_config_set(vccdc, &cfg); if ( rc != VPX_CODEC_OK) { LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); return -1; @@ -310,28 +310,6 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint return 0; } -int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height) -{ - if (!vc) - return -1; - - vpx_codec_enc_cfg_t cfg = *vc->test_encoder->config.enc; - if (cfg.rc_target_bitrate == (uint32_t) bit_rate && cfg.g_w == width && cfg.g_h == height) - return 0; /* Nothing changed */ - - cfg.rc_target_bitrate = bit_rate; - cfg.g_w = width; - cfg.g_h = height; - - int rc = vpx_codec_enc_config_set(vc->test_encoder, &cfg); - if ( rc != VPX_CODEC_OK) { - LOGGER_ERROR("Failed to set test encoder control setting: %s", vpx_codec_err_to_string(rc)); - return -1; - } - - return 0; -} - bool 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); /* * Set new values to the encoders. */ -int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height); -int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height); +int vc_reconfigure_encoder(vpx_codec_ctx_t* vccdc, uint32_t bit_rate, uint16_t width, uint16_t height); #endif /* VIDEO_H */ \ No newline at end of file