summaryrefslogtreecommitdiff
path: root/toxav/toxav.c
diff options
context:
space:
mode:
authormannol <mannol@users.noreply.github.com>2017-11-25 15:39:37 +0100
committerRobin Lindén <dev@robinlinden.eu>2017-12-17 16:31:23 +0100
commite996a030f09052928c8484771c476778ca321e4a (patch)
treec76f1d02f3e506327322c34c94535b981bc7f805 /toxav/toxav.c
parent57115f0e751e50262705bafc998eae5f35fae9cc (diff)
Split video payload into multiple packets when >65k
This is the implementation of the [proposed fix](https://github.com/TokTok/c-toxcore/issues/620#issuecomment-346902071) for [this issue](https://github.com/TokTok/c-toxcore/issues/620).
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r--toxav/toxav.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c
index deb71c49..74836691 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -814,13 +814,22 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
814 const vpx_codec_cx_pkt_t *pkt; 814 const vpx_codec_cx_pkt_t *pkt;
815 815
816 while ((pkt = vpx_codec_get_cx_data(call->video.second->encoder, &iter))) { 816 while ((pkt = vpx_codec_get_cx_data(call->video.second->encoder, &iter))) {
817 if (pkt->kind == VPX_CODEC_CX_FRAME_PKT && 817 if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
818 rtp_send_data(call->video.first, (const uint8_t *)pkt->data.frame.buf, pkt->data.frame.sz, av->m->log) < 0) { 818 const uint8_t *buf = (const uint8_t *)pkt->data.frame.buf;
819 const uint8_t *end = buf + pkt->data.frame.sz;
819 820
820 pthread_mutex_unlock(call->mutex_video); 821 while (buf < end) {
821 LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno)); 822 uint16_t size = MIN(UINT16_MAX, end - buf);
822 rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; 823
823 goto END; 824 if (rtp_send_data(call->video.first, buf, size, av->m->log) < 0) {
825 pthread_mutex_unlock(call->mutex_video);
826 LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno));
827 rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED;
828 goto END;
829 }
830
831 buf += size;
832 }
824 } 833 }
825 } 834 }
826 } 835 }