diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-04-26 00:31:03 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-04-26 00:31:03 +0200 |
commit | 144fc94d6987c8c6f74d8024af5a5c1738fe4678 (patch) | |
tree | bc5ad70ea24dafb8e358911ba118fc599f3f9999 /toxav/video.c | |
parent | 1bfd93e64a2a6d3bf9c90a9aa89abd29f3d826a7 (diff) |
Almost done
Diffstat (limited to 'toxav/video.c')
-rw-r--r-- | toxav/video.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/toxav/video.c b/toxav/video.c index 039fc2a0..cdc3c0ae 100644 --- a/toxav/video.c +++ b/toxav/video.c | |||
@@ -65,15 +65,15 @@ VCSession* vc_new(ToxAV* av, uint32_t friend_id, toxav_receive_video_frame_cb* c | |||
65 | if ( !(vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE)) ) | 65 | if ( !(vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE)) ) |
66 | goto BASE_CLEANUP; | 66 | goto BASE_CLEANUP; |
67 | 67 | ||
68 | int rc = vpx_codec_dec_init_ver(vc->v_decoder, VIDEO_CODEC_DECODER_INTERFACE, | 68 | int rc = vpx_codec_dec_init_ver(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE, |
69 | NULL, 0, VPX_DECODER_ABI_VERSION); | 69 | NULL, 0, VPX_DECODER_ABI_VERSION); |
70 | if ( rc != VPX_CODEC_OK) { | 70 | if ( rc != VPX_CODEC_OK) { |
71 | LOGGER_ERROR("Init video_decoder failed: %s", vpx_codec_err_to_string(rc)); | 71 | LOGGER_ERROR("Init video_decoder failed: %s", vpx_codec_err_to_string(rc)); |
72 | goto BASE_CLEANUP; | 72 | goto BASE_CLEANUP; |
73 | } | 73 | } |
74 | 74 | ||
75 | if (!create_video_encoder(vc->v_encoder, 500000)) { | 75 | if (!create_video_encoder(vc->encoder, 500000)) { |
76 | vpx_codec_destroy(vc->v_decoder); | 76 | vpx_codec_destroy(vc->decoder); |
77 | goto BASE_CLEANUP; | 77 | goto BASE_CLEANUP; |
78 | } | 78 | } |
79 | 79 | ||
@@ -99,8 +99,8 @@ void vc_kill(VCSession* vc) | |||
99 | if (!vc) | 99 | if (!vc) |
100 | return; | 100 | return; |
101 | 101 | ||
102 | vpx_codec_destroy(vc->v_encoder); | 102 | vpx_codec_destroy(vc->encoder); |
103 | vpx_codec_destroy(vc->v_decoder); | 103 | vpx_codec_destroy(vc->decoder); |
104 | rb_free(vc->vbuf_raw); | 104 | rb_free(vc->vbuf_raw); |
105 | free(vc->split_video_frame); | 105 | free(vc->split_video_frame); |
106 | free(vc->frame_buf); | 106 | free(vc->frame_buf); |
@@ -122,17 +122,17 @@ void vc_do(VCSession* vc) | |||
122 | if (rb_read(vc->vbuf_raw, (void**)&p)) { | 122 | if (rb_read(vc->vbuf_raw, (void**)&p)) { |
123 | pthread_mutex_unlock(vc->queue_mutex); | 123 | pthread_mutex_unlock(vc->queue_mutex); |
124 | 124 | ||
125 | rc = vpx_codec_decode(vc->v_decoder, p->data, p->size, NULL, MAX_DECODE_TIME_US); | 125 | rc = vpx_codec_decode(vc->decoder, p->data, p->size, NULL, MAX_DECODE_TIME_US); |
126 | free(p); | 126 | free(p); |
127 | 127 | ||
128 | if (rc != VPX_CODEC_OK) { | 128 | if (rc != VPX_CODEC_OK) { |
129 | LOGGER_ERROR("Error decoding video: %s", vpx_codec_err_to_string(rc)); | 129 | LOGGER_ERROR("Error decoding video: %s", vpx_codec_err_to_string(rc)); |
130 | } else { | 130 | } else { |
131 | vpx_codec_iter_t iter = NULL; | 131 | vpx_codec_iter_t iter = NULL; |
132 | vpx_image_t *dest = vpx_codec_get_frame(vc->v_decoder, &iter); | 132 | vpx_image_t *dest = vpx_codec_get_frame(vc->decoder, &iter); |
133 | 133 | ||
134 | /* Play decoded images */ | 134 | /* Play decoded images */ |
135 | for (; dest; dest = vpx_codec_get_frame(vc->v_decoder, &iter)) { | 135 | for (; dest; dest = vpx_codec_get_frame(vc->decoder, &iter)) { |
136 | if (vc->vcb.first) | 136 | if (vc->vcb.first) |
137 | vc->vcb.first(vc->av, vc->friend_id, dest->d_w, dest->d_h, | 137 | vc->vcb.first(vc->av, vc->friend_id, dest->d_w, dest->d_h, |
138 | (const uint8_t*)dest->planes[0], (const uint8_t*)dest->planes[1], (const uint8_t*)dest->planes[2], | 138 | (const uint8_t*)dest->planes[0], (const uint8_t*)dest->planes[1], (const uint8_t*)dest->planes[2], |
@@ -157,7 +157,7 @@ void vc_init_video_splitter_cycle(VCSession* vc) | |||
157 | int vc_update_video_splitter_cycle(VCSession* vc, const uint8_t* payload, uint16_t length) | 157 | int vc_update_video_splitter_cycle(VCSession* vc, const uint8_t* payload, uint16_t length) |
158 | { | 158 | { |
159 | if (!vc) | 159 | if (!vc) |
160 | return; | 160 | return 0; |
161 | 161 | ||
162 | vc->processing_video_frame = payload; | 162 | vc->processing_video_frame = payload; |
163 | vc->processing_video_frame_size = length; | 163 | vc->processing_video_frame_size = length; |
@@ -198,15 +198,15 @@ int vc_queue_message(void* vcp, struct RTPMessage_s *msg) | |||
198 | if (!vcp || !msg) | 198 | if (!vcp || !msg) |
199 | return -1; | 199 | return -1; |
200 | 200 | ||
201 | if ((msg->header->marker_payloadt & 0x7f) == rtp_TypeDummyVideo % 128) { | 201 | if ((msg->header->marker_payloadt & 0x7f) == (rtp_TypeVideo + 2) % 128) { |
202 | LOGGER_WARNING("Got dummy!"); | 202 | LOGGER_WARNING("Got dummy!"); |
203 | rtp_free_msg(NULL, msg); | 203 | rtp_free_msg(msg); |
204 | return 0; | 204 | return 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | if ((msg->header->marker_payloadt & 0x7f) != rtp_TypeVideo % 128) { | 207 | if ((msg->header->marker_payloadt & 0x7f) != rtp_TypeVideo % 128) { |
208 | LOGGER_WARNING("Invalid payload type!"); | 208 | LOGGER_WARNING("Invalid payload type!"); |
209 | rtp_free_msg(NULL, msg); | 209 | rtp_free_msg(msg); |
210 | return -1; | 210 | return -1; |
211 | } | 211 | } |
212 | 212 | ||
@@ -280,15 +280,15 @@ int vc_queue_message(void* vcp, struct RTPMessage_s *msg) | |||
280 | vc->frame_size = framebuf_new_length; | 280 | vc->frame_size = framebuf_new_length; |
281 | 281 | ||
282 | end: | 282 | end: |
283 | rtp_free_msg(NULL, msg); | 283 | rtp_free_msg(msg); |
284 | return 0; | 284 | return 0; |
285 | } | 285 | } |
286 | int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint16_t height) | 286 | int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint16_t height) |
287 | { | 287 | { |
288 | if (!vc) | 288 | if (!vc) |
289 | return; | 289 | return -1; |
290 | 290 | ||
291 | vpx_codec_enc_cfg_t cfg = *vc->v_encoder[0].config.enc; | 291 | vpx_codec_enc_cfg_t cfg = *vc->encoder[0].config.enc; |
292 | if (cfg.rc_target_bitrate == bitrate && cfg.g_w == width && cfg.g_h == height) | 292 | if (cfg.rc_target_bitrate == bitrate && cfg.g_w == width && cfg.g_h == height) |
293 | return 0; /* Nothing changed */ | 293 | return 0; /* Nothing changed */ |
294 | 294 | ||
@@ -296,7 +296,7 @@ int vc_reconfigure_encoder(VCSession* vc, int32_t bitrate, uint16_t width, uint1 | |||
296 | cfg.g_w = width; | 296 | cfg.g_w = width; |
297 | cfg.g_h = height; | 297 | cfg.g_h = height; |
298 | 298 | ||
299 | int rc = vpx_codec_enc_config_set(vc->v_encoder, &cfg); | 299 | int rc = vpx_codec_enc_config_set(vc->encoder, &cfg); |
300 | if ( rc != VPX_CODEC_OK) { | 300 | if ( rc != VPX_CODEC_OK) { |
301 | LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); | 301 | LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); |
302 | return -1; | 302 | return -1; |