8000 test: add coverage of RTCP-XR DLRR by alfredh · Pull Request #1307 · baresip/re · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: add coverage of RTCP-XR DLRR #1307

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

Merged
merged 1 commit into from
Apr 19, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 85 additions & 1 deletion test/rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static int rrtr_encode_handler(struct mbuf *mb, void *arg)
}


int test_rtcp_xr_rrtr(void)
static int test_rtcp_xr_rrtr(void)
{
const uint8_t packet[] = {
/* header */
Expand Down Expand Up @@ -541,3 +541,87 @@ int test_rtcp_xr_rrtr(void)
mem_deref(msg);
return err;
}


static int dlrr_encode_handler(struct mbuf *mb, void *arg)
{
const uint16_t block_length = 3;
const uint32_t ssrc = 0xa534b254;
const uint32_t lrr = 0x03040506;
const uint32_t dlrr = 0x00008376;
int err;
(void)arg;

err = mbuf_write_u8(mb, RTCP_XR_DLRR);
err |= mbuf_write_u8(mb, 0); /* reserved */
err |= mbuf_write_u16(mb, htons(block_length));
err |= mbuf_write_u32(mb, htonl(ssrc));
err |= mbuf_write_u32(mb, htonl(lrr));
err |= mbuf_write_u32(mb, htonl(dlrr));

return err;
}


static int test_rtcp_xr_dlrr(void)
{
/* RTCP-XR packet from Chrome 126 */
static const uint8_t packet[] = {

/* header */
0x80, 0xcf, 0x00, 0x05,

/* RTCP-XR */
0x62, 0x8e, 0x09, 0xbd,
0x05, 0x00, 0x00, 0x03,
0xa5, 0x34, 0xb2, 0x54,
0x03, 0x04, 0x05, 0x06,
0x00, 0x00, 0x83, 0x76,
};

struct mbuf *mb = mbuf_alloc(sizeof(packet));
if (!mb)
return ENOMEM;

struct rtcp_msg *msg = NULL;
const uint32_t ssrc = 0x628e09bd;

int err = rtcp_encode(mb, RTCP_XR, 0, ssrc, dlrr_encode_handler, NULL);
TEST_ERR(err);

mbuf_set_pos(mb, 0);

TEST_MEMCMP(packet, sizeof(packet), mbuf_buf(mb), mbuf_get_left(mb));

err = rtcp_decode(&msg, mb);
TEST_ERR(err);

ASSERT_EQ(RTCP_XR, msg->hdr.pt);
ASSERT_EQ(ssrc, msg->r.xr.ssrc);
ASSERT_EQ(RTCP_XR_DLRR, msg->r.xr.bt);
ASSERT_EQ(3, msg->r.xr.block_len);
ASSERT_EQ(0xa534b254, msg->r.xr.rb.dlrrb.ssrc);
ASSERT_EQ(0x03040506, msg->r.xr.rb.dlrrb.lrr);
ASSERT_EQ(0x00008376, msg->r.xr.rb.dlrrb.dlrr);

out:
mem_deref(msg);
mem_deref(mb);

return err;
}


int test_rtcp_xr(void)
{
int err;

err = test_rtcp_xr_dlrr();
TEST_ERR(err);

err = test_rtcp_xr_rrtr();
TEST_ERR(err);

out:
return err;
}
2 changes: 1 addition & 1 deletion test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static const struct test tests[] = {
TEST(test_rtcp_decode_badmsg),
TEST(test_rtcp_packetloss),
TEST(test_rtcp_twcc),
TEST(test_rtcp_xr_rrtr),
TEST(test_rtcp_xr),
TEST(test_rtcp_loop),
TEST(test_sa_class),
TEST(test_sa_cmp),
Expand Down
2 changes: 1 addition & 1 deletion test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int test_rtcp_decode(void);
int test_rtcp_decode_badmsg(void);
int test_rtcp_packetloss(void);
int test_rtcp_twcc(void);
int test_rtcp_xr_rrtr(void);
int test_rtcp_xr(void);
int test_rtcp_loop(void);
int test_sa_class(void);
int test_sa_cmp(void);
Expand Down
Loading
0