summaryrefslogtreecommitdiff
path: root/toxav/video.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-18 01:31:55 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-24 21:53:50 +0100
commit15cb4261665bab4ef02a5b1b9db48b9477c9b87a (patch)
treed0c40a45afa19fff26ce1eb5bb703e18a9acdd4a /toxav/video.c
parent0d347c2b2e69aa09b079f6daaa00007fef4fe52f (diff)
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This change lets us see more clearly where implicit conversions occur by making them explicit.
Diffstat (limited to 'toxav/video.c')
-rw-r--r--toxav/video.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/toxav/video.c b/toxav/video.c
index de028c7c..5bb3b8ae 100644
--- a/toxav/video.c
+++ b/toxav/video.c
@@ -39,7 +39,8 @@
39 39
40VCSession *vc_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_video_receive_frame_cb *cb, void *cb_data) 40VCSession *vc_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_video_receive_frame_cb *cb, void *cb_data)
41{ 41{
42 VCSession *vc = calloc(sizeof(VCSession), 1); 42 VCSession *vc = (VCSession *)calloc(sizeof(VCSession), 1);
43 vpx_codec_err_t rc;
43 44
44 if (!vc) { 45 if (!vc) {
45 LOGGER_WARNING(log, "Allocation failed! Application might misbehave!"); 46 LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");
@@ -56,7 +57,7 @@ VCSession *vc_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_video_re
56 goto BASE_CLEANUP; 57 goto BASE_CLEANUP;
57 } 58 }
58 59
59 int rc = vpx_codec_dec_init(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE, NULL, 0); 60 rc = vpx_codec_dec_init(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE, NULL, 0);
60 61
61 if (rc != VPX_CODEC_OK) { 62 if (rc != VPX_CODEC_OK) {
62 LOGGER_ERROR(log, "Init video_decoder failed: %s", vpx_codec_err_to_string(rc)); 63 LOGGER_ERROR(log, "Init video_decoder failed: %s", vpx_codec_err_to_string(rc));
@@ -116,7 +117,7 @@ BASE_CLEANUP_1:
116 vpx_codec_destroy(vc->decoder); 117 vpx_codec_destroy(vc->decoder);
117BASE_CLEANUP: 118BASE_CLEANUP:
118 pthread_mutex_destroy(vc->queue_mutex); 119 pthread_mutex_destroy(vc->queue_mutex);
119 rb_kill(vc->vbuf_raw); 120 rb_kill((RingBuffer *)vc->vbuf_raw);
120 free(vc); 121 free(vc);
121 return NULL; 122 return NULL;
122} 123}
@@ -131,11 +132,11 @@ void vc_kill(VCSession *vc)
131 132
132 void *p; 133 void *p;
133 134
134 while (rb_read(vc->vbuf_raw, &p)) { 135 while (rb_read((RingBuffer *)vc->vbuf_raw, &p)) {
135 free(p); 136 free(p);
136 } 137 }
137 138
138 rb_kill(vc->vbuf_raw); 139 rb_kill((RingBuffer *)vc->vbuf_raw);
139 140
140 pthread_mutex_destroy(vc->queue_mutex); 141 pthread_mutex_destroy(vc->queue_mutex);
141 142
@@ -150,11 +151,11 @@ void vc_iterate(VCSession *vc)
150 151
151 struct RTPMessage *p; 152 struct RTPMessage *p;
152 153
153 int rc; 154 vpx_codec_err_t rc;
154 155
155 pthread_mutex_lock(vc->queue_mutex); 156 pthread_mutex_lock(vc->queue_mutex);
156 157
157 if (rb_read(vc->vbuf_raw, (void **)&p)) { 158 if (rb_read((RingBuffer *)vc->vbuf_raw, (void **)&p)) {
158 pthread_mutex_unlock(vc->queue_mutex); 159 pthread_mutex_unlock(vc->queue_mutex);
159 160
160 rc = vpx_codec_decode(vc->decoder, p->data, p->len, NULL, MAX_DECODE_TIME_US); 161 rc = vpx_codec_decode(vc->decoder, p->data, p->len, NULL, MAX_DECODE_TIME_US);
@@ -192,7 +193,7 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg)
192 return -1; 193 return -1;
193 } 194 }
194 195
195 VCSession *vc = vcp; 196 VCSession *vc = (VCSession *)vcp;
196 197
197 if (msg->header.pt == (rtp_TypeVideo + 2) % 128) { 198 if (msg->header.pt == (rtp_TypeVideo + 2) % 128) {
198 LOGGER_WARNING(vc->log, "Got dummy!"); 199 LOGGER_WARNING(vc->log, "Got dummy!");
@@ -207,7 +208,7 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg)
207 } 208 }
208 209
209 pthread_mutex_lock(vc->queue_mutex); 210 pthread_mutex_lock(vc->queue_mutex);
210 free(rb_write(vc->vbuf_raw, msg)); 211 free(rb_write((RingBuffer *)vc->vbuf_raw, msg));
211 { 212 {
212 /* Calculate time took for peer to send us this frame */ 213 /* Calculate time took for peer to send us this frame */
213 uint32_t t_lcfd = current_time_monotonic() - vc->linfts; 214 uint32_t t_lcfd = current_time_monotonic() - vc->linfts;
@@ -225,7 +226,7 @@ int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uin
225 } 226 }
226 227
227 vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; 228 vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc;
228 int rc; 229 vpx_codec_err_t rc;
229 230
230 if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) { 231 if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) {
231 return 0; /* Nothing changed */ 232 return 0; /* Nothing changed */