diff options
Diffstat (limited to 'toxav/video.c')
-rw-r--r-- | toxav/video.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/toxav/video.c b/toxav/video.c index c540af3b..22ca2bee 100644 --- a/toxav/video.c +++ b/toxav/video.c | |||
@@ -35,15 +35,14 @@ | |||
35 | #define MAX_VIDEOFRAME_SIZE 0x40000 /* 256KiB */ | 35 | #define MAX_VIDEOFRAME_SIZE 0x40000 /* 256KiB */ |
36 | #define VIDEOFRAME_HEADER_SIZE 0x2 | 36 | #define VIDEOFRAME_HEADER_SIZE 0x2 |
37 | 37 | ||
38 | /* FIXME: Might not be enough? NOTE: I think it is enough */ | ||
39 | #define VIDEO_DECODE_BUFFER_SIZE 20 | 38 | #define VIDEO_DECODE_BUFFER_SIZE 20 |
40 | 39 | ||
41 | typedef struct { uint16_t size; uint8_t data[]; } Payload; | 40 | typedef struct { uint16_t size; uint8_t data[]; } Payload; |
42 | 41 | ||
43 | bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bitrate); | 42 | bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bit_rate); |
44 | 43 | ||
45 | 44 | ||
46 | VCSession* vc_new(ToxAV* av, uint32_t friend_id, toxav_receive_video_frame_cb* cb, void* cb_data, uint32_t mvfpsz) | 45 | VCSession* vc_new(ToxAV* av, uint32_t friend_number, toxav_receive_video_frame_cb* cb, void* cb_data, uint32_t mvfpsz) |
47 | { | 46 | { |
48 | VCSession *vc = calloc(sizeof(VCSession), 1); | 47 | VCSession *vc = calloc(sizeof(VCSession), 1); |
49 | 48 | ||
@@ -86,7 +85,7 @@ VCSession* vc_new(ToxAV* av, uint32_t friend_id, toxav_receive_video_frame_cb* c | |||
86 | vc->lcfd = 60; | 85 | vc->lcfd = 60; |
87 | vc->vcb.first = cb; | 86 | vc->vcb.first = cb; |
88 | vc->vcb.second = cb_data; | 87 | vc->vcb.second = cb_data; |
89 | vc->friend_id = friend_id; | 88 | vc->friend_number = friend_number; |
90 | vc->peer_video_frame_piece_size = mvfpsz; | 89 | vc->peer_video_frame_piece_size = mvfpsz; |
91 | 90 | ||
92 | return vc; | 91 | return vc; |
@@ -140,7 +139,7 @@ void vc_do(VCSession* vc) | |||
140 | /* Play decoded images */ | 139 | /* Play decoded images */ |
141 | for (; dest; dest = vpx_codec_get_frame(vc->decoder, &iter)) { | 140 | for (; dest; dest = vpx_codec_get_frame(vc->decoder, &iter)) { |
142 | if (vc->vcb.first) | 141 | if (vc->vcb.first) |
143 | vc->vcb.first(vc->av, vc->friend_id, dest->d_w, dest->d_h, | 142 | vc->vcb.first(vc->av, vc->friend_number, dest->d_w, dest->d_h, |
144 | (const uint8_t*)dest->planes[0], (const uint8_t*)dest->planes[1], (const uint8_t*)dest->planes[2], | 143 | (const uint8_t*)dest->planes[0], (const uint8_t*)dest->planes[1], (const uint8_t*)dest->planes[2], |
145 | dest->stride[0], dest->stride[1], dest->stride[2], vc->vcb.second); | 144 | dest->stride[0], dest->stride[1], dest->stride[2], vc->vcb.second); |
146 | 145 | ||
@@ -289,16 +288,16 @@ end: | |||
289 | rtp_free_msg(msg); | 288 | rtp_free_msg(msg); |
290 | return 0; | 289 | return 0; |
291 | } | 290 | } |
292 | int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint16_t height) | 291 | int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height) |
293 | { | 292 | { |
294 | if (!vc) | 293 | if (!vc) |
295 | return -1; | 294 | return -1; |
296 | 295 | ||
297 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; | 296 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; |
298 | if (cfg.rc_target_bitrate == bitrate && cfg.g_w == width && cfg.g_h == height) | 297 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) |
299 | return 0; /* Nothing changed */ | 298 | return 0; /* Nothing changed */ |
300 | 299 | ||
301 | cfg.rc_target_bitrate = bitrate; | 300 | cfg.rc_target_bitrate = bit_rate; |
302 | cfg.g_w = width; | 301 | cfg.g_w = width; |
303 | cfg.g_h = height; | 302 | cfg.g_h = height; |
304 | 303 | ||
@@ -310,16 +309,16 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint1 | |||
310 | 309 | ||
311 | return 0; | 310 | return 0; |
312 | } | 311 | } |
313 | int vc_reconfigure_test_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint16_t height) | 312 | int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height) |
314 | { | 313 | { |
315 | if (!vc) | 314 | if (!vc) |
316 | return -1; | 315 | return -1; |
317 | 316 | ||
318 | vpx_codec_enc_cfg_t cfg = *vc->test_encoder->config.enc; | 317 | 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) | 318 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) |
320 | return 0; /* Nothing changed */ | 319 | return 0; /* Nothing changed */ |
321 | 320 | ||
322 | cfg.rc_target_bitrate = bitrate; | 321 | cfg.rc_target_bitrate = bit_rate; |
323 | cfg.g_w = width; | 322 | cfg.g_w = width; |
324 | cfg.g_h = height; | 323 | cfg.g_h = height; |
325 | 324 | ||
@@ -334,7 +333,7 @@ int vc_reconfigure_test_encoder(VCSession* vc, int32_t bitrate, uint16_t width, | |||
334 | 333 | ||
335 | 334 | ||
336 | 335 | ||
337 | bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bitrate) | 336 | bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bit_rate) |
338 | { | 337 | { |
339 | assert(dest); | 338 | assert(dest); |
340 | 339 | ||
@@ -354,7 +353,7 @@ bool create_video_encoder (vpx_codec_ctx_t* dest, int32_t bitrate) | |||
354 | return false; | 353 | return false; |
355 | } | 354 | } |
356 | 355 | ||
357 | cfg.rc_target_bitrate = bitrate; | 356 | cfg.rc_target_bitrate = bit_rate; |
358 | cfg.g_w = 800; | 357 | cfg.g_w = 800; |
359 | cfg.g_h = 600; | 358 | cfg.g_h = 600; |
360 | cfg.g_pass = VPX_RC_ONE_PASS; | 359 | cfg.g_pass = VPX_RC_ONE_PASS; |