mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
RtpParameters: respect https://abseil.io/tips/1.
This CL replaces a few usages of const std::string& with absl::string_view, to comply closer with https://abseil.io/tips/1. Bug: webrtc:11428 Change-Id: Ibf6fac9b084cb21e17db63f73d667793ab9cafeb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170466 Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30845}
This commit is contained in:
parent
f4306ebfea
commit
dfeb0dff73
6 changed files with 31 additions and 29 deletions
|
@ -317,6 +317,7 @@ rtc_library("rtp_parameters") {
|
|||
"../rtc_base:checks",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/system:rtc_export",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
|
@ -31,24 +32,23 @@ RtpCodecCapability::RtpCodecCapability() = default;
|
|||
RtpCodecCapability::~RtpCodecCapability() = default;
|
||||
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability() = default;
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(
|
||||
const std::string& uri)
|
||||
: uri(uri) {}
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(
|
||||
const std::string& uri,
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(std::string uri)
|
||||
: uri(std::move(uri)) {}
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(std::string uri,
|
||||
int preferred_id)
|
||||
: uri(uri), preferred_id(preferred_id) {}
|
||||
: uri(std::move(uri)), preferred_id(preferred_id) {}
|
||||
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(
|
||||
const std::string& uri,
|
||||
std::string uri,
|
||||
int preferred_id,
|
||||
RtpTransceiverDirection direction)
|
||||
: uri(uri), preferred_id(preferred_id), direction(direction) {}
|
||||
: uri(std::move(uri)), preferred_id(preferred_id), direction(direction) {}
|
||||
RtpHeaderExtensionCapability::~RtpHeaderExtensionCapability() = default;
|
||||
|
||||
RtpExtension::RtpExtension() = default;
|
||||
RtpExtension::RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {}
|
||||
RtpExtension::RtpExtension(const std::string& uri, int id, bool encrypt)
|
||||
: uri(uri), id(id), encrypt(encrypt) {}
|
||||
RtpExtension::RtpExtension(std::string uri, int id)
|
||||
: uri(std::move(uri)), id(id) {}
|
||||
RtpExtension::RtpExtension(std::string uri, int id, bool encrypt)
|
||||
: uri(std::move(uri)), id(id), encrypt(encrypt) {}
|
||||
RtpExtension::~RtpExtension() = default;
|
||||
|
||||
RtpFecParameters::RtpFecParameters() = default;
|
||||
|
@ -161,7 +161,7 @@ constexpr int RtpExtension::kMaxValueSize;
|
|||
constexpr int RtpExtension::kOneByteHeaderExtensionMaxId;
|
||||
constexpr int RtpExtension::kOneByteHeaderExtensionMaxValueSize;
|
||||
|
||||
bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
|
||||
bool RtpExtension::IsSupportedForAudio(absl::string_view uri) {
|
||||
return uri == webrtc::RtpExtension::kAudioLevelUri ||
|
||||
uri == webrtc::RtpExtension::kAbsSendTimeUri ||
|
||||
uri == webrtc::RtpExtension::kAbsoluteCaptureTimeUri ||
|
||||
|
@ -172,7 +172,7 @@ bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
|
|||
uri == webrtc::RtpExtension::kRepairedRidUri;
|
||||
}
|
||||
|
||||
bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
|
||||
bool RtpExtension::IsSupportedForVideo(absl::string_view uri) {
|
||||
return uri == webrtc::RtpExtension::kTimestampOffsetUri ||
|
||||
uri == webrtc::RtpExtension::kAbsSendTimeUri ||
|
||||
uri == webrtc::RtpExtension::kAbsoluteCaptureTimeUri ||
|
||||
|
@ -192,7 +192,7 @@ bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
|
|||
uri == webrtc::RtpExtension::kRepairedRidUri;
|
||||
}
|
||||
|
||||
bool RtpExtension::IsEncryptionSupported(const std::string& uri) {
|
||||
bool RtpExtension::IsEncryptionSupported(absl::string_view uri) {
|
||||
return uri == webrtc::RtpExtension::kAudioLevelUri ||
|
||||
uri == webrtc::RtpExtension::kTimestampOffsetUri ||
|
||||
#if !defined(ENABLE_EXTERNAL_AUTH)
|
||||
|
@ -216,7 +216,7 @@ bool RtpExtension::IsEncryptionSupported(const std::string& uri) {
|
|||
|
||||
const RtpExtension* RtpExtension::FindHeaderExtensionByUri(
|
||||
const std::vector<RtpExtension>& extensions,
|
||||
const std::string& uri) {
|
||||
absl::string_view uri) {
|
||||
for (const auto& extension : extensions) {
|
||||
if (extension.uri == uri) {
|
||||
return &extension;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/media_types.h"
|
||||
#include "api/rtp_transceiver_direction.h"
|
||||
|
@ -230,9 +231,9 @@ struct RTC_EXPORT RtpHeaderExtensionCapability {
|
|||
|
||||
// Constructors for convenience.
|
||||
RtpHeaderExtensionCapability();
|
||||
explicit RtpHeaderExtensionCapability(const std::string& uri);
|
||||
RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
|
||||
RtpHeaderExtensionCapability(const std::string& uri,
|
||||
explicit RtpHeaderExtensionCapability(std::string uri);
|
||||
RtpHeaderExtensionCapability(std::string uri, int preferred_id);
|
||||
RtpHeaderExtensionCapability(std::string uri,
|
||||
int preferred_id,
|
||||
RtpTransceiverDirection direction);
|
||||
~RtpHeaderExtensionCapability();
|
||||
|
@ -249,23 +250,23 @@ struct RTC_EXPORT RtpHeaderExtensionCapability {
|
|||
// RTP header extension, see RFC8285.
|
||||
struct RTC_EXPORT RtpExtension {
|
||||
RtpExtension();
|
||||
RtpExtension(const std::string& uri, int id);
|
||||
RtpExtension(const std::string& uri, int id, bool encrypt);
|
||||
RtpExtension(std::string uri, int id);
|
||||
RtpExtension(std::string uri, int id, bool encrypt);
|
||||
~RtpExtension();
|
||||
std::string ToString() const;
|
||||
bool operator==(const RtpExtension& rhs) const {
|
||||
return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
|
||||
}
|
||||
static bool IsSupportedForAudio(const std::string& uri);
|
||||
static bool IsSupportedForVideo(const std::string& uri);
|
||||
static bool IsSupportedForAudio(absl::string_view uri);
|
||||
static bool IsSupportedForVideo(absl::string_view uri);
|
||||
// Return "true" if the given RTP header extension URI may be encrypted.
|
||||
static bool IsEncryptionSupported(const std::string& uri);
|
||||
static bool IsEncryptionSupported(absl::string_view uri);
|
||||
|
||||
// Returns the named header extension if found among all extensions,
|
||||
// nullptr otherwise.
|
||||
static const RtpExtension* FindHeaderExtensionByUri(
|
||||
const std::vector<RtpExtension>& extensions,
|
||||
const std::string& uri);
|
||||
absl::string_view uri);
|
||||
|
||||
// Return a list of RTP header extensions with the non-encrypted extensions
|
||||
// removed if both the encrypted and non-encrypted extension is present for
|
||||
|
|
|
@ -86,7 +86,7 @@ bool ValidateRtpExtensions(
|
|||
|
||||
std::vector<webrtc::RtpExtension> FilterRtpExtensions(
|
||||
const std::vector<webrtc::RtpExtension>& extensions,
|
||||
bool (*supported)(const std::string&),
|
||||
bool (*supported)(absl::string_view),
|
||||
bool filter_redundant_extensions) {
|
||||
RTC_DCHECK(ValidateRtpExtensions(extensions));
|
||||
RTC_DCHECK(supported);
|
||||
|
|
|
@ -65,7 +65,7 @@ bool ValidateRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions);
|
|||
// mutually exclusive extensions (see implementation for details) are removed.
|
||||
std::vector<webrtc::RtpExtension> FilterRtpExtensions(
|
||||
const std::vector<webrtc::RtpExtension>& extensions,
|
||||
bool (*supported)(const std::string&),
|
||||
bool (*supported)(absl::string_view),
|
||||
bool filter_redundant_extensions);
|
||||
|
||||
webrtc::BitrateConstraints GetBitrateConfigForCodec(const Codec& codec);
|
||||
|
|
|
@ -45,11 +45,11 @@ std::vector<RtpExtension> MakeRedundantExtensions() {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool SupportedExtensions1(const std::string& name) {
|
||||
bool SupportedExtensions1(absl::string_view name) {
|
||||
return name == "c" || name == "i";
|
||||
}
|
||||
|
||||
bool SupportedExtensions2(const std::string& name) {
|
||||
bool SupportedExtensions2(absl::string_view name) {
|
||||
return name != "a" && name != "n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue