Removing dependence on base file atomic_sequence_num.h
This part of issue #346. Change-Id: If03736b688a0bf95aaf09ed3cfd5d5a0134e1c44
This commit is contained in:
parent
335a659fab
commit
f331f18f0e
|
@ -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});
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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<uint32_t, std::unique_ptr<StreamEntry>> stream_map_;
|
||||
std::list<MediaPlaylist*> media_playlists_;
|
||||
|
||||
base::AtomicSequenceNumber sequence_number_;
|
||||
uint32_t sequence_number_ = 0;
|
||||
|
||||
base::Lock lock_;
|
||||
|
||||
|
|
|
@ -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<RepresentationStateChangeListener> listener(
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#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<uint32_t, std::unique_ptr<Representation>> representation_map_;
|
||||
|
||||
base::AtomicSequenceNumber* const representation_counter_;
|
||||
uint32_t* const representation_counter_;
|
||||
|
||||
base::Optional<uint32_t> id_;
|
||||
const std::string language_;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#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<std::string> 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.
|
||||
|
|
|
@ -96,7 +96,6 @@ class MpdBuilderTest : public ::testing::Test {
|
|||
|
||||
private:
|
||||
Period* period_ = nullptr;
|
||||
base::AtomicSequenceNumber representation_counter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MpdBuilderTest);
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ std::set<std::string> 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<AdaptationSet*> Period::GetAdaptationSets() const {
|
|||
std::unique_ptr<AdaptationSet> Period::NewAdaptationSet(
|
||||
const std::string& language,
|
||||
const MpdOptions& options,
|
||||
base::AtomicSequenceNumber* representation_counter) {
|
||||
uint32_t* representation_counter) {
|
||||
return std::unique_ptr<AdaptationSet>(
|
||||
new AdaptationSet(language, options, representation_counter));
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#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<AdaptationSet> 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<std::unique_ptr<AdaptationSet>> adaptation_sets_;
|
||||
// AdaptationSets grouped by a specific adaptation set grouping key.
|
||||
// AdaptationSets with the same key contain identical parameters except
|
||||
|
|
|
@ -80,15 +80,15 @@ class TestablePeriod : public Period {
|
|||
mpd_options,
|
||||
&sequence_number_) {}
|
||||
|
||||
MOCK_METHOD3(NewAdaptationSet,
|
||||
std::unique_ptr<AdaptationSet>(
|
||||
const std::string& lang,
|
||||
const MpdOptions& options,
|
||||
base::AtomicSequenceNumber* representation_counter));
|
||||
MOCK_METHOD3(
|
||||
NewAdaptationSet,
|
||||
std::unique_ptr<AdaptationSet>(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
|
||||
|
|
Loading…
Reference in New Issue