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

SRT Fixes #2

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/upipe-srt/upipe_srt_handshake.c
funman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,34 @@ static struct uref *upipe_srt_handshake_handle_hs(struct upipe *upipe, const uin
}
}

static struct uref *upipe_srt_handshake_handle_keepalive(struct upipe *upipe, const uint8_t *buf, int size, uint64_t now)
{
struct upipe_srt_handshake *upipe_srt_handshake = upipe_srt_handshake_from_upipe(upipe);
uint32_t timestamp = (now - upipe_srt_handshake->establish_time) / 27;

struct uref *uref = uref_block_alloc(upipe_srt_handshake->uref_mgr,
upipe_srt_handshake->ubuf_mgr, SRT_HEADER_SIZE + 4 /* WTF */);
funman marked this conversation as resolved.
Show resolved Hide resolved
if (!uref)
return NULL;
uint8_t *out;
int output_size = -1;
if (unlikely(!ubase_check(uref_block_write(uref, 0, &output_size, &out)))) {
uref_free(uref);
upipe_throw_fatal(upipe, UBASE_ERR_ALLOC);
}

srt_set_packet_control(out, true);
srt_set_packet_timestamp(out, timestamp);
srt_set_packet_dst_socket_id(out, upipe_srt_handshake->remote_socket_id);
srt_set_control_packet_type(out, SRT_CONTROL_TYPE_KEEPALIVE);
srt_set_control_packet_subtype(out, 0);
srt_set_control_packet_type_specific(out, srt_get_control_packet_type_specific(buf));

uref_block_unmap(uref, 0);
return uref;
// should go to sender
}

static struct uref *upipe_srt_handshake_handle_ack(struct upipe *upipe, const uint8_t *buf, int size, uint64_t now)
{
struct upipe_srt_handshake *upipe_srt_handshake = upipe_srt_handshake_from_upipe(upipe);
Expand Down Expand Up @@ -1373,6 +1401,7 @@ static struct uref *upipe_srt_handshake_input_control(struct upipe *upipe, const
if (type == SRT_CONTROL_TYPE_HANDSHAKE) {
return upipe_srt_handshake_handle_hs(upipe, buf, size, now);
} else if (type == SRT_CONTROL_TYPE_KEEPALIVE) {
return upipe_srt_handshake_handle_keepalive(upipe, buf, size, now);
} else if (type == SRT_CONTROL_TYPE_ACK) {
return upipe_srt_handshake_handle_ack(upipe, buf, size, now);
} else if (type == SRT_CONTROL_TYPE_NAK) {
Expand Down