Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split video payload into multiple RTP messages when too big to fit into one #623

Merged
merged 1 commit into from
Dec 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions toxav/toxav.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down