Bug 1952339 - Vendor libwebrtc from 5f8bcf9fc8

Upstream commit: https://webrtc.googlesource.com/src/+/5f8bcf9fc880d673c1bec571d77dbdbb1325e3d9
    Move unique_id_generator.h to webrtc namespace

    Bug: webrtc:42232595
    Change-Id: I9690d88f920b2623f82bddd76e5583006ed2cc07
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/378860
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#43985}

Differential Revision: https://phabricator.services.mozilla.com/D243991
This commit is contained in:
Michael Froman
2025-03-07 16:36:33 -06:00
parent d30d26b5c4
commit 9dc1aa8e38
18 changed files with 58 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-03-07T22:35:34.289187+00:00.
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-03-07T22:36:23.476168+00:00.
# base of lastest vendoring
d3cb43adf8
5f8bcf9fc8

View File

@@ -232,7 +232,7 @@ TEST(StreamParams, ToString) {
}
TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithRtxAndFlex) {
rtc::UniqueRandomIdGenerator generator;
webrtc::UniqueRandomIdGenerator generator;
cricket::StreamParams stream;
stream.GenerateSsrcs(1, true, true, &generator);
uint32_t primary_ssrc = stream.first_ssrc();
@@ -250,7 +250,7 @@ TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithRtxAndFlex) {
}
TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithRtx) {
rtc::UniqueRandomIdGenerator generator;
webrtc::UniqueRandomIdGenerator generator;
cricket::StreamParams stream;
stream.GenerateSsrcs(1, true, false, &generator);
uint32_t primary_ssrc = stream.first_ssrc();
@@ -267,7 +267,7 @@ TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithRtx) {
}
TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithFlex) {
rtc::UniqueRandomIdGenerator generator;
webrtc::UniqueRandomIdGenerator generator;
cricket::StreamParams stream;
stream.GenerateSsrcs(1, false, true, &generator);
uint32_t primary_ssrc = stream.first_ssrc();
@@ -285,7 +285,7 @@ TEST(StreamParams, TestGenerateSsrcs_SingleStreamWithFlex) {
TEST(StreamParams, TestGenerateSsrcs_SimulcastLayersAndRtx) {
const size_t kNumStreams = 3;
rtc::UniqueRandomIdGenerator generator;
webrtc::UniqueRandomIdGenerator generator;
cricket::StreamParams stream;
stream.GenerateSsrcs(kNumStreams, true, false, &generator);
EXPECT_EQ(kNumStreams * 2, stream.ssrcs.size());

View File

@@ -644,7 +644,7 @@ index 3053b829f2..703e561c85 100644
import("../../webrtc.gni")
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 8c515bc4d8..b80d1483f6 100644
index 332a87a7c6..8b99d22469 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -30,8 +30,8 @@

View File

@@ -871,6 +871,7 @@ rtc_library("connection_context") {
"../rtc_base:socket_server",
"../rtc_base:threading",
"../rtc_base:timeutils",
"../rtc_base:unique_id_generator",
"../rtc_base/memory:always_valid_pointer",
]
}

View File

@@ -137,7 +137,7 @@ BaseChannel::BaseChannel(
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
rtc::UniqueRandomIdGenerator* ssrc_generator)
: media_send_channel_(std::move(send_media_channel_impl)),
media_receive_channel_(std::move(receive_media_channel_impl)),
worker_thread_(worker_thread),
@@ -856,7 +856,7 @@ VoiceChannel::VoiceChannel(
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
rtc::UniqueRandomIdGenerator* ssrc_generator)
: BaseChannel(worker_thread,
network_thread,
signaling_thread,
@@ -998,7 +998,7 @@ VideoChannel::VideoChannel(
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
rtc::UniqueRandomIdGenerator* ssrc_generator)
: BaseChannel(worker_thread,
network_thread,
signaling_thread,

View File

@@ -1589,7 +1589,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
rtc::Buffer rtp_packet_;
rtc::Buffer rtcp_packet_;
cricket::CandidatePairInterface* last_selected_candidate_pair_;
rtc::UniqueRandomIdGenerator ssrc_generator_;
webrtc::UniqueRandomIdGenerator ssrc_generator_;
webrtc::test::ScopedKeyValueConfig field_trials_;
};

View File

@@ -30,10 +30,10 @@
#include "rtc_base/socket_factory.h"
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/unique_id_generator.h"
namespace rtc {
class BasicPacketSocketFactory;
class UniqueRandomIdGenerator;
} // namespace rtc
namespace webrtc {
@@ -91,7 +91,7 @@ class ConnectionContext final : public RefCountedNonVirtual<ConnectionContext> {
RTC_DCHECK_RUN_ON(worker_thread());
return call_factory_.get();
}
rtc::UniqueRandomIdGenerator* ssrc_generator() { return &ssrc_generator_; }
UniqueRandomIdGenerator* ssrc_generator() { return &ssrc_generator_; }
// Note: There is lots of code that wants to know whether or not we
// use RTX, but so far, no code has been found that sets it to false.
// Kept in the API in order to ease introduction if we want to resurrect
@@ -129,7 +129,7 @@ class ConnectionContext final : public RefCountedNonVirtual<ConnectionContext> {
// specified by the user (or by the remote party).
// TODO(bugs.webrtc.org/12666): This variable is used from both the signaling
// and worker threads. See if we can't restrict usage to a single thread.
rtc::UniqueRandomIdGenerator ssrc_generator_;
UniqueRandomIdGenerator ssrc_generator_;
std::unique_ptr<rtc::NetworkMonitorFactory> const network_monitor_factory_
RTC_GUARDED_BY(signaling_thread_);
std::unique_ptr<rtc::NetworkManager> default_network_manager_

View File

@@ -169,7 +169,7 @@ StreamParams CreateStreamParamsForNewSenderWithSsrcs(
const std::string& rtcp_cname,
bool include_rtx_streams,
bool include_flexfec_stream,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
const webrtc::FieldTrialsView& field_trials) {
StreamParams result;
result.id = sender.track_id;
@@ -264,7 +264,7 @@ void AddSimulcastToMediaDescription(
// `current_params` - All currently known StreamParams of any media type.
bool AddStreamParams(const std::vector<SenderOptions>& sender_options,
const std::string& rtcp_cname,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
StreamParamsVec* current_streams,
MediaContentDescription* content_description,
const webrtc::FieldTrialsView& field_trials) {
@@ -374,7 +374,7 @@ RTCError CreateContentOffer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const RtpHeaderExtensions& rtp_extensions,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
StreamParamsVec* current_streams,
MediaContentDescription* offer) {
offer->set_rtcp_mux(session_options.rtcp_mux_enabled);
@@ -408,7 +408,7 @@ RTCError CreateMediaContentOffer(
const MediaSessionOptions& session_options,
const std::vector<Codec>& codecs,
const RtpHeaderExtensions& rtp_extensions,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
StreamParamsVec* current_streams,
MediaContentDescription* offer,
const webrtc::FieldTrialsView& field_trials) {
@@ -597,7 +597,7 @@ bool SetCodecsInAnswer(const MediaContentDescription* offer,
const std::vector<Codec>& local_codecs,
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
StreamParamsVec* current_streams,
MediaContentDescription* answer,
const webrtc::FieldTrialsView& field_trials) {
@@ -625,7 +625,7 @@ bool CreateMediaContentAnswer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const RtpHeaderExtensions& local_rtp_extensions,
UniqueRandomIdGenerator* ssrc_generator,
rtc::UniqueRandomIdGenerator* ssrc_generator,
bool enable_encrypted_rtp_header_extensions,
StreamParamsVec* current_streams,
bool bundle_enabled,

View File

@@ -756,8 +756,8 @@ class MediaSessionDescriptionFactoryTest : public testing::Test {
protected:
webrtc::test::ScopedKeyValueConfig field_trials;
UniqueRandomIdGenerator ssrc_generator1;
UniqueRandomIdGenerator ssrc_generator2;
rtc::UniqueRandomIdGenerator ssrc_generator1;
rtc::UniqueRandomIdGenerator ssrc_generator2;
TransportDescriptionFactory tdf1_;
TransportDescriptionFactory tdf2_;
webrtc::FakePayloadTypeSuggester pt_suggester_1_;
@@ -4617,8 +4617,8 @@ class MediaProtocolTest : public testing::TestWithParam<const char*> {
webrtc::FakePayloadTypeSuggester pt_suggester_2_;
MediaSessionDescriptionFactory f1_;
MediaSessionDescriptionFactory f2_;
UniqueRandomIdGenerator ssrc_generator1;
UniqueRandomIdGenerator ssrc_generator2;
rtc::UniqueRandomIdGenerator ssrc_generator1;
rtc::UniqueRandomIdGenerator ssrc_generator2;
};
TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) {
@@ -4673,7 +4673,7 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) {
tdf.set_certificate(rtc::RTCCertificate::Create(
std::unique_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id"))));
UniqueRandomIdGenerator ssrc_generator;
rtc::UniqueRandomIdGenerator ssrc_generator;
webrtc::FakePayloadTypeSuggester pt_suggester;
MediaSessionDescriptionFactory sf(nullptr, false, &ssrc_generator, &tdf,
&pt_suggester);
@@ -4780,7 +4780,7 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction,
answer_tdf.set_certificate(
rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
new rtc::FakeSSLIdentity("answer_id"))));
UniqueRandomIdGenerator ssrc_generator1, ssrc_generator2;
rtc::UniqueRandomIdGenerator ssrc_generator1, ssrc_generator2;
webrtc::FakePayloadTypeSuggester offer_pt_suggester;
MediaSessionDescriptionFactory offer_factory(nullptr, false, &ssrc_generator1,
&offer_tdf, &offer_pt_suggester);
@@ -4963,8 +4963,8 @@ class VideoCodecsOfferH265LevelIdTest : public testing::Test {
webrtc::test::ScopedKeyValueConfig field_trials_;
TransportDescriptionFactory tdf_offerer_;
TransportDescriptionFactory tdf_answerer_;
UniqueRandomIdGenerator ssrc_generator_offerer_;
UniqueRandomIdGenerator ssrc_generator_answerer_;
rtc::UniqueRandomIdGenerator ssrc_generator_offerer_;
rtc::UniqueRandomIdGenerator ssrc_generator_answerer_;
MediaSessionDescriptionFactory sf_offerer_;
MediaSessionDescriptionFactory sf_answerer_;
webrtc::FakePayloadTypeSuggester pt_suggester_offerer_;

View File

@@ -1194,7 +1194,7 @@ PeerConnection::AddTransceiver(
// If RIDs were not provided, they are generated for simulcast scenario.
if (parameters.encodings.size() > 1 && num_rids == 0) {
rtc::UniqueStringGenerator rid_generator;
UniqueStringGenerator rid_generator;
for (RtpEncodingParameters& encoding : parameters.encodings) {
encoding.rid = rid_generator.GenerateString();
}

View File

@@ -522,7 +522,7 @@ class RtpSenderReceiverTest
std::unique_ptr<VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_;
std::unique_ptr<cricket::FakeMediaEngine> media_engine_;
rtc::UniqueRandomIdGenerator ssrc_generator_;
UniqueRandomIdGenerator ssrc_generator_;
cricket::FakeCall fake_call_;
std::unique_ptr<cricket::VoiceMediaSendChannelInterface>
voice_media_send_channel_;

View File

@@ -248,7 +248,7 @@ class RtpTransmissionManager : public RtpSenderBase::SetStreamsObserver {
cricket::MediaEngineInterface* media_engine() const;
rtc::UniqueRandomIdGenerator* ssrc_generator() const {
UniqueRandomIdGenerator* ssrc_generator() const {
return context_->ssrc_generator();
}

View File

@@ -641,7 +641,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider {
// MIDs will be generated using this generator which will keep track of
// all the MIDs that have been seen over the life of the PeerConnection.
rtc::UniqueStringGenerator mid_generator_ RTC_GUARDED_BY(signaling_thread());
UniqueStringGenerator mid_generator_ RTC_GUARDED_BY(signaling_thread());
// List of content names for which the remote side triggered an ICE restart.
std::set<std::string> pending_ice_restarts_

View File

@@ -18,7 +18,7 @@
#include "rtc_base/string_encode.h"
#include "rtc_base/string_to_number.h"
namespace rtc {
namespace webrtc {
UniqueRandomIdGenerator::UniqueRandomIdGenerator() : known_ids_() {}
UniqueRandomIdGenerator::UniqueRandomIdGenerator(ArrayView<uint32_t> known_ids)
@@ -27,11 +27,11 @@ UniqueRandomIdGenerator::UniqueRandomIdGenerator(ArrayView<uint32_t> known_ids)
UniqueRandomIdGenerator::~UniqueRandomIdGenerator() = default;
uint32_t UniqueRandomIdGenerator::GenerateId() {
webrtc::MutexLock lock(&mutex_);
MutexLock lock(&mutex_);
RTC_CHECK_LT(known_ids_.size(), std::numeric_limits<uint32_t>::max() - 1);
while (true) {
auto pair = known_ids_.insert(CreateRandomNonZeroId());
auto pair = known_ids_.insert(rtc::CreateRandomNonZeroId());
if (pair.second) {
return *pair.first;
}
@@ -39,7 +39,7 @@ uint32_t UniqueRandomIdGenerator::GenerateId() {
}
bool UniqueRandomIdGenerator::AddKnownId(uint32_t value) {
webrtc::MutexLock lock(&mutex_);
MutexLock lock(&mutex_);
return known_ids_.insert(value).second;
}
@@ -53,7 +53,7 @@ UniqueStringGenerator::UniqueStringGenerator(ArrayView<std::string> known_ids) {
UniqueStringGenerator::~UniqueStringGenerator() = default;
std::string UniqueStringGenerator::GenerateString() {
return ToString(unique_number_generator_.GenerateNumber());
return rtc::ToString(unique_number_generator_.GenerateNumber());
}
bool UniqueStringGenerator::AddKnownId(absl::string_view value) {
@@ -69,4 +69,4 @@ bool UniqueStringGenerator::AddKnownId(absl::string_view value) {
return false;
}
} // namespace rtc
} // namespace webrtc

View File

@@ -21,7 +21,7 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/system/no_unique_address.h"
namespace rtc {
namespace webrtc {
// This class will generate numbers. A common use case is for identifiers.
// The generated numbers will be unique, in the local scope of the generator.
@@ -53,7 +53,7 @@ class UniqueNumberGenerator {
bool AddKnownId(TIntegral value);
private:
RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker sequence_checker_{
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_{
webrtc::SequenceChecker::kDetached};
static_assert(std::is_integral<TIntegral>::value, "Must be integral type.");
TIntegral counter_ RTC_GUARDED_BY(sequence_checker_);
@@ -88,7 +88,7 @@ class UniqueRandomIdGenerator {
private:
// TODO(bugs.webrtc.org/12666): This lock is needed due to an instance in
// SdpOfferAnswerHandler being shared between threads.
webrtc::Mutex mutex_;
Mutex mutex_;
std::set<uint32_t> known_ids_ RTC_GUARDED_BY(&mutex_);
};
@@ -145,6 +145,14 @@ bool UniqueNumberGenerator<TIntegral>::AddKnownId(TIntegral value) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
return known_ids_.insert(value).second;
}
} // namespace webrtc
// Re-export symbols from the webrtc namespace for backwards compatibility.
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
namespace rtc {
using ::webrtc::UniqueNumberGenerator;
using ::webrtc::UniqueRandomIdGenerator;
using ::webrtc::UniqueStringGenerator;
} // namespace rtc
#endif // RTC_BASE_UNIQUE_ID_GENERATOR_H_

View File

@@ -25,21 +25,21 @@
using ::testing::IsEmpty;
using ::testing::Test;
namespace rtc {
namespace webrtc {
namespace {
// Utility class that registers itself as the currently active task queue.
class FakeTaskQueue : public webrtc::TaskQueueBase {
class FakeTaskQueue : public TaskQueueBase {
public:
FakeTaskQueue() : task_queue_setter_(this) {}
void Delete() override {}
void PostTaskImpl(absl::AnyInvocable<void() &&> task,
const PostTaskTraits& traits,
const webrtc::Location& location) override {}
const Location& location) override {}
void PostDelayedTaskImpl(absl::AnyInvocable<void() &&> task,
webrtc::TimeDelta delay,
TimeDelta delay,
const PostDelayedTaskTraits& traits,
const webrtc::Location& location) override {}
const Location& location) override {}
private:
CurrentTaskQueueSetter task_queue_setter_;
@@ -208,4 +208,4 @@ TEST(UniqueNumberGeneratorDeathTest, FailsWhenUsedInWrongContext) {
}
#endif
} // namespace rtc
} // namespace webrtc

View File

@@ -306,7 +306,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp8Offer(
LocalAndRemoteSdp SignalingInterceptor::PatchVp9Offer(
std::unique_ptr<SessionDescriptionInterface> offer) {
rtc::UniqueRandomIdGenerator ssrcs_generator;
UniqueRandomIdGenerator ssrcs_generator;
for (auto& content : offer->description()->contents()) {
for (auto& stream : content.media_description()->streams()) {
for (auto& ssrc : stream.ssrcs) {

View File

@@ -3855,7 +3855,7 @@ class PacingFactorObserver : public test::SendTest {
}
if (configure_send_side_ && !has_send_side) {
rtc::UniqueNumberGenerator<int> unique_id_generator;
UniqueNumberGenerator<int> unique_id_generator;
unique_id_generator.AddKnownId(0); // First valid RTP extension ID is 1.
for (const RtpExtension& extension : send_config->rtp.extensions) {
unique_id_generator.AddKnownId(extension.id);