summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/media/engine
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/media/engine')
-rw-r--r--third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc10
-rw-r--r--third_party/libwebrtc/media/engine/internal_encoder_factory_unittest.cc13
-rw-r--r--third_party/libwebrtc/media/engine/simulcast_encoder_adapter_unittest.cc2
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_media_engine.cc37
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_media_engine.h42
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_video_engine.cc14
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc8
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_voice_engine.cc14
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_voice_engine.h4
-rw-r--r--third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc36
10 files changed, 69 insertions, 111 deletions
diff --git a/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc b/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc
index bb2e24d5d8..51d6a94dd6 100644
--- a/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc
+++ b/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc
@@ -43,6 +43,8 @@ constexpr bool kDav1dIsIncluded = true;
#else
constexpr bool kDav1dIsIncluded = false;
#endif
+constexpr bool kH265Enabled = false;
+
constexpr VideoDecoderFactory::CodecSupport kSupported = {
/*is_supported=*/true, /*is_power_efficient=*/false};
constexpr VideoDecoderFactory::CodecSupport kUnsupported = {
@@ -99,6 +101,14 @@ TEST(InternalDecoderFactoryTest, Av1Profile0) {
}
}
+// At current stage since internal H.265 decoder is not implemented,
+TEST(InternalDecoderFactoryTest, H265IsNotEnabled) {
+ InternalDecoderFactory factory;
+ std::unique_ptr<VideoDecoder> decoder =
+ factory.CreateVideoDecoder(SdpVideoFormat(cricket::kH265CodecName));
+ EXPECT_EQ(static_cast<bool>(decoder), kH265Enabled);
+}
+
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
TEST(InternalDecoderFactoryTest, Av1) {
InternalDecoderFactory factory;
diff --git a/third_party/libwebrtc/media/engine/internal_encoder_factory_unittest.cc b/third_party/libwebrtc/media/engine/internal_encoder_factory_unittest.cc
index a1c90b8cf4..b9ca6d88c2 100644
--- a/third_party/libwebrtc/media/engine/internal_encoder_factory_unittest.cc
+++ b/third_party/libwebrtc/media/engine/internal_encoder_factory_unittest.cc
@@ -33,6 +33,8 @@ constexpr bool kH264Enabled = true;
#else
constexpr bool kH264Enabled = false;
#endif
+constexpr bool kH265Enabled = false;
+
constexpr VideoEncoderFactory::CodecSupport kSupported = {
/*is_supported=*/true, /*is_power_efficient=*/false};
constexpr VideoEncoderFactory::CodecSupport kUnsupported = {
@@ -78,6 +80,17 @@ TEST(InternalEncoderFactoryTest, H264) {
}
}
+// At current stage H.265 is not supported by internal encoder factory.
+TEST(InternalEncoderFactoryTest, H265IsNotEnabled) {
+ InternalEncoderFactory factory;
+ std::unique_ptr<VideoEncoder> encoder =
+ factory.CreateVideoEncoder(SdpVideoFormat(cricket::kH265CodecName));
+ EXPECT_EQ(static_cast<bool>(encoder), kH265Enabled);
+ EXPECT_THAT(
+ factory.GetSupportedFormats(),
+ Not(Contains(Field(&SdpVideoFormat::name, cricket::kH265CodecName))));
+}
+
TEST(InternalEncoderFactoryTest, QueryCodecSupportWithScalabilityMode) {
InternalEncoderFactory factory;
// VP8 and VP9 supported for singles spatial layers.
diff --git a/third_party/libwebrtc/media/engine/simulcast_encoder_adapter_unittest.cc b/third_party/libwebrtc/media/engine/simulcast_encoder_adapter_unittest.cc
index e2ac5ea390..3ee3465e13 100644
--- a/third_party/libwebrtc/media/engine/simulcast_encoder_adapter_unittest.cc
+++ b/third_party/libwebrtc/media/engine/simulcast_encoder_adapter_unittest.cc
@@ -586,7 +586,7 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
absl::optional<int> last_encoded_image_simulcast_index_;
std::unique_ptr<SimulcastRateAllocator> rate_allocator_;
bool use_fallback_factory_;
- SdpVideoFormat::Parameters sdp_video_parameters_;
+ CodecParameterMap sdp_video_parameters_;
test::ScopedKeyValueConfig field_trials_;
};
diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine.cc b/third_party/libwebrtc/media/engine/webrtc_media_engine.cc
index 463ed29109..31769e05de 100644
--- a/third_party/libwebrtc/media/engine/webrtc_media_engine.cc
+++ b/third_party/libwebrtc/media/engine/webrtc_media_engine.cc
@@ -12,53 +12,16 @@
#include <algorithm>
#include <map>
-#include <memory>
#include <string>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/strings/match.h"
-#include "api/transport/field_trial_based_config.h"
#include "media/base/media_constants.h"
-#include "media/engine/webrtc_voice_engine.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
-#ifdef HAVE_WEBRTC_VIDEO
-#include "media/engine/webrtc_video_engine.h"
-#else
-#include "media/engine/null_webrtc_video_engine.h"
-#endif
-
namespace cricket {
-
-std::unique_ptr<MediaEngineInterface> CreateMediaEngine(
- MediaEngineDependencies dependencies) {
- // TODO(sprang): Make populating `dependencies.trials` mandatory and remove
- // these fallbacks.
- std::unique_ptr<webrtc::FieldTrialsView> fallback_trials(
- dependencies.trials ? nullptr : new webrtc::FieldTrialBasedConfig());
- const webrtc::FieldTrialsView& trials =
- dependencies.trials ? *dependencies.trials : *fallback_trials;
- auto audio_engine = std::make_unique<WebRtcVoiceEngine>(
- dependencies.task_queue_factory, dependencies.adm.get(),
- std::move(dependencies.audio_encoder_factory),
- std::move(dependencies.audio_decoder_factory),
- std::move(dependencies.audio_mixer),
- std::move(dependencies.audio_processing),
- std::move(dependencies.owned_audio_frame_processor), trials);
-#ifdef HAVE_WEBRTC_VIDEO
- auto video_engine = std::make_unique<WebRtcVideoEngine>(
- std::move(dependencies.video_encoder_factory),
- std::move(dependencies.video_decoder_factory), trials);
-#else
- auto video_engine = std::make_unique<NullWebRtcVideoEngine>();
-#endif
- return std::make_unique<CompositeMediaEngine>(std::move(fallback_trials),
- std::move(audio_engine),
- std::move(video_engine));
-}
-
namespace {
// Remove mutually exclusive extensions with lower priority.
void DiscardRedundantExtensions(
diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine.h b/third_party/libwebrtc/media/engine/webrtc_media_engine.h
index 863db9f278..5bd5a8bce5 100644
--- a/third_party/libwebrtc/media/engine/webrtc_media_engine.h
+++ b/third_party/libwebrtc/media/engine/webrtc_media_engine.h
@@ -11,59 +11,17 @@
#ifndef MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_
#define MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_
-#include <memory>
#include <vector>
#include "absl/strings/string_view.h"
#include "api/array_view.h"
-#include "api/audio/audio_frame_processor.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio_codecs/audio_decoder_factory.h"
-#include "api/audio_codecs/audio_encoder_factory.h"
#include "api/field_trials_view.h"
#include "api/rtp_parameters.h"
-#include "api/scoped_refptr.h"
-#include "api/task_queue/task_queue_factory.h"
#include "api/transport/bitrate_settings.h"
-#include "api/video_codecs/video_decoder_factory.h"
-#include "api/video_codecs/video_encoder_factory.h"
#include "media/base/codec.h"
-#include "media/base/media_engine.h"
-#include "modules/audio_device/include/audio_device.h"
-#include "modules/audio_processing/include/audio_processing.h"
-#include "rtc_base/system/rtc_export.h"
namespace cricket {
-struct MediaEngineDependencies {
- MediaEngineDependencies() = default;
- MediaEngineDependencies(const MediaEngineDependencies&) = delete;
- MediaEngineDependencies(MediaEngineDependencies&&) = default;
- MediaEngineDependencies& operator=(const MediaEngineDependencies&) = delete;
- MediaEngineDependencies& operator=(MediaEngineDependencies&&) = default;
- ~MediaEngineDependencies() = default;
-
- webrtc::TaskQueueFactory* task_queue_factory = nullptr;
- rtc::scoped_refptr<webrtc::AudioDeviceModule> adm;
- rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory;
- rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory;
- rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer;
- rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
- std::unique_ptr<webrtc::AudioFrameProcessor> owned_audio_frame_processor;
-
- std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory;
- std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory;
-
- const webrtc::FieldTrialsView* trials = nullptr;
-};
-
-// CreateMediaEngine may be called on any thread, though the engine is
-// only expected to be used on one thread, internally called the "worker
-// thread". This is the thread Init must be called on.
-[[deprecated("bugs.webrtc.org/15574")]] //
-RTC_EXPORT std::unique_ptr<MediaEngineInterface>
-CreateMediaEngine(MediaEngineDependencies dependencies);
-
// Verify that extension IDs are within 1-byte extension range and are not
// overlapping, and that they form a legal change from previously registerd
// extensions (if any).
diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine.cc
index 8a9d6ff95c..a5b46d3344 100644
--- a/third_party/libwebrtc/media/engine/webrtc_video_engine.cc
+++ b/third_party/libwebrtc/media/engine/webrtc_video_engine.cc
@@ -1038,13 +1038,19 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters(
return false;
}
+ std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(params.codecs);
+ if (mapped_codecs.empty()) {
+ // This suggests a failure in MapCodecs, e.g. inconsistent RTX codecs.
+ return false;
+ }
+
std::vector<VideoCodecSettings> negotiated_codecs =
- SelectSendVideoCodecs(MapCodecs(params.codecs));
+ SelectSendVideoCodecs(mapped_codecs);
- // We should only fail here if send direction is enabled.
if (params.is_stream_active && negotiated_codecs.empty()) {
- RTC_LOG(LS_ERROR) << "No video codecs supported.";
- return false;
+ // This is not a failure but will lead to the answer being rejected.
+ RTC_LOG(LS_ERROR) << "No video codecs in common.";
+ return true;
}
// Never enable sending FlexFEC, unless we are in the experiment.
diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc
index f5736679be..148223f497 100644
--- a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc
+++ b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc
@@ -3781,7 +3781,7 @@ class Vp9SettingsTest : public WebRtcVideoChannelTest {
TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
encoder_factory_->AddSupportedVideoCodec(
- webrtc::SdpVideoFormat("VP9", webrtc::SdpVideoFormat::Parameters(),
+ webrtc::SdpVideoFormat("VP9", webrtc::CodecParameterMap(),
{ScalabilityMode::kL1T1, ScalabilityMode::kL2T1}));
cricket::VideoSenderParameters parameters;
@@ -8545,7 +8545,7 @@ TEST_F(WebRtcVideoChannelTest, FallbackForUnsetOrUnsupportedScalabilityMode) {
ScalabilityMode::kL1T3};
encoder_factory_->AddSupportedVideoCodec(webrtc::SdpVideoFormat(
- "VP8", webrtc::SdpVideoFormat::Parameters(), kSupportedModes));
+ "VP8", webrtc::CodecParameterMap(), kSupportedModes));
FakeVideoSendStream* stream = SetUpSimulcast(true, /*with_rtx=*/false);
@@ -8615,9 +8615,9 @@ TEST_F(WebRtcVideoChannelTest,
kVp9SupportedModes = {ScalabilityMode::kL3T3};
encoder_factory_->AddSupportedVideoCodec(webrtc::SdpVideoFormat(
- "VP8", webrtc::SdpVideoFormat::Parameters(), {ScalabilityMode::kL1T1}));
+ "VP8", webrtc::CodecParameterMap(), {ScalabilityMode::kL1T1}));
encoder_factory_->AddSupportedVideoCodec(webrtc::SdpVideoFormat(
- "VP9", webrtc::SdpVideoFormat::Parameters(), {ScalabilityMode::kL3T3}));
+ "VP9", webrtc::CodecParameterMap(), {ScalabilityMode::kL3T3}));
cricket::VideoSenderParameters send_parameters;
send_parameters.codecs.push_back(GetEngineCodec("VP9"));
diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc
index adf662074d..fcc2703f98 100644
--- a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc
+++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc
@@ -377,9 +377,8 @@ void WebRtcVoiceEngine::Init() {
// TaskQueue expects to be created/destroyed on the same thread.
RTC_DCHECK(!low_priority_worker_queue_);
- low_priority_worker_queue_.reset(
- new rtc::TaskQueue(task_queue_factory_->CreateTaskQueue(
- "rtc-low-prio", webrtc::TaskQueueFactory::Priority::LOW)));
+ low_priority_worker_queue_ = task_queue_factory_->CreateTaskQueue(
+ "rtc-low-prio", webrtc::TaskQueueFactory::Priority::LOW);
// Load our audio codec lists.
RTC_LOG(LS_VERBOSE) << "Supported send codecs in order of preference:";
@@ -761,9 +760,9 @@ std::vector<AudioCodec> WebRtcVoiceEngine::CollectCodecs(
out.push_back(codec);
if (codec.name == kOpusCodecName) {
- std::string redFmtp =
+ std::string red_fmtp =
rtc::ToString(codec.id) + "/" + rtc::ToString(codec.id);
- map_format({kRedCodecName, 48000, 2, {{"", redFmtp}}}, &out);
+ map_format({kRedCodecName, 48000, 2, {{"", red_fmtp}}}, &out);
}
}
}
@@ -1318,7 +1317,7 @@ bool WebRtcVoiceSendChannel::SetSenderParameters(
}
}
- if (!SetMaxSendBitrate(params.max_bandwidth_bps)) {
+ if (send_codec_spec_ && !SetMaxSendBitrate(params.max_bandwidth_bps)) {
return false;
}
return SetOptions(params.options);
@@ -1402,7 +1401,8 @@ bool WebRtcVoiceSendChannel::SetSendCodecs(
}
if (!send_codec_spec) {
- return false;
+ // No codecs in common, bail out early.
+ return true;
}
RTC_DCHECK(voice_codec_info);
diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine.h b/third_party/libwebrtc/media/engine/webrtc_voice_engine.h
index ed71667525..b28b9652bb 100644
--- a/third_party/libwebrtc/media/engine/webrtc_voice_engine.h
+++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine.h
@@ -66,7 +66,6 @@
#include "rtc_base/network/sent_packet.h"
#include "rtc_base/network_route.h"
#include "rtc_base/system/file_wrapper.h"
-#include "rtc_base/task_queue.h"
namespace webrtc {
class AudioFrameProcessor;
@@ -141,7 +140,8 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface {
void ApplyOptions(const AudioOptions& options);
webrtc::TaskQueueFactory* const task_queue_factory_;
- std::unique_ptr<rtc::TaskQueue> low_priority_worker_queue_;
+ std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
+ low_priority_worker_queue_;
webrtc::AudioDeviceModule* adm();
webrtc::AudioProcessing* apm() const;
diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc
index 4d6580631d..8ae441bc69 100644
--- a/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc
+++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc
@@ -1702,27 +1702,29 @@ TEST_P(WebRtcVoiceEngineTestFake, DontRecreateSendStream) {
// TODO(ossu): Revisit if these tests need to be here, now that these kinds of
// tests should be available in AudioEncoderOpusTest.
-// Test that if clockrate is not 48000 for opus, we fail.
+// Test that if clockrate is not 48000 for opus, we do not have a send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].clockrate = 50000;
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
-// Test that if channels=0 for opus, we fail.
+// Test that if channels=0 for opus, we do not have a send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].channels = 0;
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
-// Test that if channels=0 for opus, we fail.
+// Test that if channels=0 for opus, we do not have a send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
@@ -1730,20 +1732,23 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) {
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].channels = 0;
parameters.codecs[0].params["stereo"] = "1";
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
-// Test that if channel is 1 for opus and there's no stereo, we fail.
+// Test that if channel is 1 for opus and there's no stereo, we do not have a
+// send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].channels = 1;
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
-// Test that if channel is 1 for opus and stereo=0, we fail.
+// Test that if channel is 1 for opus and stereo=0, we do not have a send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
@@ -1751,10 +1756,11 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) {
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].channels = 1;
parameters.codecs[0].params["stereo"] = "0";
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
-// Test that if channel is 1 for opus and stereo=1, we fail.
+// Test that if channel is 1 for opus and stereo=1, we do not have a send codec.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
@@ -1762,7 +1768,8 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) {
parameters.codecs[0].bitrate = 0;
parameters.codecs[0].channels = 1;
parameters.codecs[0].params["stereo"] = "1";
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
// Test that with bitrate=0 and no stereo, bitrate is 32000.
@@ -2035,11 +2042,12 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) {
}
}
-// Test that we fail if no codecs are specified.
+// Test that we do not fail if no codecs are specified.
TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) {
EXPECT_TRUE(SetupSendStream());
cricket::AudioSenderParameter parameters;
- EXPECT_FALSE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_TRUE(send_channel_->SetSenderParameters(parameters));
+ EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt);
}
// Test that we can set send codecs even with telephone-event codec as the first