Use Abseil container algorithms in media/

Bug: None
Change-Id: I292e3401bbf19a66271dd5ef2b3ca4f8dcfd155d
Reviewed-on: https://webrtc-review.googlesource.com/c/120003
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26434}
This commit is contained in:
Steve Anton 2019-01-28 17:27:58 -08:00 committed by Commit Bot
parent 64b626b03f
commit 2c9ebefb44
16 changed files with 93 additions and 133 deletions

View file

@ -136,6 +136,7 @@ rtc_static_library("libjingle_peerconnection_api") {
"units:data_rate",
"video:encoded_image",
"video:video_frame",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",

View file

@ -143,6 +143,7 @@ rtc_static_library("rtc_media_base") {
"../rtc_base:rtc_base_approved",
"../rtc_base/system:rtc_export",
"../rtc_base/third_party/sigslot",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
@ -369,6 +370,7 @@ rtc_static_library("rtc_audio_video") {
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/experiments:normalize_simulcast_size_experiment",
"../system_wrappers",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
@ -416,6 +418,7 @@ rtc_static_library("rtc_data") {
"../rtc_base:rtc_base_approved",
"../rtc_base/third_party/sigslot",
"../system_wrappers",
"//third_party/abseil-cpp/absl/algorithm:container",
]
}
@ -453,6 +456,7 @@ if (rtc_include_tests) {
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
]
@ -652,6 +656,7 @@ if (rtc_include_tests) {
"../test:audio_codec_mocks",
"../test:test_support",
"../test:video_test_common",
"//third_party/abseil-cpp/absl/algorithm:container",
]
}
}

View file

