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

SDP Attribute Fixes #2082

Merged
merged 4 commits into from
Nov 22, 2024
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
16 changes: 6 additions & 10 deletions src/source/PeerConnection/SessionDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,19 +679,12 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H264 rtcp-fb nack value could not be written");
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack pli", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H264 rtcp-fb nack-pli value could not be written");
attributeCount++;

STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "rtcp-fb");
SPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "%" PRId64 " nack", payloadType);
SPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "%" PRId64 " nack pli", payloadType);
attributeCount++;

STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "rtcp-fb");
SPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "%" PRId64 " nack", payloadType);
SPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "%" PRId64 " nack pli", payloadType);
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack pli", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H264 rtcp-fb nack-pli value could not be written");
attributeCount++;

// TODO: If level asymmetry is allowed, consider sending back DEFAULT_H264_FMTP instead of the received fmtp value.
Expand Down Expand Up @@ -787,6 +780,9 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H265 rtcp-fb nack value could not be written");
attributeCount++;

STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "rtcp-fb");
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack pli", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H265 rtcp-fb nack-pli value could not be written");
Expand Down
32 changes: 32 additions & 0 deletions tst/SdpApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace video {
namespace webrtcclient {

class SdpApiTest : public WebRtcClientTestBase {
public:
const std::string m_rtcp_h264_nack_line = "a=rtcp-fb:" + std::to_string(DEFAULT_PAYLOAD_H264) + " nack" + SDP_LINE_SEPARATOR;
const std::string m_rtcp_h264_nack_pli_line = "a=rtcp-fb:" + std::to_string(DEFAULT_PAYLOAD_H264) + " nack pli" + SDP_LINE_SEPARATOR;
const std::string m_rtcp_h265_nack_line = "a=rtcp-fb:" + std::to_string(DEFAULT_PAYLOAD_H265) + " nack" + SDP_LINE_SEPARATOR;
const std::string m_rtcp_h265_nack_pli_line = "a=rtcp-fb:" + std::to_string(DEFAULT_PAYLOAD_H265) + " nack pli" + SDP_LINE_SEPARATOR;
};

/*
Expand Down Expand Up @@ -352,6 +357,15 @@ TEST_F(SdpApiTest, populateSingleMediaSection_TestTxSendRecv)
EXPECT_EQ(STATUS_SUCCESS, createOffer(offerPc, &sessionDescriptionInit));
EXPECT_PRED_FORMAT2(testing::IsSubstring, "sendrecv", sessionDescriptionInit.sdp);

std::string offerSdp(sessionDescriptionInit.sdp);

// check nack and nack pli lines
std::string::size_type posPliOnly = offerSdp.find(m_rtcp_h264_nack_line);
std::string::size_type posPliNack = offerSdp.find(m_rtcp_h264_nack_pli_line);
EXPECT_NE(posPliOnly, posPliNack);
EXPECT_NE(posPliOnly, std::string::npos);
EXPECT_NE(posPliNack, std::string::npos);

closePeerConnection(offerPc);
freePeerConnection(&offerPc);
}
Expand Down Expand Up @@ -422,6 +436,15 @@ TEST_F(SdpApiTest, populateSingleMediaSection_TestTxSendOnly)
EXPECT_EQ(STATUS_SUCCESS, createOffer(offerPc, &sessionDescriptionInit));
EXPECT_PRED_FORMAT2(testing::IsSubstring, "sendonly", sessionDescriptionInit.sdp);

std::string offerSdp(sessionDescriptionInit.sdp);

// check nack and nack pli lines
std::string::size_type posPliOnly = offerSdp.find(m_rtcp_h264_nack_line);
std::string::size_type posPliNack = offerSdp.find(m_rtcp_h264_nack_pli_line);
EXPECT_NE(posPliOnly, posPliNack);
EXPECT_NE(posPliOnly, std::string::npos);
EXPECT_NE(posPliNack, std::string::npos);

closePeerConnection(offerPc);
freePeerConnection(&offerPc);
}
Expand Down Expand Up @@ -453,6 +476,15 @@ TEST_F(SdpApiTest, populateSingleMediaSection_TestTxSendOnly_H265)
EXPECT_EQ(STATUS_SUCCESS, createOffer(offerPc, &sessionDescriptionInit));
EXPECT_PRED_FORMAT2(testing::IsSubstring, "sendonly", sessionDescriptionInit.sdp);

std::string offerSdp(sessionDescriptionInit.sdp);

// check nack and nack pli lines
std::string::size_type posPliOnly = offerSdp.find(m_rtcp_h265_nack_line);
std::string::size_type posPliNack = offerSdp.find(m_rtcp_h265_nack_pli_line);
EXPECT_NE(posPliOnly, posPliNack);
EXPECT_NE(posPliOnly, std::string::npos);
EXPECT_NE(posPliNack, std::string::npos);

closePeerConnection(offerPc);
freePeerConnection(&offerPc);
}
Expand Down
Loading