commit e4acecf36c2155faf50a6cafaa09d05e66c91765
parent 71efddbb34e1193157ccbdeb703f1c04e0a68512
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 1 Dec 2025 21:31:10 -0700
Bug 2000941 - Vendor libwebrtc from b83fd4628c
Upstream commit: https://webrtc.googlesource.com/src/+/b83fd4628c44d72c68c6d005d5aa746df8d83915
Move candidates logic to SessionDescriptionInterface
...from JsepSessionDescription.
The `JsepSessionDescription` class was the sole implementation of the
`SessionDescriptionInterface` and still held the state and logic for
managing ICE candidates although all other state has already
been moved to `SessionDescriptionInterface`. This additional layer of
abstraction is now for the most part removed. `JsepSessionDescription`
still exists for compatibility reasons with downstream code.
`SessionDescriptionInterface` is no longer a pure abstract class and now
contains the default implementation for candidate management. A new
static `SessionDescriptionInterface::Create` factory method is
introduced to handle instantiation, and all existing factory functions
are updated to use it.
Bug: webrtc:442220720
Change-Id: I732938a958310c60a9a83592fb9b11e27778d77e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/409880
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45670}
Diffstat:
8 files changed, 78 insertions(+), 53 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:27:40.711574+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:30:56.067111+00:00.
# base of lastest vendoring
-22fd6f0934
+b83fd4628c
diff --git a/third_party/libwebrtc/api/jsep.h b/third_party/libwebrtc/api/jsep.h
@@ -269,6 +269,17 @@ class SessionDescriptionInternal {
class RTC_EXPORT SessionDescriptionInterface
: public SessionDescriptionInternal {
public:
+ static std::unique_ptr<SessionDescriptionInterface> Create(
+ SdpType type,
+ std::unique_ptr<SessionDescription> description,
+ absl::string_view id,
+ absl::string_view version,
+ std::vector<IceCandidateCollection> candidates = {});
+
+ SessionDescriptionInterface(const SessionDescriptionInterface&) = delete;
+ SessionDescriptionInterface& operator=(const SessionDescriptionInterface&) =
+ delete;
+
// String representations of the supported SDP types.
static const char kOffer[];
static const char kPrAnswer[];
@@ -279,7 +290,7 @@ class RTC_EXPORT SessionDescriptionInterface
// Create a new SessionDescriptionInterface object
// with the same values as the old object.
- virtual std::unique_ptr<SessionDescriptionInterface> Clone() const = 0;
+ virtual std::unique_ptr<SessionDescriptionInterface> Clone() const;
// Only for use internally.
virtual SessionDescription* description() {
@@ -308,7 +319,7 @@ class RTC_EXPORT SessionDescriptionInterface
// Returns false if the session description does not have a media section
// that corresponds to `candidate.sdp_mid()` or
// `candidate.sdp_mline_index()`.
- virtual bool AddCandidate(const IceCandidate* candidate) = 0;
+ virtual bool AddCandidate(const IceCandidate* candidate);
// Removes the first matching candidate (at most 1) from the description
// that meets the `Candidate::MatchesForRemoval()` requirement and matches
@@ -316,7 +327,7 @@ class RTC_EXPORT SessionDescriptionInterface
// `IceCandidate::sdp_mline_index()`.
//
// Returns false if no matching candidate was found (and removed).
- virtual bool RemoveCandidate(const IceCandidate* candidate) = 0;
+ virtual bool RemoveCandidate(const IceCandidate* candidate);
// Returns the number of m= sections in the session description.
virtual size_t number_of_mediasections() const {
@@ -326,10 +337,11 @@ class RTC_EXPORT SessionDescriptionInterface
// Returns a collection of all candidates that belong to a certain m=
// section.
virtual const IceCandidateCollection* candidates(
- size_t mediasection_index) const = 0;
+ size_t mediasection_index) const;
// Serializes the description to SDP.
- virtual bool ToString(std::string* out) const = 0;
+ virtual bool ToString(std::string* out) const;
+
template <typename Sink>
friend void AbslStringify(Sink& sink, const SessionDescriptionInterface& p) {
sink.Append("\n--- BEGIN SDP ");
@@ -349,7 +361,16 @@ class RTC_EXPORT SessionDescriptionInterface
SdpType type,
std::unique_ptr<SessionDescription> description,
absl::string_view id,
- absl::string_view version);
+ absl::string_view version,
+ std::vector<IceCandidateCollection> candidates = {});
+
+ private:
+ bool IsValidMLineIndex(int index) const;
+ bool GetMediasectionIndex(const IceCandidate* candidate, size_t* index) const;
+ int GetMediasectionIndex(absl::string_view mid) const;
+
+ std::vector<IceCandidateCollection> candidate_collection_
+ RTC_GUARDED_BY(sequence_checker());
};
// Creates a SessionDescriptionInterface based on the SDP string and the type.
diff --git a/third_party/libwebrtc/api/jsep_session_description.h b/third_party/libwebrtc/api/jsep_session_description.h
@@ -45,21 +45,6 @@ class JsepSessionDescription final : public SessionDescriptionInterface {
JsepSessionDescription(const JsepSessionDescription&) = delete;
JsepSessionDescription& operator=(const JsepSessionDescription&) = delete;
-
- std::unique_ptr<SessionDescriptionInterface> Clone() const override;
- bool AddCandidate(const IceCandidate* candidate) override;
- bool RemoveCandidate(const IceCandidate* candidate) override;
- const IceCandidateCollection* candidates(
- size_t mediasection_index) const override;
- bool ToString(std::string* out) const override;
-
- private:
- std::vector<IceCandidateCollection> candidate_collection_
- RTC_GUARDED_BY(sequence_checker());
-
- bool IsValidMLineIndex(int index) const;
- bool GetMediasectionIndex(const IceCandidate* candidate, size_t* index) const;
- int GetMediasectionIndex(absl::string_view mid) const;
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch
@@ -601,7 +601,7 @@ index b7561e53b6..fe7eb57423 100644
import("../../webrtc.gni")
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
-index 97b3af690e..5fc4b44f21 100644
+index deb0435c15..44d226504f 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -30,8 +30,8 @@
diff --git a/third_party/libwebrtc/pc/BUILD.gn b/third_party/libwebrtc/pc/BUILD.gn
@@ -1457,6 +1457,7 @@ rtc_library("webrtc_sdp") {
"../rtc_base/system:rtc_export",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/base:nullability",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/strings:string_view",
]
diff --git a/third_party/libwebrtc/pc/jsep_session_description.cc b/third_party/libwebrtc/pc/jsep_session_description.cc
@@ -19,6 +19,7 @@
#include <utility>
#include <vector>
+#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "api/candidate.h"
#include "api/jsep.h"
@@ -137,19 +138,31 @@ std::unique_ptr<SessionDescriptionInterface> CreateSessionDescription(
const std::string& session_id,
const std::string& session_version,
std::unique_ptr<SessionDescription> description) {
- if (!description && type != SdpType::kRollback)
- return nullptr;
- return std::make_unique<JsepSessionDescription>(type, std::move(description),
- session_id, session_version);
+ return SessionDescriptionInterface::Create(type, std::move(description),
+ session_id, session_version);
}
std::unique_ptr<SessionDescriptionInterface> CreateRollbackSessionDescription(
absl::string_view session_id,
absl::string_view session_version) {
- return std::make_unique<JsepSessionDescription>(
+ return SessionDescriptionInterface::Create(
SdpType::kRollback, /*description=*/nullptr, session_id, session_version);
}
+// static
+std::unique_ptr<SessionDescriptionInterface>
+SessionDescriptionInterface::Create(
+ SdpType type,
+ std::unique_ptr<SessionDescription> description,
+ absl::string_view id,
+ absl::string_view version,
+ std::vector<IceCandidateCollection> candidates) {
+ if (!description && type != SdpType::kRollback)
+ return nullptr;
+ return absl::WrapUnique(new SessionDescriptionInterface(
+ type, std::move(description), id, version, std::move(candidates)));
+}
+
SessionDescriptionInternal::SessionDescriptionInternal(
SdpType type,
std::unique_ptr<SessionDescription> description,
@@ -180,10 +193,17 @@ void SessionDescriptionInternal::RelinquishThreadOwnership() {
SessionDescriptionInterface::SessionDescriptionInterface(
SdpType type,
- std::unique_ptr<SessionDescription> description,
+ std::unique_ptr<SessionDescription> desc,
absl::string_view id,
- absl::string_view version)
- : SessionDescriptionInternal(type, std::move(description), id, version) {}
+ absl::string_view version,
+ std::vector<IceCandidateCollection> candidates)
+ : SessionDescriptionInternal(type, std::move(desc), id, version),
+ candidate_collection_(std::move(candidates)) {
+ RTC_DCHECK(description() || type == SdpType::kRollback);
+ RTC_DCHECK(candidate_collection_.empty() ||
+ candidate_collection_.size() == number_of_mediasections());
+ candidate_collection_.resize(number_of_mediasections());
+}
JsepSessionDescription::JsepSessionDescription(SdpType type)
: SessionDescriptionInterface(type, nullptr, "", "") {}
@@ -197,25 +217,20 @@ JsepSessionDescription::JsepSessionDescription(
: SessionDescriptionInterface(type,
std::move(desc),
session_id,
- session_version),
- candidate_collection_(std::move(candidates)) {
- RTC_DCHECK(description() || type == SdpType::kRollback);
- RTC_DCHECK(candidate_collection_.empty() ||
- candidate_collection_.size() == number_of_mediasections());
- candidate_collection_.resize(number_of_mediasections());
-}
+ session_version,
+ std::move(candidates)) {}
JsepSessionDescription::~JsepSessionDescription() {}
-std::unique_ptr<SessionDescriptionInterface> JsepSessionDescription::Clone()
- const {
+std::unique_ptr<SessionDescriptionInterface>
+SessionDescriptionInterface::Clone() const {
RTC_DCHECK_RUN_ON(sequence_checker());
- return std::make_unique<JsepSessionDescription>(
+ return SessionDescriptionInterface::Create(
sdp_type(), description() ? description()->Clone() : nullptr, id(),
version(), CloneCandidateCollection(candidate_collection_));
}
-bool JsepSessionDescription::AddCandidate(const IceCandidate* candidate) {
+bool SessionDescriptionInterface::AddCandidate(const IceCandidate* candidate) {
RTC_DCHECK_RUN_ON(sequence_checker());
if (!candidate)
return false;
@@ -257,7 +272,8 @@ bool JsepSessionDescription::AddCandidate(const IceCandidate* candidate) {
return true;
}
-bool JsepSessionDescription::RemoveCandidate(const IceCandidate* candidate) {
+bool SessionDescriptionInterface::RemoveCandidate(
+ const IceCandidate* candidate) {
RTC_DCHECK_RUN_ON(sequence_checker());
size_t index = 0u;
if (!GetMediasectionIndex(candidate, &index)) {
@@ -272,7 +288,7 @@ bool JsepSessionDescription::RemoveCandidate(const IceCandidate* candidate) {
return true;
}
-const IceCandidateCollection* JsepSessionDescription::candidates(
+const IceCandidateCollection* SessionDescriptionInterface::candidates(
size_t mediasection_index) const {
RTC_DCHECK_RUN_ON(sequence_checker());
if (mediasection_index >= candidate_collection_.size())
@@ -280,7 +296,7 @@ const IceCandidateCollection* JsepSessionDescription::candidates(
return &candidate_collection_[mediasection_index];
}
-bool JsepSessionDescription::ToString(std::string* out) const {
+bool SessionDescriptionInterface::ToString(std::string* out) const {
if (!description() || !out) {
return false;
}
@@ -288,14 +304,15 @@ bool JsepSessionDescription::ToString(std::string* out) const {
return !out->empty();
}
-bool JsepSessionDescription::IsValidMLineIndex(int index) const {
+bool SessionDescriptionInterface::IsValidMLineIndex(int index) const {
RTC_DCHECK(description());
return index >= 0 &&
index < static_cast<int>(description()->contents().size());
}
-bool JsepSessionDescription::GetMediasectionIndex(const IceCandidate* candidate,
- size_t* index) const {
+bool SessionDescriptionInterface::GetMediasectionIndex(
+ const IceCandidate* candidate,
+ size_t* index) const {
if (!candidate || !index || !description()) {
return false;
}
@@ -310,7 +327,8 @@ bool JsepSessionDescription::GetMediasectionIndex(const IceCandidate* candidate,
return IsValidMLineIndex(*index);
}
-int JsepSessionDescription::GetMediasectionIndex(absl::string_view mid) const {
+int SessionDescriptionInterface::GetMediasectionIndex(
+ absl::string_view mid) const {
const auto& contents = description()->contents();
auto it =
std::find_if(contents.begin(), contents.end(),
diff --git a/third_party/libwebrtc/pc/sdp_utils.cc b/third_party/libwebrtc/pc/sdp_utils.cc
@@ -37,7 +37,7 @@ std::unique_ptr<SessionDescriptionInterface> CloneSessionDescriptionAsType(
sdesc->description()->Clone());
}
RTC_DCHECK_EQ(type, SdpType::kRollback);
- return std::make_unique<JsepSessionDescription>(type, nullptr, "", "");
+ return SessionDescriptionInterface::Create(type, nullptr, "", "");
}
bool SdpContentsAll(SdpContentPredicate pred, const SessionDescription* desc) {
diff --git a/third_party/libwebrtc/pc/webrtc_session_description_factory.cc b/third_party/libwebrtc/pc/webrtc_session_description_factory.cc
@@ -296,7 +296,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
// is created regardless if it's identical to the previous one or not.
// The `session_version_` is a uint64_t, the wrap around should not happen.
RTC_DCHECK(session_version_ + 1 > session_version_);
- auto offer = std::make_unique<JsepSessionDescription>(
+ auto offer = SessionDescriptionInterface::Create(
SdpType::kOffer, std::move(desc), session_id_,
absl::StrCat(session_version_++));
if (sdp_info_->local_description()) {
@@ -355,7 +355,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
// Get a new version number by increasing the `session_version_answer_`.
// The `session_version_` is a uint64_t, the wrap around should not happen.
RTC_DCHECK(session_version_ + 1 > session_version_);
- auto answer = std::make_unique<JsepSessionDescription>(
+ auto answer = SessionDescriptionInterface::Create(
SdpType::kAnswer, std::move(desc), session_id_,
absl::StrCat(session_version_++));
if (sdp_info_->local_description()) {