Fixing direction attribute in answer for non-RTP protocols.
"non-RTP protocols" refers to SCTP data channels. Because there are no streams for SCTP data channels, the answer was being set to RECVONLY. BUG=webrtc:5228 Review URL: https://codereview.webrtc.org/1473013002 Cr-Commit-Position: refs/heads/master@{#10762}
This commit is contained in:
parent
05816eb8d7
commit
b5cb19b37c
@ -1450,8 +1450,9 @@ TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, GetDtls12Recv) {
|
||||
kDefaultSrtpCryptoSuite));
|
||||
}
|
||||
|
||||
// This test sets up a call between two parties with audio, video and data.
|
||||
TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) {
|
||||
// This test sets up a call between two parties with audio, video and an RTP
|
||||
// data channel.
|
||||
TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, LocalP2PTestRtpDataChannel) {
|
||||
FakeConstraints setup_constraints;
|
||||
setup_constraints.SetAllowRtpDataChannels();
|
||||
ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
|
||||
@ -1481,6 +1482,35 @@ TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) {
|
||||
EXPECT_FALSE(receiving_client()->data_observer()->IsOpen());
|
||||
}
|
||||
|
||||
// This test sets up a call between two parties with audio, video and an SCTP
|
||||
// data channel.
|
||||
TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, LocalP2PTestSctpDataChannel) {
|
||||
ASSERT_TRUE(CreateTestClients());
|
||||
initializing_client()->CreateDataChannel();
|
||||
LocalP2PTest();
|
||||
ASSERT_TRUE(initializing_client()->data_channel() != nullptr);
|
||||
EXPECT_TRUE_WAIT(receiving_client()->data_channel() != nullptr, kMaxWaitMs);
|
||||
EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(),
|
||||
kMaxWaitMs);
|
||||
EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), kMaxWaitMs);
|
||||
|
||||
std::string data = "hello world";
|
||||
|
||||
initializing_client()->data_channel()->Send(DataBuffer(data));
|
||||
EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(),
|
||||
kMaxWaitMs);
|
||||
|
||||
receiving_client()->data_channel()->Send(DataBuffer(data));
|
||||
EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(),
|
||||
kMaxWaitMs);
|
||||
|
||||
receiving_client()->data_channel()->Close();
|
||||
// Send new offer and answer.
|
||||
receiving_client()->Negotiate();
|
||||
EXPECT_FALSE(initializing_client()->data_observer()->IsOpen());
|
||||
EXPECT_FALSE(receiving_client()->data_observer()->IsOpen());
|
||||
}
|
||||
|
||||
// This test sets up a call between two parties and creates a data channel.
|
||||
// The test tests that received data is buffered unless an observer has been
|
||||
// registered.
|
||||
|
||||
@ -633,6 +633,11 @@ static void PruneCryptos(const CryptoParamsVec& filter,
|
||||
target_cryptos->end());
|
||||
}
|
||||
|
||||
static bool IsRtpProtocol(const std::string& protocol) {
|
||||
return protocol.empty() ||
|
||||
(protocol.find(cricket::kMediaProtocolRtpPrefix) != std::string::npos);
|
||||
}
|
||||
|
||||
static bool IsRtpContent(SessionDescription* sdesc,
|
||||
const std::string& content_name) {
|
||||
bool is_rtp = false;
|
||||
@ -643,9 +648,7 @@ static bool IsRtpContent(SessionDescription* sdesc,
|
||||
if (!media_desc) {
|
||||
return false;
|
||||
}
|
||||
is_rtp = media_desc->protocol().empty() ||
|
||||
(media_desc->protocol().find(cricket::kMediaProtocolRtpPrefix) !=
|
||||
std::string::npos);
|
||||
is_rtp = IsRtpProtocol(media_desc->protocol());
|
||||
}
|
||||
return is_rtp;
|
||||
}
|
||||
@ -1067,12 +1070,16 @@ static bool CreateMediaContentAnswer(
|
||||
answer->set_direction(MD_RECVONLY);
|
||||
break;
|
||||
case MD_RECVONLY:
|
||||
answer->set_direction(answer->streams().empty() ? MD_INACTIVE
|
||||
: MD_SENDONLY);
|
||||
answer->set_direction(IsRtpProtocol(answer->protocol()) &&
|
||||
answer->streams().empty()
|
||||
? MD_INACTIVE
|
||||
: MD_SENDONLY);
|
||||
break;
|
||||
case MD_SENDRECV:
|
||||
answer->set_direction(answer->streams().empty() ? MD_RECVONLY
|
||||
: MD_SENDRECV);
|
||||
answer->set_direction(IsRtpProtocol(answer->protocol()) &&
|
||||
answer->streams().empty()
|
||||
? MD_RECVONLY
|
||||
: MD_SENDRECV);
|
||||
break;
|
||||
default:
|
||||
RTC_DCHECK(false && "MediaContentDescription has unexpected direction.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user