Removing dependence on base file atomic_sequence_num.h

This part of issue #346.

Change-Id: If03736b688a0bf95aaf09ed3cfd5d5a0134e1c44
This commit is contained in:
Yohann Connell 2018-07-23 15:24:20 -07:00
parent 335a659fab
commit f331f18f0e
12 changed files with 24 additions and 30 deletions

View File

@ -313,8 +313,8 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info,
encryption_method = enc_method.value(); encryption_method = enc_method.value();
} }
*stream_id = sequence_number_.GetNext();
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
*stream_id = sequence_number_++;
media_playlists_.push_back(media_playlist.get()); media_playlists_.push_back(media_playlist.get());
stream_map_[*stream_id].reset( stream_map_[*stream_id].reset(
new StreamEntry{std::move(media_playlist), encryption_method}); new StreamEntry{std::move(media_playlist), encryption_method});

View File

@ -13,7 +13,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "packager/base/atomic_sequence_num.h"
#include "packager/base/macros.h" #include "packager/base/macros.h"
#include "packager/base/synchronization/lock.h" #include "packager/base/synchronization/lock.h"
#include "packager/hls/base/hls_notifier.h" #include "packager/hls/base/hls_notifier.h"
@ -88,7 +87,7 @@ class SimpleHlsNotifier : public HlsNotifier {
std::map<uint32_t, std::unique_ptr<StreamEntry>> stream_map_; std::map<uint32_t, std::unique_ptr<StreamEntry>> stream_map_;
std::list<MediaPlaylist*> media_playlists_; std::list<MediaPlaylist*> media_playlists_;
base::AtomicSequenceNumber sequence_number_; uint32_t sequence_number_ = 0;
base::Lock lock_; base::Lock lock_;

View File

@ -168,7 +168,7 @@ class RepresentationStateChangeListenerImpl
AdaptationSet::AdaptationSet(const std::string& language, AdaptationSet::AdaptationSet(const std::string& language,
const MpdOptions& mpd_options, const MpdOptions& mpd_options,
base::AtomicSequenceNumber* counter) uint32_t* counter)
: representation_counter_(counter), : representation_counter_(counter),
language_(language), language_(language),
mpd_options_(mpd_options), mpd_options_(mpd_options),
@ -180,7 +180,7 @@ AdaptationSet::AdaptationSet(const std::string& language,
AdaptationSet::~AdaptationSet() {} AdaptationSet::~AdaptationSet() {}
Representation* AdaptationSet::AddRepresentation(const MediaInfo& media_info) { 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 // Note that AdaptationSet outlive Representation, so this object
// will die before AdaptationSet. // will die before AdaptationSet.
std::unique_ptr<RepresentationStateChangeListener> listener( std::unique_ptr<RepresentationStateChangeListener> listener(

View File

@ -17,7 +17,6 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "packager/base/atomic_sequence_num.h"
#include "packager/base/optional.h" #include "packager/base/optional.h"
#include "packager/mpd/base/xml/scoped_xml_ptr.h" #include "packager/mpd/base/xml/scoped_xml_ptr.h"
@ -178,7 +177,7 @@ class AdaptationSet {
/// Representation. It can not be NULL. /// Representation. It can not be NULL.
AdaptationSet(const std::string& language, AdaptationSet(const std::string& language,
const MpdOptions& mpd_options, const MpdOptions& mpd_options,
base::AtomicSequenceNumber* representation_counter); uint32_t* representation_counter);
private: private:
AdaptationSet(const AdaptationSet&) = delete; AdaptationSet(const AdaptationSet&) = delete;
@ -235,7 +234,7 @@ class AdaptationSet {
// sorted by default. // sorted by default.
std::map<uint32_t, std::unique_ptr<Representation>> representation_map_; std::map<uint32_t, std::unique_ptr<Representation>> representation_map_;
base::AtomicSequenceNumber* const representation_counter_; uint32_t* const representation_counter_;
base::Optional<uint32_t> id_; base::Optional<uint32_t> id_;
const std::string language_; const std::string language_;

View File

@ -33,7 +33,7 @@ class AdaptationSetTest : public ::testing::Test {
protected: protected:
MpdOptions mpd_options_; MpdOptions mpd_options_;
base::AtomicSequenceNumber representation_counter_; uint32_t representation_counter_ = 0;
}; };
class OnDemandAdaptationSetTest : public AdaptationSetTest { class OnDemandAdaptationSetTest : public AdaptationSetTest {

View File

@ -38,7 +38,7 @@ class MockPeriod : public Period {
private: private:
// Only for constructing the super class. Not used for testing. // Only for constructing the super class. Not used for testing.
base::AtomicSequenceNumber sequence_counter_; uint32_t sequence_counter_ = 0;
}; };
class MockAdaptationSet : public AdaptationSet { class MockAdaptationSet : public AdaptationSet {
@ -62,7 +62,7 @@ class MockAdaptationSet : public AdaptationSet {
private: private:
// Only for constructing the super class. Not used for testing. // Only for constructing the super class. Not used for testing.
base::AtomicSequenceNumber sequence_counter_; uint32_t sequence_counter_ = 0;
}; };
class MockRepresentation : public Representation { class MockRepresentation : public Representation {

View File

@ -131,9 +131,8 @@ Period* MpdBuilder::GetOrCreatePeriod(double start_time_in_seconds) {
if (match) if (match)
return period.get(); return period.get();
} }
periods_.emplace_back(new Period(period_counter_.GetNext(), periods_.emplace_back(new Period(period_counter_++, start_time_in_seconds,
start_time_in_seconds, mpd_options_, mpd_options_, &representation_counter_));
&representation_counter_));
return periods_.back().get(); return periods_.back().get();
} }

View File

@ -17,7 +17,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "packager/base/atomic_sequence_num.h"
#include "packager/base/time/clock.h" #include "packager/base/time/clock.h"
#include "packager/mpd/base/mpd_options.h" #include "packager/mpd/base/mpd_options.h"
@ -122,8 +121,8 @@ class MpdBuilder {
std::list<std::string> base_urls_; std::list<std::string> base_urls_;
std::string availability_start_time_; std::string availability_start_time_;
base::AtomicSequenceNumber period_counter_; uint32_t period_counter_ = 0;
base::AtomicSequenceNumber representation_counter_; uint32_t representation_counter_ = 0;
// By default, this returns the current time. This can be injected for // By default, this returns the current time. This can be injected for
// testing. // testing.

View File

@ -96,7 +96,6 @@ class MpdBuilderTest : public ::testing::Test {
private: private:
Period* period_ = nullptr; Period* period_ = nullptr;
base::AtomicSequenceNumber representation_counter_;
DISALLOW_COPY_AND_ASSIGN(MpdBuilderTest); DISALLOW_COPY_AND_ASSIGN(MpdBuilderTest);
}; };

View File

@ -37,7 +37,7 @@ std::set<std::string> GetUUIDs(
Period::Period(uint32_t period_id, Period::Period(uint32_t period_id,
double start_time_in_seconds, double start_time_in_seconds,
const MpdOptions& mpd_options, const MpdOptions& mpd_options,
base::AtomicSequenceNumber* representation_counter) uint32_t* representation_counter)
: id_(period_id), : id_(period_id),
start_time_in_seconds_(start_time_in_seconds), start_time_in_seconds_(start_time_in_seconds),
mpd_options_(mpd_options), mpd_options_(mpd_options),
@ -139,7 +139,7 @@ const std::list<AdaptationSet*> Period::GetAdaptationSets() const {
std::unique_ptr<AdaptationSet> Period::NewAdaptationSet( std::unique_ptr<AdaptationSet> Period::NewAdaptationSet(
const std::string& language, const std::string& language,
const MpdOptions& options, const MpdOptions& options,
base::AtomicSequenceNumber* representation_counter) { uint32_t* representation_counter) {
return std::unique_ptr<AdaptationSet>( return std::unique_ptr<AdaptationSet>(
new AdaptationSet(language, options, representation_counter)); new AdaptationSet(language, options, representation_counter));
} }

View File

@ -12,7 +12,6 @@
#include <list> #include <list>
#include <map> #include <map>
#include "packager/base/atomic_sequence_num.h"
#include "packager/base/optional.h" #include "packager/base/optional.h"
#include "packager/mpd/base/adaptation_set.h" #include "packager/mpd/base/adaptation_set.h"
#include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/media_info.pb.h"
@ -76,7 +75,7 @@ class Period {
Period(uint32_t period_id, Period(uint32_t period_id,
double start_time_in_seconds, double start_time_in_seconds,
const MpdOptions& mpd_options, const MpdOptions& mpd_options,
base::AtomicSequenceNumber* representation_counter); uint32_t* representation_counter);
private: private:
Period(const Period&) = delete; Period(const Period&) = delete;
@ -89,7 +88,7 @@ class Period {
virtual std::unique_ptr<AdaptationSet> NewAdaptationSet( virtual std::unique_ptr<AdaptationSet> NewAdaptationSet(
const std::string& lang, const std::string& lang,
const MpdOptions& options, const MpdOptions& options,
base::AtomicSequenceNumber* representation_counter); uint32_t* representation_counter);
// Helper function to set new AdaptationSet attributes. // Helper function to set new AdaptationSet attributes.
bool SetNewAdaptationSetAttributes( bool SetNewAdaptationSetAttributes(
@ -109,7 +108,7 @@ class Period {
const double start_time_in_seconds_; const double start_time_in_seconds_;
double duration_seconds_ = 0; double duration_seconds_ = 0;
const MpdOptions& mpd_options_; const MpdOptions& mpd_options_;
base::AtomicSequenceNumber* const representation_counter_; uint32_t* const representation_counter_;
std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_; std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_;
// AdaptationSets grouped by a specific adaptation set grouping key. // AdaptationSets grouped by a specific adaptation set grouping key.
// AdaptationSets with the same key contain identical parameters except // AdaptationSets with the same key contain identical parameters except

View File

@ -80,15 +80,15 @@ class TestablePeriod : public Period {
mpd_options, mpd_options,
&sequence_number_) {} &sequence_number_) {}
MOCK_METHOD3(NewAdaptationSet, MOCK_METHOD3(
std::unique_ptr<AdaptationSet>( NewAdaptationSet,
const std::string& lang, std::unique_ptr<AdaptationSet>(const std::string& lang,
const MpdOptions& options, const MpdOptions& options,
base::AtomicSequenceNumber* representation_counter)); uint32_t* representation_counter));
private: private:
// Only for constructing the super class. Not used for testing. // Only for constructing the super class. Not used for testing.
base::AtomicSequenceNumber sequence_number_; uint32_t sequence_number_ = 0;
}; };
} // namespace } // namespace