diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index 730f6f2c1a..e9fd7e074e 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -313,8 +313,8 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info, encryption_method = enc_method.value(); } - *stream_id = sequence_number_.GetNext(); base::AutoLock auto_lock(lock_); + *stream_id = sequence_number_++; media_playlists_.push_back(media_playlist.get()); stream_map_[*stream_id].reset( new StreamEntry{std::move(media_playlist), encryption_method}); diff --git a/packager/hls/base/simple_hls_notifier.h b/packager/hls/base/simple_hls_notifier.h index 8a558127b9..d835169191 100644 --- a/packager/hls/base/simple_hls_notifier.h +++ b/packager/hls/base/simple_hls_notifier.h @@ -13,7 +13,6 @@ #include #include -#include "packager/base/atomic_sequence_num.h" #include "packager/base/macros.h" #include "packager/base/synchronization/lock.h" #include "packager/hls/base/hls_notifier.h" @@ -88,7 +87,7 @@ class SimpleHlsNotifier : public HlsNotifier { std::map> stream_map_; std::list media_playlists_; - base::AtomicSequenceNumber sequence_number_; + uint32_t sequence_number_ = 0; base::Lock lock_; diff --git a/packager/mpd/base/adaptation_set.cc b/packager/mpd/base/adaptation_set.cc index 8959960350..782847237b 100644 --- a/packager/mpd/base/adaptation_set.cc +++ b/packager/mpd/base/adaptation_set.cc @@ -168,7 +168,7 @@ class RepresentationStateChangeListenerImpl AdaptationSet::AdaptationSet(const std::string& language, const MpdOptions& mpd_options, - base::AtomicSequenceNumber* counter) + uint32_t* counter) : representation_counter_(counter), language_(language), mpd_options_(mpd_options), @@ -180,7 +180,7 @@ AdaptationSet::AdaptationSet(const std::string& language, AdaptationSet::~AdaptationSet() {} Representation* AdaptationSet::AddRepresentation(const MediaInfo& media_info) { - const uint32_t representation_id = representation_counter_->GetNext(); + const uint32_t representation_id = (*representation_counter_)++; // Note that AdaptationSet outlive Representation, so this object // will die before AdaptationSet. std::unique_ptr listener( diff --git a/packager/mpd/base/adaptation_set.h b/packager/mpd/base/adaptation_set.h index 86a531e27b..41911cfc6b 100644 --- a/packager/mpd/base/adaptation_set.h +++ b/packager/mpd/base/adaptation_set.h @@ -17,7 +17,6 @@ #include #include -#include "packager/base/atomic_sequence_num.h" #include "packager/base/optional.h" #include "packager/mpd/base/xml/scoped_xml_ptr.h" @@ -178,7 +177,7 @@ class AdaptationSet { /// Representation. It can not be NULL. AdaptationSet(const std::string& language, const MpdOptions& mpd_options, - base::AtomicSequenceNumber* representation_counter); + uint32_t* representation_counter); private: AdaptationSet(const AdaptationSet&) = delete; @@ -235,7 +234,7 @@ class AdaptationSet { // sorted by default. std::map> representation_map_; - base::AtomicSequenceNumber* const representation_counter_; + uint32_t* const representation_counter_; base::Optional id_; const std::string language_; diff --git a/packager/mpd/base/adaptation_set_unittest.cc b/packager/mpd/base/adaptation_set_unittest.cc index 820dc4528f..b145e8df9e 100644 --- a/packager/mpd/base/adaptation_set_unittest.cc +++ b/packager/mpd/base/adaptation_set_unittest.cc @@ -33,7 +33,7 @@ class AdaptationSetTest : public ::testing::Test { protected: MpdOptions mpd_options_; - base::AtomicSequenceNumber representation_counter_; + uint32_t representation_counter_ = 0; }; class OnDemandAdaptationSetTest : public AdaptationSetTest { diff --git a/packager/mpd/base/mock_mpd_builder.h b/packager/mpd/base/mock_mpd_builder.h index 2ec4a74fe1..6d46396f30 100644 --- a/packager/mpd/base/mock_mpd_builder.h +++ b/packager/mpd/base/mock_mpd_builder.h @@ -38,7 +38,7 @@ class MockPeriod : public Period { private: // Only for constructing the super class. Not used for testing. - base::AtomicSequenceNumber sequence_counter_; + uint32_t sequence_counter_ = 0; }; class MockAdaptationSet : public AdaptationSet { @@ -62,7 +62,7 @@ class MockAdaptationSet : public AdaptationSet { private: // Only for constructing the super class. Not used for testing. - base::AtomicSequenceNumber sequence_counter_; + uint32_t sequence_counter_ = 0; }; class MockRepresentation : public Representation { diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index ad01f7c08e..8cb405505c 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -131,9 +131,8 @@ Period* MpdBuilder::GetOrCreatePeriod(double start_time_in_seconds) { if (match) return period.get(); } - periods_.emplace_back(new Period(period_counter_.GetNext(), - start_time_in_seconds, mpd_options_, - &representation_counter_)); + periods_.emplace_back(new Period(period_counter_++, start_time_in_seconds, + mpd_options_, &representation_counter_)); return periods_.back().get(); } diff --git a/packager/mpd/base/mpd_builder.h b/packager/mpd/base/mpd_builder.h index 9a81df8cb9..cba41001c5 100644 --- a/packager/mpd/base/mpd_builder.h +++ b/packager/mpd/base/mpd_builder.h @@ -17,7 +17,6 @@ #include #include -#include "packager/base/atomic_sequence_num.h" #include "packager/base/time/clock.h" #include "packager/mpd/base/mpd_options.h" @@ -122,8 +121,8 @@ class MpdBuilder { std::list base_urls_; std::string availability_start_time_; - base::AtomicSequenceNumber period_counter_; - base::AtomicSequenceNumber representation_counter_; + uint32_t period_counter_ = 0; + uint32_t representation_counter_ = 0; // By default, this returns the current time. This can be injected for // testing. diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index c33c89b79d..0f129b9a29 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -96,7 +96,6 @@ class MpdBuilderTest : public ::testing::Test { private: Period* period_ = nullptr; - base::AtomicSequenceNumber representation_counter_; DISALLOW_COPY_AND_ASSIGN(MpdBuilderTest); }; diff --git a/packager/mpd/base/period.cc b/packager/mpd/base/period.cc index 08952ac690..fa41da2d67 100644 --- a/packager/mpd/base/period.cc +++ b/packager/mpd/base/period.cc @@ -37,7 +37,7 @@ std::set GetUUIDs( Period::Period(uint32_t period_id, double start_time_in_seconds, const MpdOptions& mpd_options, - base::AtomicSequenceNumber* representation_counter) + uint32_t* representation_counter) : id_(period_id), start_time_in_seconds_(start_time_in_seconds), mpd_options_(mpd_options), @@ -139,7 +139,7 @@ const std::list Period::GetAdaptationSets() const { std::unique_ptr Period::NewAdaptationSet( const std::string& language, const MpdOptions& options, - base::AtomicSequenceNumber* representation_counter) { + uint32_t* representation_counter) { return std::unique_ptr( new AdaptationSet(language, options, representation_counter)); } diff --git a/packager/mpd/base/period.h b/packager/mpd/base/period.h index e4955d3578..7a4b0ad37d 100644 --- a/packager/mpd/base/period.h +++ b/packager/mpd/base/period.h @@ -12,7 +12,6 @@ #include #include -#include "packager/base/atomic_sequence_num.h" #include "packager/base/optional.h" #include "packager/mpd/base/adaptation_set.h" #include "packager/mpd/base/media_info.pb.h" @@ -76,7 +75,7 @@ class Period { Period(uint32_t period_id, double start_time_in_seconds, const MpdOptions& mpd_options, - base::AtomicSequenceNumber* representation_counter); + uint32_t* representation_counter); private: Period(const Period&) = delete; @@ -89,7 +88,7 @@ class Period { virtual std::unique_ptr NewAdaptationSet( const std::string& lang, const MpdOptions& options, - base::AtomicSequenceNumber* representation_counter); + uint32_t* representation_counter); // Helper function to set new AdaptationSet attributes. bool SetNewAdaptationSetAttributes( @@ -109,7 +108,7 @@ class Period { const double start_time_in_seconds_; double duration_seconds_ = 0; const MpdOptions& mpd_options_; - base::AtomicSequenceNumber* const representation_counter_; + uint32_t* const representation_counter_; std::list> adaptation_sets_; // AdaptationSets grouped by a specific adaptation set grouping key. // AdaptationSets with the same key contain identical parameters except diff --git a/packager/mpd/base/period_unittest.cc b/packager/mpd/base/period_unittest.cc index 7e94befb54..0c5afa5f75 100644 --- a/packager/mpd/base/period_unittest.cc +++ b/packager/mpd/base/period_unittest.cc @@ -80,15 +80,15 @@ class TestablePeriod : public Period { mpd_options, &sequence_number_) {} - MOCK_METHOD3(NewAdaptationSet, - std::unique_ptr( - const std::string& lang, - const MpdOptions& options, - base::AtomicSequenceNumber* representation_counter)); + MOCK_METHOD3( + NewAdaptationSet, + std::unique_ptr(const std::string& lang, + const MpdOptions& options, + uint32_t* representation_counter)); private: // Only for constructing the super class. Not used for testing. - base::AtomicSequenceNumber sequence_number_; + uint32_t sequence_number_ = 0; }; } // namespace