mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 14:20:45 +01:00

As of recent changes, we can simply look at numberOfSimulcastStreams because in the {active,inactive,inactive} case we get a single webrtc::VideoStream here[1] which results in numberOfSimulcastStreams being 1 here[2]. Looking at numberOfSimulcastStreams instead of using a helper is preferred because it is more descriptive and in the future, when {inactive,active,inactive} or {inactive,inactive,active} cases of VP9 simulcast is also supported (webrtc:15046) then this gating will work even when the first layer is not the active one. [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/video/config/encoder_stream_factory.cc;l=146;drc=c99753ac8f051e379ae68e281aaef04b0a5ca8f2 [2] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/modules/video_coding/video_codec_initializer.cc;l=77;drc=4baea5b07f2fd309892845cf2d1c0f4ca77862d3 # No need to wait for win chrome bot, everything else green NOTRY=True Bug: webrtc:15046 Change-Id: I8aaea2e8cc350bd01fb00cc7fd85032b7fdfe24d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299942 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39759}
155 lines
4.6 KiB
C++
155 lines
4.6 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "api/video_codecs/video_codec.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <string>
|
|
|
|
#include "absl/strings/match.h"
|
|
#include "rtc_base/checks.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
constexpr char kPayloadNameVp8[] = "VP8";
|
|
constexpr char kPayloadNameVp9[] = "VP9";
|
|
constexpr char kPayloadNameAv1[] = "AV1";
|
|
// TODO(bugs.webrtc.org/13166): Remove AV1X when backwards compatibility is not
|
|
// needed.
|
|
constexpr char kPayloadNameAv1x[] = "AV1X";
|
|
constexpr char kPayloadNameH264[] = "H264";
|
|
constexpr char kPayloadNameGeneric[] = "Generic";
|
|
constexpr char kPayloadNameMultiplex[] = "Multiplex";
|
|
} // namespace
|
|
|
|
bool VideoCodecVP8::operator==(const VideoCodecVP8& other) const {
|
|
return (numberOfTemporalLayers == other.numberOfTemporalLayers &&
|
|
denoisingOn == other.denoisingOn &&
|
|
automaticResizeOn == other.automaticResizeOn &&
|
|
keyFrameInterval == other.keyFrameInterval);
|
|
}
|
|
|
|
bool VideoCodecVP9::operator==(const VideoCodecVP9& other) const {
|
|
return (numberOfTemporalLayers == other.numberOfTemporalLayers &&
|
|
denoisingOn == other.denoisingOn &&
|
|
keyFrameInterval == other.keyFrameInterval &&
|
|
adaptiveQpMode == other.adaptiveQpMode &&
|
|
automaticResizeOn == other.automaticResizeOn &&
|
|
numberOfSpatialLayers == other.numberOfSpatialLayers &&
|
|
flexibleMode == other.flexibleMode);
|
|
}
|
|
|
|
bool VideoCodecH264::operator==(const VideoCodecH264& other) const {
|
|
return (keyFrameInterval == other.keyFrameInterval &&
|
|
numberOfTemporalLayers == other.numberOfTemporalLayers);
|
|
}
|
|
|
|
VideoCodec::VideoCodec()
|
|
: codecType(kVideoCodecGeneric),
|
|
width(0),
|
|
height(0),
|
|
startBitrate(0),
|
|
maxBitrate(0),
|
|
minBitrate(0),
|
|
maxFramerate(0),
|
|
active(true),
|
|
qpMax(0),
|
|
numberOfSimulcastStreams(0),
|
|
simulcastStream(),
|
|
spatialLayers(),
|
|
mode(VideoCodecMode::kRealtimeVideo),
|
|
expect_encode_from_texture(false),
|
|
timing_frame_thresholds({0, 0}),
|
|
legacy_conference_mode(false),
|
|
codec_specific_(),
|
|
complexity_(VideoCodecComplexity::kComplexityNormal) {}
|
|
|
|
VideoCodecVP8* VideoCodec::VP8() {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
|
|
return &codec_specific_.VP8;
|
|
}
|
|
|
|
const VideoCodecVP8& VideoCodec::VP8() const {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
|
|
return codec_specific_.VP8;
|
|
}
|
|
|
|
VideoCodecVP9* VideoCodec::VP9() {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecVP9);
|
|
return &codec_specific_.VP9;
|
|
}
|
|
|
|
const VideoCodecVP9& VideoCodec::VP9() const {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecVP9);
|
|
return codec_specific_.VP9;
|
|
}
|
|
|
|
VideoCodecH264* VideoCodec::H264() {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecH264);
|
|
return &codec_specific_.H264;
|
|
}
|
|
|
|
const VideoCodecH264& VideoCodec::H264() const {
|
|
RTC_DCHECK_EQ(codecType, kVideoCodecH264);
|
|
return codec_specific_.H264;
|
|
}
|
|
|
|
const char* CodecTypeToPayloadString(VideoCodecType type) {
|
|
switch (type) {
|
|
case kVideoCodecVP8:
|
|
return kPayloadNameVp8;
|
|
case kVideoCodecVP9:
|
|
return kPayloadNameVp9;
|
|
case kVideoCodecAV1:
|
|
return kPayloadNameAv1;
|
|
case kVideoCodecH264:
|
|
return kPayloadNameH264;
|
|
case kVideoCodecMultiplex:
|
|
return kPayloadNameMultiplex;
|
|
case kVideoCodecGeneric:
|
|
return kPayloadNameGeneric;
|
|
}
|
|
RTC_CHECK_NOTREACHED();
|
|
}
|
|
|
|
VideoCodecType PayloadStringToCodecType(const std::string& name) {
|
|
if (absl::EqualsIgnoreCase(name, kPayloadNameVp8))
|
|
return kVideoCodecVP8;
|
|
if (absl::EqualsIgnoreCase(name, kPayloadNameVp9))
|
|
return kVideoCodecVP9;
|
|
if (absl::EqualsIgnoreCase(name, kPayloadNameAv1) ||
|
|
absl::EqualsIgnoreCase(name, kPayloadNameAv1x))
|
|
return kVideoCodecAV1;
|
|
if (absl::EqualsIgnoreCase(name, kPayloadNameH264))
|
|
return kVideoCodecH264;
|
|
if (absl::EqualsIgnoreCase(name, kPayloadNameMultiplex))
|
|
return kVideoCodecMultiplex;
|
|
return kVideoCodecGeneric;
|
|
}
|
|
|
|
VideoCodecComplexity VideoCodec::GetVideoEncoderComplexity() const {
|
|
return complexity_;
|
|
}
|
|
|
|
void VideoCodec::SetVideoEncoderComplexity(
|
|
VideoCodecComplexity complexity_setting) {
|
|
complexity_ = complexity_setting;
|
|
}
|
|
|
|
bool VideoCodec::GetFrameDropEnabled() const {
|
|
return frame_drop_enabled_;
|
|
}
|
|
|
|
void VideoCodec::SetFrameDropEnabled(bool enabled) {
|
|
frame_drop_enabled_ = enabled;
|
|
}
|
|
|
|
} // namespace webrtc
|