@ -10,8 +10,7 @@
#include "media/base/codec.h"
#include <algorithm>
#include "absl/algorithm/container.h"
#include "absl/strings/match.h"
#include "media/base/h264_profile_level_id.h"
#include "media/base/vp9_profile.h"
@ -35,7 +34,7 @@ bool FeedbackParams::operator==(const FeedbackParams& other) const {
}
bool FeedbackParams::Has(const FeedbackParam& param) const {
return std::find(params_.begin(), params_.end(), param) != params_.end();
return absl::c_linear_search(params_, param);
}
void FeedbackParams::Add(const FeedbackParam& param) {

View file

@ -12,6 +12,7 @@
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "rtc_base/checks.h"
@ -482,7 +483,7 @@ FakeVoiceMediaChannel* FakeVoiceEngine::GetChannel(size_t index) {
return (channels_.size() > index) ? channels_[index] : NULL;
}
void FakeVoiceEngine::UnregisterChannel(VoiceMediaChannel* channel) {
channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
channels_.erase(absl::c_find(channels_, channel));
}
const std::vector<AudioCodec>& FakeVoiceEngine::send_codecs() const {
return codecs_;
@ -537,7 +538,7 @@ FakeVideoMediaChannel* FakeVideoEngine::GetChannel(size_t index) {
return (channels_.size() > index) ? channels_[index] : nullptr;
}
void FakeVideoEngine::UnregisterChannel(VideoMediaChannel* channel) {
auto it = std::find(channels_.begin(), channels_.end(), channel);
auto it = absl::c_find(channels_, channel);
RTC_DCHECK(it != channels_.end());
channels_.erase(it);
}
@ -586,7 +587,7 @@ FakeDataMediaChannel* FakeDataEngine::GetChannel(size_t index) {
return (channels_.size() > index) ? channels_[index] : NULL;
}
void FakeDataEngine::UnregisterChannel(DataMediaChannel* channel) {
channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
channels_.erase(absl::c_find(channels_, channel));
}
void FakeDataEngine::SetDataCodecs(const std::vector<DataCodec>& data_codecs) {
data_codecs_ = data_codecs;

View file

@ -19,6 +19,7 @@
#include <tuple>
#include <vector>
#include "absl/algorithm/container.h"
#include "api/call/audio_sink.h"
#include "media/base/audio_source.h"
#include "media/base/media_engine.h"
@ -101,8 +102,7 @@ class RtpHelper : public Base {
void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; }
void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; }
virtual bool AddSendStream(const StreamParams& sp) {
if (std::find(send_streams_.begin(), send_streams_.end(), sp) !=
send_streams_.end()) {
if (absl::c_linear_search(send_streams_, sp)) {
return false;
}
send_streams_.push_back(sp);
@ -118,8 +118,7 @@ class RtpHelper : public Base {
return RemoveStreamBySsrc(&send_streams_, ssrc);
}
virtual bool AddRecvStream(const StreamParams& sp) {
if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) !=
receive_streams_.end()) {
if (absl::c_linear_search(receive_streams_, sp)) {
return false;
}
receive_streams_.push_back(sp);

View file

@ -10,8 +10,8 @@
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include "absl/algorithm/container.h"
#include "media/base/fake_rtp.h"
#include "rtc_base/checks.h"
#include "test/gtest.h"
@ -53,9 +53,7 @@ void CompareHeaderExtensions(const char* packet1,
// The header extension doesn't get encrypted if the id is not in the
// list of header extensions to encrypt.
if (expect_equal ||
std::find(encrypted_headers.begin(), encrypted_headers.end(), id) ==
encrypted_headers.end()) {
if (expect_equal || !absl::c_linear_search(encrypted_headers, id)) {
EXPECT_EQ(0, memcmp(extension_data1, extension_data2, len));
} else {
EXPECT_NE(0, memcmp(extension_data1, extension_data2, len));

View file

@ -11,9 +11,9 @@
#include "media/base/stream_params.h"
#include <stdint.h>
#include <algorithm>
#include <list>
#include "absl/algorithm/container.h"
#include "api/array_view.h"
#include "rtc_base/strings/string_builder.h"
@ -153,8 +153,7 @@ bool StreamParams::operator==(const StreamParams& other) const {
ssrc_groups == other.ssrc_groups && cname == other.cname &&
stream_ids_ == other.stream_ids_ &&
// RIDs are not required to be in the same order for equality.
rids_.size() == other.rids_.size() &&
std::is_permutation(rids_.begin(), rids_.end(), other.rids_.begin()));
absl::c_is_permutation(rids_, other.rids_));
}
std::string StreamParams::ToString() const {
@ -328,8 +327,7 @@ bool IsOneSsrcStream(const StreamParams& sp) {
namespace {
void RemoveFirst(std::list<uint32_t>* ssrcs, uint32_t value) {
std::list<uint32_t>::iterator it =
std::find(ssrcs->begin(), ssrcs->end(), value);
auto it = absl::c_find(*ssrcs, value);
if (it != ssrcs->end()) {
ssrcs->erase(it);
}

View file

@ -47,11 +47,11 @@
#define MEDIA_BASE_STREAM_PARAMS_H_
#include <stddef.h>
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
#include "absl/algorithm/container.h"
#include "media/base/rid_description.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/unique_id_generator.h"
@ -114,7 +114,7 @@ struct StreamParams {
}
bool has_ssrcs() const { return !ssrcs.empty(); }
bool has_ssrc(uint32_t ssrc) const {
return std::find(ssrcs.begin(), ssrcs.end(), ssrc) != ssrcs.end();
return absl::c_linear_search(ssrcs, ssrc);
}
void add_ssrc(uint32_t ssrc) { ssrcs.push_back(ssrc); }
bool has_ssrc_groups() const { return !ssrc_groups.empty(); }
@ -296,15 +296,13 @@ struct MediaStreams {
template <class Condition>
const StreamParams* GetStream(const StreamParamsVec& streams,
Condition condition) {
StreamParamsVec::const_iterator found =
std::find_if(streams.begin(), streams.end(), condition);
auto found = absl::c_find_if(streams, condition);
return found == streams.end() ? nullptr : &(*found);
}
template <class Condition>
StreamParams* GetStream(StreamParamsVec& streams, Condition condition) {
StreamParamsVec::iterator found =
std::find_if(streams.begin(), streams.end(), condition);
auto found = absl::c_find_if(streams, condition);
return found == streams.end() ? nullptr : &(*found);
}

View file

@ -10,8 +10,7 @@
#include "media/base/video_source_base.h"
#include <algorithm>
#include "absl/algorithm/container.h"
#include "rtc_base/checks.h"
namespace rtc {
@ -44,8 +43,8 @@ void VideoSourceBase::RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) {
VideoSourceBase::SinkPair* VideoSourceBase::FindSinkPair(
const VideoSinkInterface<webrtc::VideoFrame>* sink) {
auto sink_pair_it = std::find_if(
sinks_.begin(), sinks_.end(),
auto sink_pair_it = absl::c_find_if(
sinks_,
[sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
if (sink_pair_it != sinks_.end()) {
return &*sink_pair_it;

View file

@ -10,9 +10,9 @@
#include "media/engine/fake_webrtc_call.h"
#include <algorithm>
#include <utility>
#include "absl/algorithm/container.h"
#include "api/call/audio_sink.h"
#include "media/base/rtp_utils.h"
#include "rtc_base/checks.h"
@ -467,9 +467,8 @@ webrtc::AudioSendStream* FakeCall::CreateAudioSendStream(
}
void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
auto it = std::find(audio_send_streams_.begin(),
audio_send_streams_.end(),
static_cast<FakeAudioSendStream*>(send_stream));
auto it = absl::c_find(audio_send_streams_,
static_cast<FakeAudioSendStream*>(send_stream));
if (it == audio_send_streams_.end()) {
ADD_FAILURE() << "DestroyAudioSendStream called with unknown parameter.";
} else {
@ -488,9 +487,8 @@ webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream(
void FakeCall::DestroyAudioReceiveStream(
webrtc::AudioReceiveStream* receive_stream) {
auto it = std::find(audio_receive_streams_.begin(),
audio_receive_streams_.end(),
static_cast<FakeAudioReceiveStream*>(receive_stream));
auto it = absl::c_find(audio_receive_streams_,
static_cast<FakeAudioReceiveStream*>(receive_stream));
if (it == audio_receive_streams_.end()) {
ADD_FAILURE() << "DestroyAudioReceiveStream called with unknown parameter.";
} else {
@ -510,9 +508,8 @@ webrtc::VideoSendStream* FakeCall::CreateVideoSendStream(
}
void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
auto it = std::find(video_send_streams_.begin(),
video_send_streams_.end(),
static_cast<FakeVideoSendStream*>(send_stream));
auto it = absl::c_find(video_send_streams_,
static_cast<FakeVideoSendStream*>(send_stream));
if (it == video_send_streams_.end()) {
ADD_FAILURE() << "DestroyVideoSendStream called with unknown parameter.";
} else {
@ -531,9 +528,8 @@ webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream(
void FakeCall::DestroyVideoReceiveStream(
webrtc::VideoReceiveStream* receive_stream) {
auto it = std::find(video_receive_streams_.begin(),
video_receive_streams_.end(),
static_cast<FakeVideoReceiveStream*>(receive_stream));
auto it = absl::c_find(video_receive_streams_,
static_cast<FakeVideoReceiveStream*>(receive_stream));
if (it == video_receive_streams_.end()) {
ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown parameter.";
} else {
@ -552,9 +548,9 @@ webrtc::FlexfecReceiveStream* FakeCall::CreateFlexfecReceiveStream(
void FakeCall::DestroyFlexfecReceiveStream(
webrtc::FlexfecReceiveStream* receive_stream) {
auto it = std::find(flexfec_receive_streams_.begin(),
flexfec_receive_streams_.end(),
static_cast<FakeFlexfecReceiveStream*>(receive_stream));
auto it =
absl::c_find(flexfec_receive_streams_,
static_cast<FakeFlexfecReceiveStream*>(receive_stream));
if (it == flexfec_receive_streams_.end()) {
ADD_FAILURE()
<< "DestroyFlexfecReceiveStream called with unknown parameter.";

View file

@ -10,9 +10,9 @@
#include "media/engine/webrtc_media_engine.h"
#include <algorithm>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video_codecs/video_decoder_factory.h"
@ -82,8 +82,8 @@ void DiscardRedundantExtensions(
RTC_DCHECK(extensions);
bool found = false;
for (const char* uri : extensions_decreasing_prio) {
auto it = std::find_if(
extensions->begin(), extensions->end(),
auto it = absl::c_find_if(
*extensions,
[uri](const webrtc::RtpExtension& rhs) { return rhs.uri == uri; });
if (it != extensions->end()) {
if (found) {
@ -135,8 +135,8 @@ std::vector<webrtc::RtpExtension> FilterRtpExtensions(
// Sort by name, ascending (prioritise encryption), so that we don't reset
// extensions if they were specified in a different order (also allows us
// to use std::unique below).
std::sort(
result.begin(), result.end(),
absl::c_sort(
result,
[](const webrtc::RtpExtension& rhs, const webrtc::RtpExtension& lhs) {
return rhs.encrypt == lhs.encrypt ? rhs.uri < lhs.uri
: rhs.encrypt > lhs.encrypt;

View file

@ -560,10 +560,6 @@ WebRtcVideoChannel::SelectSendVideoCodec(
bool WebRtcVideoChannel::NonFlexfecReceiveCodecsHaveChanged(
std::vector<VideoCodecSettings> before,
std::vector<VideoCodecSettings> after) {
if (before.size() != after.size()) {
return true;
}
// The receive codec order doesn't matter, so we sort the codecs before
// comparing. This is necessary because currently the
// only way to change the send codec is to munge SDP, which causes
@ -576,14 +572,14 @@ bool WebRtcVideoChannel::NonFlexfecReceiveCodecsHaveChanged(
const VideoCodecSettings& codec2) {
return codec1.codec.id > codec2.codec.id;
};
std::sort(before.begin(), before.end(), comparison);
std::sort(after.begin(), after.end(), comparison);
absl::c_sort(before, comparison);
absl::c_sort(after, comparison);
// Changes in FlexFEC payload type are handled separately in
// WebRtcVideoChannel::GetChangedRecvParameters, so disregard FlexFEC in the
// comparison here.
return !std::equal(before.begin(), before.end(), after.begin(),
VideoCodecSettings::EqualsDisregardingFlexfec);
return !absl::c_equal(before, after,
VideoCodecSettings::EqualsDisregardingFlexfec);
}
bool WebRtcVideoChannel::GetChangedSendParameters(

View file

@ -8,12 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <algorithm>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "api/rtp_parameters.h"
@ -681,8 +681,7 @@ WebRtcVideoEngineTest::SetSendParamsWithAllSupportedCodecs() {
for (const webrtc::SdpVideoFormat& format :
encoder_factory_->GetSupportedFormats()) {
cricket::VideoCodec engine_codec = GetEngineCodec(format.name);
if (std::find(parameters.codecs.begin(), parameters.codecs.end(),
engine_codec) == parameters.codecs.end()) {
if (!absl::c_linear_search(parameters.codecs, engine_codec)) {
parameters.codecs.push_back(engine_codec);
}
}
@ -878,23 +877,15 @@ TEST_F(WebRtcVideoEngineTest,
Flexfec03SupportedAsInternalCodecBehindFieldTrial) {
encoder_factory_->AddSupportedVideoCodecType("VP8");
auto is_flexfec = [](const VideoCodec& codec) {
if (codec.name == "flexfec-03")
return true;
return false;
};
auto flexfec = Field("name", &VideoCodec::name, "flexfec-03");
// FlexFEC is not active without field trial.
const std::vector<VideoCodec> codecs_before = engine_.codecs();
EXPECT_EQ(codecs_before.end(), std::find_if(codecs_before.begin(),
codecs_before.end(), is_flexfec));
EXPECT_THAT(engine_.codecs(), Not(Contains(flexfec)));
// FlexFEC is active with field trial.
webrtc::test::ScopedFieldTrials override_field_trials_(
"WebRTC-FlexFEC-03-Advertised/Enabled/");
const std::vector<VideoCodec> codecs_after = engine_.codecs();
EXPECT_NE(codecs_after.end(),
std::find_if(codecs_after.begin(), codecs_after.end(), is_flexfec));
EXPECT_THAT(engine_.codecs(), Contains(flexfec));
}
// Test that codecs are added in the order they are reported from the factory.
@ -2461,8 +2452,7 @@ TEST_F(WebRtcVideoChannelTest, IdenticalSendExtensionsDoesntRecreateStream) {
// Setting the same extensions (even if in different order) shouldn't
// reallocate the stream.
std::reverse(send_parameters_.extensions.begin(),
send_parameters_.extensions.end());
absl::c_reverse(send_parameters_.extensions);
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
@ -2494,8 +2484,7 @@ TEST_F(WebRtcVideoChannelTest, IdenticalRecvExtensionsDoesntRecreateStream) {
// Setting the same extensions (even if in different order) shouldn't
// reallocate the stream.
std::reverse(recv_parameters_.extensions.begin(),
recv_parameters_.extensions.end());
absl::c_reverse(recv_parameters_.extensions);
EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
@ -6869,16 +6858,12 @@ TEST_F(WebRtcVideoChannelTestWithClock, GetContributingSources) {
std::vector<webrtc::RtpSource> sources = channel_->GetSources(kSsrc);
EXPECT_EQ(sources[0].timestamp_ms(), sources[1].timestamp_ms());
// 1 SSRC and 1 CSRC.
EXPECT_EQ(1, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(1, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::CSRC;
}));
EXPECT_EQ(1, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(1, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::CSRC;
}));
}
int64_t timestamp1 = channel_->GetSources(kSsrc)[0].timestamp_ms();
@ -6898,22 +6883,18 @@ TEST_F(WebRtcVideoChannelTestWithClock, GetContributingSources) {
std::vector<webrtc::RtpSource> sources = channel_->GetSources(kSsrc);
EXPECT_NE(sources[0].timestamp_ms(), sources[1].timestamp_ms());
// 1 SSRC and 1 CSRC.
EXPECT_EQ(1, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(1, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::CSRC;
}));
auto ssrcSource = std::find_if(
sources.begin(), sources.end(), [](const webrtc::RtpSource& source) {
EXPECT_EQ(1, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(1, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::CSRC;
}));
auto ssrcSource =
absl::c_find_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::SSRC;
});
auto csrcSource = std::find_if(
sources.begin(), sources.end(), [](const webrtc::RtpSource& source) {
auto csrcSource =
absl::c_find_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::CSRC;
});
@ -6928,16 +6909,12 @@ TEST_F(WebRtcVideoChannelTestWithClock, GetContributingSources) {
ASSERT_EQ(1u, channel_->GetSources(kSsrc).size());
EXPECT_EQ(0u, channel_->GetSources(kCsrc).size());
std::vector<webrtc::RtpSource> sources = channel_->GetSources(kSsrc);
EXPECT_EQ(1, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(0, std::count_if(sources.begin(), sources.end(),
[](const webrtc::RtpSource& source) {
return source.source_type() ==
webrtc::RtpSourceType::CSRC;
}));
EXPECT_EQ(1, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::SSRC;
}));
EXPECT_EQ(0, absl::c_count_if(sources, [](const webrtc::RtpSource& source) {
return source.source_type() == webrtc::RtpSourceType::CSRC;
}));
}
fake_clock_.AdvanceTime(webrtc::TimeDelta::ms(1));

View file

@ -19,6 +19,7 @@
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/strings/match.h"
#include "api/audio_codecs/audio_codec_pair_id.h"
#include "api/call/audio_sink.h"
@ -125,12 +126,10 @@ bool VerifyUniquePayloadTypes(const std::vector<AudioCodec>& codecs) {
return true;
}
std::vector<int> payload_types;
for (const AudioCodec& codec : codecs) {
payload_types.push_back(codec.id);
}
std::sort(payload_types.begin(), payload_types.end());
auto it = std::unique(payload_types.begin(), payload_types.end());
return it == payload_types.end();
absl::c_transform(codecs, std::back_inserter(payload_types),
[](const AudioCodec& codec) { return codec.id; });
absl::c_sort(payload_types);
return absl::c_adjacent_find(payload_types) == payload_types.end();
}
absl::optional<std::string> GetAudioNetworkAdaptorConfig(
@ -579,7 +578,7 @@ void WebRtcVoiceEngine::RegisterChannel(WebRtcVoiceMediaChannel* channel) {
void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
auto it = std::find(channels_.begin(), channels_.end(), channel);
auto it = absl::c_find(channels_, channel);
RTC_DCHECK(it != channels_.end());
channels_.erase(it);
}
@ -2029,9 +2028,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
if (!GetRtpSsrc(packet->cdata(), packet->size(), &ssrc)) {
return;
}
RTC_DCHECK(std::find(unsignaled_recv_ssrcs_.begin(),
unsignaled_recv_ssrcs_.end(),
ssrc) == unsignaled_recv_ssrcs_.end());
RTC_DCHECK(!absl::c_linear_search(unsignaled_recv_ssrcs_, ssrc));
// Add new stream.
StreamParams sp = unsignaled_stream_params_;
@ -2181,7 +2178,7 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8158
if (!unsignaled_recv_ssrcs_.empty()) {
auto end_it = --unsignaled_recv_ssrcs_.end();
if (std::find(unsignaled_recv_ssrcs_.begin(), end_it, ssrc) != end_it) {
if (absl::linear_search(unsignaled_recv_ssrcs_.begin(), end_it, ssrc)) {
continue;
}
}
@ -2280,8 +2277,7 @@ std::vector<webrtc::RtpSource> WebRtcVoiceMediaChannel::GetSources(
bool WebRtcVoiceMediaChannel::MaybeDeregisterUnsignaledRecvStream(
uint32_t ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
auto it = std::find(unsignaled_recv_ssrcs_.begin(),
unsignaled_recv_ssrcs_.end(), ssrc);
auto it = absl::c_find(unsignaled_recv_ssrcs_, ssrc);
if (it != unsignaled_recv_ssrcs_.end()) {
unsignaled_recv_ssrcs_.erase(it);
return true;

View file

@ -23,9 +23,9 @@ enum PreservedErrno {
#include <stdarg.h>
#include <stdio.h>
#include <algorithm>
#include <memory>
#include "absl/algorithm/container.h"
#include "media/base/codec.h"
#include "media/base/media_constants.h"
#include "media/base/stream_params.h"
@ -779,8 +779,8 @@ bool SctpTransport::SendQueuedStreamResets() {
// Figure out how many streams need to be reset. We need to do this so we can
// allocate the right amount of memory for the sctp_reset_streams structure.
size_t num_streams = std::count_if(
stream_status_by_sid_.begin(), stream_status_by_sid_.end(),
size_t num_streams = absl::c_count_if(
stream_status_by_sid_,
[](const std::map<uint32_t, StreamStatus>::value_type& stream) {
return stream.second.need_outgoing_reset();
});

View file

@ -10,11 +10,11 @@
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include "absl/algorithm/container.h"
#include "media/sctp/sctp_transport.h"
#include "p2p/base/fake_dtls_transport.h"
#include "rtc_base/copy_on_write_buffer.h"
@ -75,12 +75,11 @@ class SctpTransportObserver : public sigslot::has_slots<> {
}
int StreamCloseCount(int stream) {
return std::count(closed_streams_.begin(), closed_streams_.end(), stream);
return absl::c_count(closed_streams_, stream);
}
bool WasStreamClosed(int stream) {
return std::find(closed_streams_.begin(), closed_streams_.end(), stream) !=
closed_streams_.end();
return absl::c_linear_search(closed_streams_, stream);
}
bool ReadyToSend() { return ready_to_send_; }
@ -102,9 +101,7 @@ class SignalTransportClosedReopener : public sigslot::has_slots<> {
SignalTransportClosedReopener(SctpTransport* transport, SctpTransport* peer)
: transport_(transport), peer_(peer) {}
int StreamCloseCount(int stream) {
return std::count(streams_.begin(), streams_.end(), stream);
}
int StreamCloseCount(int stream) { return absl::c_count(streams_, stream); }
private:
void OnStreamClosed(int stream) {