2015-10-16 14:35:07 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-07-05 19:08:33 +02:00
|
|
|
#include "call/call.h"
|
|
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
#include <list>
|
2017-03-27 07:15:49 -07:00
|
|
|
#include <map>
|
2016-03-12 06:10:44 -08:00
|
|
|
#include <memory>
|
2017-05-08 11:52:38 -07:00
|
|
|
#include <utility>
|
2015-10-16 14:35:07 -07:00
|
|
|
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2022-05-17 11:48:46 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
2017-11-02 13:04:41 +01:00
|
|
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
2019-08-07 12:24:53 +02:00
|
|
|
#include "api/rtc_event_log/rtc_event_log.h"
|
2019-07-03 14:56:33 +02:00
|
|
|
#include "api/task_queue/default_task_queue_factory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/test/mock_audio_mixer.h"
|
2020-06-11 12:07:14 +02:00
|
|
|
#include "api/test/video/function_video_encoder_factory.h"
|
2019-11-28 13:44:25 +01:00
|
|
|
#include "api/transport/field_trial_based_config.h"
|
2020-06-11 12:07:14 +02:00
|
|
|
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
2018-01-11 13:52:30 +01:00
|
|
|
#include "audio/audio_receive_stream.h"
|
2018-06-19 15:03:05 +02:00
|
|
|
#include "audio/audio_send_stream.h"
|
2020-06-11 12:07:14 +02:00
|
|
|
#include "call/adaptation/test/fake_resource.h"
|
2020-07-01 15:48:46 +02:00
|
|
|
#include "call/adaptation/test/mock_resource_listener.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/audio_state.h"
|
|
|
|
|
#include "modules/audio_device/include/mock_audio_device.h"
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
#include "modules/audio_processing/include/mock_audio_processing.h"
|
2020-06-03 22:55:33 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/fake_encoder.h"
|
|
|
|
|
#include "test/gtest.h"
|
|
|
|
|
#include "test/mock_audio_decoder_factory.h"
|
|
|
|
|
#include "test/mock_transport.h"
|
2020-05-05 15:35:45 +02:00
|
|
|
#include "test/run_loop.h"
|
2015-10-16 14:35:07 -07:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2020-07-01 15:48:46 +02:00
|
|
|
using ::testing::_;
|
2020-06-11 12:07:14 +02:00
|
|
|
using ::testing::Contains;
|
2020-12-03 11:30:34 -05:00
|
|
|
using ::testing::NiceMock;
|
2020-07-01 15:48:46 +02:00
|
|
|
using ::testing::StrictMock;
|
2020-06-11 12:07:14 +02:00
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
struct CallHelper {
|
2020-04-26 23:56:17 +02:00
|
|
|
explicit CallHelper(bool use_null_audio_processing) {
|
2019-07-03 14:56:33 +02:00
|
|
|
task_queue_factory_ = webrtc::CreateDefaultTaskQueueFactory();
|
2015-11-06 15:34:49 -08:00
|
|
|
webrtc::AudioState::Config audio_state_config;
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
audio_state_config.audio_mixer =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::test::MockAudioMixer>();
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
audio_state_config.audio_processing =
|
2020-04-26 23:56:17 +02:00
|
|
|
use_null_audio_processing
|
|
|
|
|
? nullptr
|
2021-04-22 19:21:43 +02:00
|
|
|
: rtc::make_ref_counted<
|
2020-12-03 11:30:34 -05:00
|
|
|
NiceMock<webrtc::test::MockAudioProcessing>>();
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
audio_state_config.audio_device_module =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::test::MockAudioDeviceModule>();
|
2016-10-07 11:53:05 -07:00
|
|
|
webrtc::Call::Config config(&event_log_);
|
2015-11-06 15:34:49 -08:00
|
|
|
config.audio_state = webrtc::AudioState::Create(audio_state_config);
|
2019-07-03 14:56:33 +02:00
|
|
|
config.task_queue_factory = task_queue_factory_.get();
|
2019-11-28 13:44:25 +01:00
|
|
|
config.trials = &field_trials_;
|
2015-10-16 14:35:07 -07:00
|
|
|
call_.reset(webrtc::Call::Create(config));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::Call* operator->() { return call_.get(); }
|
|
|
|
|
|
|
|
|
|
private:
|
2020-05-05 15:35:45 +02:00
|
|
|
webrtc::test::RunLoop loop_;
|
2019-08-07 12:24:53 +02:00
|
|
|
webrtc::RtcEventLogNull event_log_;
|
2019-11-28 13:44:25 +01:00
|
|
|
webrtc::FieldTrialBasedConfig field_trials_;
|
2019-07-03 14:56:33 +02:00
|
|
|
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
|
2016-03-12 06:10:44 -08:00
|
|
|
std::unique_ptr<webrtc::Call> call_;
|
2015-10-16 14:35:07 -07:00
|
|
|
};
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2020-07-01 15:48:46 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<Resource> FindResourceWhoseNameContains(
|
|
|
|
|
const std::vector<rtc::scoped_refptr<Resource>>& resources,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view name_contains) {
|
2020-07-01 15:48:46 +02:00
|
|
|
for (const auto& resource : resources) {
|
2022-05-17 11:48:46 +02:00
|
|
|
if (resource->Name().find(std::string(name_contains)) != std::string::npos)
|
2020-07-01 15:48:46 +02:00
|
|
|
return resource;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
TEST(CallTest, ConstructDestruct) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
}
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_AudioSendStream) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
AudioSendStream::Config config(&send_transport);
|
|
|
|
|
config.rtp.ssrc = 42;
|
|
|
|
|
AudioSendStream* stream = call->CreateAudioSendStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
call->DestroyAudioSendStream(stream);
|
|
|
|
|
}
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_AudioReceiveStream) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface::Config config;
|
2020-04-26 23:56:17 +02:00
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
config.rtp.remote_ssrc = 42;
|
|
|
|
|
config.rtcp_send_transport = &rtcp_send_transport;
|
|
|
|
|
config.decoder_factory =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::MockAudioDecoderFactory>();
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface* stream =
|
|
|
|
|
call->CreateAudioReceiveStream(config);
|
2020-04-26 23:56:17 +02:00
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
call->DestroyAudioReceiveStream(stream);
|
|
|
|
|
}
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_AudioSendStreams) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
AudioSendStream::Config config(&send_transport);
|
|
|
|
|
std::list<AudioSendStream*> streams;
|
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
|
for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
|
|
|
|
|
config.rtp.ssrc = ssrc;
|
|
|
|
|
AudioSendStream* stream = call->CreateAudioSendStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
if (ssrc & 1) {
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
} else {
|
|
|
|
|
streams.push_front(stream);
|
|
|
|
|
}
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
2020-04-26 23:56:17 +02:00
|
|
|
for (auto s : streams) {
|
|
|
|
|
call->DestroyAudioSendStream(s);
|
|
|
|
|
}
|
|
|
|
|
streams.clear();
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_AudioReceiveStreams) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface::Config config;
|
2020-04-26 23:56:17 +02:00
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
config.rtcp_send_transport = &rtcp_send_transport;
|
|
|
|
|
config.decoder_factory =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::MockAudioDecoderFactory>();
|
2022-05-22 20:47:28 +02:00
|
|
|
std::list<AudioReceiveStreamInterface*> streams;
|
2020-04-26 23:56:17 +02:00
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
|
for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
|
|
|
|
|
config.rtp.remote_ssrc = ssrc;
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface* stream =
|
|
|
|
|
call->CreateAudioReceiveStream(config);
|
2020-04-26 23:56:17 +02:00
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
if (ssrc & 1) {
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
} else {
|
|
|
|
|
streams.push_front(stream);
|
|
|
|
|
}
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
2020-04-26 23:56:17 +02:00
|
|
|
for (auto s : streams) {
|
|
|
|
|
call->DestroyAudioReceiveStream(s);
|
|
|
|
|
}
|
|
|
|
|
streams.clear();
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-23 23:37:14 -07:00
|
|
|
|
2016-11-14 11:30:07 -08:00
|
|
|
TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface::Config recv_config;
|
2020-04-26 23:56:17 +02:00
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
recv_config.rtp.remote_ssrc = 42;
|
|
|
|
|
recv_config.rtp.local_ssrc = 777;
|
|
|
|
|
recv_config.rtcp_send_transport = &rtcp_send_transport;
|
|
|
|
|
recv_config.decoder_factory =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::MockAudioDecoderFactory>();
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface* recv_stream =
|
2020-04-26 23:56:17 +02:00
|
|
|
call->CreateAudioReceiveStream(recv_config);
|
|
|
|
|
EXPECT_NE(recv_stream, nullptr);
|
|
|
|
|
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
AudioSendStream::Config send_config(&send_transport);
|
|
|
|
|
send_config.rtp.ssrc = 777;
|
|
|
|
|
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
|
|
|
|
|
EXPECT_NE(send_stream, nullptr);
|
|
|
|
|
|
2022-05-20 15:21:33 +02:00
|
|
|
AudioReceiveStreamImpl* internal_recv_stream =
|
|
|
|
|
static_cast<AudioReceiveStreamImpl*>(recv_stream);
|
2020-04-26 23:56:17 +02:00
|
|
|
EXPECT_EQ(send_stream,
|
|
|
|
|
internal_recv_stream->GetAssociatedSendStreamForTesting());
|
|
|
|
|
|
|
|
|
|
call->DestroyAudioSendStream(send_stream);
|
|
|
|
|
EXPECT_EQ(nullptr,
|
|
|
|
|
internal_recv_stream->GetAssociatedSendStreamForTesting());
|
|
|
|
|
|
|
|
|
|
call->DestroyAudioReceiveStream(recv_stream);
|
|
|
|
|
}
|
2016-11-14 11:30:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
AudioSendStream::Config send_config(&send_transport);
|
|
|
|
|
send_config.rtp.ssrc = 777;
|
|
|
|
|
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
|
|
|
|
|
EXPECT_NE(send_stream, nullptr);
|
|
|
|
|
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface::Config recv_config;
|
2020-04-26 23:56:17 +02:00
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
recv_config.rtp.remote_ssrc = 42;
|
|
|
|
|
recv_config.rtp.local_ssrc = 777;
|
|
|
|
|
recv_config.rtcp_send_transport = &rtcp_send_transport;
|
|
|
|
|
recv_config.decoder_factory =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<webrtc::MockAudioDecoderFactory>();
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface* recv_stream =
|
2020-04-26 23:56:17 +02:00
|
|
|
call->CreateAudioReceiveStream(recv_config);
|
|
|
|
|
EXPECT_NE(recv_stream, nullptr);
|
|
|
|
|
|
2022-05-20 15:21:33 +02:00
|
|
|
AudioReceiveStreamImpl* internal_recv_stream =
|
|
|
|
|
static_cast<AudioReceiveStreamImpl*>(recv_stream);
|
2020-04-26 23:56:17 +02:00
|
|
|
EXPECT_EQ(send_stream,
|
|
|
|
|
internal_recv_stream->GetAssociatedSendStreamForTesting());
|
|
|
|
|
|
|
|
|
|
call->DestroyAudioReceiveStream(recv_stream);
|
|
|
|
|
|
|
|
|
|
call->DestroyAudioSendStream(send_stream);
|
|
|
|
|
}
|
2016-11-14 11:30:07 -08:00
|
|
|
}
|
|
|
|
|
|
2016-10-23 23:37:14 -07:00
|
|
|
TEST(CallTest, CreateDestroy_FlexfecReceiveStream) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
FlexfecReceiveStream::Config config(&rtcp_send_transport);
|
|
|
|
|
config.payload_type = 118;
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = 38837212;
|
2020-04-26 23:56:17 +02:00
|
|
|
config.protected_media_ssrcs = {27273};
|
|
|
|
|
|
|
|
|
|
FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
call->DestroyFlexfecReceiveStream(stream);
|
|
|
|
|
}
|
2016-10-23 23:37:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, CreateDestroy_FlexfecReceiveStreams) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
FlexfecReceiveStream::Config config(&rtcp_send_transport);
|
|
|
|
|
config.payload_type = 118;
|
|
|
|
|
std::list<FlexfecReceiveStream*> streams;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
|
for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = ssrc;
|
2020-04-26 23:56:17 +02:00
|
|
|
config.protected_media_ssrcs = {ssrc + 1};
|
|
|
|
|
FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
if (ssrc & 1) {
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
} else {
|
|
|
|
|
streams.push_front(stream);
|
|
|
|
|
}
|
2016-10-23 23:37:14 -07:00
|
|
|
}
|
2020-04-26 23:56:17 +02:00
|
|
|
for (auto s : streams) {
|
|
|
|
|
call->DestroyFlexfecReceiveStream(s);
|
|
|
|
|
}
|
|
|
|
|
streams.clear();
|
2016-10-23 23:37:14 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) {
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
|
|
|
|
MockTransport rtcp_send_transport;
|
|
|
|
|
FlexfecReceiveStream::Config config(&rtcp_send_transport);
|
|
|
|
|
config.payload_type = 118;
|
|
|
|
|
config.protected_media_ssrcs = {1324234};
|
|
|
|
|
FlexfecReceiveStream* stream;
|
|
|
|
|
std::list<FlexfecReceiveStream*> streams;
|
|
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = 838383;
|
2020-04-26 23:56:17 +02:00
|
|
|
stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = 424993;
|
2020-04-26 23:56:17 +02:00
|
|
|
stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = 99383;
|
2020-04-26 23:56:17 +02:00
|
|
|
stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
config.rtp.remote_ssrc = 5548;
|
2020-04-26 23:56:17 +02:00
|
|
|
stream = call->CreateFlexfecReceiveStream(config);
|
|
|
|
|
EXPECT_NE(stream, nullptr);
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
|
|
|
|
|
for (auto s : streams) {
|
|
|
|
|
call->DestroyFlexfecReceiveStream(s);
|
|
|
|
|
}
|
2016-10-23 23:37:14 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 06:07:11 -07:00
|
|
|
TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) {
|
|
|
|
|
constexpr uint32_t kSSRC = 12345;
|
2020-04-26 23:56:17 +02:00
|
|
|
for (bool use_null_audio_processing : {false, true}) {
|
|
|
|
|
CallHelper call(use_null_audio_processing);
|
2017-05-23 06:07:11 -07:00
|
|
|
|
2020-04-26 23:56:17 +02:00
|
|
|
auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) {
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
AudioSendStream::Config config(&send_transport);
|
|
|
|
|
config.rtp.ssrc = ssrc;
|
|
|
|
|
AudioSendStream* stream = call->CreateAudioSendStream(config);
|
|
|
|
|
const RtpState rtp_state =
|
|
|
|
|
static_cast<internal::AudioSendStream*>(stream)->GetRtpState();
|
|
|
|
|
call->DestroyAudioSendStream(stream);
|
|
|
|
|
return rtp_state;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const RtpState rtp_state1 = create_stream_and_get_rtp_state(kSSRC);
|
|
|
|
|
const RtpState rtp_state2 = create_stream_and_get_rtp_state(kSSRC);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(rtp_state1.sequence_number, rtp_state2.sequence_number);
|
|
|
|
|
EXPECT_EQ(rtp_state1.start_timestamp, rtp_state2.start_timestamp);
|
|
|
|
|
EXPECT_EQ(rtp_state1.timestamp, rtp_state2.timestamp);
|
|
|
|
|
EXPECT_EQ(rtp_state1.capture_time_ms, rtp_state2.capture_time_ms);
|
|
|
|
|
EXPECT_EQ(rtp_state1.last_timestamp_time_ms,
|
|
|
|
|
rtp_state2.last_timestamp_time_ms);
|
|
|
|
|
}
|
2017-05-23 06:07:11 -07:00
|
|
|
}
|
2018-01-11 13:52:30 +01:00
|
|
|
|
2020-06-11 12:07:14 +02:00
|
|
|
TEST(CallTest, AddAdaptationResourceAfterCreatingVideoSendStream) {
|
|
|
|
|
CallHelper call(true);
|
|
|
|
|
// Create a VideoSendStream.
|
|
|
|
|
test::FunctionVideoEncoderFactory fake_encoder_factory([]() {
|
|
|
|
|
return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
|
|
|
|
|
});
|
|
|
|
|
auto bitrate_allocator_factory = CreateBuiltinVideoBitrateAllocatorFactory();
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
VideoSendStream::Config config(&send_transport);
|
|
|
|
|
config.rtp.payload_type = 110;
|
|
|
|
|
config.rtp.ssrcs = {42};
|
|
|
|
|
config.encoder_settings.encoder_factory = &fake_encoder_factory;
|
|
|
|
|
config.encoder_settings.bitrate_allocator_factory =
|
|
|
|
|
bitrate_allocator_factory.get();
|
|
|
|
|
VideoEncoderConfig encoder_config;
|
|
|
|
|
encoder_config.max_bitrate_bps = 1337;
|
2020-07-01 15:48:46 +02:00
|
|
|
VideoSendStream* stream1 =
|
|
|
|
|
call->CreateVideoSendStream(config.Copy(), encoder_config.Copy());
|
|
|
|
|
EXPECT_NE(stream1, nullptr);
|
|
|
|
|
config.rtp.ssrcs = {43};
|
|
|
|
|
VideoSendStream* stream2 =
|
|
|
|
|
call->CreateVideoSendStream(config.Copy(), encoder_config.Copy());
|
|
|
|
|
EXPECT_NE(stream2, nullptr);
|
|
|
|
|
// Add a fake resource.
|
2020-06-11 12:07:14 +02:00
|
|
|
auto fake_resource = FakeResource::Create("FakeResource");
|
|
|
|
|
call->AddAdaptationResource(fake_resource);
|
2021-07-26 12:40:21 +02:00
|
|
|
// An adapter resource mirroring the `fake_resource` should now be present on
|
2020-07-01 15:48:46 +02:00
|
|
|
// both streams.
|
|
|
|
|
auto injected_resource1 = FindResourceWhoseNameContains(
|
|
|
|
|
stream1->GetAdaptationResources(), fake_resource->Name());
|
|
|
|
|
EXPECT_TRUE(injected_resource1);
|
|
|
|
|
auto injected_resource2 = FindResourceWhoseNameContains(
|
|
|
|
|
stream2->GetAdaptationResources(), fake_resource->Name());
|
|
|
|
|
EXPECT_TRUE(injected_resource2);
|
|
|
|
|
// Overwrite the real resource listeners with mock ones to verify the signal
|
|
|
|
|
// gets through.
|
|
|
|
|
injected_resource1->SetResourceListener(nullptr);
|
|
|
|
|
StrictMock<MockResourceListener> resource_listener1;
|
|
|
|
|
EXPECT_CALL(resource_listener1, OnResourceUsageStateMeasured(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce([injected_resource1](rtc::scoped_refptr<Resource> resource,
|
|
|
|
|
ResourceUsageState usage_state) {
|
|
|
|
|
EXPECT_EQ(injected_resource1, resource);
|
|
|
|
|
EXPECT_EQ(ResourceUsageState::kOveruse, usage_state);
|
|
|
|
|
});
|
|
|
|
|
injected_resource1->SetResourceListener(&resource_listener1);
|
|
|
|
|
injected_resource2->SetResourceListener(nullptr);
|
|
|
|
|
StrictMock<MockResourceListener> resource_listener2;
|
|
|
|
|
EXPECT_CALL(resource_listener2, OnResourceUsageStateMeasured(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce([injected_resource2](rtc::scoped_refptr<Resource> resource,
|
|
|
|
|
ResourceUsageState usage_state) {
|
|
|
|
|
EXPECT_EQ(injected_resource2, resource);
|
|
|
|
|
EXPECT_EQ(ResourceUsageState::kOveruse, usage_state);
|
|
|
|
|
});
|
|
|
|
|
injected_resource2->SetResourceListener(&resource_listener2);
|
|
|
|
|
// The kOveruse signal should get to our resource listeners.
|
|
|
|
|
fake_resource->SetUsageState(ResourceUsageState::kOveruse);
|
|
|
|
|
call->DestroyVideoSendStream(stream1);
|
|
|
|
|
call->DestroyVideoSendStream(stream2);
|
2020-06-11 12:07:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CallTest, AddAdaptationResourceBeforeCreatingVideoSendStream) {
|
|
|
|
|
CallHelper call(true);
|
|
|
|
|
// Add a fake resource.
|
|
|
|
|
auto fake_resource = FakeResource::Create("FakeResource");
|
|
|
|
|
call->AddAdaptationResource(fake_resource);
|
|
|
|
|
// Create a VideoSendStream.
|
|
|
|
|
test::FunctionVideoEncoderFactory fake_encoder_factory([]() {
|
|
|
|
|
return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
|
|
|
|
|
});
|
|
|
|
|
auto bitrate_allocator_factory = CreateBuiltinVideoBitrateAllocatorFactory();
|
|
|
|
|
MockTransport send_transport;
|
|
|
|
|
VideoSendStream::Config config(&send_transport);
|
|
|
|
|
config.rtp.payload_type = 110;
|
|
|
|
|
config.rtp.ssrcs = {42};
|
|
|
|
|
config.encoder_settings.encoder_factory = &fake_encoder_factory;
|
|
|
|
|
config.encoder_settings.bitrate_allocator_factory =
|
|
|
|
|
bitrate_allocator_factory.get();
|
|
|
|
|
VideoEncoderConfig encoder_config;
|
|
|
|
|
encoder_config.max_bitrate_bps = 1337;
|
2020-07-01 15:48:46 +02:00
|
|
|
VideoSendStream* stream1 =
|
|
|
|
|
call->CreateVideoSendStream(config.Copy(), encoder_config.Copy());
|
|
|
|
|
EXPECT_NE(stream1, nullptr);
|
|
|
|
|
config.rtp.ssrcs = {43};
|
|
|
|
|
VideoSendStream* stream2 =
|
|
|
|
|
call->CreateVideoSendStream(config.Copy(), encoder_config.Copy());
|
|
|
|
|
EXPECT_NE(stream2, nullptr);
|
2021-07-26 12:40:21 +02:00
|
|
|
// An adapter resource mirroring the `fake_resource` should be present on both
|
2020-07-01 15:48:46 +02:00
|
|
|
// streams.
|
|
|
|
|
auto injected_resource1 = FindResourceWhoseNameContains(
|
|
|
|
|
stream1->GetAdaptationResources(), fake_resource->Name());
|
|
|
|
|
EXPECT_TRUE(injected_resource1);
|
|
|
|
|
auto injected_resource2 = FindResourceWhoseNameContains(
|
|
|
|
|
stream2->GetAdaptationResources(), fake_resource->Name());
|
|
|
|
|
EXPECT_TRUE(injected_resource2);
|
|
|
|
|
// Overwrite the real resource listeners with mock ones to verify the signal
|
|
|
|
|
// gets through.
|
|
|
|
|
injected_resource1->SetResourceListener(nullptr);
|
|
|
|
|
StrictMock<MockResourceListener> resource_listener1;
|
|
|
|
|
EXPECT_CALL(resource_listener1, OnResourceUsageStateMeasured(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce([injected_resource1](rtc::scoped_refptr<Resource> resource,
|
|
|
|
|
ResourceUsageState usage_state) {
|
|
|
|
|
EXPECT_EQ(injected_resource1, resource);
|
|
|
|
|
EXPECT_EQ(ResourceUsageState::kUnderuse, usage_state);
|
|
|
|
|
});
|
|
|
|
|
injected_resource1->SetResourceListener(&resource_listener1);
|
|
|
|
|
injected_resource2->SetResourceListener(nullptr);
|
|
|
|
|
StrictMock<MockResourceListener> resource_listener2;
|
|
|
|
|
EXPECT_CALL(resource_listener2, OnResourceUsageStateMeasured(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce([injected_resource2](rtc::scoped_refptr<Resource> resource,
|
|
|
|
|
ResourceUsageState usage_state) {
|
|
|
|
|
EXPECT_EQ(injected_resource2, resource);
|
|
|
|
|
EXPECT_EQ(ResourceUsageState::kUnderuse, usage_state);
|
|
|
|
|
});
|
|
|
|
|
injected_resource2->SetResourceListener(&resource_listener2);
|
|
|
|
|
// The kUnderuse signal should get to our resource listeners.
|
|
|
|
|
fake_resource->SetUsageState(ResourceUsageState::kUnderuse);
|
|
|
|
|
call->DestroyVideoSendStream(stream1);
|
|
|
|
|
call->DestroyVideoSendStream(stream2);
|
2020-06-11 12:07:14 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
} // namespace webrtc
|