Fail SetLocalDescription if a=mid lines are missing
Bug: webrtc:9540 Change-Id: I5f75feedf2aca5162269e6b4ded6e797b064415a Reviewed-on: https://webrtc-review.googlesource.com/c/115062 Reviewed-by: Amit Hilbuch <amithi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26063}
This commit is contained in:
parent
b275788016
commit
ceac0152b1
@ -6156,6 +6156,10 @@ bool PeerConnection::HasRtcpMuxEnabled(const cricket::ContentInfo* content) {
|
||||
static RTCError ValidateMids(const cricket::SessionDescription& description) {
|
||||
std::set<std::string> mids;
|
||||
for (const cricket::ContentInfo& content : description.contents()) {
|
||||
if (content.name.empty()) {
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
|
||||
"A media section is missing a MID attribute.");
|
||||
}
|
||||
if (!mids.insert(content.name).second) {
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
|
||||
"Duplicate a=mid value '" + content.name + "'.");
|
||||
|
||||
@ -1694,4 +1694,20 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioVideoAnswer) {
|
||||
ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer)));
|
||||
}
|
||||
|
||||
// Test that SetLocalDescription fails if a=mid lines are missing.
|
||||
TEST_F(PeerConnectionJsepTest, SetLocalDescriptionFailsMissingMid) {
|
||||
auto caller = CreatePeerConnection();
|
||||
caller->AddAudioTrack("audio");
|
||||
|
||||
auto offer = caller->CreateOffer();
|
||||
ClearMids(offer.get());
|
||||
|
||||
std::string error;
|
||||
ASSERT_FALSE(caller->SetLocalDescription(std::move(offer), &error));
|
||||
EXPECT_EQ(
|
||||
"Failed to set local offer sdp: A media section is missing a MID "
|
||||
"attribute.",
|
||||
error);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user