2013-12-13 12:48:05 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 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.
|
|
|
|
|
*/
|
2016-03-15 01:00:47 -07:00
|
|
|
|
2013-12-13 12:48:05 +00:00
|
|
|
#include <algorithm>
|
2024-09-02 20:55:52 +00:00
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <iterator>
|
2016-03-15 01:00:47 -07:00
|
|
|
#include <limits>
|
2024-09-02 20:55:52 +00:00
|
|
|
#include <map>
|
2016-03-12 06:10:44 -08:00
|
|
|
#include <memory>
|
2013-12-13 12:48:05 +00:00
|
|
|
#include <string>
|
2024-09-02 20:55:52 +00:00
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2023-10-09 16:39:40 +02:00
|
|
|
#include "absl/flags/flag.h"
|
2022-05-17 11:48:46 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/array_view.h"
|
2024-04-19 19:46:03 +00:00
|
|
|
#include "api/audio/audio_device.h"
|
2024-11-01 11:43:08 +01:00
|
|
|
#include "api/audio/builtin_audio_processing_builder.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/environment/environment.h"
|
|
|
|
|
#include "api/field_trials_view.h"
|
|
|
|
|
#include "api/make_ref_counted.h"
|
2022-09-26 13:21:14 +02:00
|
|
|
#include "api/numerics/samples_stats_counter.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/rtp_parameters.h"
|
|
|
|
|
#include "api/scoped_refptr.h"
|
2022-06-16 21:27:45 +02:00
|
|
|
#include "api/task_queue/pending_task_safety_flag.h"
|
2019-09-30 04:16:28 +02:00
|
|
|
#include "api/task_queue/task_queue_base.h"
|
2022-09-26 13:21:14 +02:00
|
|
|
#include "api/test/metrics/global_metrics_logger_and_exporter.h"
|
|
|
|
|
#include "api/test/metrics/metric.h"
|
2018-08-17 14:26:54 +02:00
|
|
|
#include "api/test/simulated_network.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/test/video/function_video_encoder_factory.h"
|
|
|
|
|
#include "api/transport/bitrate_settings.h"
|
2024-05-15 15:53:02 +00:00
|
|
|
#include "api/units/data_rate.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/units/time_delta.h"
|
|
|
|
|
#include "api/units/timestamp.h"
|
2018-11-08 10:02:56 -08:00
|
|
|
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
2018-05-15 15:18:36 +02:00
|
|
|
#include "api/video/video_bitrate_allocation.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/video/video_bitrate_allocator_factory.h"
|
|
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "api/video/video_sink_interface.h"
|
|
|
|
|
#include "api/video/video_source_interface.h"
|
|
|
|
|
#include "api/video_codecs/sdp_video_format.h"
|
|
|
|
|
#include "api/video_codecs/video_codec.h"
|
2019-06-11 14:57:57 +02:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/video_codecs/video_encoder_factory.h"
|
|
|
|
|
#include "call/audio_receive_stream.h"
|
|
|
|
|
#include "call/audio_send_stream.h"
|
|
|
|
|
#include "call/audio_state.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/call.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "call/call_config.h"
|
2018-08-20 13:30:39 +02:00
|
|
|
#include "call/fake_network_pipe.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "call/video_receive_stream.h"
|
|
|
|
|
#include "call/video_send_stream.h"
|
2021-08-26 12:04:27 +02:00
|
|
|
#include "media/engine/internal_encoder_factory.h"
|
|
|
|
|
#include "media/engine/simulcast_encoder_adapter.h"
|
2018-03-07 14:44:00 +01:00
|
|
|
#include "modules/audio_device/include/test_audio_device.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_mixer/audio_mixer_impl.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "rtc_base/event.h"
|
2023-01-26 16:11:31 +01:00
|
|
|
#include "rtc_base/logging.h"
|
2019-10-21 09:24:27 +02:00
|
|
|
#include "rtc_base/task_queue_for_test.h"
|
2019-09-02 15:16:49 +02:00
|
|
|
#include "rtc_base/thread.h"
|
2018-09-28 08:51:10 +02:00
|
|
|
#include "system_wrappers/include/metrics.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/call_test.h"
|
|
|
|
|
#include "test/drifting_clock.h"
|
|
|
|
|
#include "test/encoder_settings.h"
|
|
|
|
|
#include "test/fake_encoder.h"
|
|
|
|
|
#include "test/field_trial.h"
|
|
|
|
|
#include "test/frame_generator_capturer.h"
|
|
|
|
|
#include "test/gtest.h"
|
2024-04-29 08:37:37 +00:00
|
|
|
#include "test/network/simulated_network.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/rtp_rtcp_observer.h"
|
2023-10-09 16:39:40 +02:00
|
|
|
#include "test/test_flags.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "test/testsupport/file_utils.h"
|
2018-09-28 09:07:24 +02:00
|
|
|
#include "test/video_encoder_proxy_factory.h"
|
2023-04-25 09:56:49 +02:00
|
|
|
#include "test/video_test_constants.h"
|
2022-09-29 10:28:24 +02:00
|
|
|
#include "video/config/video_encoder_config.h"
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2016-02-10 10:54:47 -08:00
|
|
|
using webrtc::test::DriftingClock;
|
|
|
|
|
|
2013-12-13 12:48:05 +00:00
|
|
|
namespace webrtc {
|
Reland "Delete test/constants.h"
This reverts commit 4f36b7a478c2763463c7a9ea970548ec68bc3ea6.
Reason for revert: Failing tests fixed.
Original change's description:
> Revert "Delete test/constants.h"
>
> This reverts commit 389b1672a32f2dd49af6c6ed40e8ddf394b986de.
>
> Reason for revert: Causes failure (and empty result list) in CallPerfTest.PadsToMinTransmitBitrate
>
> Original change's description:
> > Delete test/constants.h
> >
> > It's not possible to use constants.h for all RTP extensions
> > after the number of extensions exceeds 14, which is the maximum
> > number of one-byte RTP extensions. This is because some extensions
> > would have to be assigned a number greater than 14, even if the
> > test only involves 14 extensions or less.
> >
> > For uniformity's sake, this CL also edits some files to use an
> > enum as the files involved in this CL, rather than free-floating
> > const-ints.
> >
> > Bug: webrtc:10288
> > Change-Id: Ib5e58ad72c4d3756f4c4f6521f140ec59617f3f5
> > Reviewed-on: https://webrtc-review.googlesource.com/c/123048
> > Commit-Queue: Elad Alon <eladalon@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#26728}
>
> TBR=danilchap@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
>
> Bug: webrtc:10288, chromium:933127
> Change-Id: If1de0bd8992137c52bf0b877b3cb0a2bafc809d4
> Reviewed-on: https://webrtc-review.googlesource.com/c/123381
> Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
> Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#26744}
TBR=danilchap@webrtc.org,oprypin@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
Change-Id: I65e391325d3a6df6db3c0739185e2002e70fb954
Bug: webrtc:10288, chromium:933127
Reviewed-on: https://webrtc-review.googlesource.com/c/123384
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26750}
2019-02-18 23:45:57 +01:00
|
|
|
namespace {
|
2022-09-26 13:21:14 +02:00
|
|
|
|
|
|
|
|
using ::webrtc::test::GetGlobalMetricsLogger;
|
|
|
|
|
using ::webrtc::test::ImprovementDirection;
|
|
|
|
|
using ::webrtc::test::Unit;
|
|
|
|
|
|
Reland "Delete test/constants.h"
This reverts commit 4f36b7a478c2763463c7a9ea970548ec68bc3ea6.
Reason for revert: Failing tests fixed.
Original change's description:
> Revert "Delete test/constants.h"
>
> This reverts commit 389b1672a32f2dd49af6c6ed40e8ddf394b986de.
>
> Reason for revert: Causes failure (and empty result list) in CallPerfTest.PadsToMinTransmitBitrate
>
> Original change's description:
> > Delete test/constants.h
> >
> > It's not possible to use constants.h for all RTP extensions
> > after the number of extensions exceeds 14, which is the maximum
> > number of one-byte RTP extensions. This is because some extensions
> > would have to be assigned a number greater than 14, even if the
> > test only involves 14 extensions or less.
> >
> > For uniformity's sake, this CL also edits some files to use an
> > enum as the files involved in this CL, rather than free-floating
> > const-ints.
> >
> > Bug: webrtc:10288
> > Change-Id: Ib5e58ad72c4d3756f4c4f6521f140ec59617f3f5
> > Reviewed-on: https://webrtc-review.googlesource.com/c/123048
> > Commit-Queue: Elad Alon <eladalon@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#26728}
>
> TBR=danilchap@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
>
> Bug: webrtc:10288, chromium:933127
> Change-Id: If1de0bd8992137c52bf0b877b3cb0a2bafc809d4
> Reviewed-on: https://webrtc-review.googlesource.com/c/123381
> Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
> Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#26744}
TBR=danilchap@webrtc.org,oprypin@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
Change-Id: I65e391325d3a6df6db3c0739185e2002e70fb954
Bug: webrtc:10288, chromium:933127
Reviewed-on: https://webrtc-review.googlesource.com/c/123384
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26750}
2019-02-18 23:45:57 +01:00
|
|
|
enum : int { // The first valid value is 1.
|
|
|
|
|
kTransportSequenceNumberExtensionId = 1,
|
|
|
|
|
};
|
2022-09-26 13:21:14 +02:00
|
|
|
|
Reland "Delete test/constants.h"
This reverts commit 4f36b7a478c2763463c7a9ea970548ec68bc3ea6.
Reason for revert: Failing tests fixed.
Original change's description:
> Revert "Delete test/constants.h"
>
> This reverts commit 389b1672a32f2dd49af6c6ed40e8ddf394b986de.
>
> Reason for revert: Causes failure (and empty result list) in CallPerfTest.PadsToMinTransmitBitrate
>
> Original change's description:
> > Delete test/constants.h
> >
> > It's not possible to use constants.h for all RTP extensions
> > after the number of extensions exceeds 14, which is the maximum
> > number of one-byte RTP extensions. This is because some extensions
> > would have to be assigned a number greater than 14, even if the
> > test only involves 14 extensions or less.
> >
> > For uniformity's sake, this CL also edits some files to use an
> > enum as the files involved in this CL, rather than free-floating
> > const-ints.
> >
> > Bug: webrtc:10288
> > Change-Id: Ib5e58ad72c4d3756f4c4f6521f140ec59617f3f5
> > Reviewed-on: https://webrtc-review.googlesource.com/c/123048
> > Commit-Queue: Elad Alon <eladalon@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#26728}
>
> TBR=danilchap@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
>
> Bug: webrtc:10288, chromium:933127
> Change-Id: If1de0bd8992137c52bf0b877b3cb0a2bafc809d4
> Reviewed-on: https://webrtc-review.googlesource.com/c/123381
> Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
> Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#26744}
TBR=danilchap@webrtc.org,oprypin@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
Change-Id: I65e391325d3a6df6db3c0739185e2002e70fb954
Bug: webrtc:10288, chromium:933127
Reviewed-on: https://webrtc-review.googlesource.com/c/123384
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26750}
2019-02-18 23:45:57 +01:00
|
|
|
} // namespace
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2014-06-27 08:47:52 +00:00
|
|
|
class CallPerfTest : public test::CallTest {
|
Reland "Delete test/constants.h"
This reverts commit 4f36b7a478c2763463c7a9ea970548ec68bc3ea6.
Reason for revert: Failing tests fixed.
Original change's description:
> Revert "Delete test/constants.h"
>
> This reverts commit 389b1672a32f2dd49af6c6ed40e8ddf394b986de.
>
> Reason for revert: Causes failure (and empty result list) in CallPerfTest.PadsToMinTransmitBitrate
>
> Original change's description:
> > Delete test/constants.h
> >
> > It's not possible to use constants.h for all RTP extensions
> > after the number of extensions exceeds 14, which is the maximum
> > number of one-byte RTP extensions. This is because some extensions
> > would have to be assigned a number greater than 14, even if the
> > test only involves 14 extensions or less.
> >
> > For uniformity's sake, this CL also edits some files to use an
> > enum as the files involved in this CL, rather than free-floating
> > const-ints.
> >
> > Bug: webrtc:10288
> > Change-Id: Ib5e58ad72c4d3756f4c4f6521f140ec59617f3f5
> > Reviewed-on: https://webrtc-review.googlesource.com/c/123048
> > Commit-Queue: Elad Alon <eladalon@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#26728}
>
> TBR=danilchap@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
>
> Bug: webrtc:10288, chromium:933127
> Change-Id: If1de0bd8992137c52bf0b877b3cb0a2bafc809d4
> Reviewed-on: https://webrtc-review.googlesource.com/c/123381
> Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
> Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#26744}
TBR=danilchap@webrtc.org,oprypin@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
Change-Id: I65e391325d3a6df6db3c0739185e2002e70fb954
Bug: webrtc:10288, chromium:933127
Reviewed-on: https://webrtc-review.googlesource.com/c/123384
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26750}
2019-02-18 23:45:57 +01:00
|
|
|
public:
|
|
|
|
|
CallPerfTest() {
|
|
|
|
|
RegisterRtpExtension(RtpExtension(RtpExtension::kTransportSequenceNumberUri,
|
|
|
|
|
kTransportSequenceNumberExtensionId));
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-31 10:05:07 +00:00
|
|
|
protected:
|
2018-06-19 15:03:05 +02:00
|
|
|
enum class FecMode { kOn, kOff };
|
|
|
|
|
enum class CreateOrder { kAudioFirst, kVideoFirst };
|
2016-02-15 11:14:58 +01:00
|
|
|
void TestAudioVideoSync(FecMode fec,
|
|
|
|
|
CreateOrder create_first,
|
2016-02-10 10:54:47 -08:00
|
|
|
float video_ntp_speed,
|
|
|
|
|
float video_rtp_speed,
|
2017-12-28 15:50:33 +01:00
|
|
|
float audio_rtp_speed,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view test_label);
|
2014-09-04 06:48:14 +00:00
|
|
|
|
2014-03-13 12:52:27 +00:00
|
|
|
void TestMinTransmitBitrate(bool pad_to_min_bitrate);
|
|
|
|
|
|
2018-10-08 12:28:56 +02:00
|
|
|
void TestCaptureNtpTime(const BuiltInNetworkBehaviorConfig& net_config,
|
2014-04-24 22:10:24 +00:00
|
|
|
int threshold_ms,
|
|
|
|
|
int start_time_ms,
|
|
|
|
|
int run_time_ms);
|
2019-07-09 12:31:20 +02:00
|
|
|
void TestMinAudioVideoBitrate(int test_bitrate_from,
|
2017-11-22 17:22:35 +01:00
|
|
|
int test_bitrate_to,
|
|
|
|
|
int test_bitrate_step,
|
|
|
|
|
int min_bwe,
|
|
|
|
|
int start_bwe,
|
|
|
|
|
int max_bwe);
|
2021-08-26 12:04:27 +02:00
|
|
|
void TestEncodeFramerate(VideoEncoderFactory* encoder_factory,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view payload_name,
|
2021-08-26 12:04:27 +02:00
|
|
|
const std::vector<int>& max_framerates);
|
2013-12-13 12:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
2016-03-15 01:00:47 -07:00
|
|
|
class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver,
|
2016-03-23 04:48:10 -07:00
|
|
|
public rtc::VideoSinkInterface<VideoFrame> {
|
2013-12-13 12:48:05 +00:00
|
|
|
static const int kInSyncThresholdMs = 50;
|
|
|
|
|
static const int kStartupTimeMs = 2000;
|
|
|
|
|
static const int kMinRunTimeMs = 30000;
|
|
|
|
|
|
|
|
|
|
public:
|
2020-04-15 16:45:47 +02:00
|
|
|
explicit VideoRtcpAndSyncObserver(TaskQueueBase* task_queue,
|
|
|
|
|
Clock* clock,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view test_label)
|
2023-04-25 09:56:49 +02:00
|
|
|
: test::RtpRtcpObserver(test::VideoTestConstants::kLongTimeout),
|
2016-03-15 01:00:47 -07:00
|
|
|
clock_(clock),
|
2017-12-28 15:50:33 +01:00
|
|
|
test_label_(test_label),
|
2013-12-13 12:48:05 +00:00
|
|
|
creation_time_ms_(clock_->TimeInMilliseconds()),
|
2020-04-15 16:45:47 +02:00
|
|
|
task_queue_(task_queue) {}
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2024-10-29 14:47:48 +02:00
|
|
|
void OnFrame(const VideoFrame& /* video_frame */) override {
|
2022-07-06 18:35:01 +02:00
|
|
|
task_queue_->PostTask([this]() { CheckStats(); });
|
2020-04-15 16:45:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CheckStats() {
|
|
|
|
|
if (!receive_stream_)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-05-20 15:21:20 +02:00
|
|
|
VideoReceiveStreamInterface::Stats stats = receive_stream_->GetStats();
|
2016-03-15 01:00:47 -07:00
|
|
|
if (stats.sync_offset_ms == std::numeric_limits<int>::max())
|
2013-12-13 12:48:05 +00:00
|
|
|
return;
|
2016-03-15 01:00:47 -07:00
|
|
|
|
|
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
2013-12-13 12:48:05 +00:00
|
|
|
int64_t time_since_creation = now_ms - creation_time_ms_;
|
|
|
|
|
// During the first couple of seconds audio and video can falsely be
|
|
|
|
|
// estimated as being synchronized. We don't want to trigger on those.
|
|
|
|
|
if (time_since_creation < kStartupTimeMs)
|
|
|
|
|
return;
|
2016-03-15 01:00:47 -07:00
|
|
|
if (std::abs(stats.sync_offset_ms) < kInSyncThresholdMs) {
|
2013-12-13 12:48:05 +00:00
|
|
|
if (first_time_in_sync_ == -1) {
|
|
|
|
|
first_time_in_sync_ = now_ms;
|
2022-09-26 13:21:14 +02:00
|
|
|
GetGlobalMetricsLogger()->LogSingleValueMetric(
|
|
|
|
|
"sync_convergence_time" + test_label_, "synchronization",
|
|
|
|
|
time_since_creation, Unit::kMilliseconds,
|
|
|
|
|
ImprovementDirection::kSmallerIsBetter);
|
2013-12-13 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
if (time_since_creation > kMinRunTimeMs)
|
2015-12-10 13:02:50 +01:00
|
|
|
observation_complete_.Set();
|
2013-12-13 12:48:05 +00:00
|
|
|
}
|
2016-06-16 09:58:44 +02:00
|
|
|
if (first_time_in_sync_ != -1)
|
2022-09-26 13:21:14 +02:00
|
|
|
sync_offset_ms_list_.AddSample(stats.sync_offset_ms);
|
2013-12-13 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 15:21:20 +02:00
|
|
|
void set_receive_stream(VideoReceiveStreamInterface* receive_stream) {
|
2020-04-15 16:45:47 +02:00
|
|
|
RTC_DCHECK_EQ(task_queue_, TaskQueueBase::Current());
|
|
|
|
|
// Note that receive_stream may be nullptr.
|
2016-03-15 01:00:47 -07:00
|
|
|
receive_stream_ = receive_stream;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-03 09:27:37 -07:00
|
|
|
void PrintResults() {
|
2022-09-26 13:21:14 +02:00
|
|
|
GetGlobalMetricsLogger()->LogMetric(
|
|
|
|
|
"stream_offset" + test_label_, "synchronization", sync_offset_ms_list_,
|
|
|
|
|
Unit::kMilliseconds, ImprovementDirection::kNeitherIsBetter);
|
2016-06-03 09:27:37 -07:00
|
|
|
}
|
|
|
|
|
|
2013-12-13 12:48:05 +00:00
|
|
|
private:
|
2014-04-28 13:00:21 +00:00
|
|
|
Clock* const clock_;
|
2021-08-26 12:04:27 +02:00
|
|
|
const std::string test_label_;
|
2015-10-27 08:29:42 -07:00
|
|
|
const int64_t creation_time_ms_;
|
2020-04-15 16:45:47 +02:00
|
|
|
int64_t first_time_in_sync_ = -1;
|
2022-05-20 15:21:20 +02:00
|
|
|
VideoReceiveStreamInterface* receive_stream_ = nullptr;
|
2022-09-26 13:21:14 +02:00
|
|
|
SamplesStatsCounter sync_offset_ms_list_;
|
2020-04-15 16:45:47 +02:00
|
|
|
TaskQueueBase* const task_queue_;
|
2013-12-13 12:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
2016-02-15 11:14:58 +01:00
|
|
|
void CallPerfTest::TestAudioVideoSync(FecMode fec,
|
|
|
|
|
CreateOrder create_first,
|
2016-02-10 10:54:47 -08:00
|
|
|
float video_ntp_speed,
|
|
|
|
|
float video_rtp_speed,
|
2017-12-28 15:50:33 +01:00
|
|
|
float audio_rtp_speed,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view test_label) {
|
2015-07-15 08:02:58 -07:00
|
|
|
const char* kSyncGroup = "av_sync";
|
2015-12-07 10:26:18 +01:00
|
|
|
const uint32_t kAudioSendSsrc = 1234;
|
|
|
|
|
const uint32_t kAudioRecvSsrc = 5678;
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2018-10-08 12:28:56 +02:00
|
|
|
BuiltInNetworkBehaviorConfig audio_net_config;
|
2016-04-29 00:57:13 -07:00
|
|
|
audio_net_config.queue_delay_ms = 500;
|
|
|
|
|
audio_net_config.loss_percent = 5;
|
2017-04-10 16:57:57 -07:00
|
|
|
|
2020-04-15 16:45:47 +02:00
|
|
|
auto observer = std::make_unique<VideoRtcpAndSyncObserver>(
|
|
|
|
|
task_queue(), Clock::GetRealTimeClock(), test_label);
|
2017-08-22 04:02:52 -07:00
|
|
|
|
2017-04-10 16:57:57 -07:00
|
|
|
std::map<uint8_t, MediaType> audio_pt_map;
|
|
|
|
|
std::map<uint8_t, MediaType> video_pt_map;
|
2015-07-15 08:02:58 -07:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
std::unique_ptr<test::PacketTransport> audio_send_transport;
|
|
|
|
|
std::unique_ptr<test::PacketTransport> video_send_transport;
|
|
|
|
|
std::unique_ptr<test::PacketTransport> receive_transport;
|
2015-07-15 08:02:58 -07:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
AudioSendStream* audio_send_stream;
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface* audio_receive_stream;
|
2017-08-22 04:02:52 -07:00
|
|
|
std::unique_ptr<DriftingClock> drifting_clock;
|
|
|
|
|
|
2022-08-11 12:26:09 +02:00
|
|
|
SendTask(task_queue(), [&]() {
|
2017-08-22 04:02:52 -07:00
|
|
|
metrics::Reset();
|
2023-04-11 11:44:53 +02:00
|
|
|
rtc::scoped_refptr<AudioDeviceModule> fake_audio_device =
|
2019-06-12 11:49:17 +00:00
|
|
|
TestAudioDeviceModule::Create(
|
2023-11-29 15:54:32 +01:00
|
|
|
&env().task_queue_factory(),
|
2018-03-07 14:44:00 +01:00
|
|
|
TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000),
|
|
|
|
|
TestAudioDeviceModule::CreateDiscardRenderer(48000),
|
|
|
|
|
audio_rtp_speed);
|
2017-11-21 20:33:05 +01:00
|
|
|
EXPECT_EQ(0, fake_audio_device->Init());
|
2017-08-22 04:02:52 -07:00
|
|
|
|
|
|
|
|
AudioState::Config send_audio_state_config;
|
|
|
|
|
send_audio_state_config.audio_mixer = AudioMixerImpl::Create();
|
2018-01-09 14:17:33 +01:00
|
|
|
send_audio_state_config.audio_processing =
|
2024-11-01 11:43:08 +01:00
|
|
|
BuiltinAudioProcessingBuilder().Build(env());
|
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
|
|
|
send_audio_state_config.audio_device_module = fake_audio_device;
|
2023-11-29 15:54:32 +01:00
|
|
|
CallConfig sender_config = SendCallConfig();
|
2017-08-22 04:02:52 -07:00
|
|
|
|
2017-11-21 20:33:05 +01:00
|
|
|
auto audio_state = AudioState::Create(send_audio_state_config);
|
|
|
|
|
fake_audio_device->RegisterAudioCallback(audio_state->audio_transport());
|
|
|
|
|
sender_config.audio_state = audio_state;
|
2023-11-29 15:54:32 +01:00
|
|
|
CallConfig receiver_config = RecvCallConfig();
|
2017-11-21 20:33:05 +01:00
|
|
|
receiver_config.audio_state = audio_state;
|
2024-07-29 07:54:20 +02:00
|
|
|
CreateCalls(std::move(sender_config), std::move(receiver_config));
|
2017-08-22 04:02:52 -07:00
|
|
|
|
|
|
|
|
std::copy_if(std::begin(payload_type_map_), std::end(payload_type_map_),
|
|
|
|
|
std::inserter(audio_pt_map, audio_pt_map.end()),
|
|
|
|
|
[](const std::pair<const uint8_t, MediaType>& pair) {
|
|
|
|
|
return pair.second == MediaType::AUDIO;
|
|
|
|
|
});
|
|
|
|
|
std::copy_if(std::begin(payload_type_map_), std::end(payload_type_map_),
|
|
|
|
|
std::inserter(video_pt_map, video_pt_map.end()),
|
|
|
|
|
[](const std::pair<const uint8_t, MediaType>& pair) {
|
|
|
|
|
return pair.second == MediaType::VIDEO;
|
|
|
|
|
});
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
audio_send_transport = std::make_unique<test::PacketTransport>(
|
2020-04-15 16:45:47 +02:00
|
|
|
task_queue(), sender_call_.get(), observer.get(),
|
2018-08-20 13:30:39 +02:00
|
|
|
test::PacketTransport::kSender, audio_pt_map,
|
2019-09-17 17:06:18 +02:00
|
|
|
std::make_unique<FakeNetworkPipe>(
|
2018-08-20 13:30:39 +02:00
|
|
|
Clock::GetRealTimeClock(),
|
2023-01-19 15:45:58 +00:00
|
|
|
std::make_unique<SimulatedNetwork>(audio_net_config)),
|
|
|
|
|
GetRegisteredExtensions(), GetRegisteredExtensions());
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_send_transport->SetReceiver(receiver_call_->Receiver());
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
video_send_transport = std::make_unique<test::PacketTransport>(
|
2020-04-15 16:45:47 +02:00
|
|
|
task_queue(), sender_call_.get(), observer.get(),
|
2017-08-22 04:02:52 -07:00
|
|
|
test::PacketTransport::kSender, video_pt_map,
|
2023-01-19 15:45:58 +00:00
|
|
|
std::make_unique<FakeNetworkPipe>(
|
|
|
|
|
Clock::GetRealTimeClock(),
|
|
|
|
|
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig())),
|
|
|
|
|
GetRegisteredExtensions(), GetRegisteredExtensions());
|
2017-08-22 04:02:52 -07:00
|
|
|
video_send_transport->SetReceiver(receiver_call_->Receiver());
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
receive_transport = std::make_unique<test::PacketTransport>(
|
2020-04-15 16:45:47 +02:00
|
|
|
task_queue(), receiver_call_.get(), observer.get(),
|
2017-08-22 04:02:52 -07:00
|
|
|
test::PacketTransport::kReceiver, payload_type_map_,
|
2023-01-19 15:45:58 +00:00
|
|
|
std::make_unique<FakeNetworkPipe>(
|
|
|
|
|
Clock::GetRealTimeClock(),
|
|
|
|
|
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig())),
|
|
|
|
|
GetRegisteredExtensions(), GetRegisteredExtensions());
|
2017-08-22 04:02:52 -07:00
|
|
|
receive_transport->SetReceiver(sender_call_->Receiver());
|
|
|
|
|
|
|
|
|
|
CreateSendConfig(1, 0, 0, video_send_transport.get());
|
|
|
|
|
CreateMatchingReceiveConfigs(receive_transport.get());
|
|
|
|
|
|
2019-11-26 09:19:40 -08:00
|
|
|
AudioSendStream::Config audio_send_config(audio_send_transport.get());
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_send_config.rtp.ssrc = kAudioSendSsrc;
|
2022-11-18 11:52:19 +01:00
|
|
|
// TODO(bugs.webrtc.org/14683): Let the tests fail with invalid config.
|
2017-11-16 10:55:08 +01:00
|
|
|
audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
|
2023-04-25 09:56:49 +02:00
|
|
|
test::VideoTestConstants::kAudioSendPayloadType, {"OPUS", 48000, 2});
|
2022-11-18 11:52:19 +01:00
|
|
|
audio_send_config.min_bitrate_bps = 6000;
|
|
|
|
|
audio_send_config.max_bitrate_bps = 510000;
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_send_config.encoder_factory = CreateBuiltinAudioEncoderFactory();
|
|
|
|
|
audio_send_stream = sender_call_->CreateAudioSendStream(audio_send_config);
|
|
|
|
|
|
2023-04-25 09:56:49 +02:00
|
|
|
GetVideoSendConfig()->rtp.nack.rtp_history_ms =
|
|
|
|
|
test::VideoTestConstants::kNackRtpHistoryMs;
|
2017-08-22 04:02:52 -07:00
|
|
|
if (fec == FecMode::kOn) {
|
2023-04-25 09:56:49 +02:00
|
|
|
GetVideoSendConfig()->rtp.ulpfec.red_payload_type =
|
|
|
|
|
test::VideoTestConstants::kRedPayloadType;
|
|
|
|
|
GetVideoSendConfig()->rtp.ulpfec.ulpfec_payload_type =
|
|
|
|
|
test::VideoTestConstants::kUlpfecPayloadType;
|
|
|
|
|
video_receive_configs_[0].rtp.red_payload_type =
|
|
|
|
|
test::VideoTestConstants::kRedPayloadType;
|
|
|
|
|
video_receive_configs_[0].rtp.ulpfec_payload_type =
|
|
|
|
|
test::VideoTestConstants::kUlpfecPayloadType;
|
2017-08-22 04:02:52 -07:00
|
|
|
}
|
|
|
|
|
video_receive_configs_[0].rtp.nack.rtp_history_ms = 1000;
|
2020-04-15 16:45:47 +02:00
|
|
|
video_receive_configs_[0].renderer = observer.get();
|
2017-08-22 04:02:52 -07:00
|
|
|
video_receive_configs_[0].sync_group = kSyncGroup;
|
|
|
|
|
|
2022-05-22 20:47:28 +02:00
|
|
|
AudioReceiveStreamInterface::Config audio_recv_config;
|
2023-04-24 19:01:33 +00:00
|
|
|
audio_recv_config.rtp.remote_ssrc = kAudioSendSsrc;
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_recv_config.rtp.local_ssrc = kAudioRecvSsrc;
|
2020-10-31 12:40:43 +01:00
|
|
|
audio_recv_config.rtcp_send_transport = receive_transport.get();
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_recv_config.sync_group = kSyncGroup;
|
2018-03-28 14:16:04 +02:00
|
|
|
audio_recv_config.decoder_factory = audio_decoder_factory_;
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_recv_config.decoder_map = {
|
2023-04-25 09:56:49 +02:00
|
|
|
{test::VideoTestConstants::kAudioSendPayloadType, {"OPUS", 48000, 2}}};
|
2017-08-22 04:02:52 -07:00
|
|
|
|
|
|
|
|
if (create_first == CreateOrder::kAudioFirst) {
|
|
|
|
|
audio_receive_stream =
|
|
|
|
|
receiver_call_->CreateAudioReceiveStream(audio_recv_config);
|
|
|
|
|
CreateVideoStreams();
|
|
|
|
|
} else {
|
|
|
|
|
CreateVideoStreams();
|
|
|
|
|
audio_receive_stream =
|
|
|
|
|
receiver_call_->CreateAudioReceiveStream(audio_recv_config);
|
|
|
|
|
}
|
|
|
|
|
EXPECT_EQ(1u, video_receive_streams_.size());
|
2020-04-15 16:45:47 +02:00
|
|
|
observer->set_receive_stream(video_receive_streams_[0]);
|
2023-11-29 15:54:32 +01:00
|
|
|
drifting_clock =
|
|
|
|
|
std::make_unique<DriftingClock>(&env().clock(), video_ntp_speed);
|
2023-04-25 09:56:49 +02:00
|
|
|
CreateFrameGeneratorCapturerWithDrift(
|
|
|
|
|
drifting_clock.get(), video_rtp_speed,
|
|
|
|
|
test::VideoTestConstants::kDefaultFramerate,
|
|
|
|
|
test::VideoTestConstants::kDefaultWidth,
|
|
|
|
|
test::VideoTestConstants::kDefaultHeight);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
Start();
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_send_stream->Start();
|
|
|
|
|
audio_receive_stream->Start();
|
|
|
|
|
});
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2020-04-15 16:45:47 +02:00
|
|
|
EXPECT_TRUE(observer->Wait())
|
2013-12-13 12:48:05 +00:00
|
|
|
<< "Timed out while waiting for audio and video to be synchronized.";
|
|
|
|
|
|
2022-08-11 12:26:09 +02:00
|
|
|
SendTask(task_queue(), [&]() {
|
2020-04-15 16:45:47 +02:00
|
|
|
// Clear the pointer to the receive stream since it will now be deleted.
|
|
|
|
|
observer->set_receive_stream(nullptr);
|
|
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
audio_send_stream->Stop();
|
|
|
|
|
audio_receive_stream->Stop();
|
|
|
|
|
|
|
|
|
|
Stop();
|
|
|
|
|
|
|
|
|
|
DestroyStreams();
|
2013-12-13 12:48:05 +00:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
sender_call_->DestroyAudioSendStream(audio_send_stream);
|
|
|
|
|
receiver_call_->DestroyAudioReceiveStream(audio_receive_stream);
|
2015-12-07 10:26:18 +01:00
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
DestroyCalls();
|
2020-12-30 17:12:27 +01:00
|
|
|
// Call may post periodic rtcp packet to the transport on the process
|
|
|
|
|
// thread, thus transport should be destroyed after the call objects.
|
|
|
|
|
// Though transports keep pointers to the call objects, transports handle
|
|
|
|
|
// packets on the task_queue() and thus wouldn't create a race while current
|
|
|
|
|
// destruction happens in the same task as destruction of the call objects.
|
|
|
|
|
video_send_transport.reset();
|
|
|
|
|
audio_send_transport.reset();
|
|
|
|
|
receive_transport.reset();
|
2017-08-22 04:02:52 -07:00
|
|
|
});
|
2016-03-15 01:00:47 -07:00
|
|
|
|
2020-04-15 16:45:47 +02:00
|
|
|
observer->PrintResults();
|
2017-02-21 05:20:28 -08:00
|
|
|
|
|
|
|
|
// In quick test synchronization may not be achieved in time.
|
2023-10-09 16:39:40 +02:00
|
|
|
if (!absl::GetFlag(FLAGS_webrtc_quick_perf_test)) {
|
2019-03-15 11:36:39 +01:00
|
|
|
// TODO(bugs.webrtc.org/10417): Reenable this for iOS
|
|
|
|
|
#if !defined(WEBRTC_IOS)
|
2019-12-09 13:06:53 +01:00
|
|
|
EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs"));
|
2019-03-15 11:36:39 +01:00
|
|
|
#endif
|
2017-02-21 05:20:28 -08:00
|
|
|
}
|
2020-04-15 16:45:47 +02:00
|
|
|
|
|
|
|
|
task_queue()->PostTask(
|
2022-07-06 18:35:01 +02:00
|
|
|
[to_delete = observer.release()]() { delete to_delete; });
|
2014-06-27 08:47:52 +00:00
|
|
|
}
|
2014-04-24 22:10:24 +00:00
|
|
|
|
2020-09-10 20:46:33 +02:00
|
|
|
TEST_F(CallPerfTest, Synchronization_PlaysOutAudioAndVideoWithoutClockDrift) {
|
2018-08-09 11:04:32 +02:00
|
|
|
TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
|
|
|
|
|
DriftingClock::kNoDrift, DriftingClock::kNoDrift,
|
|
|
|
|
DriftingClock::kNoDrift, "_video_no_drift");
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 20:46:33 +02:00
|
|
|
TEST_F(CallPerfTest, Synchronization_PlaysOutAudioAndVideoWithVideoNtpDrift) {
|
2016-02-15 11:14:58 +01:00
|
|
|
TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
|
|
|
|
|
DriftingClock::PercentsFaster(10.0f),
|
2017-12-28 15:50:33 +01:00
|
|
|
DriftingClock::kNoDrift, DriftingClock::kNoDrift,
|
|
|
|
|
"_video_ntp_drift");
|
2016-02-10 10:54:47 -08:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 20:46:33 +02:00
|
|
|
TEST_F(CallPerfTest,
|
|
|
|
|
Synchronization_PlaysOutAudioAndVideoWithAudioFasterThanVideoDrift) {
|
2016-02-15 11:14:58 +01:00
|
|
|
TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
|
|
|
|
|
DriftingClock::kNoDrift,
|
2016-02-10 10:54:47 -08:00
|
|
|
DriftingClock::PercentsSlower(30.0f),
|
2017-12-28 15:50:33 +01:00
|
|
|
DriftingClock::PercentsFaster(30.0f), "_audio_faster");
|
2016-02-10 10:54:47 -08:00
|
|
|
}
|
|
|
|
|
|
2020-12-30 17:12:27 +01:00
|
|
|
TEST_F(CallPerfTest,
|
|
|
|
|
Synchronization_PlaysOutAudioAndVideoWithVideoFasterThanAudioDrift) {
|
2016-02-15 11:14:58 +01:00
|
|
|
TestAudioVideoSync(FecMode::kOn, CreateOrder::kVideoFirst,
|
|
|
|
|
DriftingClock::kNoDrift,
|
2016-02-10 10:54:47 -08:00
|
|
|
DriftingClock::PercentsFaster(30.0f),
|
2017-12-28 15:50:33 +01:00
|
|
|
DriftingClock::PercentsSlower(30.0f), "_video_faster");
|
2014-09-04 06:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
|
Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2783183003/ )
Reason for revert:
Seem to be a flaky test rather than an issue with this cl. Creating reland, will add code to reduce flakiness to that test.
Original issue's description:
> Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #8 id:410001 of https://codereview.webrtc.org/2781433002/ )
>
> Reason for revert:
> This has resulted in failure of CallPerfTest.ReceivesCpuOveruseAndUnderuse test on the Win7 build bot https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1780
>
> Original issue's description:
> > Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2764133002/ )
> >
> > Reason for revert:
> > Found issue with test case, will add fix to reland cl.
> >
> > Original issue's description:
> > > Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #14 id:250001 of https://codereview.webrtc.org/2716643002/ )
> > >
> > > Reason for revert:
> > > Breaks perf tests:
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1679
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/2325
> > >
> > > Original issue's description:
> > > > Add framerate to VideoSinkWants and ability to signal on overuse
> > > >
> > > > In ViEEncoder, try to reduce framerate instead of resolution if the
> > > > current degradation preference is maintain-resolution rather than
> > > > balanced.
> > > >
> > > > BUG=webrtc:4172
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2716643002
> > > > Cr-Commit-Position: refs/heads/master@{#17327}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/72acf2526177bb4dbb5103cd6e165eb4361a5ae6
> > >
> > > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,sprang@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4172
> > >
> > > Review-Url: https://codereview.webrtc.org/2764133002
> > > Cr-Commit-Position: refs/heads/master@{#17331}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/8b45b11144c968b4173215c76f78c710c9a2ed0b
> >
> > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:4172
> >
> > Review-Url: https://codereview.webrtc.org/2781433002
> > Cr-Commit-Position: refs/heads/master@{#17474}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/3ea3c77e93121b1ab9d5e46641e6764f2cca0d51
>
> TBR=ilnik@webrtc.org,stefan@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2783183003
> Cr-Commit-Position: refs/heads/master@{#17477}
> Committed: https://chromium.googlesource.com/external/webrtc/+/f9ed235c9b7248694edcb46feb1f29ce7456ab59
R=ilnik@webrtc.org,stefan@webrtc.org
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2789823002
Cr-Commit-Position: refs/heads/master@{#17498}
2017-04-02 23:53:04 -07:00
|
|
|
// Minimal normal usage at the start, then 30s overuse to allow filter to
|
|
|
|
|
// settle, and then 80s underuse to allow plenty of time for rampup again.
|
|
|
|
|
test::ScopedFieldTrials fake_overuse_settings(
|
|
|
|
|
"WebRTC-ForceSimulatedOveruseIntervalMs/1-30000-80000/");
|
|
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
class LoadObserver : public test::SendTest,
|
|
|
|
|
public test::FrameGeneratorCapturer::SinkWantsObserver {
|
2014-01-31 10:05:07 +00:00
|
|
|
public:
|
2023-04-25 09:56:49 +02:00
|
|
|
LoadObserver()
|
|
|
|
|
: SendTest(test::VideoTestConstants::kLongTimeout),
|
|
|
|
|
test_phase_(TestPhase::kInit) {}
|
2016-11-01 11:45:46 -07:00
|
|
|
|
|
|
|
|
void OnFrameGeneratorCapturerCreated(
|
|
|
|
|
test::FrameGeneratorCapturer* frame_generator_capturer) override {
|
|
|
|
|
frame_generator_capturer->SetSinkWantsObserver(this);
|
2017-02-27 00:15:31 -08:00
|
|
|
// Set a high initial resolution to be sure that we can scale down.
|
|
|
|
|
frame_generator_capturer->ChangeResolution(1920, 1080);
|
2016-11-01 11:45:46 -07:00
|
|
|
}
|
2014-01-31 10:05:07 +00:00
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
// OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
|
|
|
|
|
// is called.
|
Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2783183003/ )
Reason for revert:
Seem to be a flaky test rather than an issue with this cl. Creating reland, will add code to reduce flakiness to that test.
Original issue's description:
> Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #8 id:410001 of https://codereview.webrtc.org/2781433002/ )
>
> Reason for revert:
> This has resulted in failure of CallPerfTest.ReceivesCpuOveruseAndUnderuse test on the Win7 build bot https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1780
>
> Original issue's description:
> > Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2764133002/ )
> >
> > Reason for revert:
> > Found issue with test case, will add fix to reland cl.
> >
> > Original issue's description:
> > > Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #14 id:250001 of https://codereview.webrtc.org/2716643002/ )
> > >
> > > Reason for revert:
> > > Breaks perf tests:
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1679
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/2325
> > >
> > > Original issue's description:
> > > > Add framerate to VideoSinkWants and ability to signal on overuse
> > > >
> > > > In ViEEncoder, try to reduce framerate instead of resolution if the
> > > > current degradation preference is maintain-resolution rather than
> > > > balanced.
> > > >
> > > > BUG=webrtc:4172
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2716643002
> > > > Cr-Commit-Position: refs/heads/master@{#17327}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/72acf2526177bb4dbb5103cd6e165eb4361a5ae6
> > >
> > > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,sprang@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4172
> > >
> > > Review-Url: https://codereview.webrtc.org/2764133002
> > > Cr-Commit-Position: refs/heads/master@{#17331}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/8b45b11144c968b4173215c76f78c710c9a2ed0b
> >
> > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:4172
> >
> > Review-Url: https://codereview.webrtc.org/2781433002
> > Cr-Commit-Position: refs/heads/master@{#17474}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/3ea3c77e93121b1ab9d5e46641e6764f2cca0d51
>
> TBR=ilnik@webrtc.org,stefan@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2783183003
> Cr-Commit-Position: refs/heads/master@{#17477}
> Committed: https://chromium.googlesource.com/external/webrtc/+/f9ed235c9b7248694edcb46feb1f29ce7456ab59
R=ilnik@webrtc.org,stefan@webrtc.org
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2789823002
Cr-Commit-Position: refs/heads/master@{#17498}
2017-04-02 23:53:04 -07:00
|
|
|
// TODO(sprang): Add integration test for maintain-framerate mode?
|
2024-10-29 14:47:48 +02:00
|
|
|
void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* /* sink */,
|
2016-11-01 11:45:46 -07:00
|
|
|
const rtc::VideoSinkWants& wants) override {
|
2024-03-22 12:07:38 +01:00
|
|
|
RTC_LOG(LS_INFO) << "OnSinkWantsChanged fps:" << wants.max_framerate_fps
|
|
|
|
|
<< " max_pixel_count " << wants.max_pixel_count
|
|
|
|
|
<< " target_pixel_count"
|
|
|
|
|
<< wants.target_pixel_count.value_or(-1);
|
|
|
|
|
// The sink wants can change either because an adaptation happened
|
|
|
|
|
// (i.e. the pixels or frame rate changed) or for other reasons, such
|
|
|
|
|
// as encoded resolutions being communicated (happens whenever we
|
|
|
|
|
// capture a new frame size). In this test, we only care about
|
|
|
|
|
// adaptations.
|
2021-02-25 10:30:39 +01:00
|
|
|
bool did_adapt =
|
|
|
|
|
last_wants_.max_pixel_count != wants.max_pixel_count ||
|
|
|
|
|
last_wants_.target_pixel_count != wants.target_pixel_count ||
|
|
|
|
|
last_wants_.max_framerate_fps != wants.max_framerate_fps;
|
|
|
|
|
last_wants_ = wants;
|
|
|
|
|
if (!did_adapt) {
|
2024-03-22 12:07:38 +01:00
|
|
|
if (test_phase_ == TestPhase::kInit) {
|
|
|
|
|
test_phase_ = TestPhase::kStart;
|
|
|
|
|
}
|
2021-02-25 10:30:39 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2018-09-13 10:42:19 +02:00
|
|
|
// At kStart expect CPU overuse. Then expect CPU underuse when the encoder
|
2016-11-01 11:45:46 -07:00
|
|
|
// delay has been decreased.
|
Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2783183003/ )
Reason for revert:
Seem to be a flaky test rather than an issue with this cl. Creating reland, will add code to reduce flakiness to that test.
Original issue's description:
> Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #8 id:410001 of https://codereview.webrtc.org/2781433002/ )
>
> Reason for revert:
> This has resulted in failure of CallPerfTest.ReceivesCpuOveruseAndUnderuse test on the Win7 build bot https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1780
>
> Original issue's description:
> > Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2764133002/ )
> >
> > Reason for revert:
> > Found issue with test case, will add fix to reland cl.
> >
> > Original issue's description:
> > > Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #14 id:250001 of https://codereview.webrtc.org/2716643002/ )
> > >
> > > Reason for revert:
> > > Breaks perf tests:
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1679
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/2325
> > >
> > > Original issue's description:
> > > > Add framerate to VideoSinkWants and ability to signal on overuse
> > > >
> > > > In ViEEncoder, try to reduce framerate instead of resolution if the
> > > > current degradation preference is maintain-resolution rather than
> > > > balanced.
> > > >
> > > > BUG=webrtc:4172
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2716643002
> > > > Cr-Commit-Position: refs/heads/master@{#17327}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/72acf2526177bb4dbb5103cd6e165eb4361a5ae6
> > >
> > > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,sprang@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4172
> > >
> > > Review-Url: https://codereview.webrtc.org/2764133002
> > > Cr-Commit-Position: refs/heads/master@{#17331}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/8b45b11144c968b4173215c76f78c710c9a2ed0b
> >
> > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:4172
> >
> > Review-Url: https://codereview.webrtc.org/2781433002
> > Cr-Commit-Position: refs/heads/master@{#17474}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/3ea3c77e93121b1ab9d5e46641e6764f2cca0d51
>
> TBR=ilnik@webrtc.org,stefan@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2783183003
> Cr-Commit-Position: refs/heads/master@{#17477}
> Committed: https://chromium.googlesource.com/external/webrtc/+/f9ed235c9b7248694edcb46feb1f29ce7456ab59
R=ilnik@webrtc.org,stefan@webrtc.org
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2789823002
Cr-Commit-Position: refs/heads/master@{#17498}
2017-04-02 23:53:04 -07:00
|
|
|
switch (test_phase_) {
|
2018-09-13 10:42:19 +02:00
|
|
|
case TestPhase::kInit:
|
2024-03-22 12:07:38 +01:00
|
|
|
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
|
|
|
|
<< wants.max_pixel_count << ", target res = "
|
|
|
|
|
<< wants.target_pixel_count.value_or(-1)
|
|
|
|
|
<< ", max fps = " << wants.max_framerate_fps;
|
2018-09-13 10:42:19 +02:00
|
|
|
break;
|
Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2783183003/ )
Reason for revert:
Seem to be a flaky test rather than an issue with this cl. Creating reland, will add code to reduce flakiness to that test.
Original issue's description:
> Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #8 id:410001 of https://codereview.webrtc.org/2781433002/ )
>
> Reason for revert:
> This has resulted in failure of CallPerfTest.ReceivesCpuOveruseAndUnderuse test on the Win7 build bot https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1780
>
> Original issue's description:
> > Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2764133002/ )
> >
> > Reason for revert:
> > Found issue with test case, will add fix to reland cl.
> >
> > Original issue's description:
> > > Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #14 id:250001 of https://codereview.webrtc.org/2716643002/ )
> > >
> > > Reason for revert:
> > > Breaks perf tests:
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1679
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/2325
> > >
> > > Original issue's description:
> > > > Add framerate to VideoSinkWants and ability to signal on overuse
> > > >
> > > > In ViEEncoder, try to reduce framerate instead of resolution if the
> > > > current degradation preference is maintain-resolution rather than
> > > > balanced.
> > > >
> > > > BUG=webrtc:4172
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2716643002
> > > > Cr-Commit-Position: refs/heads/master@{#17327}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/72acf2526177bb4dbb5103cd6e165eb4361a5ae6
> > >
> > > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,sprang@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4172
> > >
> > > Review-Url: https://codereview.webrtc.org/2764133002
> > > Cr-Commit-Position: refs/heads/master@{#17331}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/8b45b11144c968b4173215c76f78c710c9a2ed0b
> >
> > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:4172
> >
> > Review-Url: https://codereview.webrtc.org/2781433002
> > Cr-Commit-Position: refs/heads/master@{#17474}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/3ea3c77e93121b1ab9d5e46641e6764f2cca0d51
>
> TBR=ilnik@webrtc.org,stefan@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2783183003
> Cr-Commit-Position: refs/heads/master@{#17477}
> Committed: https://chromium.googlesource.com/external/webrtc/+/f9ed235c9b7248694edcb46feb1f29ce7456ab59
R=ilnik@webrtc.org,stefan@webrtc.org
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2789823002
Cr-Commit-Position: refs/heads/master@{#17498}
2017-04-02 23:53:04 -07:00
|
|
|
case TestPhase::kStart:
|
|
|
|
|
if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
|
2017-08-03 08:27:51 -07:00
|
|
|
// On adapting down, VideoStreamEncoder::VideoSourceProxy will set
|
|
|
|
|
// only the max pixel count, leaving the target unset.
|
Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2783183003/ )
Reason for revert:
Seem to be a flaky test rather than an issue with this cl. Creating reland, will add code to reduce flakiness to that test.
Original issue's description:
> Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #8 id:410001 of https://codereview.webrtc.org/2781433002/ )
>
> Reason for revert:
> This has resulted in failure of CallPerfTest.ReceivesCpuOveruseAndUnderuse test on the Win7 build bot https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1780
>
> Original issue's description:
> > Reland of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #1 id:1 of https://codereview.webrtc.org/2764133002/ )
> >
> > Reason for revert:
> > Found issue with test case, will add fix to reland cl.
> >
> > Original issue's description:
> > > Revert of Add framerate to VideoSinkWants and ability to signal on overuse (patchset #14 id:250001 of https://codereview.webrtc.org/2716643002/ )
> > >
> > > Reason for revert:
> > > Breaks perf tests:
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Win7/builds/1679
> > > https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/2325
> > >
> > > Original issue's description:
> > > > Add framerate to VideoSinkWants and ability to signal on overuse
> > > >
> > > > In ViEEncoder, try to reduce framerate instead of resolution if the
> > > > current degradation preference is maintain-resolution rather than
> > > > balanced.
> > > >
> > > > BUG=webrtc:4172
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2716643002
> > > > Cr-Commit-Position: refs/heads/master@{#17327}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/72acf2526177bb4dbb5103cd6e165eb4361a5ae6
> > >
> > > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,sprang@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4172
> > >
> > > Review-Url: https://codereview.webrtc.org/2764133002
> > > Cr-Commit-Position: refs/heads/master@{#17331}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/8b45b11144c968b4173215c76f78c710c9a2ed0b
> >
> > TBR=nisse@webrtc.org,magjed@webrtc.org,kthelgason@webrtc.org,ilnik@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:4172
> >
> > Review-Url: https://codereview.webrtc.org/2781433002
> > Cr-Commit-Position: refs/heads/master@{#17474}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/3ea3c77e93121b1ab9d5e46641e6764f2cca0d51
>
> TBR=ilnik@webrtc.org,stefan@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2783183003
> Cr-Commit-Position: refs/heads/master@{#17477}
> Committed: https://chromium.googlesource.com/external/webrtc/+/f9ed235c9b7248694edcb46feb1f29ce7456ab59
R=ilnik@webrtc.org,stefan@webrtc.org
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2789823002
Cr-Commit-Position: refs/heads/master@{#17498}
2017-04-02 23:53:04 -07:00
|
|
|
test_phase_ = TestPhase::kAdaptedDown;
|
|
|
|
|
} else {
|
|
|
|
|
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
|
|
|
|
<< wants.max_pixel_count << ", target res = "
|
|
|
|
|
<< wants.target_pixel_count.value_or(-1)
|
|
|
|
|
<< ", max fps = " << wants.max_framerate_fps;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case TestPhase::kAdaptedDown:
|
|
|
|
|
// On adapting up, the adaptation counter will again be at zero, and
|
|
|
|
|
// so all constraints will be reset.
|
|
|
|
|
if (wants.max_pixel_count == std::numeric_limits<int>::max() &&
|
|
|
|
|
!wants.target_pixel_count) {
|
|
|
|
|
test_phase_ = TestPhase::kAdaptedUp;
|
|
|
|
|
observation_complete_.Set();
|
|
|
|
|
} else {
|
|
|
|
|
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
|
|
|
|
<< wants.max_pixel_count << ", target res = "
|
|
|
|
|
<< wants.target_pixel_count.value_or(-1)
|
|
|
|
|
<< ", max fps = " << wants.max_framerate_fps;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case TestPhase::kAdaptedUp:
|
|
|
|
|
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
|
|
|
|
<< wants.max_pixel_count << ", target res = "
|
|
|
|
|
<< wants.target_pixel_count.value_or(-1)
|
|
|
|
|
<< ", max fps = " << wants.max_framerate_fps;
|
2016-11-01 11:45:46 -07:00
|
|
|
}
|
2014-01-31 10:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 03:14:00 -08:00
|
|
|
void ModifyVideoConfigs(
|
2024-10-29 14:47:48 +02:00
|
|
|
VideoSendStream::Config* /* send_config */,
|
|
|
|
|
std::vector<VideoReceiveStreamInterface::Config>* /* receive_configs */,
|
|
|
|
|
VideoEncoderConfig* /* encoder_config */) override {}
|
2014-11-20 10:19:46 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void PerformTest() override {
|
2015-12-10 13:02:50 +01:00
|
|
|
EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
|
2014-06-27 08:47:52 +00:00
|
|
|
}
|
2014-11-20 10:19:46 +00:00
|
|
|
|
2018-09-13 10:42:19 +02:00
|
|
|
enum class TestPhase {
|
|
|
|
|
kInit,
|
|
|
|
|
kStart,
|
|
|
|
|
kAdaptedDown,
|
|
|
|
|
kAdaptedUp
|
|
|
|
|
} test_phase_;
|
2021-02-25 10:30:39 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
rtc::VideoSinkWants last_wants_;
|
2016-11-01 11:45:46 -07:00
|
|
|
} test;
|
2014-01-31 10:05:07 +00:00
|
|
|
|
2016-01-08 06:47:13 -08:00
|
|
|
RunBaseTest(&test);
|
2014-01-31 10:05:07 +00:00
|
|
|
}
|
2014-03-13 12:52:27 +00:00
|
|
|
|
|
|
|
|
void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
|
|
|
|
|
static const int kMaxEncodeBitrateKbps = 30;
|
2014-03-19 10:59:52 +00:00
|
|
|
static const int kMinTransmitBitrateBps = 150000;
|
2014-03-13 12:52:27 +00:00
|
|
|
static const int kMinAcceptableTransmitBitrate = 130;
|
|
|
|
|
static const int kMaxAcceptableTransmitBitrate = 170;
|
|
|
|
|
static const int kNumBitrateObservationsInRange = 100;
|
2015-08-03 04:38:41 -07:00
|
|
|
static const int kAcceptableBitrateErrorMargin = 15; // +- 7
|
2015-10-27 08:29:42 -07:00
|
|
|
class BitrateObserver : public test::EndToEndTest {
|
2014-03-13 12:52:27 +00:00
|
|
|
public:
|
2021-05-03 16:23:08 +02:00
|
|
|
explicit BitrateObserver(bool using_min_transmit_bitrate,
|
|
|
|
|
TaskQueueBase* task_queue)
|
2023-04-25 09:56:49 +02:00
|
|
|
: EndToEndTest(test::VideoTestConstants::kLongTimeout),
|
2015-03-23 13:12:24 +00:00
|
|
|
send_stream_(nullptr),
|
2016-06-16 09:58:44 +02:00
|
|
|
converged_(false),
|
2014-06-27 08:47:52 +00:00
|
|
|
pad_to_min_bitrate_(using_min_transmit_bitrate),
|
2016-06-16 09:58:44 +02:00
|
|
|
min_acceptable_bitrate_(using_min_transmit_bitrate
|
|
|
|
|
? kMinAcceptableTransmitBitrate
|
|
|
|
|
: (kMaxEncodeBitrateKbps -
|
|
|
|
|
kAcceptableBitrateErrorMargin / 2)),
|
|
|
|
|
max_acceptable_bitrate_(using_min_transmit_bitrate
|
|
|
|
|
? kMaxAcceptableTransmitBitrate
|
|
|
|
|
: (kMaxEncodeBitrateKbps +
|
|
|
|
|
kAcceptableBitrateErrorMargin / 2)),
|
2021-05-03 16:23:08 +02:00
|
|
|
num_bitrate_observations_in_range_(0),
|
2021-08-13 14:00:44 +02:00
|
|
|
task_queue_(task_queue),
|
|
|
|
|
task_safety_flag_(PendingTaskSafetyFlag::CreateDetached()) {}
|
2014-03-13 12:52:27 +00:00
|
|
|
|
2014-06-27 08:47:52 +00:00
|
|
|
private:
|
2015-10-27 08:29:42 -07:00
|
|
|
// TODO(holmer): Run this with a timer instead of once per packet.
|
2024-10-29 14:47:48 +02:00
|
|
|
Action OnSendRtp(rtc::ArrayView<const uint8_t> /* packet */) override {
|
2022-07-06 18:35:01 +02:00
|
|
|
task_queue_->PostTask(SafeTask(task_safety_flag_, [this]() {
|
2021-05-03 16:23:08 +02:00
|
|
|
VideoSendStream::Stats stats = send_stream_->GetStats();
|
|
|
|
|
|
|
|
|
|
if (!stats.substreams.empty()) {
|
|
|
|
|
RTC_DCHECK_EQ(1, stats.substreams.size());
|
|
|
|
|
int bitrate_kbps =
|
|
|
|
|
stats.substreams.begin()->second.total_bitrate_bps / 1000;
|
|
|
|
|
if (bitrate_kbps > min_acceptable_bitrate_ &&
|
|
|
|
|
bitrate_kbps < max_acceptable_bitrate_) {
|
|
|
|
|
converged_ = true;
|
|
|
|
|
++num_bitrate_observations_in_range_;
|
|
|
|
|
if (num_bitrate_observations_in_range_ ==
|
|
|
|
|
kNumBitrateObservationsInRange)
|
|
|
|
|
observation_complete_.Set();
|
|
|
|
|
}
|
|
|
|
|
if (converged_)
|
2022-09-26 13:21:14 +02:00
|
|
|
bitrate_kbps_list_.AddSample(bitrate_kbps);
|
2014-03-13 12:52:27 +00:00
|
|
|
}
|
2021-05-03 16:23:08 +02:00
|
|
|
}));
|
2015-10-27 08:29:42 -07:00
|
|
|
return SEND_PACKET;
|
2014-03-13 12:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 15:21:20 +02:00
|
|
|
void OnVideoStreamsCreated(VideoSendStream* send_stream,
|
|
|
|
|
const std::vector<VideoReceiveStreamInterface*>&
|
2024-10-29 14:47:48 +02:00
|
|
|
/* receive_streams */) override {
|
2014-06-27 08:47:52 +00:00
|
|
|
send_stream_ = send_stream;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-13 14:00:44 +02:00
|
|
|
void OnStreamsStopped() override { task_safety_flag_->SetNotAlive(); }
|
|
|
|
|
|
2015-12-21 03:14:00 -08:00
|
|
|
void ModifyVideoConfigs(
|
2024-10-29 14:47:48 +02:00
|
|
|
VideoSendStream::Config* /* send_config */,
|
|
|
|
|
std::vector<VideoReceiveStreamInterface::Config>* /* receive_configs */,
|
2015-12-21 03:14:00 -08:00
|
|
|
VideoEncoderConfig* encoder_config) override {
|
2014-06-27 08:47:52 +00:00
|
|
|
if (pad_to_min_bitrate_) {
|
2014-10-24 09:23:21 +00:00
|
|
|
encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps;
|
2014-06-27 08:47:52 +00:00
|
|
|
} else {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps);
|
2014-06-27 08:47:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void PerformTest() override {
|
2015-12-10 13:02:50 +01:00
|
|
|
EXPECT_TRUE(Wait()) << "Timeout while waiting for send-bitrate stats.";
|
2022-09-26 13:21:14 +02:00
|
|
|
GetGlobalMetricsLogger()->LogMetric(
|
|
|
|
|
std::string("bitrate_stats_") +
|
|
|
|
|
(pad_to_min_bitrate_ ? "min_transmit_bitrate"
|
|
|
|
|
: "without_min_transmit_bitrate"),
|
2022-09-28 15:18:33 +02:00
|
|
|
"bitrate_kbps", bitrate_kbps_list_, Unit::kUnitless,
|
2022-09-26 13:21:14 +02:00
|
|
|
ImprovementDirection::kNeitherIsBetter);
|
2014-06-27 08:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-13 12:52:27 +00:00
|
|
|
VideoSendStream* send_stream_;
|
2016-06-16 09:58:44 +02:00
|
|
|
bool converged_;
|
2014-06-27 08:47:52 +00:00
|
|
|
const bool pad_to_min_bitrate_;
|
2016-06-16 09:58:44 +02:00
|
|
|
const int min_acceptable_bitrate_;
|
|
|
|
|
const int max_acceptable_bitrate_;
|
2014-03-13 12:52:27 +00:00
|
|
|
int num_bitrate_observations_in_range_;
|
2022-09-26 13:21:14 +02:00
|
|
|
SamplesStatsCounter bitrate_kbps_list_;
|
2021-05-03 16:23:08 +02:00
|
|
|
TaskQueueBase* task_queue_;
|
2021-08-13 14:00:44 +02:00
|
|
|
rtc::scoped_refptr<PendingTaskSafetyFlag> task_safety_flag_;
|
2021-05-03 16:23:08 +02:00
|
|
|
} test(pad_to_min_bitrate, task_queue());
|
2014-03-13 12:52:27 +00:00
|
|
|
|
2018-04-19 09:04:13 +02:00
|
|
|
fake_encoder_max_bitrate_ = kMaxEncodeBitrateKbps;
|
2016-01-08 06:47:13 -08:00
|
|
|
RunBaseTest(&test);
|
2014-03-13 12:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 20:46:33 +02:00
|
|
|
TEST_F(CallPerfTest, Bitrate_Kbps_PadsToMinTransmitBitrate) {
|
2018-06-19 15:03:05 +02:00
|
|
|
TestMinTransmitBitrate(true);
|
|
|
|
|
}
|
2014-03-13 12:52:27 +00:00
|
|
|
|
2020-09-10 20:46:33 +02:00
|
|
|
TEST_F(CallPerfTest, Bitrate_Kbps_NoPadWithoutMinTransmitBitrate) {
|
2014-03-13 12:52:27 +00:00
|
|
|
TestMinTransmitBitrate(false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-16 10:11:49 -08:00
|
|
|
// TODO(bugs.webrtc.org/8878)
|
|
|
|
|
#if defined(WEBRTC_MAC)
|
|
|
|
|
#define MAYBE_KeepsHighBitrateWhenReconfiguringSender \
|
|
|
|
|
DISABLED_KeepsHighBitrateWhenReconfiguringSender
|
|
|
|
|
#else
|
|
|
|
|
#define MAYBE_KeepsHighBitrateWhenReconfiguringSender \
|
|
|
|
|
KeepsHighBitrateWhenReconfiguringSender
|
|
|
|
|
#endif
|
|
|
|
|
TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
2014-10-22 12:15:24 +00:00
|
|
|
static const uint32_t kInitialBitrateKbps = 400;
|
2022-11-30 19:41:22 +01:00
|
|
|
static const uint32_t kInitialBitrateOverheadKpbs = 6;
|
2014-10-22 12:15:24 +00:00
|
|
|
static const uint32_t kReconfigureThresholdKbps = 600;
|
|
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
class VideoStreamFactory
|
|
|
|
|
: public VideoEncoderConfig::VideoStreamFactoryInterface {
|
|
|
|
|
public:
|
|
|
|
|
VideoStreamFactory() {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<VideoStream> CreateEncoderStreams(
|
2024-04-17 12:11:29 +02:00
|
|
|
const FieldTrialsView& /*field_trials*/,
|
2022-09-29 15:01:09 +02:00
|
|
|
int frame_width,
|
|
|
|
|
int frame_height,
|
|
|
|
|
const webrtc::VideoEncoderConfig& encoder_config) override {
|
2016-10-02 23:45:26 -07:00
|
|
|
std::vector<VideoStream> streams =
|
2022-09-29 15:01:09 +02:00
|
|
|
test::CreateVideoStreams(frame_width, frame_height, encoder_config);
|
2016-10-02 23:45:26 -07:00
|
|
|
streams[0].min_bitrate_bps = 50000;
|
|
|
|
|
streams[0].target_bitrate_bps = streams[0].max_bitrate_bps = 2000000;
|
|
|
|
|
return streams;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-22 12:15:24 +00:00
|
|
|
class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder {
|
|
|
|
|
public:
|
2024-04-15 13:53:03 +02:00
|
|
|
explicit BitrateObserver(const Environment& env, TaskQueueBase* task_queue)
|
2023-04-25 09:56:49 +02:00
|
|
|
: EndToEndTest(test::VideoTestConstants::kDefaultTimeout),
|
2024-04-15 13:53:03 +02:00
|
|
|
FakeEncoder(env),
|
2015-08-03 04:38:41 -07:00
|
|
|
encoder_inits_(0),
|
2016-11-16 16:41:30 +01:00
|
|
|
last_set_bitrate_kbps_(0),
|
|
|
|
|
send_stream_(nullptr),
|
2018-04-19 09:04:13 +02:00
|
|
|
frame_generator_(nullptr),
|
2018-11-08 10:02:56 -08:00
|
|
|
encoder_factory_(this),
|
|
|
|
|
bitrate_allocator_factory_(
|
2021-05-03 16:23:08 +02:00
|
|
|
CreateBuiltinVideoBitrateAllocatorFactory()),
|
|
|
|
|
task_queue_(task_queue) {}
|
2014-10-22 12:15:24 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t InitEncode(const VideoCodec* config,
|
2019-06-11 14:57:57 +02:00
|
|
|
const VideoEncoder::Settings& settings) override {
|
2016-10-02 23:45:26 -07:00
|
|
|
++encoder_inits_;
|
|
|
|
|
if (encoder_inits_ == 1) {
|
2016-10-28 14:06:29 -07:00
|
|
|
// First time initialization. Frame size is known.
|
2021-07-26 12:40:21 +02:00
|
|
|
// `expected_bitrate` is affected by bandwidth estimation before the
|
2016-10-30 21:37:57 +01:00
|
|
|
// first frame arrives to the encoder.
|
2022-11-30 19:41:22 +01:00
|
|
|
uint32_t expected_bitrate =
|
|
|
|
|
last_set_bitrate_kbps_ > 0
|
|
|
|
|
? last_set_bitrate_kbps_
|
|
|
|
|
: kInitialBitrateKbps - kInitialBitrateOverheadKpbs;
|
2016-10-30 21:37:57 +01:00
|
|
|
EXPECT_EQ(expected_bitrate, config->startBitrate)
|
|
|
|
|
<< "Encoder not initialized at expected bitrate.";
|
2023-04-25 09:56:49 +02:00
|
|
|
EXPECT_EQ(test::VideoTestConstants::kDefaultWidth, config->width);
|
|
|
|
|
EXPECT_EQ(test::VideoTestConstants::kDefaultHeight, config->height);
|
2016-10-30 21:37:57 +01:00
|
|
|
} else if (encoder_inits_ == 2) {
|
2023-04-25 09:56:49 +02:00
|
|
|
EXPECT_EQ(2 * test::VideoTestConstants::kDefaultWidth, config->width);
|
|
|
|
|
EXPECT_EQ(2 * test::VideoTestConstants::kDefaultHeight, config->height);
|
2016-11-16 16:41:30 +01:00
|
|
|
EXPECT_GE(last_set_bitrate_kbps_, kReconfigureThresholdKbps);
|
2018-04-17 16:12:21 +02:00
|
|
|
EXPECT_GT(config->startBitrate, kReconfigureThresholdKbps)
|
2014-10-22 12:15:24 +00:00
|
|
|
<< "Encoder reconfigured with bitrate too far away from last set.";
|
2015-12-10 13:02:50 +01:00
|
|
|
observation_complete_.Set();
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
2019-06-11 14:57:57 +02:00
|
|
|
return FakeEncoder::InitEncode(config, settings);
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-12 13:59:09 +02:00
|
|
|
void SetRates(const RateControlParameters& parameters) override {
|
|
|
|
|
last_set_bitrate_kbps_ = parameters.bitrate.get_sum_kbps();
|
2016-10-30 21:37:57 +01:00
|
|
|
if (encoder_inits_ == 1 &&
|
2019-04-12 13:59:09 +02:00
|
|
|
parameters.bitrate.get_sum_kbps() > kReconfigureThresholdKbps) {
|
2015-12-10 13:02:50 +01:00
|
|
|
time_to_reconfigure_.Set();
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
2019-04-12 13:59:09 +02:00
|
|
|
FakeEncoder::SetRates(parameters);
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-13 15:10:33 +01:00
|
|
|
void ModifySenderBitrateConfig(
|
|
|
|
|
BitrateConstraints* bitrate_config) override {
|
|
|
|
|
bitrate_config->start_bitrate_bps = kInitialBitrateKbps * 1000;
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 03:14:00 -08:00
|
|
|
void ModifyVideoConfigs(
|
|
|
|
|
VideoSendStream::Config* send_config,
|
2024-10-29 14:47:48 +02:00
|
|
|
std::vector<VideoReceiveStreamInterface::Config>* /* receive_configs */,
|
2015-12-21 03:14:00 -08:00
|
|
|
VideoEncoderConfig* encoder_config) override {
|
2018-04-19 09:04:13 +02:00
|
|
|
send_config->encoder_settings.encoder_factory = &encoder_factory_;
|
2018-11-08 10:02:56 -08:00
|
|
|
send_config->encoder_settings.bitrate_allocator_factory =
|
|
|
|
|
bitrate_allocator_factory_.get();
|
2016-10-30 21:37:57 +01:00
|
|
|
encoder_config->max_bitrate_bps = 2 * kReconfigureThresholdKbps * 1000;
|
2016-10-02 23:45:26 -07:00
|
|
|
encoder_config->video_stream_factory =
|
2021-04-22 19:21:43 +02:00
|
|
|
rtc::make_ref_counted<VideoStreamFactory>();
|
2014-10-22 12:15:24 +00:00
|
|
|
|
2016-09-01 01:17:40 -07:00
|
|
|
encoder_config_ = encoder_config->Copy();
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 15:21:20 +02:00
|
|
|
void OnVideoStreamsCreated(VideoSendStream* send_stream,
|
|
|
|
|
const std::vector<VideoReceiveStreamInterface*>&
|
2024-10-30 11:44:20 +02:00
|
|
|
/* receive_streams */) override {
|
2014-10-22 12:15:24 +00:00
|
|
|
send_stream_ = send_stream;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
void OnFrameGeneratorCapturerCreated(
|
|
|
|
|
test::FrameGeneratorCapturer* frame_generator_capturer) override {
|
|
|
|
|
frame_generator_ = frame_generator_capturer;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void PerformTest() override {
|
2023-04-25 09:56:49 +02:00
|
|
|
ASSERT_TRUE(
|
|
|
|
|
time_to_reconfigure_.Wait(test::VideoTestConstants::kDefaultTimeout))
|
2014-10-22 12:15:24 +00:00
|
|
|
<< "Timed out before receiving an initial high bitrate.";
|
2023-04-25 09:56:49 +02:00
|
|
|
frame_generator_->ChangeResolution(
|
|
|
|
|
test::VideoTestConstants::kDefaultWidth * 2,
|
|
|
|
|
test::VideoTestConstants::kDefaultHeight * 2);
|
2022-08-11 12:26:09 +02:00
|
|
|
SendTask(task_queue_, [&]() {
|
2021-05-03 16:23:08 +02:00
|
|
|
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
|
|
|
|
});
|
2015-12-10 13:02:50 +01:00
|
|
|
EXPECT_TRUE(Wait())
|
2014-10-22 12:15:24 +00:00
|
|
|
<< "Timed out while waiting for a couple of high bitrate estimates "
|
|
|
|
|
"after reconfiguring the send stream.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2015-12-10 13:02:50 +01:00
|
|
|
rtc::Event time_to_reconfigure_;
|
2014-10-22 12:15:24 +00:00
|
|
|
int encoder_inits_;
|
2016-11-16 16:41:30 +01:00
|
|
|
uint32_t last_set_bitrate_kbps_;
|
2014-10-22 12:15:24 +00:00
|
|
|
VideoSendStream* send_stream_;
|
2016-10-02 23:45:26 -07:00
|
|
|
test::FrameGeneratorCapturer* frame_generator_;
|
2018-09-28 09:07:24 +02:00
|
|
|
test::VideoEncoderProxyFactory encoder_factory_;
|
2018-11-08 10:02:56 -08:00
|
|
|
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
2014-10-22 12:15:24 +00:00
|
|
|
VideoEncoderConfig encoder_config_;
|
2021-05-03 16:23:08 +02:00
|
|
|
TaskQueueBase* task_queue_;
|
2024-04-15 13:53:03 +02:00
|
|
|
} test(env(), task_queue());
|
2014-10-22 12:15:24 +00:00
|
|
|
|
2016-01-08 06:47:13 -08:00
|
|
|
RunBaseTest(&test);
|
2014-10-22 12:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-22 17:22:35 +01:00
|
|
|
// Discovers the minimal supported audio+video bitrate. The test bitrate is
|
|
|
|
|
// considered supported if Rtt does not go above 400ms with the network
|
|
|
|
|
// contrained to the test bitrate.
|
|
|
|
|
//
|
|
|
|
|
// |test_bitrate_from test_bitrate_to| bitrate constraint range
|
2021-07-26 12:40:21 +02:00
|
|
|
// `test_bitrate_step` bitrate constraint update step during the test
|
2017-11-22 17:22:35 +01:00
|
|
|
// |min_bwe max_bwe| BWE range
|
2021-07-26 12:40:21 +02:00
|
|
|
// `start_bwe` initial BWE
|
2019-07-09 12:31:20 +02:00
|
|
|
void CallPerfTest::TestMinAudioVideoBitrate(int test_bitrate_from,
|
|
|
|
|
int test_bitrate_to,
|
|
|
|
|
int test_bitrate_step,
|
|
|
|
|
int min_bwe,
|
|
|
|
|
int start_bwe,
|
|
|
|
|
int max_bwe) {
|
2017-11-22 17:22:35 +01:00
|
|
|
static const std::string kAudioTrackId = "audio_track_0";
|
|
|
|
|
static constexpr int kBitrateStabilizationMs = 10000;
|
|
|
|
|
static constexpr int kBitrateMeasurements = 10;
|
|
|
|
|
static constexpr int kBitrateMeasurementMs = 1000;
|
2019-01-22 11:12:51 +01:00
|
|
|
static constexpr int kShortDelayMs = 10;
|
2017-11-22 17:22:35 +01:00
|
|
|
static constexpr int kMinGoodRttMs = 400;
|
|
|
|
|
|
|
|
|
|
class MinVideoAndAudioBitrateTester : public test::EndToEndTest {
|
|
|
|
|
public:
|
2019-10-21 15:00:53 +02:00
|
|
|
MinVideoAndAudioBitrateTester(int test_bitrate_from,
|
|
|
|
|
int test_bitrate_to,
|
|
|
|
|
int test_bitrate_step,
|
|
|
|
|
int min_bwe,
|
|
|
|
|
int start_bwe,
|
|
|
|
|
int max_bwe,
|
|
|
|
|
TaskQueueBase* task_queue)
|
2017-11-22 17:22:35 +01:00
|
|
|
: EndToEndTest(),
|
|
|
|
|
test_bitrate_from_(test_bitrate_from),
|
|
|
|
|
test_bitrate_to_(test_bitrate_to),
|
|
|
|
|
test_bitrate_step_(test_bitrate_step),
|
|
|
|
|
min_bwe_(min_bwe),
|
|
|
|
|
start_bwe_(start_bwe),
|
2019-08-05 15:23:45 +02:00
|
|
|
max_bwe_(max_bwe),
|
|
|
|
|
task_queue_(task_queue) {}
|
2017-11-22 17:22:35 +01:00
|
|
|
|
|
|
|
|
protected:
|
2023-01-19 15:45:58 +00:00
|
|
|
BuiltInNetworkBehaviorConfig GetFakeNetworkPipeConfig() const {
|
2018-10-08 12:28:56 +02:00
|
|
|
BuiltInNetworkBehaviorConfig pipe_config;
|
2024-05-15 15:53:02 +00:00
|
|
|
pipe_config.link_capacity = DataRate::KilobitsPerSec(test_bitrate_from_);
|
2017-11-22 17:22:35 +01:00
|
|
|
return pipe_config;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-19 15:45:58 +00:00
|
|
|
BuiltInNetworkBehaviorConfig GetSendTransportConfig() const override {
|
|
|
|
|
return GetFakeNetworkPipeConfig();
|
|
|
|
|
}
|
|
|
|
|
BuiltInNetworkBehaviorConfig GetReceiveTransportConfig() const override {
|
|
|
|
|
return GetFakeNetworkPipeConfig();
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-19 15:45:58 +00:00
|
|
|
void OnTransportCreated(
|
2024-10-30 11:44:20 +02:00
|
|
|
test::PacketTransport* /* to_receiver */,
|
2023-01-19 15:45:58 +00:00
|
|
|
SimulatedNetworkInterface* sender_network,
|
2024-10-30 11:44:20 +02:00
|
|
|
test::PacketTransport* /* to_sender */,
|
2023-01-19 15:45:58 +00:00
|
|
|
SimulatedNetworkInterface* receiver_network) override {
|
|
|
|
|
send_simulated_network_ = sender_network;
|
|
|
|
|
receive_simulated_network_ = receiver_network;
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerformTest() override {
|
2019-01-22 11:12:51 +01:00
|
|
|
// Quick test mode, just to exercise all the code paths without actually
|
|
|
|
|
// caring about performance measurements.
|
2023-10-09 16:39:40 +02:00
|
|
|
const bool quick_perf_test = absl::GetFlag(FLAGS_webrtc_quick_perf_test);
|
|
|
|
|
|
2017-11-22 17:22:35 +01:00
|
|
|
int last_passed_test_bitrate = -1;
|
|
|
|
|
for (int test_bitrate = test_bitrate_from_;
|
|
|
|
|
test_bitrate_from_ < test_bitrate_to_
|
|
|
|
|
? test_bitrate <= test_bitrate_to_
|
|
|
|
|
: test_bitrate >= test_bitrate_to_;
|
|
|
|
|
test_bitrate += test_bitrate_step_) {
|
2018-10-08 12:28:56 +02:00
|
|
|
BuiltInNetworkBehaviorConfig pipe_config;
|
2024-05-15 15:53:02 +00:00
|
|
|
pipe_config.link_capacity = DataRate::KilobitsPerSec(test_bitrate);
|
2018-08-21 21:01:00 +02:00
|
|
|
send_simulated_network_->SetConfig(pipe_config);
|
|
|
|
|
receive_simulated_network_->SetConfig(pipe_config);
|
2017-11-22 17:22:35 +01:00
|
|
|
|
2019-08-05 15:23:45 +02:00
|
|
|
rtc::Thread::SleepMs(quick_perf_test ? kShortDelayMs
|
|
|
|
|
: kBitrateStabilizationMs);
|
2017-11-22 17:22:35 +01:00
|
|
|
|
|
|
|
|
int64_t avg_rtt = 0;
|
|
|
|
|
for (int i = 0; i < kBitrateMeasurements; i++) {
|
2019-08-05 15:23:45 +02:00
|
|
|
Call::Stats call_stats;
|
2022-08-11 12:26:09 +02:00
|
|
|
SendTask(task_queue_, [this, &call_stats]() {
|
2019-10-21 09:24:27 +02:00
|
|
|
call_stats = sender_call_->GetStats();
|
|
|
|
|
});
|
2017-11-22 17:22:35 +01:00
|
|
|
avg_rtt += call_stats.rtt_ms;
|
2019-08-05 15:23:45 +02:00
|
|
|
rtc::Thread::SleepMs(quick_perf_test ? kShortDelayMs
|
|
|
|
|
: kBitrateMeasurementMs);
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
avg_rtt = avg_rtt / kBitrateMeasurements;
|
|
|
|
|
if (avg_rtt > kMinGoodRttMs) {
|
2023-01-26 16:11:31 +01:00
|
|
|
RTC_LOG(LS_WARNING)
|
|
|
|
|
<< "Failed test bitrate: " << test_bitrate << " RTT: " << avg_rtt;
|
2017-11-22 17:22:35 +01:00
|
|
|
break;
|
|
|
|
|
} else {
|
2023-01-26 16:11:31 +01:00
|
|
|
RTC_LOG(LS_INFO) << "Passed test bitrate: " << test_bitrate
|
|
|
|
|
<< " RTT: " << avg_rtt;
|
2017-11-22 17:22:35 +01:00
|
|
|
last_passed_test_bitrate = test_bitrate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EXPECT_GT(last_passed_test_bitrate, -1)
|
|
|
|
|
<< "Minimum supported bitrate out of the test scope";
|
2022-09-26 13:21:14 +02:00
|
|
|
GetGlobalMetricsLogger()->LogSingleValueMetric(
|
|
|
|
|
"min_test_bitrate_", "min_bitrate", last_passed_test_bitrate,
|
2022-09-28 15:18:33 +02:00
|
|
|
Unit::kUnitless, ImprovementDirection::kNeitherIsBetter);
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-30 11:44:20 +02:00
|
|
|
void OnCallsCreated(Call* sender_call, Call* /* receiver_call */) override {
|
2017-11-22 17:22:35 +01:00
|
|
|
sender_call_ = sender_call;
|
2018-02-21 09:52:06 +01:00
|
|
|
BitrateConstraints bitrate_config;
|
2017-11-22 17:22:35 +01:00
|
|
|
bitrate_config.min_bitrate_bps = min_bwe_;
|
|
|
|
|
bitrate_config.start_bitrate_bps = start_bwe_;
|
|
|
|
|
bitrate_config.max_bitrate_bps = max_bwe_;
|
2018-02-21 13:07:13 +01:00
|
|
|
sender_call->GetTransportControllerSend()->SetSdpBitrateParameters(
|
|
|
|
|
bitrate_config);
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t GetNumVideoStreams() const override { return 1; }
|
|
|
|
|
|
|
|
|
|
size_t GetNumAudioStreams() const override { return 1; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const int test_bitrate_from_;
|
|
|
|
|
const int test_bitrate_to_;
|
|
|
|
|
const int test_bitrate_step_;
|
|
|
|
|
const int min_bwe_;
|
|
|
|
|
const int start_bwe_;
|
|
|
|
|
const int max_bwe_;
|
2023-01-19 15:45:58 +00:00
|
|
|
SimulatedNetworkInterface* send_simulated_network_;
|
|
|
|
|
SimulatedNetworkInterface* receive_simulated_network_;
|
2017-11-22 17:22:35 +01:00
|
|
|
Call* sender_call_;
|
2019-10-21 15:00:53 +02:00
|
|
|
TaskQueueBase* const task_queue_;
|
2019-07-09 12:31:20 +02:00
|
|
|
} test(test_bitrate_from, test_bitrate_to, test_bitrate_step, min_bwe,
|
2019-10-22 10:48:17 +02:00
|
|
|
start_bwe, max_bwe, task_queue());
|
2017-11-22 17:22:35 +01:00
|
|
|
|
|
|
|
|
RunBaseTest(&test);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-26 16:11:31 +01:00
|
|
|
TEST_F(CallPerfTest, Min_Bitrate_VideoAndAudio) {
|
2019-07-09 12:31:20 +02:00
|
|
|
TestMinAudioVideoBitrate(110, 40, -10, 10000, 70000, 200000);
|
2017-11-22 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-26 12:04:27 +02:00
|
|
|
void CallPerfTest::TestEncodeFramerate(VideoEncoderFactory* encoder_factory,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view payload_name,
|
2021-08-26 12:04:27 +02:00
|
|
|
const std::vector<int>& max_framerates) {
|
|
|
|
|
static constexpr double kAllowedFpsDiff = 1.5;
|
|
|
|
|
static constexpr TimeDelta kMinGetStatsInterval = TimeDelta::Millis(400);
|
|
|
|
|
static constexpr TimeDelta kMinRunTime = TimeDelta::Seconds(15);
|
|
|
|
|
static constexpr DataRate kMaxBitrate = DataRate::KilobitsPerSec(1000);
|
|
|
|
|
|
|
|
|
|
class FramerateObserver
|
|
|
|
|
: public test::EndToEndTest,
|
|
|
|
|
public test::FrameGeneratorCapturer::SinkWantsObserver {
|
|
|
|
|
public:
|
|
|
|
|
FramerateObserver(VideoEncoderFactory* encoder_factory,
|
2022-05-17 11:48:46 +02:00
|
|
|
absl::string_view payload_name,
|
2021-08-26 12:04:27 +02:00
|
|
|
const std::vector<int>& max_framerates,
|
|
|
|
|
TaskQueueBase* task_queue)
|
2023-04-25 09:56:49 +02:00
|
|
|
: EndToEndTest(test::VideoTestConstants::kDefaultTimeout),
|
2021-08-26 12:04:27 +02:00
|
|
|
clock_(Clock::GetRealTimeClock()),
|
|
|
|
|
encoder_factory_(encoder_factory),
|
|
|
|
|
payload_name_(payload_name),
|
|
|
|
|
max_framerates_(max_framerates),
|
|
|
|
|
task_queue_(task_queue),
|
|
|
|
|
start_time_(clock_->CurrentTime()),
|
|
|
|
|
last_getstats_time_(start_time_),
|
|
|
|
|
send_stream_(nullptr) {}
|
|
|
|
|
|
|
|
|
|
void OnFrameGeneratorCapturerCreated(
|
|
|
|
|
test::FrameGeneratorCapturer* frame_generator_capturer) override {
|
|
|
|
|
frame_generator_capturer->ChangeResolution(640, 360);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-30 11:44:20 +02:00
|
|
|
void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* /* sink */,
|
|
|
|
|
const rtc::VideoSinkWants& /* wants */) override {}
|
2021-08-26 12:04:27 +02:00
|
|
|
|
|
|
|
|
void ModifySenderBitrateConfig(
|
|
|
|
|
BitrateConstraints* bitrate_config) override {
|
|
|
|
|
bitrate_config->start_bitrate_bps = kMaxBitrate.bps() / 2;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 15:21:20 +02:00
|
|
|
void OnVideoStreamsCreated(VideoSendStream* send_stream,
|
|
|
|
|
const std::vector<VideoReceiveStreamInterface*>&
|
2024-10-30 11:44:20 +02:00
|
|
|
/* receive_streams */) override {
|
2021-08-26 12:04:27 +02:00
|
|
|
send_stream_ = send_stream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t GetNumVideoStreams() const override {
|
|
|
|
|
return max_framerates_.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModifyVideoConfigs(
|
|
|
|
|
VideoSendStream::Config* send_config,
|
2024-10-30 11:44:20 +02:00
|
|
|
std::vector<VideoReceiveStreamInterface::Config>* /* receive_configs */,
|
2021-08-26 12:04:27 +02:00
|
|
|
VideoEncoderConfig* encoder_config) override {
|
|
|
|
|
send_config->encoder_settings.encoder_factory = encoder_factory_;
|
|
|
|
|
send_config->rtp.payload_name = payload_name_;
|
2023-04-25 09:56:49 +02:00
|
|
|
send_config->rtp.payload_type =
|
|
|
|
|
test::VideoTestConstants::kVideoSendPayloadType;
|
2021-08-26 12:04:27 +02:00
|
|
|
encoder_config->video_format.name = payload_name_;
|
|
|
|
|
encoder_config->codec_type = PayloadStringToCodecType(payload_name_);
|
|
|
|
|
encoder_config->max_bitrate_bps = kMaxBitrate.bps();
|
|
|
|
|
for (size_t i = 0; i < max_framerates_.size(); ++i) {
|
|
|
|
|
encoder_config->simulcast_layers[i].max_framerate = max_framerates_[i];
|
|
|
|
|
configured_framerates_[send_config->rtp.ssrcs[i]] = max_framerates_[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerformTest() override {
|
|
|
|
|
EXPECT_TRUE(Wait()) << "Timeout while waiting for framerate stats.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VerifyStats() const {
|
2023-10-09 16:39:40 +02:00
|
|
|
const bool quick_perf_test = absl::GetFlag(FLAGS_webrtc_quick_perf_test);
|
2021-08-31 09:53:46 +02:00
|
|
|
double input_fps = 0.0;
|
|
|
|
|
for (const auto& configured_framerate : configured_framerates_) {
|
|
|
|
|
input_fps = std::max(configured_framerate.second, input_fps);
|
|
|
|
|
}
|
2021-08-26 12:04:27 +02:00
|
|
|
for (const auto& encode_frame_rate_list : encode_frame_rate_lists_) {
|
2022-09-26 13:21:14 +02:00
|
|
|
const SamplesStatsCounter& values = encode_frame_rate_list.second;
|
|
|
|
|
GetGlobalMetricsLogger()->LogMetric(
|
|
|
|
|
"substream_fps", "encode_frame_rate", values, Unit::kUnitless,
|
|
|
|
|
ImprovementDirection::kNeitherIsBetter);
|
|
|
|
|
if (values.IsEmpty()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
double average_fps = values.GetAverage();
|
2021-08-26 12:04:27 +02:00
|
|
|
uint32_t ssrc = encode_frame_rate_list.first;
|
|
|
|
|
double expected_fps = configured_framerates_.find(ssrc)->second;
|
2023-01-11 08:37:34 +01:00
|
|
|
if (quick_perf_test && expected_fps != input_fps)
|
2021-08-31 09:53:46 +02:00
|
|
|
EXPECT_NEAR(expected_fps, average_fps, kAllowedFpsDiff);
|
2021-08-26 12:04:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-30 11:44:20 +02:00
|
|
|
Action OnSendRtp(rtc::ArrayView<const uint8_t> /* packet */) override {
|
2021-08-26 12:04:27 +02:00
|
|
|
const Timestamp now = clock_->CurrentTime();
|
|
|
|
|
if (now - last_getstats_time_ > kMinGetStatsInterval) {
|
|
|
|
|
last_getstats_time_ = now;
|
2022-07-06 18:35:01 +02:00
|
|
|
task_queue_->PostTask([this, now]() {
|
2021-08-26 12:04:27 +02:00
|
|
|
VideoSendStream::Stats stats = send_stream_->GetStats();
|
|
|
|
|
for (const auto& stat : stats.substreams) {
|
2022-09-26 13:21:14 +02:00
|
|
|
encode_frame_rate_lists_[stat.first].AddSample(
|
2021-08-26 12:04:27 +02:00
|
|
|
stat.second.encode_frame_rate);
|
|
|
|
|
}
|
|
|
|
|
if (now - start_time_ > kMinRunTime) {
|
|
|
|
|
VerifyStats();
|
|
|
|
|
observation_complete_.Set();
|
|
|
|
|
}
|
2022-07-06 18:35:01 +02:00
|
|
|
});
|
2021-08-26 12:04:27 +02:00
|
|
|
}
|
|
|
|
|
return SEND_PACKET;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Clock* const clock_;
|
|
|
|
|
VideoEncoderFactory* const encoder_factory_;
|
|
|
|
|
const std::string payload_name_;
|
|
|
|
|
const std::vector<int> max_framerates_;
|
|
|
|
|
TaskQueueBase* const task_queue_;
|
|
|
|
|
const Timestamp start_time_;
|
|
|
|
|
Timestamp last_getstats_time_;
|
|
|
|
|
VideoSendStream* send_stream_;
|
2022-09-26 13:21:14 +02:00
|
|
|
std::map<uint32_t, SamplesStatsCounter> encode_frame_rate_lists_;
|
2021-08-26 12:04:27 +02:00
|
|
|
std::map<uint32_t, double> configured_framerates_;
|
|
|
|
|
} test(encoder_factory, payload_name, max_framerates, task_queue());
|
|
|
|
|
|
|
|
|
|
RunBaseTest(&test);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(CallPerfTest, TestEncodeFramerateVp8Simulcast) {
|
|
|
|
|
InternalEncoderFactory internal_encoder_factory;
|
|
|
|
|
test::FunctionVideoEncoderFactory encoder_factory(
|
2024-03-12 16:58:18 +01:00
|
|
|
[&internal_encoder_factory](const Environment& env,
|
2024-10-30 11:44:20 +02:00
|
|
|
const SdpVideoFormat& /* format */) {
|
2021-08-26 12:04:27 +02:00
|
|
|
return std::make_unique<SimulcastEncoderAdapter>(
|
2024-03-12 16:58:18 +01:00
|
|
|
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
2021-08-26 12:04:27 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TestEncodeFramerate(&encoder_factory, "VP8",
|
|
|
|
|
/*max_framerates=*/{20, 30});
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 13:19:05 +02:00
|
|
|
TEST_F(CallPerfTest, TestEncodeFramerateVp8SimulcastLowerInputFps) {
|
|
|
|
|
InternalEncoderFactory internal_encoder_factory;
|
|
|
|
|
test::FunctionVideoEncoderFactory encoder_factory(
|
2024-03-12 16:58:18 +01:00
|
|
|
[&internal_encoder_factory](const Environment& env,
|
2024-10-30 11:44:20 +02:00
|
|
|
const SdpVideoFormat& /* format */) {
|
2021-09-02 13:19:05 +02:00
|
|
|
return std::make_unique<SimulcastEncoderAdapter>(
|
2024-03-12 16:58:18 +01:00
|
|
|
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
2021-09-02 13:19:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TestEncodeFramerate(&encoder_factory, "VP8",
|
|
|
|
|
/*max_framerates=*/{14, 20});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 12:48:05 +00:00
|
|
|
} // namespace webrtc
|