blob: 09b9118cc76f59500e09438a2948927a1a09b760 [file] [log] [blame]
Sebastian Janssone92f93f2017-06-22 12:44:041/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
Artem Titov46c4e602018-08-17 12:26:5410
Mirko Bonadei317a1f02019-09-17 15:06:1811#include <memory>
12
Artem Titov46c4e602018-08-17 12:26:5413#include "api/test/simulated_network.h"
Danil Chapovalov99b71df2018-10-26 13:57:4814#include "api/test/video/function_video_encoder_factory.h"
Artem Titov4e199e92018-08-20 11:30:3915#include "call/fake_network_pipe.h"
16#include "call/simulated_network.h"
Steve Anton10542f22019-01-11 17:11:0017#include "media/engine/internal_encoder_factory.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3118#include "media/engine/simulcast_encoder_adapter.h"
Danil Chapovalovb57fe172019-12-11 08:38:4419#include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h"
Danil Chapovalovc3475852019-12-05 12:51:3220#include "modules/rtp_rtcp/source/rtp_packet.h"
Sergio Garcia Murillo43800f92018-06-21 14:16:3821#include "modules/video_coding/codecs/vp8/include/vp8.h"
Åsa Perssonad3c7a42017-11-29 09:24:2722#include "modules/video_coding/codecs/vp9/include/vp9.h"
Oleh Prypina40f8242017-12-21 12:32:2323#include "rtc_base/numerics/safe_conversions.h"
Bjorn Tereliusa194e582017-10-25 11:07:0924#include "rtc_base/numerics/sequence_number_util.h"
Markus Handella3765182020-07-08 11:13:3225#include "rtc_base/synchronization/mutex.h"
Danil Chapovalov82a3f0a2019-10-21 07:24:2726#include "rtc_base/task_queue_for_test.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3127#include "test/call_test.h"
Artem Titov8a9f3a82023-04-25 07:56:4928#include "test/video_test_constants.h"
Sebastian Janssone92f93f2017-06-22 12:44:0429
30namespace webrtc {
Åsa Persson4bece9a2017-10-06 08:04:0431namespace {
Sebastian Janssone92f93f2017-06-22 12:44:0432const int kFrameMaxWidth = 1280;
33const int kFrameMaxHeight = 720;
34const int kFrameRate = 30;
35const int kMaxSecondsLost = 5;
36const int kMaxFramesLost = kFrameRate * kMaxSecondsLost;
37const int kMinPacketsToObserve = 10;
Åsa Persson6a1b7ad2017-12-11 11:30:5538const int kEncoderBitrateBps = 300000;
Sebastian Janssone92f93f2017-06-22 12:44:0439const uint32_t kPictureIdWraparound = (1 << 15);
Åsa Persson71485ac2017-12-04 10:11:1940const size_t kNumTemporalLayers[] = {1, 2, 3};
Sebastian Janssone92f93f2017-06-22 12:44:0441
Åsa Persson4bece9a2017-10-06 08:04:0442} // namespace
43
Sebastian Janssone92f93f2017-06-22 12:44:0444class PictureIdObserver : public test::RtpRtcpObserver {
45 public:
Niels Möller520ca4e2018-06-04 09:14:3846 explicit PictureIdObserver(VideoCodecType codec_type)
Artem Titov8a9f3a82023-04-25 07:56:4947 : test::RtpRtcpObserver(test::VideoTestConstants::kDefaultTimeout),
Danil Chapovalovb57fe172019-12-11 08:38:4448 depacketizer_(CreateVideoRtpDepacketizer(codec_type)),
Sebastian Janssone92f93f2017-06-22 12:44:0449 max_expected_picture_id_gap_(0),
Åsa Persson71485ac2017-12-04 10:11:1950 max_expected_tl0_idx_gap_(0),
Sebastian Janssone92f93f2017-06-22 12:44:0451 num_ssrcs_to_observe_(1) {}
52
53 void SetExpectedSsrcs(size_t num_expected_ssrcs) {
Markus Handella3765182020-07-08 11:13:3254 MutexLock lock(&mutex_);
Sebastian Janssone92f93f2017-06-22 12:44:0455 num_ssrcs_to_observe_ = num_expected_ssrcs;
56 }
57
58 void ResetObservedSsrcs() {
Markus Handella3765182020-07-08 11:13:3259 MutexLock lock(&mutex_);
Sebastian Janssone92f93f2017-06-22 12:44:0460 // Do not clear the timestamp and picture_id, to ensure that we check
61 // consistency between reinits and recreations.
62 num_packets_sent_.clear();
63 observed_ssrcs_.clear();
64 }
65
66 void SetMaxExpectedPictureIdGap(int max_expected_picture_id_gap) {
Markus Handella3765182020-07-08 11:13:3267 MutexLock lock(&mutex_);
Sebastian Janssone92f93f2017-06-22 12:44:0468 max_expected_picture_id_gap_ = max_expected_picture_id_gap;
Artem Titovab30d722021-07-27 14:22:1169 // Expect smaller gap for `tl0_pic_idx` (running index for temporal_idx 0).
Åsa Persson71485ac2017-12-04 10:11:1970 max_expected_tl0_idx_gap_ = max_expected_picture_id_gap_ / 2;
Sebastian Janssone92f93f2017-06-22 12:44:0471 }
72
73 private:
Åsa Perssonad3c7a42017-11-29 09:24:2774 struct ParsedPacket {
75 uint32_t timestamp;
76 uint32_t ssrc;
Åsa Persson71485ac2017-12-04 10:11:1977 int16_t picture_id;
78 int16_t tl0_pic_idx;
79 uint8_t temporal_idx;
Niels Möller87e2d782019-03-07 09:18:2380 VideoFrameType frame_type;
Åsa Perssonad3c7a42017-11-29 09:24:2781 };
82
83 bool ParsePayload(const uint8_t* packet,
84 size_t length,
Åsa Persson71485ac2017-12-04 10:11:1985 ParsedPacket* parsed) const {
Danil Chapovalovc3475852019-12-05 12:51:3286 RtpPacket rtp_packet;
87 EXPECT_TRUE(rtp_packet.Parse(packet, length));
Artem Titov8a9f3a82023-04-25 07:56:4988 EXPECT_TRUE(
89 rtp_packet.Ssrc() == test::VideoTestConstants::kVideoSendSsrcs[0] ||
90 rtp_packet.Ssrc() == test::VideoTestConstants::kVideoSendSsrcs[1] ||
91 rtp_packet.Ssrc() == test::VideoTestConstants::kVideoSendSsrcs[2])
Åsa Perssonad3c7a42017-11-29 09:24:2792 << "Unknown SSRC sent.";
93
Danil Chapovalovb57fe172019-12-11 08:38:4494 if (rtp_packet.payload_size() == 0) {
Åsa Perssonad3c7a42017-11-29 09:24:2795 return false; // Padding packet.
96 }
97
Danil Chapovalovc3475852019-12-05 12:51:3298 parsed->timestamp = rtp_packet.Timestamp();
99 parsed->ssrc = rtp_packet.Ssrc();
Åsa Perssonad3c7a42017-11-29 09:24:27100
Danil Chapovalovb57fe172019-12-11 08:38:44101 absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload =
102 depacketizer_->Parse(rtp_packet.PayloadBuffer());
103 EXPECT_TRUE(parsed_payload);
Åsa Perssonad3c7a42017-11-29 09:24:27104
Danil Chapovalovb57fe172019-12-11 08:38:44105 if (const auto* vp8_header = absl::get_if<RTPVideoHeaderVP8>(
106 &parsed_payload->video_header.video_type_header)) {
107 parsed->picture_id = vp8_header->pictureId;
108 parsed->tl0_pic_idx = vp8_header->tl0PicIdx;
109 parsed->temporal_idx = vp8_header->temporalIdx;
110 } else if (const auto* vp9_header = absl::get_if<RTPVideoHeaderVP9>(
111 &parsed_payload->video_header.video_type_header)) {
112 parsed->picture_id = vp9_header->picture_id;
113 parsed->tl0_pic_idx = vp9_header->tl0_pic_idx;
114 parsed->temporal_idx = vp9_header->temporal_idx;
115 } else {
Artem Titovd3251962021-11-15 15:57:07116 RTC_DCHECK_NOTREACHED();
Åsa Perssonad3c7a42017-11-29 09:24:27117 }
118
Danil Chapovalovb57fe172019-12-11 08:38:44119 parsed->frame_type = parsed_payload->video_header.frame_type;
Åsa Perssonad3c7a42017-11-29 09:24:27120 return true;
121 }
122
Åsa Persson71485ac2017-12-04 10:11:19123 // Verify continuity and monotonicity of picture_id sequence.
124 void VerifyPictureId(const ParsedPacket& current,
125 const ParsedPacket& last) const
Markus Handella3765182020-07-08 11:13:32126 RTC_EXCLUSIVE_LOCKS_REQUIRED(&mutex_) {
Åsa Persson71485ac2017-12-04 10:11:19127 if (current.timestamp == last.timestamp) {
128 EXPECT_EQ(last.picture_id, current.picture_id);
129 return; // Same frame.
130 }
131
132 // Packet belongs to a new frame.
133 // Picture id should be increasing.
134 EXPECT_TRUE((AheadOf<uint16_t, kPictureIdWraparound>(current.picture_id,
135 last.picture_id)));
136
137 // Expect continuously increasing picture id.
138 int diff = ForwardDiff<uint16_t, kPictureIdWraparound>(last.picture_id,
139 current.picture_id);
Byoungchan Leea1aedc02022-07-28 14:35:34140 EXPECT_LE(diff - 1, max_expected_picture_id_gap_);
141 if (diff > 2) {
Åsa Persson71485ac2017-12-04 10:11:19142 // If the VideoSendStream is destroyed, any frames still in queue is lost.
Byoungchan Leea1aedc02022-07-28 14:35:34143 // This can result in a two-frame gap, which will result in logs like
144 // "packet transmission failed, no matching RTP module found, or
145 // transmission error".
146 // A larger gap is only possible for first frame after a recreation, i.e.
147 // key frames.
Niels Möller8f7ce222019-03-21 14:43:58148 EXPECT_EQ(VideoFrameType::kVideoFrameKey, current.frame_type);
Åsa Persson71485ac2017-12-04 10:11:19149 }
150 }
151
152 void VerifyTl0Idx(const ParsedPacket& current, const ParsedPacket& last) const
Markus Handella3765182020-07-08 11:13:32153 RTC_EXCLUSIVE_LOCKS_REQUIRED(&mutex_) {
Åsa Persson71485ac2017-12-04 10:11:19154 if (current.tl0_pic_idx == kNoTl0PicIdx ||
155 current.temporal_idx == kNoTemporalIdx) {
156 return; // No temporal layers.
157 }
158
159 if (current.timestamp == last.timestamp || current.temporal_idx != 0) {
160 EXPECT_EQ(last.tl0_pic_idx, current.tl0_pic_idx);
161 return;
162 }
163
Artem Titovab30d722021-07-27 14:22:11164 // New frame with `temporal_idx` 0.
165 // `tl0_pic_idx` should be increasing.
Åsa Persson71485ac2017-12-04 10:11:19166 EXPECT_TRUE(AheadOf<uint8_t>(current.tl0_pic_idx, last.tl0_pic_idx));
167
168 // Expect continuously increasing idx.
169 int diff = ForwardDiff<uint8_t>(last.tl0_pic_idx, current.tl0_pic_idx);
170 if (diff > 1) {
171 // If the VideoSendStream is destroyed, any frames still in queue is lost.
172 // Gaps only possible for first frame after a recreation, i.e. key frames.
Niels Möller8f7ce222019-03-21 14:43:58173 EXPECT_EQ(VideoFrameType::kVideoFrameKey, current.frame_type);
Åsa Persson71485ac2017-12-04 10:11:19174 EXPECT_LE(diff - 1, max_expected_tl0_idx_gap_);
175 }
176 }
177
Harald Alvestrandd43af912023-08-15 11:41:45178 Action OnSendRtp(rtc::ArrayView<const uint8_t> packet) override {
Markus Handella3765182020-07-08 11:13:32179 MutexLock lock(&mutex_);
Sebastian Janssone92f93f2017-06-22 12:44:04180
Åsa Perssonad3c7a42017-11-29 09:24:27181 ParsedPacket parsed;
Harald Alvestrandd43af912023-08-15 11:41:45182 if (!ParsePayload(packet.data(), packet.size(), &parsed))
Sebastian Janssone92f93f2017-06-22 12:44:04183 return SEND_PACKET;
Sebastian Janssone92f93f2017-06-22 12:44:04184
Åsa Perssonad3c7a42017-11-29 09:24:27185 uint32_t ssrc = parsed.ssrc;
186 if (last_observed_packet_.find(ssrc) != last_observed_packet_.end()) {
Åsa Perssonad3c7a42017-11-29 09:24:27187 // Compare to last packet.
Åsa Persson71485ac2017-12-04 10:11:19188 VerifyPictureId(parsed, last_observed_packet_[ssrc]);
189 VerifyTl0Idx(parsed, last_observed_packet_[ssrc]);
Sebastian Janssone92f93f2017-06-22 12:44:04190 }
Sebastian Janssone92f93f2017-06-22 12:44:04191
Åsa Perssonad3c7a42017-11-29 09:24:27192 last_observed_packet_[ssrc] = parsed;
193
194 // Pass the test when enough media packets have been received on all
195 // streams.
Sebastian Janssone92f93f2017-06-22 12:44:04196 if (++num_packets_sent_[ssrc] >= kMinPacketsToObserve &&
197 observed_ssrcs_.find(ssrc) == observed_ssrcs_.end()) {
198 observed_ssrcs_.insert(ssrc);
199 if (observed_ssrcs_.size() == num_ssrcs_to_observe_) {
200 observation_complete_.Set();
201 }
202 }
Sebastian Janssone92f93f2017-06-22 12:44:04203 return SEND_PACKET;
204 }
205
Markus Handella3765182020-07-08 11:13:32206 Mutex mutex_;
Danil Chapovalovb57fe172019-12-11 08:38:44207 const std::unique_ptr<VideoRtpDepacketizer> depacketizer_;
Markus Handella3765182020-07-08 11:13:32208 std::map<uint32_t, ParsedPacket> last_observed_packet_ RTC_GUARDED_BY(mutex_);
209 std::map<uint32_t, size_t> num_packets_sent_ RTC_GUARDED_BY(mutex_);
210 int max_expected_picture_id_gap_ RTC_GUARDED_BY(mutex_);
211 int max_expected_tl0_idx_gap_ RTC_GUARDED_BY(mutex_);
212 size_t num_ssrcs_to_observe_ RTC_GUARDED_BY(mutex_);
213 std::set<uint32_t> observed_ssrcs_ RTC_GUARDED_BY(mutex_);
Sebastian Janssone92f93f2017-06-22 12:44:04214};
215
Åsa Persson4bece9a2017-10-06 08:04:04216class PictureIdTest : public test::CallTest,
Åsa Persson677f42c2018-03-16 12:09:17217 public ::testing::WithParamInterface<size_t> {
Sebastian Janssone92f93f2017-06-22 12:44:04218 public:
Åsa Persson677f42c2018-03-16 12:09:17219 PictureIdTest() : num_temporal_layers_(GetParam()) {}
Sebastian Janssone92f93f2017-06-22 12:44:04220
221 virtual ~PictureIdTest() {
Danil Chapovalove519f382022-08-11 10:26:09222 SendTask(task_queue(), [this]() {
eladalon413ee9a2017-08-22 11:02:52223 send_transport_.reset();
224 receive_transport_.reset();
225 DestroyCalls();
226 });
Sebastian Janssone92f93f2017-06-22 12:44:04227 }
228
Niels Möller4db138e2018-04-19 07:04:13229 void SetupEncoder(VideoEncoderFactory* encoder_factory,
230 const std::string& payload_name);
Åsa Persson44327c32019-08-08 07:33:41231 void SetVideoEncoderConfig(int num_streams);
Sebastian Janssone92f93f2017-06-22 12:44:04232 void TestPictureIdContinuousAfterReconfigure(
233 const std::vector<int>& ssrc_counts);
234 void TestPictureIdIncreaseAfterRecreateStreams(
235 const std::vector<int>& ssrc_counts);
236
237 private:
Åsa Persson71485ac2017-12-04 10:11:19238 const size_t num_temporal_layers_;
Åsa Perssonad3c7a42017-11-29 09:24:27239 std::unique_ptr<PictureIdObserver> observer_;
Sebastian Janssone92f93f2017-06-22 12:44:04240};
241
Evan Shrubsolef8542b82022-08-08 12:30:14242// TODO(bugs.webrtc.org/13725): Enable on android when flakiness fixed.
243#if defined(WEBRTC_ANDROID)
244#define MAYBE_TemporalLayers DISABLED_TemporalLayers
245#else
246#define MAYBE_TemporalLayers TemporalLayers
247#endif
248
249INSTANTIATE_TEST_SUITE_P(MAYBE_TemporalLayers,
Mirko Bonadeic84f6612019-01-31 11:20:57250 PictureIdTest,
251 ::testing::ValuesIn(kNumTemporalLayers));
Åsa Persson4bece9a2017-10-06 08:04:04252
Niels Möller4db138e2018-04-19 07:04:13253void PictureIdTest::SetupEncoder(VideoEncoderFactory* encoder_factory,
Åsa Perssonad3c7a42017-11-29 09:24:27254 const std::string& payload_name) {
255 observer_.reset(
Niels Möller520ca4e2018-06-04 09:14:38256 new PictureIdObserver(PayloadStringToCodecType(payload_name)));
Åsa Perssonad3c7a42017-11-29 09:24:27257
Jared Siskin7220ee92023-05-03 09:06:14258 SendTask(task_queue(), [this, encoder_factory, payload_name]() {
259 CreateCalls();
260 CreateSendTransport(BuiltInNetworkBehaviorConfig(), observer_.get());
261 CreateSendConfig(test::VideoTestConstants::kNumSimulcastStreams, 0, 0,
262 send_transport_.get());
263 GetVideoSendConfig()->encoder_settings.encoder_factory = encoder_factory;
264 GetVideoSendConfig()->rtp.payload_name = payload_name;
265 GetVideoEncoderConfig()->codec_type =
266 PayloadStringToCodecType(payload_name);
267 SetVideoEncoderConfig(/* number_of_streams */ 1);
268 });
Sebastian Janssone92f93f2017-06-22 12:44:04269}
270
Åsa Persson44327c32019-08-08 07:33:41271void PictureIdTest::SetVideoEncoderConfig(int num_streams) {
272 GetVideoEncoderConfig()->number_of_streams = num_streams;
273 GetVideoEncoderConfig()->max_bitrate_bps = kEncoderBitrateBps;
274
275 // Always divide the same total bitrate across all streams so that sending a
276 // single stream avoids lowering the bitrate estimate and requiring a
277 // subsequent rampup.
278 const int encoder_stream_bps = kEncoderBitrateBps / num_streams;
279 double scale_factor = 1.0;
280 for (int i = num_streams - 1; i >= 0; --i) {
281 VideoStream& stream = GetVideoEncoderConfig()->simulcast_layers[i];
282 // Reduce the min bitrate by 10% to account for overhead that might
283 // otherwise cause streams to not be enabled.
284 stream.min_bitrate_bps = static_cast<int>(encoder_stream_bps * 0.9);
285 stream.target_bitrate_bps = encoder_stream_bps;
286 stream.max_bitrate_bps = encoder_stream_bps;
287 stream.num_temporal_layers = num_temporal_layers_;
288 stream.scale_resolution_down_by = scale_factor;
289 scale_factor *= 2.0;
290 }
291}
292
Sebastian Janssone92f93f2017-06-22 12:44:04293void PictureIdTest::TestPictureIdContinuousAfterReconfigure(
294 const std::vector<int>& ssrc_counts) {
Danil Chapovalove519f382022-08-11 10:26:09295 SendTask(task_queue(), [this]() {
eladalon413ee9a2017-08-22 11:02:52296 CreateVideoStreams();
297 CreateFrameGeneratorCapturer(kFrameRate, kFrameMaxWidth, kFrameMaxHeight);
Sebastian Janssone92f93f2017-06-22 12:44:04298
eladalon413ee9a2017-08-22 11:02:52299 // Initial test with a single stream.
300 Start();
301 });
302
Åsa Perssonad3c7a42017-11-29 09:24:27303 EXPECT_TRUE(observer_->Wait()) << "Timed out waiting for packets.";
Sebastian Janssone92f93f2017-06-22 12:44:04304
305 // Reconfigure VideoEncoder and test picture id increase.
Åsa Perssonae819752017-10-10 09:05:59306 // Expect continuously increasing picture id, equivalent to no gaps.
Åsa Perssonad3c7a42017-11-29 09:24:27307 observer_->SetMaxExpectedPictureIdGap(0);
Sebastian Janssone92f93f2017-06-22 12:44:04308 for (int ssrc_count : ssrc_counts) {
Åsa Persson44327c32019-08-08 07:33:41309 SetVideoEncoderConfig(ssrc_count);
Åsa Perssonad3c7a42017-11-29 09:24:27310 observer_->SetExpectedSsrcs(ssrc_count);
311 observer_->ResetObservedSsrcs();
Sebastian Janssone92f93f2017-06-22 12:44:04312 // Make sure the picture_id sequence is continuous on reinit and recreate.
Danil Chapovalove519f382022-08-11 10:26:09313 SendTask(task_queue(), [this]() {
Sebastian Janssonf33905d2018-07-13 07:49:00314 GetVideoSendStream()->ReconfigureVideoEncoder(
315 GetVideoEncoderConfig()->Copy());
eladalon413ee9a2017-08-22 11:02:52316 });
Åsa Perssonad3c7a42017-11-29 09:24:27317 EXPECT_TRUE(observer_->Wait()) << "Timed out waiting for packets.";
Sebastian Janssone92f93f2017-06-22 12:44:04318 }
319
Danil Chapovalove519f382022-08-11 10:26:09320 SendTask(task_queue(), [this]() {
eladalon413ee9a2017-08-22 11:02:52321 Stop();
322 DestroyStreams();
eladalon413ee9a2017-08-22 11:02:52323 });
Sebastian Janssone92f93f2017-06-22 12:44:04324}
325
326void PictureIdTest::TestPictureIdIncreaseAfterRecreateStreams(
327 const std::vector<int>& ssrc_counts) {
Danil Chapovalove519f382022-08-11 10:26:09328 SendTask(task_queue(), [this]() {
eladalon413ee9a2017-08-22 11:02:52329 CreateVideoStreams();
330 CreateFrameGeneratorCapturer(kFrameRate, kFrameMaxWidth, kFrameMaxHeight);
Sebastian Janssone92f93f2017-06-22 12:44:04331
eladalon413ee9a2017-08-22 11:02:52332 // Initial test with a single stream.
333 Start();
334 });
335
Åsa Perssonad3c7a42017-11-29 09:24:27336 EXPECT_TRUE(observer_->Wait()) << "Timed out waiting for packets.";
Sebastian Janssone92f93f2017-06-22 12:44:04337
338 // Recreate VideoSendStream and test picture id increase.
339 // When the VideoSendStream is destroyed, any frames still in queue is lost
340 // with it, therefore it is expected that some frames might be lost.
Åsa Perssonad3c7a42017-11-29 09:24:27341 observer_->SetMaxExpectedPictureIdGap(kMaxFramesLost);
Sebastian Janssone92f93f2017-06-22 12:44:04342 for (int ssrc_count : ssrc_counts) {
Danil Chapovalove519f382022-08-11 10:26:09343 SendTask(task_queue(), [this, &ssrc_count]() {
Sebastian Janssonf33905d2018-07-13 07:49:00344 DestroyVideoSendStreams();
Sebastian Janssone92f93f2017-06-22 12:44:04345
Åsa Persson44327c32019-08-08 07:33:41346 SetVideoEncoderConfig(ssrc_count);
Åsa Perssonad3c7a42017-11-29 09:24:27347 observer_->SetExpectedSsrcs(ssrc_count);
348 observer_->ResetObservedSsrcs();
Sebastian Janssone92f93f2017-06-22 12:44:04349
Sebastian Janssonf33905d2018-07-13 07:49:00350 CreateVideoSendStreams();
351 GetVideoSendStream()->Start();
eladalon413ee9a2017-08-22 11:02:52352 CreateFrameGeneratorCapturer(kFrameRate, kFrameMaxWidth, kFrameMaxHeight);
eladalon413ee9a2017-08-22 11:02:52353 });
354
Åsa Perssonad3c7a42017-11-29 09:24:27355 EXPECT_TRUE(observer_->Wait()) << "Timed out waiting for packets.";
Sebastian Janssone92f93f2017-06-22 12:44:04356 }
357
Danil Chapovalove519f382022-08-11 10:26:09358 SendTask(task_queue(), [this]() {
eladalon413ee9a2017-08-22 11:02:52359 Stop();
360 DestroyStreams();
eladalon413ee9a2017-08-22 11:02:52361 });
Sebastian Janssone92f93f2017-06-22 12:44:04362}
363
Åsa Perssonad3c7a42017-11-29 09:24:27364TEST_P(PictureIdTest, ContinuousAfterReconfigureVp8) {
Niels Möller4db138e2018-04-19 07:04:13365 test::FunctionVideoEncoderFactory encoder_factory(
366 []() { return VP8Encoder::Create(); });
367 SetupEncoder(&encoder_factory, "VP8");
Sebastian Janssone92f93f2017-06-22 12:44:04368 TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1});
369}
370
Jeremy Leconteeeacddb2023-06-02 06:45:02371// TODO(bugs.webrtc.org/14985): Investigate and reenable.
372TEST_P(PictureIdTest, DISABLED_IncreasingAfterRecreateStreamVp8) {
Niels Möller4db138e2018-04-19 07:04:13373 test::FunctionVideoEncoderFactory encoder_factory(
374 []() { return VP8Encoder::Create(); });
375 SetupEncoder(&encoder_factory, "VP8");
Sebastian Janssone92f93f2017-06-22 12:44:04376 TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1});
377}
378
Åsa Perssonad3c7a42017-11-29 09:24:27379TEST_P(PictureIdTest, ContinuousAfterStreamCountChangeVp8) {
Niels Möller4db138e2018-04-19 07:04:13380 test::FunctionVideoEncoderFactory encoder_factory(
381 []() { return VP8Encoder::Create(); });
Åsa Persson71485ac2017-12-04 10:11:19382 // Make sure that the picture id is not reset if the stream count goes
Sebastian Janssone92f93f2017-06-22 12:44:04383 // down and then up.
Niels Möller4db138e2018-04-19 07:04:13384 SetupEncoder(&encoder_factory, "VP8");
Åsa Perssonad3c7a42017-11-29 09:24:27385 TestPictureIdContinuousAfterReconfigure({3, 1, 3});
Sebastian Janssone92f93f2017-06-22 12:44:04386}
387
Åsa Perssonad3c7a42017-11-29 09:24:27388TEST_P(PictureIdTest, ContinuousAfterReconfigureSimulcastEncoderAdapter) {
Magnus Jedvertdf4883d2017-11-17 13:44:55389 InternalEncoderFactory internal_encoder_factory;
Niels Möller4db138e2018-04-19 07:04:13390 test::FunctionVideoEncoderFactory encoder_factory(
391 [&internal_encoder_factory]() {
Mirko Bonadei317a1f02019-09-17 15:06:18392 return std::make_unique<SimulcastEncoderAdapter>(
Ilya Nikolaevskiy97b4ee52018-05-28 08:24:22393 &internal_encoder_factory, SdpVideoFormat("VP8"));
Niels Möller4db138e2018-04-19 07:04:13394 });
395 SetupEncoder(&encoder_factory, "VP8");
Sebastian Janssone92f93f2017-06-22 12:44:04396 TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1});
397}
398
Jeremy Leconteeeacddb2023-06-02 06:45:02399// TODO(bugs.webrtc.org/14985): Investigate and reenable.
400TEST_P(PictureIdTest,
401 DISABLED_IncreasingAfterRecreateStreamSimulcastEncoderAdapter) {
Magnus Jedvertdf4883d2017-11-17 13:44:55402 InternalEncoderFactory internal_encoder_factory;
Niels Möller4db138e2018-04-19 07:04:13403 test::FunctionVideoEncoderFactory encoder_factory(
404 [&internal_encoder_factory]() {
Mirko Bonadei317a1f02019-09-17 15:06:18405 return std::make_unique<SimulcastEncoderAdapter>(
Ilya Nikolaevskiy97b4ee52018-05-28 08:24:22406 &internal_encoder_factory, SdpVideoFormat("VP8"));
Niels Möller4db138e2018-04-19 07:04:13407 });
408 SetupEncoder(&encoder_factory, "VP8");
Sebastian Janssone92f93f2017-06-22 12:44:04409 TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1});
410}
411
Åsa Perssonad3c7a42017-11-29 09:24:27412TEST_P(PictureIdTest, ContinuousAfterStreamCountChangeSimulcastEncoderAdapter) {
Åsa Persson677f42c2018-03-16 12:09:17413 InternalEncoderFactory internal_encoder_factory;
Niels Möller4db138e2018-04-19 07:04:13414 test::FunctionVideoEncoderFactory encoder_factory(
415 [&internal_encoder_factory]() {
Mirko Bonadei317a1f02019-09-17 15:06:18416 return std::make_unique<SimulcastEncoderAdapter>(
Ilya Nikolaevskiy97b4ee52018-05-28 08:24:22417 &internal_encoder_factory, SdpVideoFormat("VP8"));
Niels Möller4db138e2018-04-19 07:04:13418 });
Åsa Persson677f42c2018-03-16 12:09:17419 // Make sure that the picture id is not reset if the stream count goes
420 // down and then up.
Niels Möller4db138e2018-04-19 07:04:13421 SetupEncoder(&encoder_factory, "VP8");
Åsa Persson677f42c2018-03-16 12:09:17422 TestPictureIdContinuousAfterReconfigure({3, 1, 3});
Sebastian Janssone92f93f2017-06-22 12:44:04423}
424
Jeremy Leconteeeacddb2023-06-02 06:45:02425// TODO(bugs.webrtc.org/14985): Investigate and reenable.
426TEST_P(PictureIdTest, DISABLED_IncreasingAfterRecreateStreamVp9) {
Niels Möller4db138e2018-04-19 07:04:13427 test::FunctionVideoEncoderFactory encoder_factory(
428 []() { return VP9Encoder::Create(); });
429 SetupEncoder(&encoder_factory, "VP9");
Åsa Perssonad3c7a42017-11-29 09:24:27430 TestPictureIdIncreaseAfterRecreateStreams({1, 1});
431}
432
Sebastian Janssone92f93f2017-06-22 12:44:04433} // namespace webrtc