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
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion examples/rist_tx.c
funman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ static int start(void)
struct upipe *upipe_srt_handshake = upipe_void_alloc_output(upipe_udpsrc_srt, upipe_srt_handshake_mgr,
uprobe_pfx_alloc_va(uprobe_use(&uprobe_hs), loglevel, "srt handshake %u", z));
upipe_set_option(upipe_srt_handshake, "listener", listener ? "1" : "0");
upipe_srt_handshake_set_password(upipe_srt_handshake, password, key_length / 8);
if (password)
upipe_srt_handshake_set_password(upipe_srt_handshake, password, key_length / 8);

upipe_mgr_release(upipe_srt_handshake_mgr);

Expand Down
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
2 changes: 1 addition & 1 deletion lib/upipe-srt/upipe_srt_sender.c
funman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static inline void upipe_srt_sender_input(struct upipe *upipe, struct uref *uref
srt_set_data_packet_message_number(buf, seqnum);
srt_set_data_packet_seq(buf, seqnum);
srt_set_data_packet_position(buf, SRT_DATA_POSITION_ONLY);
srt_set_data_packet_order(buf, true);
srt_set_data_packet_order(buf, false);
srt_set_data_packet_retransmit(buf, false);

#ifdef UPIPE_HAVE_GCRYPT_H
Expand Down