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 const vpx_codec_cx_pkt_t *pkt; while ((pkt = vpx_codec_get_cx_data(call->video.second->encoder, &iter))) { - if (pkt->kind == VPX_CODEC_CX_FRAME_PKT && - rtp_send_data(call->video.first, (const uint8_t *)pkt->data.frame.buf, pkt->data.frame.sz, av->m->log) < 0) { + if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) { + const uint8_t *buf = (const uint8_t *)pkt->data.frame.buf; + const uint8_t *end = buf + pkt->data.frame.sz; - pthread_mutex_unlock(call->mutex_video); - LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno)); - rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; - goto END; + while (buf < end) { + uint16_t size = MIN(UINT16_MAX, end - buf); + + if (rtp_send_data(call->video.first, buf, size, av->m->log) < 0) { + pthread_mutex_unlock(call->mutex_video); + LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno)); + rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; + goto END; + } + + buf += size; + } } } }