Check the rid direction matches the direction in simulcast description

Section 5.2 of draft-ietf-mmusic-sdp-simulcast-14:
The direction for an rid-id MUST be aligned with the direction
specified for the corresponding RTP stream identifier on
the "a=rid" line.

Bug: webrtc:10785
Change-Id: I1fc70706511ae17c821c5ec4d90a0b854171454f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144245
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Amit Hilbuch <amithi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28452}
diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc
index 2fa004f..e167d95 100644
--- a/pc/webrtc_sdp.cc
+++ b/pc/webrtc_sdp.cc
@@ -2567,7 +2567,8 @@
   // Add any rid that is not in the valid list to the remove set.
   for (const SimulcastLayer& send_layer : all_send_layers) {
     if (absl::c_none_of(valid_rids, [&send_layer](const RidDescription& rid) {
-          return send_layer.rid == rid.rid;
+          return send_layer.rid == rid.rid &&
+                 rid.direction == cricket::RidDirection::kSend;
         })) {
       to_remove.insert(send_layer.rid);
     }
@@ -2575,10 +2576,11 @@
 
   // Add any rid that is not in the valid list to the remove set.
   for (const SimulcastLayer& receive_layer : all_receive_layers) {
-    if (absl::c_none_of(valid_rids,
-                        [&receive_layer](const RidDescription& rid) {
-                          return receive_layer.rid == rid.rid;
-                        })) {
+    if (absl::c_none_of(
+            valid_rids, [&receive_layer](const RidDescription& rid) {
+              return receive_layer.rid == rid.rid &&
+                     rid.direction == cricket::RidDirection::kReceive;
+            })) {
       to_remove.insert(receive_layer.rid);
     }
   }