mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30: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}
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2018 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/builtin_video_bitrate_allocator_factory.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "absl/base/attributes.h"
|
|
#include "absl/base/macros.h"
|
|
#include "api/video/video_bitrate_allocator.h"
|
|
#include "api/video_codecs/video_codec.h"
|
|
#include "modules/video_coding/svc/svc_rate_allocator.h"
|
|
#include "modules/video_coding/utility/simulcast_rate_allocator.h"
|
|
|
|
namespace webrtc {
|
|
|
|
namespace {
|
|
|
|
class BuiltinVideoBitrateAllocatorFactory
|
|
: public VideoBitrateAllocatorFactory {
|
|
public:
|
|
BuiltinVideoBitrateAllocatorFactory() = default;
|
|
~BuiltinVideoBitrateAllocatorFactory() override = default;
|
|
|
|
std::unique_ptr<VideoBitrateAllocator> CreateVideoBitrateAllocator(
|
|
const VideoCodec& codec) override {
|
|
// TODO(https://crbug.com/webrtc/14884): Update SvcRateAllocator to
|
|
// support simulcast and use it for VP9/AV1 simulcast as well.
|
|
if ((codec.codecType == kVideoCodecAV1 ||
|
|
codec.codecType == kVideoCodecVP9) &&
|
|
codec.numberOfSimulcastStreams <= 1) {
|
|
return std::make_unique<SvcRateAllocator>(codec);
|
|
}
|
|
return std::make_unique<SimulcastRateAllocator>(codec);
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
std::unique_ptr<VideoBitrateAllocatorFactory>
|
|
CreateBuiltinVideoBitrateAllocatorFactory() {
|
|
return std::make_unique<BuiltinVideoBitrateAllocatorFactory>();
|
|
}
|
|
|
|
} // namespace webrtc
|