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).
This commit is contained in:
mannol 2017-11-25 15:39:37 +01:00 committed by Robin Lindén
parent 57115f0e75
commit e996a030f0
No known key found for this signature in database
GPG Key ID: 601A604B7E605776

View File

@ -814,14 +814,23 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
const vpx_codec_cx_pkt_t *pkt; const vpx_codec_cx_pkt_t *pkt;
while ((pkt = vpx_codec_get_cx_data(call->video.second->encoder, &iter))) { while ((pkt = vpx_codec_get_cx_data(call->video.second->encoder, &iter))) {
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT && 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) { const uint8_t *buf = (const uint8_t *)pkt->data.frame.buf;
const uint8_t *end = buf + pkt->data.frame.sz;
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); pthread_mutex_unlock(call->mutex_video);
LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno)); LOGGER_WARNING(av->m->log, "Could not send video frame: %s\n", strerror(errno));
rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED;
goto END; goto END;
} }
buf += size;
}
}
} }
} }