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

handle null stream track in case of recvonly #1346

Merged
merged 4 commits into from
Dec 8, 2021
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
10 changes: 10 additions & 0 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,21 @@ STATUS addTransceiver(PRtcPeerConnection pPeerConnection, PRtcMediaStreamTrack p
UINT32 clockRate = 0;
UINT32 ssrc = (UINT32) RAND(), rtxSsrc = (UINT32) RAND();
RTC_RTP_TRANSCEIVER_DIRECTION direction = RTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV;
RtcMediaStreamTrack videoTrack;
if (pRtcRtpTransceiverInit != NULL) {
direction = pRtcRtpTransceiverInit->direction;
}

CHK(pKvsPeerConnection != NULL, STATUS_NULL_ARG);

if (direction == RTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY && pRtcMediaStreamTrack == NULL) {
MEMSET(&videoTrack, 0x00, SIZEOF(RtcMediaStreamTrack));
videoTrack.kind = MEDIA_STREAM_TRACK_KIND_VIDEO;
videoTrack.codec = RTC_CODEC_H264_PROFILE_42E01F_LEVEL_ASYMMETRY_ALLOWED_PACKETIZATION_MODE;
STRCPY(videoTrack.streamId, "myKvsVideoStream");
STRCPY(videoTrack.trackId, "myVideoTrack");
pRtcMediaStreamTrack = &videoTrack;
}

switch (pRtcMediaStreamTrack->codec) {
case RTC_CODEC_OPUS:
Expand Down
2 changes: 1 addition & 1 deletion src/source/PeerConnection/Rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static STATUS onRtcpSLIPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPe
pTransceiver->outboundStats.sliCount++;
MUTEX_UNLOCK(pTransceiver->statsLock);
} else {
DLOGW("Received FIR for non existing ssrc: %u", mediaSSRC);
DLOGW("Received SLI for non existing ssrc: %u", mediaSSRC);
}

CleanUp:
Expand Down
23 changes: 23 additions & 0 deletions tst/SdpApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,29 @@ TEST_F(SdpApiTest, populateSingleMediaSection_TestTxRecvOnly)
freePeerConnection(&offerPc);
}

TEST_F(SdpApiTest, populateSingleMediaSection_TestTxRecvOnlyStreamNull)
{
PRtcPeerConnection offerPc = NULL;
RtcConfiguration configuration;
RtcSessionDescriptionInit sessionDescriptionInit;

MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration));

// Create peer connection
EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS);

PRtcRtpTransceiver pTransceiver;
RtcRtpTransceiverInit rtcRtpTransceiverInit;
rtcRtpTransceiverInit.direction = RTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY;

EXPECT_EQ(STATUS_SUCCESS, addTransceiver(offerPc, NULL, &rtcRtpTransceiverInit, &pTransceiver));
EXPECT_EQ(STATUS_SUCCESS, createOffer(offerPc, &sessionDescriptionInit));
EXPECT_PRED_FORMAT2(testing::IsSubstring, "recvonly", sessionDescriptionInit.sdp);

closePeerConnection(offerPc);
freePeerConnection(&offerPc);
}

TEST_F(SdpApiTest, populateSingleMediaSection_TestPayloadNoFmtp)
{
CHAR remoteSessionDescription[] = R"(v=0
Expand Down