summaryrefslogtreecommitdiff
path: root/toxav/video.c
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2015-04-28 00:55:57 +0200
committermannol <eniz_vukovic@hotmail.com>2015-04-28 00:55:57 +0200
commite4a020333d76bc30172f54f2545677f01bdd54b6 (patch)
treeb7efcf3680b41e8f597fee447f86e87c1083e7ff /toxav/video.c
parent27e0254a98a32fad89ecc1c19121394754cfda2d (diff)
working av new api
Diffstat (limited to 'toxav/video.c')
-rw-r--r--toxav/video.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/toxav/video.c b/toxav/video.c
index cdc3c0ae..c540af3b 100644
--- a/toxav/video.c
+++ b/toxav/video.c
@@ -76,6 +76,11 @@ VCSession* vc_new(ToxAV* av, uint32_t friend_id, toxav_receive_video_frame_cb* c
76 vpx_codec_destroy(vc->decoder); 76 vpx_codec_destroy(vc->decoder);
77 goto BASE_CLEANUP; 77 goto BASE_CLEANUP;
78 } 78 }
79 if (!create_video_encoder(vc->test_encoder, 500000)) {
80 vpx_codec_destroy(vc->encoder);
81 vpx_codec_destroy(vc->decoder);
82 goto BASE_CLEANUP;
83 }
79 84
80 vc->linfts = current_time_monotonic(); 85 vc->linfts = current_time_monotonic();
81 vc->lcfd = 60; 86 vc->lcfd = 60;
@@ -100,6 +105,7 @@ void vc_kill(VCSession* vc)
100 return; 105 return;
101 106
102 vpx_codec_destroy(vc->encoder); 107 vpx_codec_destroy(vc->encoder);
108 vpx_codec_destroy(vc->test_encoder);
103 vpx_codec_destroy(vc->decoder); 109 vpx_codec_destroy(vc->decoder);
104 rb_free(vc->vbuf_raw); 110 rb_free(vc->vbuf_raw);
105 free(vc->split_video_frame); 111 free(vc->split_video_frame);
@@ -288,7 +294,7 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint1
288 if (!vc) 294 if (!vc)
289 return -1; 295 return -1;
290 296
291 vpx_codec_enc_cfg_t cfg = *vc->encoder[0].config.enc; 297 vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc;
292 if (cfg.rc_target_bitrate == bitrate && cfg.g_w == width && cfg.g_h == height) 298 if (cfg.rc_target_bitrate == bitrate && cfg.g_w == width && cfg.g_h == height)
293 return 0; /* Nothing changed */ 299 return 0; /* Nothing changed */
294 300
@@ -304,6 +310,27 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint1
304 310
305 return 0; 311 return 0;
306} 312}
313int vc_reconfigure_test_encoder(VCSession* vc, int32_t bitrate, 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 == bitrate && cfg.g_w == width && cfg.g_h == height)
320 return 0; /* Nothing changed */
321
322 cfg.rc_target_bitrate = bitrate;
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}
307 334
308 335
309 336