Bug 1432931: Added sanity check for simulcast send rid. r=bwc draft
authorJohannes Willbold <j.willbold@mozilla.com>
Thu, 28 Jun 2018 10:55:50 -0700
changeset 812176 6f39939b2d1aad85ec0e760611f1e799a6c41c14
parent 811977 6041c030780420b6205cf2d6640513606609884c
push id114475
push userbmo:johannes.willbold@rub.de
push dateThu, 28 Jun 2018 17:56:45 +0000
reviewersbwc
bugs1432931
milestone63.0a1
Bug 1432931: Added sanity check for simulcast send rid. r=bwc Added sanity check to check if the send rid in simulcast is defined by any send rid. MozReview-Commit-ID: GISzaQqdqBI
media/webrtc/signaling/gtest/sdp_unittests.cpp
media/webrtc/signaling/src/sdp/rsdparsa/src/lib.rs
--- a/media/webrtc/signaling/gtest/sdp_unittests.cpp
+++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp
@@ -3755,17 +3755,16 @@ TEST_P(NewSdpTest, CheckMalformedImageat
     return;
   }
 
   ParseSdp(kMalformedImageattr, false);
   ASSERT_NE("", GetParseErrors());
 }
 
 TEST_P(NewSdpTest, ParseInvalidSimulcastNoSuchSendRid) {
-  SKIP_TEST_WITH_RUST_PARSER; // See Bug 1432931
   ParseSdp("v=0" CRLF
            "o=- 4294967296 2 IN IP4 127.0.0.1" CRLF
            "s=SIP Call" CRLF
            "c=IN IP4 198.51.100.7" CRLF
            "b=CT:5000" CRLF
            "t=0 0" CRLF
            "m=video 56436 RTP/SAVPF 120" CRLF
            "a=rtpmap:120 VP8/90000" CRLF
--- a/media/webrtc/signaling/src/sdp/rsdparsa/src/lib.rs
+++ b/media/webrtc/signaling/src/sdp/rsdparsa/src/lib.rs
@@ -694,16 +694,22 @@ fn sanity_check_sdp_session(session: &Sd
                                                          }
                                                   }).collect();
         let recv_rids:Vec<&str> = rids.iter().filter_map(|rid| {
           match rid.direction {
               SdpSingleDirection::Recv => Some(rid.id.as_str()),
               _ => None,
           }
         }).collect();
+        let send_rids:Vec<&str> = rids.iter().filter_map(|rid| {
+          match rid.direction {
+              SdpSingleDirection::Send => Some(rid.id.as_str()),
+              _ => None,
+          }
+        }).collect();
 
 
         for rid_format in rids.iter().flat_map(|rid| &rid.formats) {
             match msection.get_formats() {
                 &SdpFormatList::Integers(ref int_fmt) => {
                     if !int_fmt.contains(&(*rid_format as u32))  {
                         return Err(make_error("Rid pts must be declared in the media section"));
                     }
@@ -713,29 +719,29 @@ fn sanity_check_sdp_session(session: &Sd
                         return Err(make_error("Rid pts must be declared in the media section"));
                     }
                 }
             }
         }
 
         if let Some(&SdpAttribute::Simulcast(ref simulcast)) =
                                             msection.get_attribute(SdpAttributeType::Simulcast) {
-            // This is already a closure as the next Bug 1432931 will require the same procedure
             let check_defined_rids = |simulcast_version_list: &Vec<SdpAttributeSimulcastVersion>,
                                       rid_ids: &[&str]| -> Result<(),SdpParserError> {
                 for simulcast_rid in simulcast_version_list.iter().flat_map(|x| &x.ids) {
                     if !rid_ids.contains(&simulcast_rid.id.as_str()) {
                         return Err(make_error(
                                        "Simulcast RIDs must be defined in any rid attribute"));
                     }
                 }
                 Ok(())
             };
 
-            check_defined_rids(&simulcast.receive, &recv_rids)?
+            check_defined_rids(&simulcast.receive, &recv_rids)?;
+            check_defined_rids(&simulcast.send, &send_rids)?;
         }
     }
 
     Ok(())
 }
 
 #[cfg(test)]
 fn create_dummy_sdp_session() -> SdpSession {