Changeset 240320 in webkit


Ignore:
Timestamp:
Jan 22, 2019 8:42:54 PM (5 years ago)
Author:
youenn@apple.com
Message:

Resync libwebrtc with latest M72 branch
https://bugs.webkit.org/show_bug.cgi?id=193693
LayoutTests/imported/w3c:

<rdar://problem/47463803>

Reviewed by Eric Carlson.

  • web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt:

Source/ThirdParty/libwebrtc:

Reviewed by Eric Carlson.

Update libwebrtc up to latest M72 branch to fix some identified issues:

  • Bad bandwidth estimation in case of multiple transceivers
  • mid handling for legacy endpoints
  • msid handling for updating mediastreams accordingly.
  • Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.cc:
  • Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.h:
  • Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc:
  • Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc:
  • Source/webrtc/modules/congestion_controller/send_side_congestion_controller_unittest.cc:
  • Source/webrtc/pc/jsepsessiondescription_unittest.cc:
  • Source/webrtc/pc/mediasession.cc:
  • Source/webrtc/pc/mediasession_unittest.cc:
  • Source/webrtc/pc/peerconnection.cc:
  • Source/webrtc/pc/peerconnection.h:
  • Source/webrtc/pc/peerconnection_jsep_unittest.cc:
  • Source/webrtc/pc/peerconnection_media_unittest.cc:
  • Source/webrtc/pc/peerconnection_rtp_unittest.cc:
  • Source/webrtc/pc/sessiondescription.cc:
  • Source/webrtc/pc/sessiondescription.h:
  • Source/webrtc/pc/webrtcsdp.cc:
  • Source/webrtc/pc/webrtcsdp_unittest.cc:
  • Source/webrtc/system_wrappers/include/metrics.h:
  • Source/webrtc/video/BUILD.gn:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r240251 r240320  
     12019-01-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Resync libwebrtc with latest M72 branch
     4        https://bugs.webkit.org/show_bug.cgi?id=193693
     5        <rdar://problem/47463803>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt:
     10
    1112019-01-22  Oriol Brufau  <obrufau@igalia.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt

    r238182 r240320  
    99PASS checkAddTransceiverWithSetRemoteOfferNoSend
    1010PASS checkAddTransceiverBadKind
    11 FAIL checkNoMidOffer promise_test: Unhandled rejection with value: object "InvalidAccessError: Failed to set remote offer sdp: The BUNDLE group contains MID:0 matching no m= section."
     11PASS checkNoMidOffer
    1212PASS checkSetDirection
    1313PASS checkCurrentDirection
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r240176 r240320  
     12019-01-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Resync libwebrtc with latest M72 branch
     4        https://bugs.webkit.org/show_bug.cgi?id=193693
     5
     6        Reviewed by Eric Carlson.
     7
     8        Update libwebrtc up to latest M72 branch to fix some identified issues:
     9        - Bad bandwidth estimation in case of multiple transceivers
     10        - mid handling for legacy endpoints
     11        - msid handling for updating mediastreams accordingly.
     12
     13        * Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.cc:
     14        * Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.h:
     15        * Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc:
     16        * Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc:
     17        * Source/webrtc/modules/congestion_controller/send_side_congestion_controller_unittest.cc:
     18        * Source/webrtc/pc/jsepsessiondescription_unittest.cc:
     19        * Source/webrtc/pc/mediasession.cc:
     20        * Source/webrtc/pc/mediasession_unittest.cc:
     21        * Source/webrtc/pc/peerconnection.cc:
     22        * Source/webrtc/pc/peerconnection.h:
     23        * Source/webrtc/pc/peerconnection_jsep_unittest.cc:
     24        * Source/webrtc/pc/peerconnection_media_unittest.cc:
     25        * Source/webrtc/pc/peerconnection_rtp_unittest.cc:
     26        * Source/webrtc/pc/sessiondescription.cc:
     27        * Source/webrtc/pc/sessiondescription.h:
     28        * Source/webrtc/pc/webrtcsdp.cc:
     29        * Source/webrtc/pc/webrtcsdp_unittest.cc:
     30        * Source/webrtc/system_wrappers/include/metrics.h:
     31        * Source/webrtc/video/BUILD.gn:
     32
    1332019-01-18  Jer Noble  <jer.noble@apple.com>
    234
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.cc

    r238967 r240320  
    4747constexpr double kDefaultTrendlineThresholdGain = 4.0;
    4848
    49 constexpr int kMaxConsecutiveFailedLookups = 5;
    50 
    5149const char kBweWindowSizeInPacketsExperiment[] =
    5250    "WebRTC-BweWindowSizeInPackets";
     
    9593      trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff),
    9694      trendline_threshold_gain_(kDefaultTrendlineThresholdGain),
    97       consecutive_delayed_feedbacks_(0),
    9895      prev_bitrate_(DataRate::Zero()),
    9996      prev_state_(BandwidthUsage::kBwNormal) {
     
    148145
    149146  if (delayed_feedback) {
    150     Timestamp arrival_time = Timestamp::PlusInfinity();
    151     if (packet_feedback_vector.back().arrival_time_ms > 0)
    152       arrival_time =
    153           Timestamp::ms(packet_feedback_vector.back().arrival_time_ms);
    154     return OnDelayedFeedback(arrival_time);
    155 
    156   } else {
    157     consecutive_delayed_feedbacks_ = 0;
    158     return MaybeUpdateEstimate(acked_bitrate, probe_bitrate,
    159                                recovered_from_overuse, at_time);
    160   }
    161   return Result();
    162 }
    163 
    164 DelayBasedBwe::Result DelayBasedBwe::OnDelayedFeedback(Timestamp receive_time) {
    165   ++consecutive_delayed_feedbacks_;
    166   if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) {
    167     consecutive_delayed_feedbacks_ = 0;
    168     return OnLongFeedbackDelay(receive_time);
    169   }
    170   return Result();
    171 }
    172 
    173 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay(
    174     Timestamp arrival_time) {
    175   // Estimate should always be valid since a start bitrate always is set in the
    176   // Call constructor. An alternative would be to return an empty Result here,
    177   // or to estimate the throughput based on the feedback we received.
    178   RTC_DCHECK(rate_control_.ValidEstimate());
    179   rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2, arrival_time);
    180   Result result;
    181   result.updated = true;
    182   result.probe = false;
    183   result.target_bitrate = rate_control_.LatestEstimate();
    184   RTC_LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to "
    185                       << ToString(result.target_bitrate);
    186   return result;
     147    // TODO(bugs.webrtc.org/10125): Design a better mechanism to safe-guard
     148    // against building very large network queues.
     149    return Result();
     150  }
     151  return MaybeUpdateEstimate(acked_bitrate, probe_bitrate,
     152                             recovered_from_overuse, at_time);
    187153}
    188154
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/congestion_controller/goog_cc/delay_based_bwe.h

    r238967 r240320  
    5050      absl::optional<DataRate> probe_bitrate,
    5151      Timestamp at_time);
    52   Result OnDelayedFeedback(Timestamp receive_time);
    5352  void OnRttUpdate(TimeDelta avg_rtt);
    5453  bool LatestEstimate(std::vector<uint32_t>* ssrcs, DataRate* bitrate) const;
     
    6160  void IncomingPacketFeedback(const PacketFeedback& packet_feedback,
    6261                              Timestamp at_time);
    63   Result OnLongFeedbackDelay(Timestamp arrival_time);
    6462  Result MaybeUpdateEstimate(absl::optional<DataRate> acked_bitrate,
    6563                             absl::optional<DataRate> probe_bitrate,
     
    8280  double trendline_smoothing_coeff_;
    8381  double trendline_threshold_gain_;
    84   int consecutive_delayed_feedbacks_;
    8582  DataRate prev_bitrate_;
    8683  BandwidthUsage prev_state_;
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc

    r238967 r240320  
    395395    TransportPacketsFeedback report) {
    396396  if (report.packet_feedbacks.empty()) {
    397     DelayBasedBwe::Result result = delay_based_bwe_->OnDelayedFeedback(
    398         report.sendless_arrival_times.back());
    399     NetworkControlUpdate update;
    400     if (result.updated) {
    401       bandwidth_estimation_->UpdateDelayBasedEstimate(report.feedback_time,
    402                                                       result.target_bitrate);
    403       MaybeTriggerOnNetworkChanged(&update, report.feedback_time);
    404     }
    405     return update;
     397    // TODO(bugs.webrtc.org/10125): Design a better mechanism to safe-guard
     398    // against building very large network queues.
     399    return NetworkControlUpdate();
    406400  }
    407401
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc

    r238967 r240320  
    192192
    193193  update = controller_->OnProcessInterval(DefaultInterval());
    194 }
    195 
    196 // Estimated bitrate reduced when the feedbacks arrive with such a long delay,
    197 // that the send-time-history no longer holds the feedbacked packets.
    198 TEST_F(GoogCcNetworkControllerTest, LongFeedbackDelays) {
    199   TargetBitrateTrackingSetup();
    200   const webrtc::PacedPacketInfo kPacingInfo0(0, 5, 2000);
    201   const webrtc::PacedPacketInfo kPacingInfo1(1, 8, 4000);
    202   const int64_t kFeedbackTimeoutMs = 60001;
    203   const int kMaxConsecutiveFailedLookups = 5;
    204   for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) {
    205     std::vector<PacketResult> packets;
    206     packets.push_back(CreateResult(i * 100, 2 * i * 100, 1500, kPacingInfo0));
    207     packets.push_back(
    208         CreateResult(i * 100 + 10, 2 * i * 100 + 10, 1500, kPacingInfo0));
    209     packets.push_back(
    210         CreateResult(i * 100 + 20, 2 * i * 100 + 20, 1500, kPacingInfo0));
    211     packets.push_back(
    212         CreateResult(i * 100 + 30, 2 * i * 100 + 30, 1500, kPacingInfo1));
    213     packets.push_back(
    214         CreateResult(i * 100 + 40, 2 * i * 100 + 40, 1500, kPacingInfo1));
    215 
    216     TransportPacketsFeedback feedback;
    217     for (PacketResult& packet : packets) {
    218       controller_->OnSentPacket(packet.sent_packet);
    219       feedback.sendless_arrival_times.push_back(packet.receive_time);
    220     }
    221 
    222     feedback.feedback_time = packets[0].receive_time;
    223     AdvanceTimeMilliseconds(kFeedbackTimeoutMs);
    224     SentPacket later_packet;
    225     later_packet.send_time = Timestamp::ms(kFeedbackTimeoutMs + i * 200 + 40);
    226     later_packet.size = DataSize::bytes(1500);
    227     later_packet.pacing_info = kPacingInfo1;
    228     controller_->OnSentPacket(later_packet);
    229 
    230     OnUpdate(controller_->OnTransportPacketsFeedback(feedback));
    231   }
    232   OnUpdate(controller_->OnProcessInterval(DefaultInterval()));
    233 
    234   EXPECT_EQ(kInitialBitrateKbps / 2, target_bitrate_->kbps());
    235 
    236   // Test with feedback that isn't late enough to time out.
    237   {
    238     std::vector<PacketResult> packets;
    239     packets.push_back(CreateResult(100, 200, 1500, kPacingInfo0));
    240     packets.push_back(CreateResult(110, 210, 1500, kPacingInfo0));
    241     packets.push_back(CreateResult(120, 220, 1500, kPacingInfo0));
    242     packets.push_back(CreateResult(130, 230, 1500, kPacingInfo1));
    243     packets.push_back(CreateResult(140, 240, 1500, kPacingInfo1));
    244 
    245     for (const PacketResult& packet : packets)
    246       controller_->OnSentPacket(packet.sent_packet);
    247 
    248     TransportPacketsFeedback feedback;
    249     feedback.feedback_time = packets[0].receive_time;
    250     feedback.packet_feedbacks = packets;
    251 
    252     AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1);
    253 
    254     SentPacket later_packet;
    255     later_packet.send_time = Timestamp::ms(kFeedbackTimeoutMs + 240);
    256     later_packet.size = DataSize::bytes(1500);
    257     later_packet.pacing_info = kPacingInfo1;
    258     controller_->OnSentPacket(later_packet);
    259 
    260     OnUpdate(controller_->OnTransportPacketsFeedback(feedback));
    261   }
    262194}
    263195
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/congestion_controller/send_side_congestion_controller_unittest.cc

    r238967 r240320  
    345345}
    346346
    347 // Estimated bitrate reduced when the feedbacks arrive with such a long delay,
    348 // that the send-time-history no longer holds the feedbacked packets.
    349 TEST_F(LegacySendSideCongestionControllerTest, LongFeedbackDelays) {
    350   TargetBitrateTrackingSetup();
    351 
    352   const int64_t kFeedbackTimeoutMs = 60001;
    353   const int kMaxConsecutiveFailedLookups = 5;
    354   for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) {
    355     std::vector<PacketFeedback> packets;
    356     packets.push_back(
    357         PacketFeedback(i * 100, 2 * i * 100, 0, 1500, kPacingInfo0));
    358     packets.push_back(
    359         PacketFeedback(i * 100 + 10, 2 * i * 100 + 10, 1, 1500, kPacingInfo0));
    360     packets.push_back(
    361         PacketFeedback(i * 100 + 20, 2 * i * 100 + 20, 2, 1500, kPacingInfo0));
    362     packets.push_back(
    363         PacketFeedback(i * 100 + 30, 2 * i * 100 + 30, 3, 1500, kPacingInfo1));
    364     packets.push_back(
    365         PacketFeedback(i * 100 + 40, 2 * i * 100 + 40, 4, 1500, kPacingInfo1));
    366 
    367     for (const PacketFeedback& packet : packets)
    368       OnSentPacket(packet);
    369 
    370     rtcp::TransportFeedback feedback;
    371     feedback.SetBase(packets[0].sequence_number,
    372                      packets[0].arrival_time_ms * 1000);
    373 
    374     for (const PacketFeedback& packet : packets) {
    375       EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
    376                                              packet.arrival_time_ms * 1000));
    377     }
    378 
    379     feedback.Build();
    380 
    381     clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs);
    382     PacketFeedback later_packet(kFeedbackTimeoutMs + i * 100 + 40,
    383                                 kFeedbackTimeoutMs + i * 200 + 40, 5, 1500,
    384                                 kPacingInfo1);
    385     OnSentPacket(later_packet);
    386 
    387     controller_->OnTransportFeedback(feedback);
    388 
    389     // Check that packets have timed out.
    390     for (PacketFeedback& packet : packets) {
    391       packet.send_time_ms = PacketFeedback::kNoSendTime;
    392       packet.payload_size = 0;
    393       packet.pacing_info = PacedPacketInfo();
    394     }
    395     ComparePacketFeedbackVectors(packets,
    396                                  controller_->GetTransportFeedbackVector());
    397   }
    398 
    399   controller_->Process();
    400 
    401   EXPECT_EQ(kInitialBitrateBps / 2, target_bitrate_bps_);
    402 
    403   // Test with feedback that isn't late enough to time out.
    404   {
    405     std::vector<PacketFeedback> packets;
    406     packets.push_back(PacketFeedback(100, 200, 0, 1500, kPacingInfo0));
    407     packets.push_back(PacketFeedback(110, 210, 1, 1500, kPacingInfo0));
    408     packets.push_back(PacketFeedback(120, 220, 2, 1500, kPacingInfo0));
    409     packets.push_back(PacketFeedback(130, 230, 3, 1500, kPacingInfo1));
    410     packets.push_back(PacketFeedback(140, 240, 4, 1500, kPacingInfo1));
    411 
    412     for (const PacketFeedback& packet : packets)
    413       OnSentPacket(packet);
    414 
    415     rtcp::TransportFeedback feedback;
    416     feedback.SetBase(packets[0].sequence_number,
    417                      packets[0].arrival_time_ms * 1000);
    418 
    419     for (const PacketFeedback& packet : packets) {
    420       EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
    421                                              packet.arrival_time_ms * 1000));
    422     }
    423 
    424     feedback.Build();
    425 
    426     clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1);
    427     PacketFeedback later_packet(kFeedbackTimeoutMs + 140,
    428                                 kFeedbackTimeoutMs + 240, 5, 1500,
    429                                 kPacingInfo1);
    430     OnSentPacket(later_packet);
    431 
    432     controller_->OnTransportFeedback(feedback);
    433     ComparePacketFeedbackVectors(packets,
    434                                  controller_->GetTransportFeedbackVector());
    435   }
    436 }
    437 
    438347// Bandwidth estimation is updated when feedbacks are received.
    439348// Feedbacks which show an increasing delay cause the estimation to be reduced.
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/jsepsessiondescription_unittest.cc

    r235230 r240320  
    6161  desc->AddContent(cricket::CN_VIDEO, MediaProtocolType::kRtp, video.release());
    6262
    63   EXPECT_TRUE(desc->AddTransportInfo(cricket::TransportInfo(
     63  desc->AddTransportInfo(cricket::TransportInfo(
    6464      cricket::CN_AUDIO,
    6565      cricket::TransportDescription(
    6666          std::vector<std::string>(), kCandidateUfragVoice, kCandidatePwdVoice,
    67           cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_NONE, NULL))));
    68   EXPECT_TRUE(desc->AddTransportInfo(cricket::TransportInfo(
     67          cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_NONE, NULL)));
     68  desc->AddTransportInfo(cricket::TransportInfo(
    6969      cricket::CN_VIDEO,
    7070      cricket::TransportDescription(
    7171          std::vector<std::string>(), kCandidateUfragVideo, kCandidatePwdVideo,
    72           cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_NONE, NULL))));
     72          cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_NONE, NULL)));
    7373  return desc;
    7474}
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/mediasession.cc

    r239136 r240320  
    18001800      transport_desc_factory_->CreateOffer(transport_options, current_tdesc,
    18011801                                           ice_credentials));
    1802   bool ret =
    1803       (new_tdesc.get() != NULL &&
    1804        offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc)));
    1805   if (!ret) {
     1802  if (!new_tdesc) {
    18061803    RTC_LOG(LS_ERROR) << "Failed to AddTransportOffer, content name="
    18071804                      << content_name;
    18081805  }
    1809   return ret;
     1806  offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc));
     1807  return true;
    18101808}
    18111809
     
    18321830    const TransportDescription& transport_desc,
    18331831    SessionDescription* answer_desc) const {
    1834   if (!answer_desc->AddTransportInfo(
    1835           TransportInfo(content_name, transport_desc))) {
    1836     RTC_LOG(LS_ERROR) << "Failed to AddTransportAnswer, content name="
    1837                       << content_name;
    1838     return false;
    1839   }
     1832  answer_desc->AddTransportInfo(TransportInfo(content_name, transport_desc));
    18401833  return true;
    18411834}
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/mediasession_unittest.cc

    r239136 r240320  
    427427    if (has_current_desc) {
    428428      current_desc.reset(new SessionDescription());
    429       EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo(
     429      current_desc->AddTransportInfo(TransportInfo(
    430430          "audio",
    431           TransportDescription(current_audio_ufrag, current_audio_pwd))));
    432       EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo(
     431          TransportDescription(current_audio_ufrag, current_audio_pwd)));
     432      current_desc->AddTransportInfo(TransportInfo(
    433433          "video",
    434           TransportDescription(current_video_ufrag, current_video_pwd))));
    435       EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo(
    436           "data", TransportDescription(current_data_ufrag, current_data_pwd))));
     434          TransportDescription(current_video_ufrag, current_video_pwd)));
     435      current_desc->AddTransportInfo(TransportInfo(
     436          "data", TransportDescription(current_data_ufrag, current_data_pwd)));
    437437    }
    438438    if (offer) {
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/peerconnection.cc

    r240053 r240320  
    648648  }
    649649  return DataMessageType::kControl;
     650}
     651
     652// Find a new MID that is not already in |used_mids|, then add it to |used_mids|
     653// and return a reference to it.
     654// Generated MIDs should be no more than 3 bytes long to take up less space in
     655// the RTP packet.
     656const std::string& AllocateMid(std::set<std::string>* used_mids) {
     657  RTC_DCHECK(used_mids);
     658  // We're boring: just generate MIDs 0, 1, 2, ...
     659  size_t i = 0;
     660  std::set<std::string>::iterator it;
     661  bool inserted;
     662  do {
     663    std::string mid = rtc::ToString(i++);
     664    auto insert_result = used_mids->insert(mid);
     665    it = insert_result.first;
     666    inserted = insert_result.second;
     667  } while (!inserted);
     668  return *it;
    650669}
    651670
     
    22322251}
    22332252
     2253// The SDP parser used to populate these values by default for the 'content
     2254// name' if an a=mid line was absent.
     2255static absl::string_view GetDefaultMidForPlanB(cricket::MediaType media_type) {
     2256  switch (media_type) {
     2257    case cricket::MEDIA_TYPE_AUDIO:
     2258      return cricket::CN_AUDIO;
     2259    case cricket::MEDIA_TYPE_VIDEO:
     2260      return cricket::CN_VIDEO;
     2261    case cricket::MEDIA_TYPE_DATA:
     2262      return cricket::CN_DATA;
     2263  }
     2264  RTC_NOTREACHED();
     2265  return "";
     2266}
     2267
     2268void PeerConnection::FillInMissingRemoteMids(
     2269    cricket::SessionDescription* remote_description) {
     2270  RTC_DCHECK(remote_description);
     2271  const cricket::ContentInfos& local_contents =
     2272      (local_description() ? local_description()->description()->contents()
     2273                           : cricket::ContentInfos());
     2274  std::set<std::string> used_mids = seen_mids_;
     2275  for (size_t i = 0; i < remote_description->contents().size(); ++i) {
     2276    cricket::ContentInfo& content = remote_description->contents()[i];
     2277    if (!content.name.empty()) {
     2278      continue;
     2279    }
     2280    absl::string_view new_mid;
     2281    absl::string_view source_explanation;
     2282    if (IsUnifiedPlan()) {
     2283      if (i < local_contents.size()) {
     2284        new_mid = local_contents[i].name;
     2285        source_explanation = "from the matching local media section";
     2286      } else {
     2287        new_mid = AllocateMid(&used_mids);
     2288        source_explanation = "generated just now";
     2289      }
     2290    } else {
     2291      new_mid = GetDefaultMidForPlanB(content.media_description()->type());
     2292      source_explanation = "to match pre-existing behavior";
     2293    }
     2294    content.name = std::string(new_mid);
     2295    remote_description->transport_infos()[i].content_name =
     2296        std::string(new_mid);
     2297    RTC_LOG(LS_INFO) << "SetRemoteDescription: Remote media section at i=" << i
     2298                     << " is missing an a=mid line. Filling in the value '"
     2299                     << new_mid << "' " << source_explanation << ".";
     2300  }
     2301}
     2302
    22342303void PeerConnection::SetRemoteDescription(
    22352304    SetSessionDescriptionObserver* observer,
     
    22712340    ReportSdpFormatReceived(*desc);
    22722341  }
     2342
     2343  // Handle remote descriptions missing a=mid lines for interop with legacy end
     2344  // points.
     2345  FillInMissingRemoteMids(desc->description());
    22732346
    22742347  RTCError error = ValidateSessionDescription(desc.get(), cricket::CS_REMOTE);
     
    24572530      RtpTransceiverDirection local_direction =
    24582531          RtpTransceiverDirectionReversed(media_desc->direction());
    2459       // From the WebRTC specification, steps 2.2.8.5/6 of section 4.4.1.6 "Set
    2460       // the RTCSessionDescription: If direction is sendrecv or recvonly, and
    2461       // transceiver's current direction is neither sendrecv nor recvonly,
    2462       // process the addition of a remote track for the media description.
    2463       std::vector<std::string> stream_ids;
    2464       if (!media_desc->streams().empty()) {
    2465         // The remote description has signaled the stream IDs.
    2466         stream_ids = media_desc->streams()[0].stream_ids();
    2467       }
    2468       if (RtpTransceiverDirectionHasRecv(local_direction) &&
    2469           (!transceiver->fired_direction() ||
    2470            !RtpTransceiverDirectionHasRecv(*transceiver->fired_direction()))) {
    2471         RTC_LOG(LS_INFO) << "Processing the addition of a new track for MID="
    2472                          << content->name << " (added to "
    2473                          << GetStreamIdsString(stream_ids) << ").";
    2474 
    2475         std::vector<rtc::scoped_refptr<MediaStreamInterface>> media_streams;
    2476         for (const std::string& stream_id : stream_ids) {
    2477           rtc::scoped_refptr<MediaStreamInterface> stream =
    2478               remote_streams_->find(stream_id);
    2479           if (!stream) {
    2480             stream = MediaStreamProxy::Create(rtc::Thread::Current(),
    2481                                               MediaStream::Create(stream_id));
    2482             remote_streams_->AddStream(stream);
    2483             added_streams.push_back(stream);
    2484           }
    2485           media_streams.push_back(stream);
     2532      // Roughly the same as steps 2.2.8.6 of section 4.4.1.6 "Set the
     2533      // RTCSessionDescription: Set the associated remote streams given
     2534      // transceiver.[[Receiver]], msids, addList, and removeList".
     2535      // https://w3c.github.io/webrtc-pc/#set-the-rtcsessiondescription
     2536      if (RtpTransceiverDirectionHasRecv(local_direction)) {
     2537        std::vector<std::string> stream_ids;
     2538        if (!media_desc->streams().empty()) {
     2539          // The remote description has signaled the stream IDs.
     2540          stream_ids = media_desc->streams()[0].stream_ids();
    24862541        }
    2487         // Special case: "a=msid" missing, use random stream ID.
    2488         if (media_streams.empty() &&
    2489             !(remote_description()->description()->msid_signaling() &
    2490               cricket::kMsidSignalingMediaSection)) {
    2491           if (!missing_msid_default_stream_) {
    2492             missing_msid_default_stream_ = MediaStreamProxy::Create(
    2493                 rtc::Thread::Current(),
    2494                 MediaStream::Create(rtc::CreateRandomUuid()));
    2495             added_streams.push_back(missing_msid_default_stream_);
    2496           }
    2497           media_streams.push_back(missing_msid_default_stream_);
     2542        RTC_LOG(LS_INFO) << "Processing the MSIDs for MID=" << content->name
     2543                         << " (" << GetStreamIdsString(stream_ids) << ").";
     2544        SetAssociatedRemoteStreams(transceiver->internal()->receiver_internal(),
     2545                                   stream_ids, &added_streams,
     2546                                   &removed_streams);
     2547        // From the WebRTC specification, steps 2.2.8.5/6 of section 4.4.1.6
     2548        // "Set the RTCSessionDescription: If direction is sendrecv or recvonly,
     2549        // and transceiver's current direction is neither sendrecv nor recvonly,
     2550        // process the addition of a remote track for the media description.
     2551        if (!transceiver->fired_direction() ||
     2552            !RtpTransceiverDirectionHasRecv(*transceiver->fired_direction())) {
     2553          RTC_LOG(LS_INFO)
     2554              << "Processing the addition of a remote track for MID="
     2555              << content->name << ".";
     2556          now_receiving_transceivers.push_back(transceiver);
    24982557        }
    2499         // This will add the remote track to the streams.
    2500         // TODO(hbos): When we remove remote_streams(), use set_stream_ids()
    2501         // instead. https://crbug.com/webrtc/9480
    2502         transceiver->internal()->receiver_internal()->SetStreams(media_streams);
    2503         now_receiving_transceivers.push_back(transceiver);
    25042558      }
    25052559      // 2.2.8.1.7: If direction is "sendonly" or "inactive", and transceiver's
     
    26442698}
    26452699
     2700void PeerConnection::SetAssociatedRemoteStreams(
     2701    rtc::scoped_refptr<RtpReceiverInternal> receiver,
     2702    const std::vector<std::string>& stream_ids,
     2703    std::vector<rtc::scoped_refptr<MediaStreamInterface>>* added_streams,
     2704    std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams) {
     2705  std::vector<rtc::scoped_refptr<MediaStreamInterface>> media_streams;
     2706  for (const std::string& stream_id : stream_ids) {
     2707    rtc::scoped_refptr<MediaStreamInterface> stream =
     2708        remote_streams_->find(stream_id);
     2709    if (!stream) {
     2710      stream = MediaStreamProxy::Create(rtc::Thread::Current(),
     2711                                        MediaStream::Create(stream_id));
     2712      remote_streams_->AddStream(stream);
     2713      added_streams->push_back(stream);
     2714    }
     2715    media_streams.push_back(stream);
     2716  }
     2717  // Special case: "a=msid" missing, use random stream ID.
     2718  if (media_streams.empty() &&
     2719      !(remote_description()->description()->msid_signaling() &
     2720        cricket::kMsidSignalingMediaSection)) {
     2721    if (!missing_msid_default_stream_) {
     2722      missing_msid_default_stream_ = MediaStreamProxy::Create(
     2723          rtc::Thread::Current(), MediaStream::Create(rtc::CreateRandomUuid()));
     2724      added_streams->push_back(missing_msid_default_stream_);
     2725    }
     2726    media_streams.push_back(missing_msid_default_stream_);
     2727  }
     2728  std::vector<rtc::scoped_refptr<MediaStreamInterface>> previous_streams =
     2729      receiver->streams();
     2730  // SetStreams() will add/remove the receiver's track to/from the streams. This
     2731  // differs from the spec - the spec uses an "addList" and "removeList" to
     2732  // update the stream-track relationships in a later step. We do this earlier,
     2733  // changing the order of things, but the end-result is the same.
     2734  // TODO(hbos): When we remove remote_streams(), use set_stream_ids()
     2735  // instead. https://crbug.com/webrtc/9480
     2736  receiver->SetStreams(media_streams);
     2737  RemoveRemoteStreamsIfEmpty(previous_streams, removed_streams);
     2738}
     2739
    26462740void PeerConnection::ProcessRemovalOfRemoteTrack(
    26472741    rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
     
    26522746  RTC_LOG(LS_INFO) << "Processing the removal of a track for MID="
    26532747                   << *transceiver->mid();
    2654   std::vector<rtc::scoped_refptr<MediaStreamInterface>> media_streams =
     2748  std::vector<rtc::scoped_refptr<MediaStreamInterface>> previous_streams =
    26552749      transceiver->internal()->receiver_internal()->streams();
    26562750  // This will remove the remote track from the streams.
    26572751  transceiver->internal()->receiver_internal()->set_stream_ids({});
    26582752  remove_list->push_back(transceiver);
    2659   // Remove any streams that no longer have tracks.
    2660   // TODO(https://crbug.com/webrtc/9480): When we use stream IDs instead
    2661   // of streams, see if the stream was removed by checking if this was the
    2662   // last receiver with that stream ID.
    2663   for (const auto& stream : media_streams) {
    2664     if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) {
    2665       remote_streams_->RemoveStream(stream);
    2666       removed_streams->push_back(stream);
     2753  RemoveRemoteStreamsIfEmpty(previous_streams, removed_streams);
     2754}
     2755
     2756void PeerConnection::RemoveRemoteStreamsIfEmpty(
     2757    const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& remote_streams,
     2758    std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams) {
     2759  // TODO(https://crbug.com/webrtc/9480): When we use stream IDs instead of
     2760  // streams, see if the stream was removed by checking if this was the last
     2761  // receiver with that stream ID.
     2762  for (auto remote_stream : remote_streams) {
     2763    if (remote_stream->GetAudioTracks().empty() &&
     2764        remote_stream->GetVideoTracks().empty()) {
     2765      remote_streams_->RemoveStream(remote_stream);
     2766      removed_streams->push_back(remote_stream);
    26672767    }
    26682768  }
     
    39074007                      video_media_description_options,
    39084008                      offer_answer_options.num_simulcast_layers);
    3909 }
    3910 
    3911 // Find a new MID that is not already in |used_mids|, then add it to |used_mids|
    3912 // and return a reference to it.
    3913 // Generated MIDs should be no more than 3 bytes long to take up less space in
    3914 // the RTP packet.
    3915 static const std::string& AllocateMid(std::set<std::string>* used_mids) {
    3916   RTC_DCHECK(used_mids);
    3917   // We're boring: just generate MIDs 0, 1, 2, ...
    3918   size_t i = 0;
    3919   std::set<std::string>::iterator it;
    3920   bool inserted;
    3921   do {
    3922     std::string mid = rtc::ToString(i++);
    3923     auto insert_result = used_mids->insert(mid);
    3924     it = insert_result.first;
    3925     inserted = insert_result.second;
    3926   } while (!inserted);
    3927   return *it;
    39284009}
    39294010
     
    60876168}
    60886169
     6170static RTCError ValidateMids(const cricket::SessionDescription& description) {
     6171  std::set<std::string> mids;
     6172  for (const cricket::ContentInfo& content : description.contents()) {
     6173    if (content.name.empty()) {
     6174      LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
     6175                           "A media section is missing a MID attribute.");
     6176    }
     6177    if (!mids.insert(content.name).second) {
     6178      LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
     6179                           "Duplicate a=mid value '" + content.name + "'.");
     6180    }
     6181  }
     6182  return RTCError::OK();
     6183}
     6184
    60896185RTCError PeerConnection::ValidateSessionDescription(
    60906186    const SessionDescriptionInterface* sdesc,
     
    61046200        RTCErrorType::INVALID_STATE,
    61056201        "Called in wrong state: " + GetSignalingStateString(signaling_state()));
     6202  }
     6203
     6204  RTCError error = ValidateMids(*sdesc->description());
     6205  if (!error.ok()) {
     6206    return error;
    61066207  }
    61076208
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/peerconnection.h

    r239396 r240320  
    473473      const SessionDescriptionInterface* sdesc) const;
    474474
     475  // Runs the algorithm **set the associated remote streams** specified in
     476  // https://w3c.github.io/webrtc-pc/#set-associated-remote-streams.
     477  void SetAssociatedRemoteStreams(
     478      rtc::scoped_refptr<RtpReceiverInternal> receiver,
     479      const std::vector<std::string>& stream_ids,
     480      std::vector<rtc::scoped_refptr<MediaStreamInterface>>* added_streams,
     481      std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams);
     482
    475483  // Runs the algorithm **process the removal of a remote track** specified in
    476484  // the WebRTC specification.
     
    487495      std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams);
    488496
     497  void RemoveRemoteStreamsIfEmpty(
     498      const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
     499          remote_streams,
     500      std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams);
     501
    489502  void OnNegotiationNeeded();
    490503
     
    649662    return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan;
    650663  }
     664
     665  // The offer/answer machinery assumes the media section MID is present and
     666  // unique. To support legacy end points that do not supply a=mid lines, this
     667  // method will modify the session description to add MIDs generated according
     668  // to the SDP semantics.
     669  void FillInMissingRemoteMids(cricket::SessionDescription* remote_description);
    651670
    652671  // Is there an RtpSender of the given type?
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/peerconnection_jsep_unittest.cc

    r239136 r240320  
    16051605}
    16061606
     1607// Removes the RTP header extension associated with the given URI from the media
     1608// description.
     1609static void RemoveRtpHeaderExtensionByUri(
     1610    MediaContentDescription* media_description,
     1611    absl::string_view uri) {
     1612  std::vector<RtpExtension> header_extensions =
     1613      media_description->rtp_header_extensions();
     1614  header_extensions.erase(std::remove_if(
     1615      header_extensions.begin(), header_extensions.end(),
     1616      [uri](const RtpExtension& extension) { return extension.uri == uri; }));
     1617  media_description->set_rtp_header_extensions(header_extensions);
     1618}
     1619
     1620// Transforms a session description to emulate a legacy endpoint which does not
     1621// support a=mid, BUNDLE, and the MID header extension.
     1622static void ClearMids(SessionDescriptionInterface* sdesc) {
     1623  cricket::SessionDescription* desc = sdesc->description();
     1624  desc->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
     1625  cricket::ContentInfo* audio_content = cricket::GetFirstAudioContent(desc);
     1626  if (audio_content) {
     1627    desc->GetTransportInfoByName(audio_content->name)->content_name = "";
     1628    audio_content->name = "";
     1629    RemoveRtpHeaderExtensionByUri(audio_content->media_description(),
     1630                                  RtpExtension::kMidUri);
     1631  }
     1632  cricket::ContentInfo* video_content = cricket::GetFirstVideoContent(desc);
     1633  if (video_content) {
     1634    desc->GetTransportInfoByName(video_content->name)->content_name = "";
     1635    video_content->name = "";
     1636    RemoveRtpHeaderExtensionByUri(video_content->media_description(),
     1637                                  RtpExtension::kMidUri);
     1638  }
     1639}
     1640
     1641// Test that negotiation works with legacy endpoints which do not support a=mid.
     1642TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioOnlyOffer) {
     1643  auto caller = CreatePeerConnection();
     1644  caller->AddAudioTrack("audio");
     1645  auto callee = CreatePeerConnection();
     1646  callee->AddAudioTrack("audio");
     1647
     1648  auto offer = caller->CreateOffer();
     1649  ClearMids(offer.get());
     1650
     1651  ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
     1652  EXPECT_TRUE(callee->SetLocalDescription(callee->CreateAnswer()));
     1653}
     1654TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioVideoOffer) {
     1655  auto caller = CreatePeerConnection();
     1656  caller->AddAudioTrack("audio");
     1657  caller->AddVideoTrack("video");
     1658  auto callee = CreatePeerConnection();
     1659  callee->AddAudioTrack("audio");
     1660  callee->AddVideoTrack("video");
     1661
     1662  auto offer = caller->CreateOffer();
     1663  ClearMids(offer.get());
     1664
     1665  ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
     1666  EXPECT_TRUE(callee->SetLocalDescription(callee->CreateAnswer()));
     1667}
     1668TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioOnlyAnswer) {
     1669  auto caller = CreatePeerConnection();
     1670  caller->AddAudioTrack("audio");
     1671  auto callee = CreatePeerConnection();
     1672  callee->AddAudioTrack("audio");
     1673
     1674  ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
     1675
     1676  auto answer = callee->CreateAnswer();
     1677  ClearMids(answer.get());
     1678
     1679  EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer)));
     1680}
     1681TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioVideoAnswer) {
     1682  auto caller = CreatePeerConnection();
     1683  caller->AddAudioTrack("audio");
     1684  caller->AddVideoTrack("video");
     1685  auto callee = CreatePeerConnection();
     1686  callee->AddAudioTrack("audio");
     1687  callee->AddVideoTrack("video");
     1688
     1689  ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
     1690
     1691  auto answer = callee->CreateAnswer();
     1692  ClearMids(answer.get());
     1693
     1694  ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer)));
     1695}
     1696
     1697// Test that SetLocalDescription fails if a=mid lines are missing.
     1698TEST_F(PeerConnectionJsepTest, SetLocalDescriptionFailsMissingMid) {
     1699  auto caller = CreatePeerConnection();
     1700  caller->AddAudioTrack("audio");
     1701
     1702  auto offer = caller->CreateOffer();
     1703  ClearMids(offer.get());
     1704
     1705  std::string error;
     1706  ASSERT_FALSE(caller->SetLocalDescription(std::move(offer), &error));
     1707  EXPECT_EQ(
     1708      "Failed to set local offer sdp: A media section is missing a MID "
     1709      "attribute.",
     1710      error);
     1711}
     1712
    16071713}  // namespace webrtc
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/peerconnection_media_unittest.cc

    r238967 r240320  
    10851085}
    10861086
     1087// Test that SetRemoteDescription returns an error if there are two m= sections
     1088// with the same MID value.
     1089TEST_P(PeerConnectionMediaTest, SetRemoteDescriptionFailsWithDuplicateMids) {
     1090  auto caller = CreatePeerConnectionWithAudioVideo();
     1091  auto callee = CreatePeerConnectionWithAudioVideo();
     1092
     1093  auto offer = caller->CreateOffer();
     1094  RenameContent(offer->description(), cricket::MEDIA_TYPE_AUDIO, "same");
     1095  RenameContent(offer->description(), cricket::MEDIA_TYPE_VIDEO, "same");
     1096
     1097  std::string error;
     1098  EXPECT_FALSE(callee->SetRemoteDescription(std::move(offer), &error));
     1099  EXPECT_EQ(error,
     1100            "Failed to set remote offer sdp: Duplicate a=mid value 'same'.");
     1101}
     1102
    10871103TEST_P(PeerConnectionMediaTest,
    10881104       CombinedAudioVideoBweConfigPropagatedToMediaEngine) {
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/peerconnection_rtp_unittest.cc

    r238967 r240320  
    456456}
    457457
     458TEST_F(PeerConnectionRtpTestUnifiedPlan, ChangeMsidWhileReceiving) {
     459  auto caller = CreatePeerConnection();
     460  caller->AddAudioTrack("audio_track", {"stream1"});
     461  auto callee = CreatePeerConnection();
     462  ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOffer()));
     463
     464  ASSERT_EQ(1u, callee->observer()->on_track_transceivers_.size());
     465  auto transceiver = callee->observer()->on_track_transceivers_[0];
     466  ASSERT_EQ(1u, transceiver->receiver()->streams().size());
     467  EXPECT_EQ("stream1", transceiver->receiver()->streams()[0]->id());
     468
     469  ASSERT_TRUE(callee->SetLocalDescription(callee->CreateAnswer()));
     470
     471  // Change the stream ID in the offer.
     472  // TODO(https://crbug.com/webrtc/10129): When RtpSenderInterface::SetStreams
     473  // is supported, this can use that instead of munging the SDP.
     474  auto offer = caller->CreateOffer();
     475  auto contents = offer->description()->contents();
     476  ASSERT_EQ(1u, contents.size());
     477  auto& stream_params = contents[0].media_description()->mutable_streams();
     478  ASSERT_EQ(1u, stream_params.size());
     479  stream_params[0].set_stream_ids({"stream2"});
     480  ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
     481  ASSERT_EQ(1u, transceiver->receiver()->streams().size());
     482  EXPECT_EQ("stream2", transceiver->receiver()->streams()[0]->id());
     483}
     484
    458485// These tests examine the state of the peer connection as a result of
    459486// performing SetRemoteDescription().
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/sessiondescription.cc

    r238967 r240320  
    197197}
    198198
    199 bool SessionDescription::AddTransportInfo(const TransportInfo& transport_info) {
    200   if (GetTransportInfoByName(transport_info.content_name) != NULL) {
    201     return false;
    202   }
     199void SessionDescription::AddTransportInfo(const TransportInfo& transport_info) {
    203200  transport_infos_.push_back(transport_info);
    204   return true;
    205201}
    206202
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/sessiondescription.h

    r238967 r240320  
    448448  }
    449449  // Adds a TransportInfo to this description.
    450   // Returns false if a TransportInfo with the same name already exists.
    451   bool AddTransportInfo(const TransportInfo& transport_info);
     450  void AddTransportInfo(const TransportInfo& transport_info);
    452451  bool RemoveTransportInfoByName(const std::string& name);
    453452
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/webrtcsdp.cc

    r238967 r240320  
    23642364                                  webrtc::SdpParseError* error) {
    23652365  C* media_desc = new C();
    2366   switch (media_type) {
    2367     case cricket::MEDIA_TYPE_AUDIO:
    2368       *content_name = cricket::CN_AUDIO;
    2369       break;
    2370     case cricket::MEDIA_TYPE_VIDEO:
    2371       *content_name = cricket::CN_VIDEO;
    2372       break;
    2373     case cricket::MEDIA_TYPE_DATA:
    2374       *content_name = cricket::CN_DATA;
    2375       break;
    2376     default:
    2377       RTC_NOTREACHED();
    2378       break;
    2379   }
    23802366  if (!ParseContent(message, media_type, mline_index, protocol, payload_types,
    23812367                    pos, content_name, bundle_only, msid_signaling, media_desc,
     
    25602546                     content_rejected, bundle_only, content.release());
    25612547    // Create TransportInfo with the media level "ice-pwd" and "ice-ufrag".
    2562     TransportInfo transport_info(content_name, transport);
    2563 
    2564     if (!desc->AddTransportInfo(transport_info)) {
    2565       rtc::StringBuilder description;
    2566       description << "Failed to AddTransportInfo with content name: "
    2567                   << content_name;
    2568       return ParseFailed("", description.str(), error);
    2569     }
     2548    desc->AddTransportInfo(TransportInfo(content_name, transport));
    25702549  }
    25712550
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/pc/webrtcsdp_unittest.cc

    r239396 r240320  
    2626#include "rtc_base/stringencode.h"
    2727#include "rtc_base/stringutils.h"
     28#include "test/gmock.h"
     29#include "test/gtest.h"
    2830
    2931#ifdef WEBRTC_ANDROID
     
    3537using cricket::AudioContentDescription;
    3638using cricket::Candidate;
     39using cricket::ContentGroup;
    3740using cricket::ContentInfo;
    3841using cricket::CryptoParams;
    39 using cricket::ContentGroup;
    4042using cricket::DataCodec;
    4143using cricket::DataContentDescription;
     
    4446using cricket::kFecSsrcGroupSemantics;
    4547using cricket::LOCAL_PORT_TYPE;
     48using cricket::MediaProtocolType;
    4649using cricket::RELAY_PORT_TYPE;
    4750using cricket::SessionDescription;
    48 using cricket::MediaProtocolType;
    4951using cricket::StreamParams;
    5052using cricket::STUN_PORT_TYPE;
     
    5355using cricket::VideoCodec;
    5456using cricket::VideoContentDescription;
     57using ::testing::ElementsAre;
     58using ::testing::Field;
    5559using webrtc::IceCandidateCollection;
    5660using webrtc::IceCandidateInterface;
     
    916920
    917921    // TransportInfo
    918     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    919         kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice))));
    920     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    921         kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo))));
     922    desc_.AddTransportInfo(TransportInfo(
     923        kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice)));
     924    desc_.AddTransportInfo(TransportInfo(
     925        kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo)));
    922926
    923927    // v4 host
     
    11131117    audio_desc_2->AddStream(audio_track_2);
    11141118    desc_.AddContent(kAudioContentName2, MediaProtocolType::kRtp, audio_desc_2);
    1115     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1116         kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2))));
     1119    desc_.AddTransportInfo(TransportInfo(
     1120        kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)));
    11171121    // Video track 2, in stream 2.
    11181122    VideoContentDescription* video_desc_2 = CreateVideoContentDescription();
     
    11241128    video_desc_2->AddStream(video_track_2);
    11251129    desc_.AddContent(kVideoContentName2, MediaProtocolType::kRtp, video_desc_2);
    1126     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1127         kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2))));
     1130    desc_.AddTransportInfo(TransportInfo(
     1131        kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2)));
    11281132
    11291133    // Video track 3, in stream 2.
     
    11361140    video_desc_3->AddStream(video_track_3);
    11371141    desc_.AddContent(kVideoContentName3, MediaProtocolType::kRtp, video_desc_3);
    1138     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1139         kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3))));
     1142    desc_.AddTransportInfo(TransportInfo(
     1143        kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3)));
    11401144    desc_.set_msid_signaling(cricket::kMsidSignalingMediaSection);
    11411145
     
    11801184    audio_desc_2->AddStream(audio_track_2);
    11811185    desc_.AddContent(kAudioContentName2, MediaProtocolType::kRtp, audio_desc_2);
    1182     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1183         kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2))));
     1186    desc_.AddTransportInfo(TransportInfo(
     1187        kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)));
    11841188
    11851189    // Audio track 3 has no stream ids.
     
    11921196    audio_desc_3->AddStream(audio_track_3);
    11931197    desc_.AddContent(kAudioContentName3, MediaProtocolType::kRtp, audio_desc_3);
    1194     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1195         kAudioContentName3, TransportDescription(kUfragVoice3, kPwdVoice3))));
     1198    desc_.AddTransportInfo(TransportInfo(
     1199        kAudioContentName3, TransportDescription(kUfragVoice3, kPwdVoice3)));
    11961200    desc_.set_msid_signaling(msid_signaling);
    11971201    ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(),
     
    14651469        const_cast<SessionDescription*>(jdesc->description());
    14661470    desc->RemoveTransportInfoByName(content_name);
    1467     EXPECT_TRUE(desc->AddTransportInfo(transport_info));
     1471    desc->AddTransportInfo(transport_info);
    14681472    for (size_t i = 0; i < jdesc_.number_of_mediasections(); ++i) {
    14691473      const IceCandidateCollection* cc = jdesc_.candidates(i);
     
    15041508    desc_.RemoveTransportInfoByName(kVideoContentName);
    15051509    rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1, kIdentityDigest);
    1506     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
     1510    desc_.AddTransportInfo(TransportInfo(
    15071511        kAudioContentName,
    15081512        TransportDescription(std::vector<std::string>(), kUfragVoice, kPwdVoice,
    15091513                             cricket::ICEMODE_FULL,
    1510                              cricket::CONNECTIONROLE_NONE, &fingerprint))));
    1511     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
     1514                             cricket::CONNECTIONROLE_NONE, &fingerprint)));
     1515    desc_.AddTransportInfo(TransportInfo(
    15121516        kVideoContentName,
    15131517        TransportDescription(std::vector<std::string>(), kUfragVideo, kPwdVideo,
    15141518                             cricket::ICEMODE_FULL,
    1515                              cricket::CONNECTIONROLE_NONE, &fingerprint))));
     1519                             cricket::CONNECTIONROLE_NONE, &fingerprint)));
    15161520  }
    15171521
     
    16301634    desc_.AddContent(kDataContentName, MediaProtocolType::kSctp,
    16311635                     data.release());
    1632     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1633         kDataContentName, TransportDescription(kUfragData, kPwdData))));
     1636    desc_.AddTransportInfo(TransportInfo(
     1637        kDataContentName, TransportDescription(kUfragData, kPwdData)));
    16341638  }
    16351639
     
    16501654    data_desc_->set_protocol(cricket::kMediaProtocolSavpf);
    16511655    desc_.AddContent(kDataContentName, MediaProtocolType::kRtp, data.release());
    1652     EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
    1653         kDataContentName, TransportDescription(kUfragData, kPwdData))));
     1656    desc_.AddTransportInfo(TransportInfo(
     1657        kDataContentName, TransportDescription(kUfragData, kPwdData)));
    16541658  }
    16551659
     
    23012305  EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc));
    23022306  cricket::AudioContentDescription* audio =
    2303       jdesc.description()
    2304           ->GetContentDescriptionByName(cricket::CN_AUDIO)
    2305           ->as_audio();
     2307      cricket::GetFirstAudioContentDescription(jdesc.description());
    23062308  AudioCodecs ref_codecs;
    23072309  // The codecs in the AudioContentDescription should be in the same order as
     
    23262328  EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc));
    23272329  cricket::AudioContentDescription* audio =
    2328       jdesc.description()
    2329           ->GetContentDescriptionByName(cricket::CN_AUDIO)
    2330           ->as_audio();
     2330      cricket::GetFirstAudioContentDescription(jdesc.description());
    23312331
    23322332  cricket::AudioCodec g729 = audio->codecs()[0];
     
    29252925  // Verify
    29262926  cricket::AudioContentDescription* audio =
    2927       jdesc.description()
    2928           ->GetContentDescriptionByName(cricket::CN_AUDIO)
    2929           ->as_audio();
     2927      cricket::GetFirstAudioContentDescription(jdesc.description());
    29302928  EXPECT_TRUE(audio->conference_mode());
    29312929
    29322930  cricket::VideoContentDescription* video =
    2933       jdesc.description()
    2934           ->GetContentDescriptionByName(cricket::CN_VIDEO)
    2935           ->as_video();
     2931      cricket::GetFirstVideoContentDescription(jdesc.description());
    29362932  EXPECT_TRUE(video->conference_mode());
    29372933}
     
    29482944  // Verify.
    29492945  cricket::AudioContentDescription* audio =
    2950       jdesc.description()
    2951           ->GetContentDescriptionByName(cricket::CN_AUDIO)
    2952           ->as_audio();
     2946      cricket::GetFirstAudioContentDescription(jdesc.description());
    29532947  EXPECT_TRUE(audio->conference_mode());
    29542948
    29552949  cricket::VideoContentDescription* video =
    2956       jdesc.description()
    2957           ->GetContentDescriptionByName(cricket::CN_VIDEO)
    2958           ->as_video();
     2950      cricket::GetFirstVideoContentDescription(jdesc.description());
    29592951  EXPECT_TRUE(video->conference_mode());
    29602952}
     
    39103902  EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc));
    39113903}
     3904
     3905// Test that the content name is empty if the media section does not have an
     3906// a=mid line.
     3907TEST_F(WebRtcSdpTest, ParseNoMid) {
     3908  std::string sdp = kSdpString;
     3909  Replace("a=mid:audio_content_name\r\n", "", &sdp);
     3910  Replace("a=mid:video_content_name\r\n", "", &sdp);
     3911
     3912  JsepSessionDescription output(kDummyType);
     3913  SdpParseError error;
     3914  ASSERT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error));
     3915
     3916  EXPECT_THAT(output.description()->contents(),
     3917              ElementsAre(Field("name", &cricket::ContentInfo::name, ""),
     3918                          Field("name", &cricket::ContentInfo::name, "")));
     3919}
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/system_wrappers/include/metrics.h

    r238967 r240320  
    134134// which is already sparse, and remove the boundary argument from the macro.
    135135#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \
    136   RTC_HISTOGRAM_COMMON_BLOCK(                                    \
     136  RTC_HISTOGRAM_COMMON_BLOCK_SLOW(                               \
    137137      name, sample,                                              \
    138138      webrtc::metrics::SparseHistogramFactoryGetEnumeration(name, boundary))
     
    149149// |boundary| should be above the max enumerator sample.
    150150#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
    151   RTC_HISTOGRAM_COMMON_BLOCK(                             \
     151  RTC_HISTOGRAM_COMMON_BLOCK_SLOW(                        \
    152152      name, sample,                                       \
    153153      webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary))
     
    176176  } while (0)
    177177
    178 // Deprecated.
    179178// The histogram is constructed/found for each call.
    180179// May be used for histograms with infrequent updates.`
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/video/BUILD.gn

    r238967 r240320  
    182182    "../modules/video_coding",
    183183    "../modules/video_coding:video_coding_utility",
     184    "../modules/video_coding:webrtc_vp9_helpers",
    184185    "../rtc_base:checks",
    185186    "../rtc_base:criticalsection",
Note: See TracChangeset for help on using the changeset viewer.