Add string<->VideoCodecType conversion for all codec types.
Use that conversion instead of duplicating it in call/ Bug: webrtc:11042 Change-Id: I035b161d429ec339dd2ad9e9ed3ede5045fb6199 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160881 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29936}
This commit is contained in:
parent
5cef9c3581
commit
b529b7aeba
@ -18,6 +18,16 @@
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
constexpr char kPayloadNameVp8[] = "VP8";
|
||||
constexpr char kPayloadNameVp9[] = "VP9";
|
||||
// TODO(bugs.webrtc.org/11042): Rename to AV1 when rtp payload format for av1 is
|
||||
// frozen.
|
||||
constexpr char kPayloadNameAv1[] = "AV1X";
|
||||
constexpr char kPayloadNameH264[] = "H264";
|
||||
constexpr char kPayloadNameGeneric[] = "Generic";
|
||||
constexpr char kPayloadNameMultiplex[] = "Multiplex";
|
||||
} // namespace
|
||||
|
||||
bool VideoCodecVP8::operator==(const VideoCodecVP8& other) const {
|
||||
return (complexity == other.complexity &&
|
||||
@ -104,22 +114,19 @@ const VideoCodecH264& VideoCodec::H264() const {
|
||||
return codec_specific_.H264;
|
||||
}
|
||||
|
||||
static const char* kPayloadNameVp8 = "VP8";
|
||||
static const char* kPayloadNameVp9 = "VP9";
|
||||
static const char* kPayloadNameH264 = "H264";
|
||||
static const char* kPayloadNameGeneric = "Generic";
|
||||
static const char* kPayloadNameMultiplex = "Multiplex";
|
||||
|
||||
const char* CodecTypeToPayloadString(VideoCodecType type) {
|
||||
switch (type) {
|
||||
case kVideoCodecVP8:
|
||||
return kPayloadNameVp8;
|
||||
case kVideoCodecVP9:
|
||||
return kPayloadNameVp9;
|
||||
case kVideoCodecAV1:
|
||||
return kPayloadNameAv1;
|
||||
case kVideoCodecH264:
|
||||
return kPayloadNameH264;
|
||||
// Other codecs default to generic.
|
||||
default:
|
||||
case kVideoCodecMultiplex:
|
||||
return kPayloadNameMultiplex;
|
||||
case kVideoCodecGeneric:
|
||||
return kPayloadNameGeneric;
|
||||
}
|
||||
}
|
||||
@ -129,6 +136,8 @@ VideoCodecType PayloadStringToCodecType(const std::string& name) {
|
||||
return kVideoCodecVP8;
|
||||
if (absl::EqualsIgnoreCase(name, kPayloadNameVp9))
|
||||
return kVideoCodecVP9;
|
||||
if (absl::EqualsIgnoreCase(name, kPayloadNameAv1))
|
||||
return kVideoCodecAV1;
|
||||
if (absl::EqualsIgnoreCase(name, kPayloadNameH264))
|
||||
return kVideoCodecH264;
|
||||
if (absl::EqualsIgnoreCase(name, kPayloadNameMultiplex))
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video_codecs/video_codec.h"
|
||||
#include "call/rtp_transport_controller_send_interface.h"
|
||||
#include "modules/pacing/packet_router.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
@ -273,19 +274,10 @@ DataRate CalculateOverheadRate(DataRate data_rate,
|
||||
}
|
||||
|
||||
absl::optional<VideoCodecType> GetVideoCodecType(const RtpConfig& config) {
|
||||
absl::optional<VideoCodecType> video_type;
|
||||
if (!config.raw_payload) {
|
||||
if (absl::EqualsIgnoreCase(config.payload_name, "VP8")) {
|
||||
video_type = kVideoCodecVP8;
|
||||
} else if (absl::EqualsIgnoreCase(config.payload_name, "VP9")) {
|
||||
video_type = kVideoCodecVP9;
|
||||
} else if (absl::EqualsIgnoreCase(config.payload_name, "H264")) {
|
||||
video_type = kVideoCodecH264;
|
||||
} else {
|
||||
video_type = kVideoCodecGeneric;
|
||||
}
|
||||
if (config.raw_payload) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
return video_type;
|
||||
return PayloadStringToCodecType(config.payload_name);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user