From 97aacc7cff6212a907d26c33018d66e1243d09a7 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Tue, 28 Nov 2023 18:03:37 +0000 Subject: [PATCH 1/3] rist_tx: Only set password if password is not null --- examples/rist_tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/rist_tx.c b/examples/rist_tx.c index 1957a8d4e..edc32178d 100644 --- a/examples/rist_tx.c +++ b/examples/rist_tx.c @@ -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); From f3b4bacfdd688329fa31525ba52f146cf473a3f4 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Wed, 29 Nov 2023 11:27:04 +0000 Subject: [PATCH 2/3] upipe_srt_handshake: Respond to remote keepalives --- lib/upipe-srt/upipe_srt_handshake.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/upipe-srt/upipe_srt_handshake.c b/lib/upipe-srt/upipe_srt_handshake.c index 8030d2147..72655fdcf 100644 --- a/lib/upipe-srt/upipe_srt_handshake.c +++ b/lib/upipe-srt/upipe_srt_handshake.c @@ -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 */); + 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); @@ -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) { From 498c45ccd138c6a9ef96d244e42c08de41e43468 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Wed, 29 Nov 2023 11:52:34 +0000 Subject: [PATCH 3/3] upipe_srt_sender: Set out of order flag to 0 as per the IETF document "In the case of live streaming, it is set to 0 allowing out of order delivery of a packet. However, in this use case the Order Flag has to be ignored by the receiver. " --- lib/upipe-srt/upipe_srt_sender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/upipe-srt/upipe_srt_sender.c b/lib/upipe-srt/upipe_srt_sender.c index 57062861a..32cd4a743 100644 --- a/lib/upipe-srt/upipe_srt_sender.c +++ b/lib/upipe-srt/upipe_srt_sender.c @@ -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