Bug 1892299 - updated libwebrtc patch stack IGNORE BAD COMMIT MESSAGES

This commit is contained in:
Nico Grunbaum 2024-05-07 19:20:01 -07:00
parent bd4877f427
commit 337db3e1a3
5 changed files with 673 additions and 0 deletions

View file

@ -0,0 +1,353 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 7 May 2024 15:09:00 -0700
Subject: Bug 1895602 - Cherry-pick upstream libwebrtc commit d7e0981281
r?mjf,pehrsons
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: https://webrtc.googlesource.com/src/+/d7e0981281fc8a94043c8a0cd72fffd28cd2df0d
Propagate webrtc::Environment through objc VideoEncoderFactory
Bug: webrtc:15860
Change-Id: I9e7ee89e1ac9f950d38734510cf843e144108d24
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342800
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41933}
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/282116b5be234fafe45f6de5fbbd6ae8a21326e5
---
sdk/BUILD.gn | 3 +
.../api/video_codec/RTCNativeVideoEncoder.h | 20 ++++++
.../api/video_codec/RTCNativeVideoEncoder.mm | 70 +++++++++++++++++++
.../RTCNativeVideoEncoderBuilder+Native.h | 25 +++++++
.../RTCWrappedNativeVideoEncoder.h | 4 +-
.../RTCWrappedNativeVideoEncoder.mm | 54 --------------
.../native/src/objc_video_encoder_factory.h | 3 +
.../native/src/objc_video_encoder_factory.mm | 16 +++++
.../objc_video_encoder_factory_tests.mm | 3 +-
9 files changed, 142 insertions(+), 56 deletions(-)
create mode 100644 sdk/objc/api/video_codec/RTCNativeVideoEncoder.h
create mode 100644 sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm
create mode 100644 sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 50065c251d..2c5d9d0360 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -1548,6 +1548,9 @@ if (is_ios || is_mac) {
"objc/api/video_codec/RTCNativeVideoDecoder.h",
"objc/api/video_codec/RTCNativeVideoDecoder.mm",
"objc/api/video_codec/RTCNativeVideoDecoderBuilder+Native.h",
+ "objc/api/video_codec/RTCNativeVideoEncoder.h",
+ "objc/api/video_codec/RTCNativeVideoEncoder.mm",
+ "objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h",
"objc/api/video_codec/RTCWrappedNativeVideoEncoder.h",
"objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm",
]
diff --git a/sdk/objc/api/video_codec/RTCNativeVideoEncoder.h b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.h
new file mode 100644
index 0000000000..4cf1c9d86e
--- /dev/null
+++ b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2024 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "base/RTCMacros.h"
+#import "base/RTCVideoEncoder.h"
+
+// NativeVideoEncoder pretends to conform to RTCVideoEncoder protocol, but
+// expects its methods won't be called.
+@interface RTC_OBJC_TYPE (RTCNativeVideoEncoder) : NSObject <RTC_OBJC_TYPE (RTCVideoEncoder)>
+
+@end
diff --git a/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm
new file mode 100644
index 0000000000..be1ddc857d
--- /dev/null
+++ b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2024 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "RTCNativeVideoEncoder.h"
+#import "base/RTCMacros.h"
+#include "rtc_base/checks.h"
+
+@implementation RTC_OBJC_TYPE (RTCNativeVideoEncoder)
+
+- (void)setCallback:(RTCVideoEncoderCallback)callback {
+ RTC_DCHECK_NOTREACHED();
+}
+
+- (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
+ numberOfCores:(int)numberOfCores {
+ RTC_DCHECK_NOTREACHED();
+ return 0;
+}
+
+- (NSInteger)releaseEncoder {
+ RTC_DCHECK_NOTREACHED();
+ return 0;
+}
+
+- (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
+ codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
+ frameTypes:(NSArray<NSNumber *> *)frameTypes {
+ RTC_DCHECK_NOTREACHED();
+ return 0;
+}
+
+- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate {
+ RTC_DCHECK_NOTREACHED();
+ return 0;
+}
+
+- (NSString *)implementationName {
+ RTC_DCHECK_NOTREACHED();
+ return nil;
+}
+
+- (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings {
+ RTC_DCHECK_NOTREACHED();
+ return nil;
+}
+
+- (NSInteger)resolutionAlignment {
+ RTC_DCHECK_NOTREACHED();
+ return 1;
+}
+
+- (BOOL)applyAlignmentToAllSimulcastLayers {
+ RTC_DCHECK_NOTREACHED();
+ return NO;
+}
+
+- (BOOL)supportsNativeHandle {
+ RTC_DCHECK_NOTREACHED();
+ return NO;
+}
+@end
diff --git a/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h b/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h
new file mode 100644
index 0000000000..6d22c6c749
--- /dev/null
+++ b/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "base/RTCMacros.h"
+
+#include <memory>
+
+#include "api/environment/environment.h"
+#include "api/video_codecs/video_encoder.h"
+
+@protocol RTC_OBJC_TYPE
+(RTCNativeVideoEncoderBuilder)
+
+ - (std::unique_ptr<webrtc::VideoEncoder>)build : (const webrtc::Environment&)env;
+
+@end
diff --git a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h
index 8df9ceec35..b0e68233d7 100644
--- a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h
+++ b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h
@@ -10,6 +10,7 @@
#import <Foundation/Foundation.h>
+#import "RTCNativeVideoEncoder.h"
#import "base/RTCMacros.h"
#import "base/RTCVideoEncoder.h"
@@ -17,7 +18,8 @@
#include "api/video_codecs/video_encoder.h"
#include "media/base/codec.h"
-@interface RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoder) : NSObject <RTC_OBJC_TYPE (RTCVideoEncoder)>
+// TODO: bugs.webrtc.org/15860 - Remove in favor of the RTCNativeVideoEncoderBuilder
+@interface RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoder) : RTC_OBJC_TYPE (RTCNativeVideoEncoder)
- (instancetype)initWithNativeEncoder:(std::unique_ptr<webrtc::VideoEncoder>)encoder;
diff --git a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
index 4160572814..0fc2eca25f 100644
--- a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
+++ b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
@@ -12,7 +12,6 @@
#import "RTCWrappedNativeVideoEncoder.h"
#import "base/RTCMacros.h"
-#import "helpers/NSString+StdString.h"
@implementation RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoder) {
std::unique_ptr<webrtc::VideoEncoder> _wrappedEncoder;
@@ -30,57 +29,4 @@ - (instancetype)initWithNativeEncoder:(std::unique_ptr<webrtc::VideoEncoder>)enc
return std::move(_wrappedEncoder);
}
-#pragma mark - RTC_OBJC_TYPE(RTCVideoEncoder)
-
-- (void)setCallback:(RTCVideoEncoderCallback)callback {
- RTC_DCHECK_NOTREACHED();
-}
-
-- (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
- numberOfCores:(int)numberOfCores {
- RTC_DCHECK_NOTREACHED();
- return 0;
-}
-
-- (NSInteger)releaseEncoder {
- RTC_DCHECK_NOTREACHED();
- return 0;
-}
-
-- (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
- codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
- frameTypes:(NSArray<NSNumber *> *)frameTypes {
- RTC_DCHECK_NOTREACHED();
- return 0;
-}
-
-- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate {
- RTC_DCHECK_NOTREACHED();
- return 0;
-}
-
-- (NSString *)implementationName {
- RTC_DCHECK_NOTREACHED();
- return nil;
-}
-
-- (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings {
- RTC_DCHECK_NOTREACHED();
- return nil;
-}
-
-- (NSInteger)resolutionAlignment {
- RTC_DCHECK_NOTREACHED();
- return 1;
-}
-
-- (BOOL)applyAlignmentToAllSimulcastLayers {
- RTC_DCHECK_NOTREACHED();
- return NO;
-}
-
-- (BOOL)supportsNativeHandle {
- RTC_DCHECK_NOTREACHED();
- return NO;
-}
@end
diff --git a/sdk/objc/native/src/objc_video_encoder_factory.h b/sdk/objc/native/src/objc_video_encoder_factory.h
index 85a1e5319d..c27782b423 100644
--- a/sdk/objc/native/src/objc_video_encoder_factory.h
+++ b/sdk/objc/native/src/objc_video_encoder_factory.h
@@ -15,6 +15,7 @@
#import "base/RTCMacros.h"
+#include "api/environment/environment.h"
#include "api/video_codecs/video_encoder_factory.h"
@protocol RTC_OBJC_TYPE
@@ -32,6 +33,8 @@ class ObjCVideoEncoderFactory : public VideoEncoderFactory {
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
std::vector<SdpVideoFormat> GetImplementations() const override;
std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format) override;
+ std::unique_ptr<VideoEncoder> Create(const Environment& env,
+ const SdpVideoFormat& format) override;
std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override;
private:
diff --git a/sdk/objc/native/src/objc_video_encoder_factory.mm b/sdk/objc/native/src/objc_video_encoder_factory.mm
index d4ea79cc88..04515af729 100644
--- a/sdk/objc/native/src/objc_video_encoder_factory.mm
+++ b/sdk/objc/native/src/objc_video_encoder_factory.mm
@@ -19,10 +19,12 @@
#import "sdk/objc/api/peerconnection/RTCEncodedImage+Private.h"
#import "sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h"
#import "sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h"
+#import "sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h"
#import "sdk/objc/api/video_codec/RTCVideoCodecConstants.h"
#import "sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h"
#import "sdk/objc/helpers/NSString+StdString.h"
+#include "api/environment/environment.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
@@ -195,6 +197,20 @@ void OnCurrentEncoder(const SdpVideoFormat &format) override {
}
}
+std::unique_ptr<VideoEncoder> ObjCVideoEncoderFactory::Create(const Environment &env,
+ const SdpVideoFormat &format) {
+ RTC_OBJC_TYPE(RTCVideoCodecInfo) *info =
+ [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithNativeSdpVideoFormat:format];
+ id<RTC_OBJC_TYPE(RTCVideoEncoder)> encoder = [encoder_factory_ createEncoder:info];
+ if ([encoder conformsToProtocol:@protocol(RTC_OBJC_TYPE(RTCNativeVideoEncoderBuilder))]) {
+ return [((id<RTC_OBJC_TYPE(RTCNativeVideoEncoderBuilder)>)encoder) build:env];
+ } else if ([encoder isKindOfClass:[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) class]]) {
+ return [(RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) *)encoder releaseWrappedEncoder];
+ } else {
+ return std::make_unique<ObjCVideoEncoder>(encoder);
+ }
+}
+
std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
ObjCVideoEncoderFactory::GetEncoderSelector() const {
if ([encoder_factory_ respondsToSelector:@selector(encoderSelector)]) {
diff --git a/sdk/objc/unittests/objc_video_encoder_factory_tests.mm b/sdk/objc/unittests/objc_video_encoder_factory_tests.mm
index 9a4fee2e95..a04e797672 100644
--- a/sdk/objc/unittests/objc_video_encoder_factory_tests.mm
+++ b/sdk/objc/unittests/objc_video_encoder_factory_tests.mm
@@ -14,6 +14,7 @@
#include "sdk/objc/native/src/objc_video_encoder_factory.h"
+#include "api/environment/environment_factory.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#import "base/RTCVideoEncoder.h"
@@ -55,7 +56,7 @@
id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> factory) {
webrtc::ObjCVideoEncoderFactory encoder_factory(factory);
webrtc::SdpVideoFormat format("H264");
- return encoder_factory.CreateVideoEncoder(format);
+ return encoder_factory.Create(webrtc::CreateEnvironment(), format);
}
#pragma mark -

View file

@ -0,0 +1,216 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 7 May 2024 15:11:00 -0700
Subject: Bug 1895602 - Cherry-pick upstream libwebrtc commit c03827db1b
r?mjf,pehrsons
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: https://webrtc.googlesource.com/src/+/c03827db1bdbf55b2e3daa0898530626d988c403
Cleanup SimulcastEncoderAdapter - require webrtc::Environment at construction time
Bug: webrtc:15860
Change-Id: I1a786fb4b04112197e49c883884fc4b30f8d13f4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/343182
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41937}
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2ebdede1f90fc98f08ebe0c5c501931801cc323f
---
api/video_codecs/BUILD.gn | 1 -
.../builtin_video_encoder_factory.cc | 17 -------
media/BUILD.gn | 1 -
media/engine/simulcast_encoder_adapter.cc | 49 +++----------------
media/engine/simulcast_encoder_adapter.h | 19 +------
5 files changed, 7 insertions(+), 80 deletions(-)
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index ddfdc376a3..dbdc23ad54 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -151,7 +151,6 @@ rtc_library("builtin_video_encoder_factory") {
"../../media:rtc_simulcast_encoder_adapter",
"../../rtc_base/system:rtc_export",
"../environment",
- "../transport:field_trial_based_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/strings",
diff --git a/api/video_codecs/builtin_video_encoder_factory.cc b/api/video_codecs/builtin_video_encoder_factory.cc
index 77a6d65c5d..bbd52221f5 100644
--- a/api/video_codecs/builtin_video_encoder_factory.cc
+++ b/api/video_codecs/builtin_video_encoder_factory.cc
@@ -16,7 +16,6 @@
#include "absl/types/optional.h"
#include "api/environment/environment.h"
-#include "api/transport/field_trial_based_config.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_factory.h"
@@ -33,22 +32,6 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
BuiltinVideoEncoderFactory()
: internal_encoder_factory_(new InternalEncoderFactory()) {}
- std::unique_ptr<VideoEncoder> CreateVideoEncoder(
- const SdpVideoFormat& format) override {
- // Try creating an InternalEncoderFactory-backed SimulcastEncoderAdapter.
- // The adapter has a passthrough mode for the case that simulcast is not
- // used, so all responsibility can be delegated to it.
- std::unique_ptr<VideoEncoder> encoder;
- if (format.IsCodecInList(
- internal_encoder_factory_->GetSupportedFormats())) {
- encoder = std::make_unique<SimulcastEncoderAdapter>(
- /*primary_factory=*/internal_encoder_factory_.get(),
- /*fallback_factory=*/nullptr, format, FieldTrialBasedConfig());
- }
-
- return encoder;
- }
-
std::unique_ptr<VideoEncoder> Create(const Environment& env,
const SdpVideoFormat& format) override {
// Try creating an InternalEncoderFactory-backed SimulcastEncoderAdapter.
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 4989f5192f..68d476133b 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -495,7 +495,6 @@ rtc_library("rtc_simulcast_encoder_adapter") {
"../api:scoped_refptr",
"../api:sequence_checker",
"../api/environment",
- "../api/transport:field_trial_based_config",
"../api/video:video_codec_constants",
"../api/video:video_frame",
"../api/video:video_rtp_headers",
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index d274c85f3b..f95ccb052a 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -22,7 +22,6 @@
#include "absl/types/optional.h"
#include "api/field_trials_view.h"
#include "api/scoped_refptr.h"
-#include "api/transport/field_trial_based_config.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_codec_constants.h"
#include "api/video/video_frame_buffer.h"
@@ -251,38 +250,7 @@ SimulcastEncoderAdapter::SimulcastEncoderAdapter(
absl::Nonnull<VideoEncoderFactory*> primary_factory,
absl::Nullable<VideoEncoderFactory*> fallback_factory,
const SdpVideoFormat& format)
- : SimulcastEncoderAdapter(&env,
- primary_factory,
- fallback_factory,
- format,
- env.field_trials()) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory,
- const SdpVideoFormat& format)
- : SimulcastEncoderAdapter(/*env=*/nullptr,
- /*primary_factory=*/factory,
- /*fallback_factory=*/nullptr,
- format,
- FieldTrialBasedConfig()) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(
- VideoEncoderFactory* primary_factory,
- VideoEncoderFactory* fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials)
- : SimulcastEncoderAdapter(/*env=*/nullptr,
- primary_factory,
- fallback_factory,
- format,
- field_trials) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(
- absl::Nullable<const Environment*> env,
- absl::Nonnull<VideoEncoderFactory*> primary_factory,
- absl::Nullable<VideoEncoderFactory*> fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials)
- : env_(env != nullptr ? absl::make_optional(*env) : absl::nullopt),
+ : env_(env),
inited_(0),
primary_encoder_factory_(primary_factory),
fallback_encoder_factory_(fallback_factory),
@@ -291,11 +259,11 @@ SimulcastEncoderAdapter::SimulcastEncoderAdapter(
bypass_mode_(false),
encoded_complete_callback_(nullptr),
experimental_boosted_screenshare_qp_(
- GetScreenshareBoostedQpValue(field_trials)),
+ GetScreenshareBoostedQpValue(env_.field_trials())),
boost_base_layer_quality_(
- RateControlSettings::ParseFromKeyValueConfig(&field_trials)
+ RateControlSettings::ParseFromKeyValueConfig(&env_.field_trials())
.Vp8BoostBaseLayerQuality()),
- prefer_temporal_support_on_base_layer_(field_trials.IsEnabled(
+ prefer_temporal_support_on_base_layer_(env_.field_trials().IsEnabled(
"WebRTC-Video-PreferTemporalSupportOnBaseLayer")),
per_layer_pli_(SupportsPerLayerPictureLossIndication(format.parameters)) {
RTC_DCHECK(primary_factory);
@@ -769,16 +737,11 @@ SimulcastEncoderAdapter::FetchOrCreateEncoderContext(
cached_encoder_contexts_.erase(encoder_context_iter);
} else {
std::unique_ptr<VideoEncoder> primary_encoder =
- env_.has_value()
- ? primary_encoder_factory_->Create(*env_, video_format_)
- : primary_encoder_factory_->CreateVideoEncoder(video_format_);
+ primary_encoder_factory_->Create(env_, video_format_);
std::unique_ptr<VideoEncoder> fallback_encoder;
if (fallback_encoder_factory_ != nullptr) {
- fallback_encoder =
- env_.has_value()
- ? fallback_encoder_factory_->Create(*env_, video_format_)
- : fallback_encoder_factory_->CreateVideoEncoder(video_format_);
+ fallback_encoder = fallback_encoder_factory_->Create(env_, video_format_);
}
std::unique_ptr<VideoEncoder> encoder;
diff --git a/media/engine/simulcast_encoder_adapter.h b/media/engine/simulcast_encoder_adapter.h
index 8732270135..951eb85726 100644
--- a/media/engine/simulcast_encoder_adapter.h
+++ b/media/engine/simulcast_encoder_adapter.h
@@ -51,15 +51,6 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
absl::Nullable<VideoEncoderFactory*> fallback_factory,
const SdpVideoFormat& format);
- [[deprecated("bugs.webrtc.org/15860")]] SimulcastEncoderAdapter(
- VideoEncoderFactory* primarty_factory,
- const SdpVideoFormat& format);
-
- // TODO: bugs.webrtc.org/15860 - Deprecate or delete when not used by chromium
- SimulcastEncoderAdapter(VideoEncoderFactory* primary_factory,
- VideoEncoderFactory* fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials);
~SimulcastEncoderAdapter() override;
// Implements VideoEncoder.
@@ -153,12 +144,6 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
bool is_paused_;
};
- SimulcastEncoderAdapter(absl::Nullable<const Environment*> env,
- absl::Nonnull<VideoEncoderFactory*> primary_factory,
- absl::Nullable<VideoEncoderFactory*> fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials);
-
bool Initialized() const;
void DestroyStoredEncoders();
@@ -184,9 +169,7 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
void OverrideFromFieldTrial(VideoEncoder::EncoderInfo* info) const;
- // TODO: bugs.webrtc.org/15860 - Make env_ non optional when deprecated
- // constructors are deleted.
- const absl::optional<Environment> env_;
+ const Environment env_;
std::atomic<int> inited_;
VideoEncoderFactory* const primary_encoder_factory_;
VideoEncoderFactory* const fallback_encoder_factory_;

View file

@ -0,0 +1,29 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Revert bug 1892045 (changeset 0b54a6f17243).
r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D208185
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ba14327877a0428a0eaf018d71579f2441ac7ac
---
modules/video_capture/linux/video_capture_v4l2.cc | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index e3061556e8..74af348a6c 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -304,12 +304,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
// start capture thread;
if (_captureThread.empty()) {
- {
- // Probably can't be accessed from another thread with
- // _captureThread empty, but the analyzer doesn't know this
- MutexLock lock(&capture_lock_);
- quit_ = false;
- }
+ quit_ = false;
_captureThread = rtc::PlatformThread::SpawnJoinable(
[self = scoped_refptr(this)] {
while (self->CaptureProcess()) {

View file

@ -0,0 +1,44 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Invert _captureThread check in
VideoCaptureModuleV4L2::StartCapture. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D208186
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ed6737b8214bf664642eb17cbf66a8c8450e569
---
.../video_capture/linux/video_capture_v4l2.cc | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 74af348a6c..29ca864e19 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,16 +303,19 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
// start capture thread;
- if (_captureThread.empty()) {
- quit_ = false;
- _captureThread = rtc::PlatformThread::SpawnJoinable(
- [self = scoped_refptr(this)] {
- while (self->CaptureProcess()) {
- }
- },
- "CaptureThread",
- rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
+ if (!_captureThread.empty()) {
+ return 0;
}
+
+ quit_ = false;
+
+ _captureThread = rtc::PlatformThread::SpawnJoinable(
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
+ }
+ },
+ "CaptureThread",
+ rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
return 0;
}

View file

@ -0,0 +1,31 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Fix threading issues in VideoCaptureModuleV4L2 once and
for all. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D208187
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/65e120a9c1dcb9c8f1c8930e808b03aa149eaf40
---
modules/video_capture/linux/video_capture_v4l2.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 29ca864e19..b6e7e79a2a 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -300,7 +300,6 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
_requestedCapability = capability;
_captureStarted = true;
_streaming = true;
- }
// start capture thread;
if (!_captureThread.empty()) {
@@ -308,6 +307,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
quit_ = false;
+ }
_captureThread = rtc::PlatformThread::SpawnJoinable(
[self = scoped_refptr(this)] {