tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ba363bb0dd690b5cede2897d896218542de15fb4
parent c60e4f51ca9cd4ac09f1da19e7c43180f917d8ab
Author: Dan Baker <dbaker@mozilla.com>
Date:   Wed, 19 Nov 2025 21:29:10 -0700

Bug 2000941 - Vendor libwebrtc from 824c352e6f

Upstream commit: https://webrtc.googlesource.com/src/+/824c352e6fe8f821798bb65ee3b09ec757597270
    Start removing JsepSessionDescription::Initialize()

    This CL starts to decouple direct usage of the JsepSessionDescription
    class and encourage the public factory functions that deal with
    SessionDescriptionInterface. The Initialize() method is not removed, but
    in a few places where we unnecessarily were using JsepSessionDescription
    + Initialize, we now just use the api.

    This CL also introduces SdpDeserialize with SessionDescriptionInterface
    which will help transition downstream code away from
    JsepSessionDescription.

    Bug: webrtc:442220720
    Change-Id: I80ef4617d9dff20dbc541690932d67505276b444
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/407444
    Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
    Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45535}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/api/jsep_session_description.h | 4++++
Mthird_party/libwebrtc/pc/jsep_session_description.cc | 9++++-----
Mthird_party/libwebrtc/pc/jsep_session_description_unittest.cc | 8++++----
Mthird_party/libwebrtc/pc/peer_connection_histogram_unittest.cc | 5++---
Mthird_party/libwebrtc/pc/sdp_utils.cc | 11++++-------
Mthird_party/libwebrtc/pc/webrtc_sdp.cc | 40++++++++++++++++++++++++++++++++++++++++
Mthird_party/libwebrtc/pc/webrtc_sdp.h | 15+++++++++++++++
Mthird_party/libwebrtc/test/pc/e2e/sdp/sdp_changer.cc | 16++++++++--------
9 files changed, 83 insertions(+), 29 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-11-20T04:26:35.127523+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-11-20T04:28:55.921938+00:00. # base of lastest vendoring -06875c48fb +824c352e6f diff --git a/third_party/libwebrtc/api/jsep_session_description.h b/third_party/libwebrtc/api/jsep_session_description.h @@ -43,6 +43,10 @@ class JsepSessionDescription final : public SessionDescriptionInterface { JsepSessionDescription& operator=(const JsepSessionDescription&) = delete; // Takes ownership of `description`. + // TODO(bugs.webrtc.org/442220720): Deprecate. + // [[deprecated( + // "Use CreateSessionDescription() to construct + // SessionDescriptionInterface objects.")]] bool Initialize(std::unique_ptr<SessionDescription> description, const std::string& session_id, const std::string& session_version); diff --git a/third_party/libwebrtc/pc/jsep_session_description.cc b/third_party/libwebrtc/pc/jsep_session_description.cc @@ -148,11 +148,10 @@ std::unique_ptr<SessionDescriptionInterface> CreateSessionDescription( const std::string& session_id, const std::string& session_version, std::unique_ptr<SessionDescription> description) { - auto jsep_description = std::make_unique<JsepSessionDescription>(type); - bool initialize_success = jsep_description->Initialize( - std::move(description), session_id, session_version); - RTC_DCHECK(initialize_success); - return std::move(jsep_description); + if (!description) + return nullptr; + return std::make_unique<JsepSessionDescription>(type, std::move(description), + session_id, session_version); } JsepSessionDescription::JsepSessionDescription(SdpType type) : type_(type) {} diff --git a/third_party/libwebrtc/pc/jsep_session_description_unittest.cc b/third_party/libwebrtc/pc/jsep_session_description_unittest.cc @@ -91,9 +91,9 @@ class JsepSessionDescriptionTest : public ::testing::Test { candidate_ = candidate; const std::string session_id = absl::StrCat(CreateRandomId64()); const std::string session_version = absl::StrCat(CreateRandomId()); - jsep_desc_ = std::make_unique<JsepSessionDescription>(SdpType::kOffer); - ASSERT_TRUE(jsep_desc_->Initialize(CreateCricketSessionDescription(), - session_id, session_version)); + jsep_desc_ = + CreateSessionDescription(SdpType::kOffer, session_id, session_version, + CreateCricketSessionDescription()); } std::string Serialize(const SessionDescriptionInterface* desc) { @@ -111,7 +111,7 @@ class JsepSessionDescriptionTest : public ::testing::Test { } Candidate candidate_; - std::unique_ptr<JsepSessionDescription> jsep_desc_; + std::unique_ptr<SessionDescriptionInterface> jsep_desc_; }; TEST_F(JsepSessionDescriptionTest, CloneDefault) { diff --git a/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc b/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc @@ -692,9 +692,8 @@ TEST_F(PeerConnectionUsageHistogramTest, ASSERT_TRUE(cur_offer); std::string sdp_with_candidates_str; cur_offer->ToString(&sdp_with_candidates_str); - auto offer = std::make_unique<JsepSessionDescription>(SdpType::kOffer); - ASSERT_TRUE(SdpDeserialize(sdp_with_candidates_str, offer.get(), - nullptr /* error */)); + std::unique_ptr<SessionDescriptionInterface> offer = + SdpDeserialize(SdpType::kOffer, sdp_with_candidates_str); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); // By default, the Answer created does not contain ICE candidates. diff --git a/third_party/libwebrtc/pc/sdp_utils.cc b/third_party/libwebrtc/pc/sdp_utils.cc @@ -31,15 +31,12 @@ std::unique_ptr<SessionDescriptionInterface> CloneSessionDescriptionAsType( const SessionDescriptionInterface* sdesc, SdpType type) { RTC_DCHECK(sdesc); - auto clone = std::make_unique<JsepSessionDescription>(type); if (sdesc->description()) { - clone->Initialize(sdesc->description()->Clone(), sdesc->session_id(), - sdesc->session_version()); + return CreateSessionDescription(type, sdesc->session_id(), + sdesc->session_version(), + sdesc->description()->Clone()); } - // As of writing, our version of GCC does not allow returning a unique_ptr of - // a subclass as a unique_ptr of a base class. To get around this, we need to - // std::move the return value. - return std::move(clone); + return std::make_unique<JsepSessionDescription>(type); } bool SdpContentsAll(SdpContentPredicate pred, const SessionDescription* desc) { diff --git a/third_party/libwebrtc/pc/webrtc_sdp.cc b/third_party/libwebrtc/pc/webrtc_sdp.cc @@ -3376,6 +3376,46 @@ bool SdpDeserialize(absl::string_view message, return true; } +std::unique_ptr<SessionDescriptionInterface> SdpDeserialize( + SdpType sdp_type, + absl::string_view message, + SdpParseError* absl_nullable error) { + std::string session_id; + std::string session_version; + TransportDescription session_td("", ""); + RtpHeaderExtensions session_extmaps; + SocketAddress session_connection_addr; + auto desc = std::make_unique<SessionDescription>(); + size_t current_pos = 0; + + // Session Description + if (!ParseSessionDescription(message, &current_pos, &session_id, + &session_version, &session_td, &session_extmaps, + &session_connection_addr, desc.get(), error)) { + return nullptr; + } + + // Media Description + std::vector<std::unique_ptr<IceCandidate>> candidates; + if (!ParseMediaDescription(message, session_td, session_extmaps, &current_pos, + session_connection_addr, desc.get(), &candidates, + error)) { + return nullptr; + } + + std::unique_ptr<SessionDescriptionInterface> description = + CreateSessionDescription(sdp_type, session_id, session_version, + std::move(desc)); + if (!description) { + return nullptr; + } + for (const auto& candidate : candidates) { + description->AddCandidate(candidate.get()); + } + + return description; +} + bool SdpDeserializeCandidate(absl::string_view transport_name, absl::string_view message, Candidate* candidate, diff --git a/third_party/libwebrtc/pc/webrtc_sdp.h b/third_party/libwebrtc/pc/webrtc_sdp.h @@ -20,8 +20,10 @@ #ifndef PC_WEBRTC_SDP_H_ #define PC_WEBRTC_SDP_H_ +#include <memory> #include <string> +#include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/jsep.h" @@ -54,10 +56,23 @@ RTC_EXPORT std::string SdpSerializeCandidate(const Candidate& candidate); // jdesc - The JsepSessionDescription deserialized from the SDP string. // error - The detail error information when parsing fails. // return - true on success, false on failure. +// TODO: bugs.webrtc.org/442220720 - Mark as deprecated and favour +// SdpDeserialize() that accepts an SdpType and returns a session description +// object. bool SdpDeserialize(absl::string_view message, JsepSessionDescription* jdesc, SdpParseError* error); +// Deserializes the `sdp` to construct a SessionDescriptionInterface object. +// sdp_type - The type of session description object that should be constructed. +// sdp - The SDP string to be Deserialized. +// error - Optional detail error information when parsing fails. +// return - A new session description object if successful, otherwise nullptr. +absl_nullable std::unique_ptr<SessionDescriptionInterface> SdpDeserialize( + SdpType sdp_type, + absl::string_view sdp, + SdpParseError* absl_nullable error = nullptr); + // Deserializes the passed in SDP string to a cricket Candidate. // The first line must be a=candidate line and only the first line will be // parsed. diff --git a/third_party/libwebrtc/test/pc/e2e/sdp/sdp_changer.cc b/third_party/libwebrtc/test/pc/e2e/sdp/sdp_changer.cc @@ -309,10 +309,10 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp8Offer( desc->set_transport_infos(transport_infos); // Create patched offer. - auto patched_offer = - std::make_unique<JsepSessionDescription>(SdpType::kOffer); - patched_offer->Initialize(std::move(desc), offer->session_id(), - offer->session_version()); + std::unique_ptr<SessionDescriptionInterface> patched_offer = + CreateSessionDescription(SdpType::kOffer, offer->session_id(), + offer->session_version(), std::move(desc)); + return LocalAndRemoteSdp(std::move(offer), std::move(patched_offer)); } @@ -497,10 +497,10 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp8Answer( } desc->set_transport_infos(transport_infos); - auto patched_answer = - std::make_unique<JsepSessionDescription>(SdpType::kAnswer); - patched_answer->Initialize(std::move(desc), answer->session_id(), - answer->session_version()); + std::unique_ptr<SessionDescriptionInterface> patched_answer = + CreateSessionDescription(SdpType::kAnswer, answer->session_id(), + answer->session_version(), std::move(desc)); + return LocalAndRemoteSdp(std::move(answer), std::move(patched_answer)); }