Delete variant of rtc::split that copies the output fields
Bug: webrtc:13579 Change-Id: I065a32704d48d5eed21aee0e9757cac9ecf7aa99 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261951 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Ali Tofigh <alito@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37160}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
774b4725a2
commit
f1d822b03b
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
|
|
||||||
// Parameters for SRTP negotiation, as described in RFC 4568.
|
// Parameters for SRTP negotiation, as described in RFC 4568.
|
||||||
@ -21,9 +23,9 @@ namespace cricket {
|
|||||||
struct CryptoParams {
|
struct CryptoParams {
|
||||||
CryptoParams() : tag(0) {}
|
CryptoParams() : tag(0) {}
|
||||||
CryptoParams(int t,
|
CryptoParams(int t,
|
||||||
const std::string& cs,
|
absl::string_view cs,
|
||||||
const std::string& kp,
|
absl::string_view kp,
|
||||||
const std::string& sp)
|
absl::string_view sp)
|
||||||
: tag(t), cipher_suite(cs), key_params(kp), session_params(sp) {}
|
: tag(t), cipher_suite(cs), key_params(kp), session_params(sp) {}
|
||||||
|
|
||||||
bool Matches(const CryptoParams& params) const {
|
bool Matches(const CryptoParams& params) const {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
#include "api/rtp_parameters.h"
|
#include "api/rtp_parameters.h"
|
||||||
@ -30,9 +31,9 @@ typedef std::map<std::string, std::string> CodecParameterMap;
|
|||||||
class FeedbackParam {
|
class FeedbackParam {
|
||||||
public:
|
public:
|
||||||
FeedbackParam() = default;
|
FeedbackParam() = default;
|
||||||
FeedbackParam(const std::string& id, const std::string& param)
|
FeedbackParam(absl::string_view id, const std::string& param)
|
||||||
: id_(id), param_(param) {}
|
: id_(id), param_(param) {}
|
||||||
explicit FeedbackParam(const std::string& id)
|
explicit FeedbackParam(absl::string_view id)
|
||||||
: id_(id), param_(kParamValueEmpty) {}
|
: id_(id), param_(kParamValueEmpty) {}
|
||||||
|
|
||||||
bool operator==(const FeedbackParam& other) const;
|
bool operator==(const FeedbackParam& other) const;
|
||||||
|
@ -52,6 +52,7 @@ rtc_library("lib") {
|
|||||||
"../../../../rtc_base:stringutils",
|
"../../../../rtc_base:stringutils",
|
||||||
"../../../../test:fileutils",
|
"../../../../test:fileutils",
|
||||||
]
|
]
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||||
visibility = [ ":*" ] # Only targets in this file can depend on this.
|
visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,15 +28,15 @@ bool Turn::operator==(const Turn& b) const {
|
|||||||
std::vector<Turn> LoadTiming(const std::string& timing_filepath) {
|
std::vector<Turn> LoadTiming(const std::string& timing_filepath) {
|
||||||
// Line parser.
|
// Line parser.
|
||||||
auto parse_line = [](const std::string& line) {
|
auto parse_line = [](const std::string& line) {
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields = rtc::split(line, ' ');
|
||||||
rtc::split(line, ' ', &fields);
|
|
||||||
RTC_CHECK_GE(fields.size(), 3);
|
RTC_CHECK_GE(fields.size(), 3);
|
||||||
RTC_CHECK_LE(fields.size(), 4);
|
RTC_CHECK_LE(fields.size(), 4);
|
||||||
int gain = 0;
|
int gain = 0;
|
||||||
if (fields.size() == 4) {
|
if (fields.size() == 4) {
|
||||||
gain = std::atof(fields[3].c_str());
|
gain = rtc::StringToNumber<int>(fields[3]).value_or(0);
|
||||||
}
|
}
|
||||||
return Turn(fields[0], fields[1], std::atol(fields[2].c_str()), gain);
|
return Turn(fields[0], fields[1],
|
||||||
|
rtc::StringToNumber<int>(fields[2]).value_or(0), gain);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Init.
|
// Init.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -21,8 +22,8 @@ namespace test {
|
|||||||
namespace conversational_speech {
|
namespace conversational_speech {
|
||||||
|
|
||||||
struct Turn {
|
struct Turn {
|
||||||
Turn(std::string new_speaker_name,
|
Turn(absl::string_view new_speaker_name,
|
||||||
std::string new_audiotrack_file_name,
|
absl::string_view new_audiotrack_file_name,
|
||||||
int new_offset,
|
int new_offset,
|
||||||
int gain)
|
int gain)
|
||||||
: speaker_name(new_speaker_name),
|
: speaker_name(new_speaker_name),
|
||||||
|
@ -37,8 +37,7 @@ PipeWireThreadLoopLock::~PipeWireThreadLoopLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) {
|
PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) {
|
||||||
std::vector<std::string> parsed_version;
|
std::vector<absl::string_view> parsed_version = rtc::split(version, '.');
|
||||||
rtc::split(version, '.', &parsed_version);
|
|
||||||
|
|
||||||
if (parsed_version.size() != 3) {
|
if (parsed_version.size() != 3) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -108,18 +108,18 @@ RTCError IceParameters::Validate() const {
|
|||||||
return RTCError::OK();
|
return RTCError::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role) {
|
absl::optional<ConnectionRole> StringToConnectionRole(
|
||||||
|
absl::string_view role_str) {
|
||||||
const char* const roles[] = {
|
const char* const roles[] = {
|
||||||
CONNECTIONROLE_ACTIVE_STR, CONNECTIONROLE_PASSIVE_STR,
|
CONNECTIONROLE_ACTIVE_STR, CONNECTIONROLE_PASSIVE_STR,
|
||||||
CONNECTIONROLE_ACTPASS_STR, CONNECTIONROLE_HOLDCONN_STR};
|
CONNECTIONROLE_ACTPASS_STR, CONNECTIONROLE_HOLDCONN_STR};
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(roles); ++i) {
|
for (size_t i = 0; i < arraysize(roles); ++i) {
|
||||||
if (absl::EqualsIgnoreCase(roles[i], role_str)) {
|
if (absl::EqualsIgnoreCase(roles[i], role_str)) {
|
||||||
*role = static_cast<ConnectionRole>(CONNECTIONROLE_ACTIVE + i);
|
return static_cast<ConnectionRole>(CONNECTIONROLE_ACTIVE + i);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str) {
|
bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str) {
|
||||||
|
@ -97,7 +97,8 @@ extern const char CONNECTIONROLE_HOLDCONN_STR[];
|
|||||||
constexpr auto* ICE_OPTION_TRICKLE = "trickle";
|
constexpr auto* ICE_OPTION_TRICKLE = "trickle";
|
||||||
constexpr auto* ICE_OPTION_RENOMINATION = "renomination";
|
constexpr auto* ICE_OPTION_RENOMINATION = "renomination";
|
||||||
|
|
||||||
bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role);
|
absl::optional<ConnectionRole> StringToConnectionRole(
|
||||||
|
absl::string_view role_str);
|
||||||
bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str);
|
bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str);
|
||||||
|
|
||||||
struct TransportDescription {
|
struct TransportDescription {
|
||||||
|
@ -676,6 +676,7 @@ rtc_source_set("session_description") {
|
|||||||
absl_deps = [
|
absl_deps = [
|
||||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||||
"//third_party/abseil-cpp/absl/memory:memory",
|
"//third_party/abseil-cpp/absl/memory:memory",
|
||||||
|
"//third_party/abseil-cpp/absl/strings",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,10 +863,10 @@ static bool FindMatchingCodec(const std::vector<C>& codecs1,
|
|||||||
// Mixed reference codecs (i.e. 111/112) are not supported.
|
// Mixed reference codecs (i.e. 111/112) are not supported.
|
||||||
// Different levels of redundancy between offer and answer are
|
// Different levels of redundancy between offer and answer are
|
||||||
// since RED is considered to be declarative.
|
// since RED is considered to be declarative.
|
||||||
std::vector<std::string> redundant_payloads_1;
|
std::vector<absl::string_view> redundant_payloads_1 =
|
||||||
std::vector<std::string> redundant_payloads_2;
|
rtc::split(red_parameters_1->second, '/');
|
||||||
rtc::split(red_parameters_1->second, '/', &redundant_payloads_1);
|
std::vector<absl::string_view> redundant_payloads_2 =
|
||||||
rtc::split(red_parameters_2->second, '/', &redundant_payloads_2);
|
rtc::split(red_parameters_2->second, '/');
|
||||||
if (redundant_payloads_1.size() > 0 &&
|
if (redundant_payloads_1.size() > 0 &&
|
||||||
redundant_payloads_2.size() > 0) {
|
redundant_payloads_2.size() > 0) {
|
||||||
bool consistent = true;
|
bool consistent = true;
|
||||||
@ -951,13 +951,12 @@ static const C* GetAssociatedCodecForRed(const std::vector<C>& codec_list,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> redundant_payloads;
|
std::vector<absl::string_view> redundant_payloads = rtc::split(fmtp, '/');
|
||||||
rtc::split(fmtp, '/', &redundant_payloads);
|
|
||||||
if (redundant_payloads.size() < 2) {
|
if (redundant_payloads.size() < 2) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string associated_pt_str = redundant_payloads[0];
|
absl::string_view associated_pt_str = redundant_payloads[0];
|
||||||
int associated_pt;
|
int associated_pt;
|
||||||
if (!rtc::FromString(associated_pt_str, &associated_pt)) {
|
if (!rtc::FromString(associated_pt_str, &associated_pt)) {
|
||||||
RTC_LOG(LS_WARNING) << "Couldn't convert first payload type "
|
RTC_LOG(LS_WARNING) << "Couldn't convert first payload type "
|
||||||
@ -1107,8 +1106,8 @@ static Codecs MatchCodecPreference(
|
|||||||
const auto fmtp =
|
const auto fmtp =
|
||||||
codec.params.find(cricket::kCodecParamNotInNameValueFormat);
|
codec.params.find(cricket::kCodecParamNotInNameValueFormat);
|
||||||
if (fmtp != codec.params.end()) {
|
if (fmtp != codec.params.end()) {
|
||||||
std::vector<std::string> redundant_payloads;
|
std::vector<absl::string_view> redundant_payloads =
|
||||||
rtc::split(fmtp->second, '/', &redundant_payloads);
|
rtc::split(fmtp->second, '/');
|
||||||
if (redundant_payloads.size() > 0 &&
|
if (redundant_payloads.size() > 0 &&
|
||||||
redundant_payloads[0] == id) {
|
redundant_payloads[0] == id) {
|
||||||
if (std::find(filtered_codecs.begin(), filtered_codecs.end(),
|
if (std::find(filtered_codecs.begin(), filtered_codecs.end(),
|
||||||
|
@ -65,17 +65,17 @@ const std::string* ContentGroup::FirstContentName() const {
|
|||||||
return (!content_names_.empty()) ? &(*content_names_.begin()) : NULL;
|
return (!content_names_.empty()) ? &(*content_names_.begin()) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentGroup::HasContentName(const std::string& content_name) const {
|
bool ContentGroup::HasContentName(absl::string_view content_name) const {
|
||||||
return absl::c_linear_search(content_names_, content_name);
|
return absl::c_linear_search(content_names_, content_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentGroup::AddContentName(const std::string& content_name) {
|
void ContentGroup::AddContentName(absl::string_view content_name) {
|
||||||
if (!HasContentName(content_name)) {
|
if (!HasContentName(content_name)) {
|
||||||
content_names_.push_back(content_name);
|
content_names_.emplace_back(content_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentGroup::RemoveContentName(const std::string& content_name) {
|
bool ContentGroup::RemoveContentName(absl::string_view content_name) {
|
||||||
ContentNames::iterator iter = absl::c_find(content_names_, content_name);
|
ContentNames::iterator iter = absl::c_find(content_names_, content_name);
|
||||||
if (iter == content_names_.end()) {
|
if (iter == content_names_.end()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/crypto_params.h"
|
#include "api/crypto_params.h"
|
||||||
#include "api/media_types.h"
|
#include "api/media_types.h"
|
||||||
#include "api/rtp_parameters.h"
|
#include "api/rtp_parameters.h"
|
||||||
@ -95,8 +96,8 @@ class MediaContentDescription {
|
|||||||
// `protocol` is the expected media transport protocol, such as RTP/AVPF,
|
// `protocol` is the expected media transport protocol, such as RTP/AVPF,
|
||||||
// RTP/SAVPF or SCTP/DTLS.
|
// RTP/SAVPF or SCTP/DTLS.
|
||||||
virtual std::string protocol() const { return protocol_; }
|
virtual std::string protocol() const { return protocol_; }
|
||||||
virtual void set_protocol(const std::string& protocol) {
|
virtual void set_protocol(absl::string_view protocol) {
|
||||||
protocol_ = protocol;
|
protocol_ = std::string(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual webrtc::RtpTransceiverDirection direction() const {
|
virtual webrtc::RtpTransceiverDirection direction() const {
|
||||||
@ -282,9 +283,9 @@ class MediaContentDescription {
|
|||||||
template <class C>
|
template <class C>
|
||||||
class MediaContentDescriptionImpl : public MediaContentDescription {
|
class MediaContentDescriptionImpl : public MediaContentDescription {
|
||||||
public:
|
public:
|
||||||
void set_protocol(const std::string& protocol) override {
|
void set_protocol(absl::string_view protocol) override {
|
||||||
RTC_DCHECK(IsRtpProtocol(protocol));
|
RTC_DCHECK(IsRtpProtocol(protocol));
|
||||||
protocol_ = protocol;
|
protocol_ = std::string(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef C CodecType;
|
typedef C CodecType;
|
||||||
@ -365,9 +366,9 @@ class SctpDataContentDescription : public MediaContentDescription {
|
|||||||
const SctpDataContentDescription* as_sctp() const override { return this; }
|
const SctpDataContentDescription* as_sctp() const override { return this; }
|
||||||
|
|
||||||
bool has_codecs() const override { return false; }
|
bool has_codecs() const override { return false; }
|
||||||
void set_protocol(const std::string& protocol) override {
|
void set_protocol(absl::string_view protocol) override {
|
||||||
RTC_DCHECK(IsSctpProtocol(protocol));
|
RTC_DCHECK(IsSctpProtocol(protocol));
|
||||||
protocol_ = protocol;
|
protocol_ = std::string(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_sctpmap() const { return use_sctpmap_; }
|
bool use_sctpmap() const { return use_sctpmap_; }
|
||||||
@ -392,7 +393,7 @@ class SctpDataContentDescription : public MediaContentDescription {
|
|||||||
|
|
||||||
class UnsupportedContentDescription : public MediaContentDescription {
|
class UnsupportedContentDescription : public MediaContentDescription {
|
||||||
public:
|
public:
|
||||||
explicit UnsupportedContentDescription(const std::string& media_type)
|
explicit UnsupportedContentDescription(absl::string_view media_type)
|
||||||
: media_type_(media_type) {}
|
: media_type_(media_type) {}
|
||||||
MediaType type() const override { return MEDIA_TYPE_UNSUPPORTED; }
|
MediaType type() const override { return MEDIA_TYPE_UNSUPPORTED; }
|
||||||
|
|
||||||
@ -478,9 +479,9 @@ class ContentGroup {
|
|||||||
const ContentNames& content_names() const { return content_names_; }
|
const ContentNames& content_names() const { return content_names_; }
|
||||||
|
|
||||||
const std::string* FirstContentName() const;
|
const std::string* FirstContentName() const;
|
||||||
bool HasContentName(const std::string& content_name) const;
|
bool HasContentName(absl::string_view content_name) const;
|
||||||
void AddContentName(const std::string& content_name);
|
void AddContentName(absl::string_view content_name);
|
||||||
bool RemoveContentName(const std::string& content_name);
|
bool RemoveContentName(absl::string_view content_name);
|
||||||
// for debugging
|
// for debugging
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
|
139
pc/webrtc_sdp.cc
139
pc/webrtc_sdp.cc
@ -1078,8 +1078,8 @@ bool ParseCandidate(absl::string_view message,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(candidate_value, kSdpDelimiterSpaceChar, &fields);
|
rtc::split(candidate_value, kSdpDelimiterSpaceChar);
|
||||||
|
|
||||||
// RFC 5245
|
// RFC 5245
|
||||||
// a=candidate:<foundation> <component-id> <transport> <priority>
|
// a=candidate:<foundation> <component-id> <transport> <priority>
|
||||||
@ -1091,18 +1091,18 @@ bool ParseCandidate(absl::string_view message,
|
|||||||
(fields[6] != kAttributeCandidateTyp)) {
|
(fields[6] != kAttributeCandidateTyp)) {
|
||||||
return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error);
|
return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error);
|
||||||
}
|
}
|
||||||
const std::string& foundation = fields[0];
|
const absl::string_view foundation = fields[0];
|
||||||
|
|
||||||
int component_id = 0;
|
int component_id = 0;
|
||||||
if (!GetValueFromString(first_line, fields[1], &component_id, error)) {
|
if (!GetValueFromString(first_line, fields[1], &component_id, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const std::string& transport = fields[2];
|
const absl::string_view transport = fields[2];
|
||||||
uint32_t priority = 0;
|
uint32_t priority = 0;
|
||||||
if (!GetValueFromString(first_line, fields[3], &priority, error)) {
|
if (!GetValueFromString(first_line, fields[3], &priority, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const std::string& connection_address = fields[4];
|
const absl::string_view connection_address = fields[4];
|
||||||
int port = 0;
|
int port = 0;
|
||||||
if (!GetValueFromString(first_line, fields[5], &port, error)) {
|
if (!GetValueFromString(first_line, fields[5], &port, error)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1131,7 +1131,7 @@ bool ParseCandidate(absl::string_view message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string candidate_type;
|
std::string candidate_type;
|
||||||
const std::string& type = fields[7];
|
const absl::string_view type = fields[7];
|
||||||
if (type == kCandidateHost) {
|
if (type == kCandidateHost) {
|
||||||
candidate_type = cricket::LOCAL_PORT_TYPE;
|
candidate_type = cricket::LOCAL_PORT_TYPE;
|
||||||
} else if (type == kCandidateSrflx) {
|
} else if (type == kCandidateSrflx) {
|
||||||
@ -1169,7 +1169,7 @@ bool ParseCandidate(absl::string_view message,
|
|||||||
|
|
||||||
// If this is a TCP candidate, it has additional extension as defined in
|
// If this is a TCP candidate, it has additional extension as defined in
|
||||||
// RFC 6544.
|
// RFC 6544.
|
||||||
std::string tcptype;
|
absl::string_view tcptype;
|
||||||
if (fields.size() >= (current_position + 2) &&
|
if (fields.size() >= (current_position + 2) &&
|
||||||
fields[current_position] == kTcpCandidateType) {
|
fields[current_position] == kTcpCandidateType) {
|
||||||
tcptype = fields[++current_position];
|
tcptype = fields[++current_position];
|
||||||
@ -1195,8 +1195,8 @@ bool ParseCandidate(absl::string_view message,
|
|||||||
// Though non-standard, we support the ICE ufrag and pwd being signaled on
|
// Though non-standard, we support the ICE ufrag and pwd being signaled on
|
||||||
// the candidate to avoid issues with confusing which generation a candidate
|
// the candidate to avoid issues with confusing which generation a candidate
|
||||||
// belongs to when trickling multiple generations at the same time.
|
// belongs to when trickling multiple generations at the same time.
|
||||||
std::string username;
|
absl::string_view username;
|
||||||
std::string password;
|
absl::string_view password;
|
||||||
uint32_t generation = 0;
|
uint32_t generation = 0;
|
||||||
uint16_t network_id = 0;
|
uint16_t network_id = 0;
|
||||||
uint16_t network_cost = 0;
|
uint16_t network_cost = 0;
|
||||||
@ -1241,10 +1241,10 @@ bool ParseIceOptions(absl::string_view line,
|
|||||||
if (!GetValue(line, kAttributeIceOption, &ice_options, error)) {
|
if (!GetValue(line, kAttributeIceOption, &ice_options, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(ice_options, kSdpDelimiterSpaceChar, &fields);
|
rtc::split(ice_options, kSdpDelimiterSpaceChar);
|
||||||
for (size_t i = 0; i < fields.size(); ++i) {
|
for (size_t i = 0; i < fields.size(); ++i) {
|
||||||
transport_options->push_back(fields[i]);
|
transport_options->emplace_back(fields[i]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1254,12 +1254,11 @@ bool ParseSctpPort(absl::string_view line,
|
|||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
// draft-ietf-mmusic-sctp-sdp-26
|
// draft-ietf-mmusic-sctp-sdp-26
|
||||||
// a=sctp-port
|
// a=sctp-port
|
||||||
std::vector<std::string> fields;
|
|
||||||
const size_t expected_min_fields = 2;
|
const size_t expected_min_fields = 2;
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar, &fields);
|
std::vector<absl::string_view> fields =
|
||||||
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar);
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
fields.resize(0);
|
fields = rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
|
||||||
}
|
}
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
||||||
@ -1275,9 +1274,9 @@ bool ParseSctpMaxMessageSize(absl::string_view line,
|
|||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
// draft-ietf-mmusic-sctp-sdp-26
|
// draft-ietf-mmusic-sctp-sdp-26
|
||||||
// a=max-message-size:199999
|
// a=max-message-size:199999
|
||||||
std::vector<std::string> fields;
|
|
||||||
const size_t expected_min_fields = 2;
|
const size_t expected_min_fields = 2;
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar, &fields);
|
std::vector<absl::string_view> fields =
|
||||||
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar);
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
||||||
}
|
}
|
||||||
@ -1292,20 +1291,20 @@ bool ParseExtmap(absl::string_view line,
|
|||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
// RFC 5285
|
// RFC 5285
|
||||||
// a=extmap:<value>["/"<direction>] <URI> <extensionattributes>
|
// a=extmap:<value>["/"<direction>] <URI> <extensionattributes>
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
const size_t expected_min_fields = 2;
|
const size_t expected_min_fields = 2;
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
||||||
}
|
}
|
||||||
std::string uri = fields[1];
|
absl::string_view uri = fields[1];
|
||||||
|
|
||||||
std::string value_direction;
|
std::string value_direction;
|
||||||
if (!GetValue(fields[0], kAttributeExtmap, &value_direction, error)) {
|
if (!GetValue(fields[0], kAttributeExtmap, &value_direction, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<std::string> sub_fields;
|
std::vector<absl::string_view> sub_fields =
|
||||||
rtc::split(value_direction, kSdpDelimiterSlashChar, &sub_fields);
|
rtc::split(value_direction, kSdpDelimiterSlashChar);
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (!GetValueFromString(line, sub_fields[0], &value, error)) {
|
if (!GetValueFromString(line, sub_fields[0], &value, error)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2116,14 +2115,14 @@ bool ParseSessionDescription(absl::string_view message,
|
|||||||
return ParseFailedExpectLine(message, *pos, kLineTypeOrigin, std::string(),
|
return ParseFailedExpectLine(message, *pos, kLineTypeOrigin, std::string(),
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line->substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line->substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
const size_t expected_fields = 6;
|
const size_t expected_fields = 6;
|
||||||
if (fields.size() != expected_fields) {
|
if (fields.size() != expected_fields) {
|
||||||
return ParseFailedExpectFieldNum(*line, expected_fields, error);
|
return ParseFailedExpectFieldNum(*line, expected_fields, error);
|
||||||
}
|
}
|
||||||
*session_id = fields[1];
|
*session_id = std::string(fields[1]);
|
||||||
*session_version = fields[2];
|
*session_version = std::string(fields[2]);
|
||||||
|
|
||||||
// RFC 4566
|
// RFC 4566
|
||||||
// s= (session name)
|
// s= (session name)
|
||||||
@ -2263,8 +2262,8 @@ bool ParseGroupAttribute(absl::string_view line,
|
|||||||
|
|
||||||
// RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00
|
// RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00
|
||||||
// a=group:BUNDLE video voice
|
// a=group:BUNDLE video voice
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
std::string semantics;
|
std::string semantics;
|
||||||
if (!GetValue(fields[0], kAttributeGroup, &semantics, error)) {
|
if (!GetValue(fields[0], kAttributeGroup, &semantics, error)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2281,8 +2280,8 @@ static bool ParseFingerprintAttribute(
|
|||||||
absl::string_view line,
|
absl::string_view line,
|
||||||
std::unique_ptr<rtc::SSLFingerprint>* fingerprint,
|
std::unique_ptr<rtc::SSLFingerprint>* fingerprint,
|
||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
const size_t expected_fields = 2;
|
const size_t expected_fields = 2;
|
||||||
if (fields.size() != expected_fields) {
|
if (fields.size() != expected_fields) {
|
||||||
return ParseFailedExpectFieldNum(line, expected_fields, error);
|
return ParseFailedExpectFieldNum(line, expected_fields, error);
|
||||||
@ -2310,21 +2309,23 @@ static bool ParseFingerprintAttribute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseDtlsSetup(absl::string_view line,
|
static bool ParseDtlsSetup(absl::string_view line,
|
||||||
cricket::ConnectionRole* role,
|
cricket::ConnectionRole* role_ptr,
|
||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
// setup-attr = "a=setup:" role
|
// setup-attr = "a=setup:" role
|
||||||
// role = "active" / "passive" / "actpass" / "holdconn"
|
// role = "active" / "passive" / "actpass" / "holdconn"
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterColonChar);
|
||||||
const size_t expected_fields = 2;
|
const size_t expected_fields = 2;
|
||||||
if (fields.size() != expected_fields) {
|
if (fields.size() != expected_fields) {
|
||||||
return ParseFailedExpectFieldNum(line, expected_fields, error);
|
return ParseFailedExpectFieldNum(line, expected_fields, error);
|
||||||
}
|
}
|
||||||
std::string role_str = fields[1];
|
if (absl::optional<cricket::ConnectionRole> role =
|
||||||
if (!cricket::StringToConnectionRole(role_str, role)) {
|
cricket::StringToConnectionRole(fields[1]);
|
||||||
return ParseFailed(line, "Invalid attribute value.", error);
|
role.has_value()) {
|
||||||
}
|
*role_ptr = *role;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return ParseFailed(line, "Invalid attribute value.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseMsidAttribute(absl::string_view line,
|
static bool ParseMsidAttribute(absl::string_view line,
|
||||||
@ -2623,9 +2624,8 @@ bool ParseMediaDescription(
|
|||||||
GetLineWithType(message, pos, kLineTypeMedia)) {
|
GetLineWithType(message, pos, kLineTypeMedia)) {
|
||||||
++mline_index;
|
++mline_index;
|
||||||
|
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(mline->substr(kLinePrefixLength), kSdpDelimiterSpaceChar,
|
rtc::split(mline->substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
&fields);
|
|
||||||
|
|
||||||
const size_t expected_min_fields = 4;
|
const size_t expected_min_fields = 4;
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
@ -2643,7 +2643,7 @@ bool ParseMediaDescription(
|
|||||||
if (!rtc::FromString<int>(fields[1], &port) || !IsValidPort(port)) {
|
if (!rtc::FromString<int>(fields[1], &port) || !IsValidPort(port)) {
|
||||||
return ParseFailed(*mline, "The port number is invalid", error);
|
return ParseFailed(*mline, "The port number is invalid", error);
|
||||||
}
|
}
|
||||||
const std::string& protocol = fields[2];
|
absl::string_view protocol = fields[2];
|
||||||
|
|
||||||
// <fmt>
|
// <fmt>
|
||||||
std::vector<int> payload_types;
|
std::vector<int> payload_types;
|
||||||
@ -2668,7 +2668,7 @@ bool ParseMediaDescription(
|
|||||||
std::string content_name;
|
std::string content_name;
|
||||||
bool bundle_only = false;
|
bool bundle_only = false;
|
||||||
int section_msid_signaling = 0;
|
int section_msid_signaling = 0;
|
||||||
const std::string& media_type = fields[0];
|
absl::string_view media_type = fields[0];
|
||||||
if ((media_type == kMediaTypeVideo || media_type == kMediaTypeAudio) &&
|
if ((media_type == kMediaTypeVideo || media_type == kMediaTypeAudio) &&
|
||||||
!cricket::IsRtpProtocol(protocol)) {
|
!cricket::IsRtpProtocol(protocol)) {
|
||||||
return ParseFailed(*mline, "Unsupported protocol for media type", error);
|
return ParseFailed(*mline, "Unsupported protocol for media type", error);
|
||||||
@ -2756,7 +2756,7 @@ bool ParseMediaDescription(
|
|||||||
if (content->as_unsupported()) {
|
if (content->as_unsupported()) {
|
||||||
content_rejected = true;
|
content_rejected = true;
|
||||||
} else if (cricket::IsRtpProtocol(protocol) && !content->as_sctp()) {
|
} else if (cricket::IsRtpProtocol(protocol) && !content->as_sctp()) {
|
||||||
content->set_protocol(protocol);
|
content->set_protocol(std::string(protocol));
|
||||||
// Set the extmap.
|
// Set the extmap.
|
||||||
if (!session_extmaps.empty() &&
|
if (!session_extmaps.empty() &&
|
||||||
!content->rtp_header_extensions().empty()) {
|
!content->rtp_header_extensions().empty()) {
|
||||||
@ -3442,15 +3442,15 @@ bool ParseSsrcAttribute(absl::string_view line,
|
|||||||
} else if (attribute == kSsrcAttributeMsid) {
|
} else if (attribute == kSsrcAttributeMsid) {
|
||||||
// draft-alvestrand-mmusic-msid-00
|
// draft-alvestrand-mmusic-msid-00
|
||||||
// msid:identifier [appdata]
|
// msid:identifier [appdata]
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(value, kSdpDelimiterSpaceChar, &fields);
|
rtc::split(value, kSdpDelimiterSpaceChar);
|
||||||
if (fields.size() < 1 || fields.size() > 2) {
|
if (fields.size() < 1 || fields.size() > 2) {
|
||||||
return ParseFailed(
|
return ParseFailed(
|
||||||
line, "Expected format \"msid:<identifier>[ <appdata>]\".", error);
|
line, "Expected format \"msid:<identifier>[ <appdata>]\".", error);
|
||||||
}
|
}
|
||||||
ssrc_info.stream_id = fields[0];
|
ssrc_info.stream_id = std::string(fields[0]);
|
||||||
if (fields.size() == 2) {
|
if (fields.size() == 2) {
|
||||||
ssrc_info.track_id = fields[1];
|
ssrc_info.track_id = std::string(fields[1]);
|
||||||
}
|
}
|
||||||
*msid_signaling |= cricket::kMsidSignalingSsrcAttribute;
|
*msid_signaling |= cricket::kMsidSignalingSsrcAttribute;
|
||||||
} else {
|
} else {
|
||||||
@ -3465,8 +3465,8 @@ bool ParseSsrcGroupAttribute(absl::string_view line,
|
|||||||
RTC_DCHECK(ssrc_groups != NULL);
|
RTC_DCHECK(ssrc_groups != NULL);
|
||||||
// RFC 5576
|
// RFC 5576
|
||||||
// a=ssrc-group:<semantics> <ssrc-id> ...
|
// a=ssrc-group:<semantics> <ssrc-id> ...
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
const size_t expected_min_fields = 2;
|
const size_t expected_min_fields = 2;
|
||||||
if (fields.size() < expected_min_fields) {
|
if (fields.size() < expected_min_fields) {
|
||||||
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
|
||||||
@ -3490,8 +3490,8 @@ bool ParseSsrcGroupAttribute(absl::string_view line,
|
|||||||
bool ParseCryptoAttribute(absl::string_view line,
|
bool ParseCryptoAttribute(absl::string_view line,
|
||||||
MediaContentDescription* media_desc,
|
MediaContentDescription* media_desc,
|
||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
// RFC 4568
|
// RFC 4568
|
||||||
// a=crypto:<tag> <crypto-suite> <key-params> [<session-params>]
|
// a=crypto:<tag> <crypto-suite> <key-params> [<session-params>]
|
||||||
const size_t expected_min_fields = 3;
|
const size_t expected_min_fields = 3;
|
||||||
@ -3506,12 +3506,13 @@ bool ParseCryptoAttribute(absl::string_view line,
|
|||||||
if (!GetValueFromString(line, tag_value, &tag, error)) {
|
if (!GetValueFromString(line, tag_value, &tag, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const std::string& crypto_suite = fields[1];
|
const absl::string_view crypto_suite = fields[1];
|
||||||
const std::string& key_params = fields[2];
|
const absl::string_view key_params = fields[2];
|
||||||
std::string session_params;
|
absl::string_view session_params;
|
||||||
if (fields.size() > 3) {
|
if (fields.size() > 3) {
|
||||||
session_params = fields[3];
|
session_params = fields[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
media_desc->AddCrypto(
|
media_desc->AddCrypto(
|
||||||
CryptoParams(tag, crypto_suite, key_params, session_params));
|
CryptoParams(tag, crypto_suite, key_params, session_params));
|
||||||
return true;
|
return true;
|
||||||
@ -3557,8 +3558,8 @@ bool ParseRtpmapAttribute(absl::string_view line,
|
|||||||
MediaContentDescription* media_desc,
|
MediaContentDescription* media_desc,
|
||||||
SdpParseError* error) {
|
SdpParseError* error) {
|
||||||
static const int kFirstDynamicPayloadTypeLowerRange = 35;
|
static const int kFirstDynamicPayloadTypeLowerRange = 35;
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields =
|
||||||
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar, &fields);
|
rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpaceChar);
|
||||||
// RFC 4566
|
// RFC 4566
|
||||||
// a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encodingparameters>]
|
// a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encodingparameters>]
|
||||||
const size_t expected_min_fields = 2;
|
const size_t expected_min_fields = 2;
|
||||||
@ -3581,9 +3582,7 @@ bool ParseRtpmapAttribute(absl::string_view line,
|
|||||||
<< line;
|
<< line;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const std::string& encoder = fields[1];
|
std::vector<absl::string_view> codec_params = rtc::split(fields[1], '/');
|
||||||
std::vector<std::string> codec_params;
|
|
||||||
rtc::split(encoder, '/', &codec_params);
|
|
||||||
// <encoding name>/<clock rate>[/<encodingparameters>]
|
// <encoding name>/<clock rate>[/<encodingparameters>]
|
||||||
// 2 mandatory fields
|
// 2 mandatory fields
|
||||||
if (codec_params.size() < 2 || codec_params.size() > 3) {
|
if (codec_params.size() < 2 || codec_params.size() > 3) {
|
||||||
@ -3592,7 +3591,7 @@ bool ParseRtpmapAttribute(absl::string_view line,
|
|||||||
"[/<encodingparameters>]\".",
|
"[/<encodingparameters>]\".",
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
const std::string& encoding_name = codec_params[0];
|
const absl::string_view encoding_name = codec_params[0];
|
||||||
int clock_rate = 0;
|
int clock_rate = 0;
|
||||||
if (!GetValueFromString(line, codec_params[1], &clock_rate, error)) {
|
if (!GetValueFromString(line, codec_params[1], &clock_rate, error)) {
|
||||||
return false;
|
return false;
|
||||||
@ -3736,8 +3735,8 @@ bool ParsePacketizationAttribute(absl::string_view line,
|
|||||||
if (media_type != cricket::MEDIA_TYPE_VIDEO) {
|
if (media_type != cricket::MEDIA_TYPE_VIDEO) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::vector<std::string> packetization_fields;
|
std::vector<absl::string_view> packetization_fields =
|
||||||
rtc::split(line, kSdpDelimiterSpaceChar, &packetization_fields);
|
rtc::split(line, kSdpDelimiterSpaceChar);
|
||||||
if (packetization_fields.size() < 2) {
|
if (packetization_fields.size() < 2) {
|
||||||
return ParseFailedGetValue(line, kAttributePacketization, error);
|
return ParseFailedGetValue(line, kAttributePacketization, error);
|
||||||
}
|
}
|
||||||
@ -3751,7 +3750,7 @@ bool ParsePacketizationAttribute(absl::string_view line,
|
|||||||
error)) {
|
error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string packetization = packetization_fields[1];
|
absl::string_view packetization = packetization_fields[1];
|
||||||
UpdateVideoCodecPacketization(media_desc->as_video(), payload_type,
|
UpdateVideoCodecPacketization(media_desc->as_video(), payload_type,
|
||||||
packetization);
|
packetization);
|
||||||
return true;
|
return true;
|
||||||
@ -3765,8 +3764,8 @@ bool ParseRtcpFbAttribute(absl::string_view line,
|
|||||||
media_type != cricket::MEDIA_TYPE_VIDEO) {
|
media_type != cricket::MEDIA_TYPE_VIDEO) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::vector<std::string> rtcp_fb_fields;
|
std::vector<absl::string_view> rtcp_fb_fields =
|
||||||
rtc::split(line, kSdpDelimiterSpaceChar, &rtcp_fb_fields);
|
rtc::split(line, kSdpDelimiterSpaceChar);
|
||||||
if (rtcp_fb_fields.size() < 2) {
|
if (rtcp_fb_fields.size() < 2) {
|
||||||
return ParseFailedGetValue(line, kAttributeRtcpFb, error);
|
return ParseFailedGetValue(line, kAttributeRtcpFb, error);
|
||||||
}
|
}
|
||||||
@ -3782,11 +3781,11 @@ bool ParseRtcpFbAttribute(absl::string_view line,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string id = rtcp_fb_fields[1];
|
absl::string_view id = rtcp_fb_fields[1];
|
||||||
std::string param = "";
|
std::string param = "";
|
||||||
for (std::vector<std::string>::iterator iter = rtcp_fb_fields.begin() + 2;
|
for (auto iter = rtcp_fb_fields.begin() + 2; iter != rtcp_fb_fields.end();
|
||||||
iter != rtcp_fb_fields.end(); ++iter) {
|
++iter) {
|
||||||
param.append(*iter);
|
param.append(iter->data(), iter->length());
|
||||||
}
|
}
|
||||||
const cricket::FeedbackParam feedback_param(id, param);
|
const cricket::FeedbackParam feedback_param(id, param);
|
||||||
|
|
||||||
|
@ -73,11 +73,9 @@ class FieldTrialList : public FieldTrialListBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> tokens;
|
|
||||||
std::vector<T> new_values_;
|
std::vector<T> new_values_;
|
||||||
rtc::split(str_value.value(), '|', &tokens);
|
|
||||||
|
|
||||||
for (std::string token : tokens) {
|
for (const absl::string_view token : rtc::split(str_value.value(), '|')) {
|
||||||
absl::optional<T> value = ParseTypedParameter<T>(token);
|
absl::optional<T> value = ParseTypedParameter<T>(token);
|
||||||
if (value) {
|
if (value) {
|
||||||
new_values_.push_back(*value);
|
new_values_.push_back(*value);
|
||||||
|
@ -187,17 +187,6 @@ std::vector<absl::string_view> split(absl::string_view source, char delimiter) {
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t split(absl::string_view source,
|
|
||||||
char delimiter,
|
|
||||||
std::vector<std::string>* fields) {
|
|
||||||
RTC_DCHECK(fields);
|
|
||||||
fields->clear();
|
|
||||||
for (const absl::string_view field_view : split(source, delimiter)) {
|
|
||||||
fields->emplace_back(field_view);
|
|
||||||
}
|
|
||||||
return fields->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToString(const bool b) {
|
std::string ToString(const bool b) {
|
||||||
return b ? "true" : "false";
|
return b ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,6 @@ size_t hex_decode_with_delimiter(ArrayView<char> buffer,
|
|||||||
// single, empty, field.
|
// single, empty, field.
|
||||||
std::vector<absl::string_view> split(absl::string_view source, char delimiter);
|
std::vector<absl::string_view> split(absl::string_view source, char delimiter);
|
||||||
|
|
||||||
size_t split(absl::string_view source,
|
|
||||||
char delimiter,
|
|
||||||
std::vector<std::string>* fields);
|
|
||||||
|
|
||||||
// Splits the source string into multiple fields separated by delimiter,
|
// Splits the source string into multiple fields separated by delimiter,
|
||||||
// with duplicates of delimiter ignored. Trailing delimiter ignored.
|
// with duplicates of delimiter ignored. Trailing delimiter ignored.
|
||||||
size_t tokenize(absl::string_view source,
|
size_t tokenize(absl::string_view source,
|
||||||
|
@ -215,53 +215,45 @@ TEST(TokenizeFirstTest, SingleToken) {
|
|||||||
|
|
||||||
// Tests counting substrings.
|
// Tests counting substrings.
|
||||||
TEST(SplitTest, CountSubstrings) {
|
TEST(SplitTest, CountSubstrings) {
|
||||||
std::vector<std::string> fields;
|
EXPECT_EQ(5ul, split("one,two,three,four,five", ',').size());
|
||||||
|
EXPECT_EQ(1ul, split("one", ',').size());
|
||||||
EXPECT_EQ(5ul, split("one,two,three,four,five", ',', &fields));
|
|
||||||
fields.clear();
|
|
||||||
EXPECT_EQ(1ul, split("one", ',', &fields));
|
|
||||||
|
|
||||||
// Empty fields between commas count.
|
// Empty fields between commas count.
|
||||||
fields.clear();
|
EXPECT_EQ(5ul, split("one,,three,four,five", ',').size());
|
||||||
EXPECT_EQ(5ul, split("one,,three,four,five", ',', &fields));
|
EXPECT_EQ(3ul, split(",three,", ',').size());
|
||||||
fields.clear();
|
EXPECT_EQ(1ul, split("", ',').size());
|
||||||
EXPECT_EQ(3ul, split(",three,", ',', &fields));
|
|
||||||
fields.clear();
|
|
||||||
EXPECT_EQ(1ul, split("", ',', &fields));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests comparing substrings.
|
// Tests comparing substrings.
|
||||||
TEST(SplitTest, CompareSubstrings) {
|
TEST(SplitTest, CompareSubstrings) {
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields = split("find,middle,one", ',');
|
||||||
|
|
||||||
split("find,middle,one", ',', &fields);
|
|
||||||
ASSERT_EQ(3ul, fields.size());
|
ASSERT_EQ(3ul, fields.size());
|
||||||
ASSERT_STREQ("middle", fields.at(1).c_str());
|
ASSERT_EQ("middle", fields.at(1));
|
||||||
fields.clear();
|
|
||||||
|
|
||||||
// Empty fields between commas count.
|
// Empty fields between commas count.
|
||||||
split("find,,middle,one", ',', &fields);
|
fields = split("find,,middle,one", ',');
|
||||||
ASSERT_EQ(4ul, fields.size());
|
ASSERT_EQ(4ul, fields.size());
|
||||||
ASSERT_STREQ("middle", fields.at(2).c_str());
|
ASSERT_EQ("middle", fields.at(2));
|
||||||
fields.clear();
|
fields = split("", ',');
|
||||||
split("", ',', &fields);
|
|
||||||
ASSERT_EQ(1ul, fields.size());
|
ASSERT_EQ(1ul, fields.size());
|
||||||
ASSERT_STREQ("", fields.at(0).c_str());
|
ASSERT_EQ("", fields.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SplitTest, EmptyTokens) {
|
TEST(SplitTest, EmptyTokens) {
|
||||||
std::vector<std::string> fields;
|
std::vector<absl::string_view> fields = split("a.b.c", '.');
|
||||||
EXPECT_EQ(3ul, split("a.b.c", '.', &fields));
|
ASSERT_EQ(3ul, fields.size());
|
||||||
EXPECT_EQ("a", fields[0]);
|
EXPECT_EQ("a", fields[0]);
|
||||||
EXPECT_EQ("b", fields[1]);
|
EXPECT_EQ("b", fields[1]);
|
||||||
EXPECT_EQ("c", fields[2]);
|
EXPECT_EQ("c", fields[2]);
|
||||||
|
|
||||||
EXPECT_EQ(3ul, split("..c", '.', &fields));
|
fields = split("..c", '.');
|
||||||
|
ASSERT_EQ(3ul, fields.size());
|
||||||
EXPECT_TRUE(fields[0].empty());
|
EXPECT_TRUE(fields[0].empty());
|
||||||
EXPECT_TRUE(fields[1].empty());
|
EXPECT_TRUE(fields[1].empty());
|
||||||
EXPECT_EQ("c", fields[2]);
|
EXPECT_EQ("c", fields[2]);
|
||||||
|
|
||||||
EXPECT_EQ(1ul, split("", '.', &fields));
|
fields = split("", '.');
|
||||||
|
ASSERT_EQ(1ul, fields.size());
|
||||||
EXPECT_TRUE(fields[0].empty());
|
EXPECT_TRUE(fields[0].empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,11 @@ void InsertOrReplaceFieldTrialStringsInMap(
|
|||||||
std::map<std::string, std::string>* fieldtrial_map,
|
std::map<std::string, std::string>* fieldtrial_map,
|
||||||
const absl::string_view trials_string) {
|
const absl::string_view trials_string) {
|
||||||
if (FieldTrialsStringIsValidInternal(trials_string)) {
|
if (FieldTrialsStringIsValidInternal(trials_string)) {
|
||||||
std::vector<std::string> tokens;
|
std::vector<absl::string_view> tokens = rtc::split(trials_string, '/');
|
||||||
rtc::split(std::string(trials_string), '/', &tokens);
|
|
||||||
// Skip last token which is empty due to trailing '/'.
|
// Skip last token which is empty due to trailing '/'.
|
||||||
for (size_t idx = 0; idx < tokens.size() - 1; idx += 2) {
|
for (size_t idx = 0; idx < tokens.size() - 1; idx += 2) {
|
||||||
(*fieldtrial_map)[tokens[idx]] = tokens[idx + 1];
|
(*fieldtrial_map)[std::string(tokens[idx])] =
|
||||||
|
std::string(tokens[idx + 1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RTC_DCHECK_NOTREACHED() << "Invalid field trials string:" << trials_string;
|
RTC_DCHECK_NOTREACHED() << "Invalid field trials string:" << trials_string;
|
||||||
|
Reference in New Issue
Block a user