Remove Codec template from RtpParameters and helper functions

BUG=webrtc:15214

Change-Id: I3874c4a5089216dab3d072df7854040d5d05bcc9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/313500
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#40492}
This commit is contained in:
Philipp Hancke 2023-07-27 12:49:00 +02:00 committed by WebRTC LUCI CQ
parent 0d8b79eb40
commit 4b87d7ac2a
4 changed files with 56 additions and 57 deletions

View File

@ -811,7 +811,6 @@ struct RtcpParameters {
bool remote_estimate = false;
};
template <class Codec>
struct RtpParameters {
virtual ~RtpParameters() = default;
@ -845,8 +844,7 @@ struct RtpParameters {
// TODO(deadbeef): Rename to RtpSenderParameters, since they're intended to
// encapsulate all the parameters needed for an RtpSender.
template <class Codec>
struct RtpSendParameters : RtpParameters<Codec> {
struct RtpSendParameters : RtpParameters {
int max_bandwidth_bps = -1;
// This is the value to be sent in the MID RTP header extension (if the header
// extension in included in the list of extensions).
@ -855,7 +853,7 @@ struct RtpSendParameters : RtpParameters<Codec> {
protected:
std::map<std::string, std::string> ToStringMap() const override {
auto params = RtpParameters<Codec>::ToStringMap();
auto params = RtpParameters::ToStringMap();
params["max_bandwidth_bps"] = rtc::ToString(max_bandwidth_bps);
params["mid"] = (mid.empty() ? "<not set>" : mid);
params["extmap-allow-mixed"] = extmap_allow_mixed ? "true" : "false";
@ -863,7 +861,7 @@ struct RtpSendParameters : RtpParameters<Codec> {
}
};
struct AudioSendParameters : RtpSendParameters<AudioCodec> {
struct AudioSendParameters : RtpSendParameters {
AudioSendParameters();
~AudioSendParameters() override;
AudioOptions options;
@ -872,7 +870,7 @@ struct AudioSendParameters : RtpSendParameters<AudioCodec> {
std::map<std::string, std::string> ToStringMap() const override;
};
struct AudioRecvParameters : RtpParameters<AudioCodec> {};
struct AudioRecvParameters : RtpParameters {};
class VoiceMediaSendChannelInterface : public MediaSendChannelInterface {
public:
@ -924,7 +922,7 @@ class VoiceMediaReceiveChannelInterface : public MediaReceiveChannelInterface {
// TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to
// encapsulate all the parameters needed for a video RtpSender.
struct VideoSendParameters : RtpSendParameters<VideoCodec> {
struct VideoSendParameters : RtpSendParameters {
VideoSendParameters();
~VideoSendParameters() override;
// Use conference mode? This flag comes from the remote
@ -941,7 +939,7 @@ struct VideoSendParameters : RtpSendParameters<VideoCodec> {
// TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to
// encapsulate all the parameters needed for a video RtpReceiver.
struct VideoRecvParameters : RtpParameters<VideoCodec> {};
struct VideoRecvParameters : RtpParameters {};
class VideoMediaSendChannelInterface : public MediaSendChannelInterface {
public:

View File

@ -171,7 +171,7 @@ AudioSendParameters::AudioSendParameters() = default;
AudioSendParameters::~AudioSendParameters() = default;
std::map<std::string, std::string> AudioSendParameters::ToStringMap() const {
auto params = RtpSendParameters<AudioCodec>::ToStringMap();
auto params = RtpSendParameters::ToStringMap();
params["options"] = options.ToString();
return params;
}
@ -180,7 +180,7 @@ VideoSendParameters::VideoSendParameters() = default;
VideoSendParameters::~VideoSendParameters() = default;
std::map<std::string, std::string> VideoSendParameters::ToStringMap() const {
auto params = RtpSendParameters<VideoCodec>::ToStringMap();
auto params = RtpSendParameters::ToStringMap();
params["conference_mode"] = (conference_mode ? "yes" : "no");
return params;
}

View File

@ -82,7 +82,7 @@ void RtpParametersFromMediaDescription(
const MediaContentDescriptionImpl<Codec>* desc,
const RtpHeaderExtensions& extensions,
bool is_stream_active,
RtpParameters<Codec>* params) {
RtpParameters* params) {
params->is_stream_active = is_stream_active;
params->codecs = desc->codecs();
// TODO(bugs.webrtc.org/11513): See if we really need
@ -98,7 +98,7 @@ template <class Codec>
void RtpSendParametersFromMediaDescription(
const MediaContentDescriptionImpl<Codec>* desc,
webrtc::RtpExtension::Filter extensions_filter,
RtpSendParameters<Codec>* send_params) {
RtpSendParameters* send_params) {
RtpHeaderExtensions extensions =
webrtc::RtpExtension::DeduplicateHeaderExtensions(
desc->rtp_header_extensions(), extensions_filter);

View File

@ -113,6 +113,52 @@ cricket::RtpHeaderExtensions UnstoppedOrPresentRtpHeaderExtensions(
namespace cricket {
static bool IsRtxCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kRtxCodecName);
}
static bool IsRtxCodec(const webrtc::RtpCodecCapability& capability) {
return absl::EqualsIgnoreCase(capability.name, kRtxCodecName);
}
static bool ContainsRtxCodec(const std::vector<Codec>& codecs) {
for (const auto& codec : codecs) {
if (IsRtxCodec(codec)) {
return true;
}
}
return false;
}
static bool IsRedCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kRedCodecName);
}
static bool IsRedCodec(const webrtc::RtpCodecCapability& capability) {
return absl::EqualsIgnoreCase(capability.name, kRedCodecName);
}
static bool IsFlexfecCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName);
}
static bool ContainsFlexfecCodec(const std::vector<Codec>& codecs) {
for (const auto& codec : codecs) {
if (IsFlexfecCodec(codec)) {
return true;
}
}
return false;
}
static bool IsUlpfecCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kUlpfecCodecName);
}
static bool IsComfortNoiseCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kComfortNoiseCodecName);
}
static RtpTransceiverDirection NegotiateRtpTransceiverDirection(
RtpTransceiverDirection offer,
RtpTransceiverDirection wants) {
@ -610,51 +656,6 @@ static std::vector<const ContentInfo*> GetActiveContents(
return active_contents;
}
template <class C>
static bool ContainsRtxCodec(const std::vector<C>& codecs) {
for (const auto& codec : codecs) {
if (IsRtxCodec(codec)) {
return true;
}
}
return false;
}
template <class C>
static bool IsRedCodec(const C& codec) {
return absl::EqualsIgnoreCase(codec.name, kRedCodecName);
}
template <class C>
static bool IsRtxCodec(const C& codec) {
return absl::EqualsIgnoreCase(codec.name, kRtxCodecName);
}
template <class C>
static bool ContainsFlexfecCodec(const std::vector<C>& codecs) {
for (const auto& codec : codecs) {
if (IsFlexfecCodec(codec)) {
return true;
}
}
return false;
}
template <class C>
static bool IsFlexfecCodec(const C& codec) {
return absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName);
}
template <class C>
static bool IsUlpfecCodec(const C& codec) {
return absl::EqualsIgnoreCase(codec.name, kUlpfecCodecName);
}
template <class C>
static bool IsComfortNoiseCodec(const C& codec) {
return absl::EqualsIgnoreCase(codec.name, kComfortNoiseCodecName);
}
// Create a media content to be offered for the given `sender_options`,
// according to the given options.rtcp_mux, session_options.is_muc, codecs,
// secure_transport, crypto, and current_streams. If we don't currently have