webrtc_m130/test/pc/e2e/peer_connection_quality_test_test.cc
Ilya Nikolaevskiy 68a7c415c5 Revert "Enforce stream id uniqueness in RtpSender::set_stream_ids"
This reverts commit 315b95ca11161bdea715d5316f92828edd41f0d5.

Reason for revert: Breaks internal bots.

Original change's description:
> Enforce stream id uniqueness in RtpSender::set_stream_ids
>
> https://w3c.github.io/webrtc-pc/#dfn-create-an-rtcrtpsender
> has a step saying
>   For each stream in streams, add stream.id to
>   [[AssociatedMediaStreamIds]] if it's not already there
>
> This applies to addTrack and setStreams and the set of streams in
> addTransceiver.
>
> BUG=webrtc:14769
>
> Change-Id: If6be813396a1987dfe49fd73f976f96c71459eaf
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287864
> Commit-Queue: Philipp Hancke <phancke@microsoft.com>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38937}

Bug: webrtc:14769
Change-Id: I6fd22ff0550c0894057fb1dc15f1b95819fa6df2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288744
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38940}
2022-12-21 13:56:05 +00:00

140 lines
4.9 KiB
C++

/*
* Copyright (c) 2022 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.
*/
#include "test/pc/e2e/peer_connection_quality_test.h"
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "api/test/create_network_emulation_manager.h"
#include "api/test/metrics/global_metrics_logger_and_exporter.h"
#include "api/test/network_emulation_manager.h"
#include "api/test/pclf/media_configuration.h"
#include "api/test/pclf/media_quality_test_params.h"
#include "api/test/pclf/peer_configurer.h"
#include "api/test/peerconnection_quality_test_fixture.h"
#include "api/units/time_delta.h"
#include "rtc_base/time_utils.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
#include "test/testsupport/frame_reader.h"
namespace webrtc {
namespace webrtc_pc_e2e {
namespace {
using ::testing::Eq;
using ::testing::Test;
using ::webrtc::webrtc_pc_e2e::PeerConfigurer;
// Remove files and directories in a directory non-recursively.
void CleanDir(absl::string_view dir, size_t expected_output_files_count) {
absl::optional<std::vector<std::string>> dir_content =
test::ReadDirectory(dir);
if (expected_output_files_count == 0) {
ASSERT_FALSE(dir_content.has_value()) << "Empty directory is expected";
} else {
ASSERT_TRUE(dir_content.has_value()) << "Test directory is empty!";
EXPECT_EQ(dir_content->size(), expected_output_files_count);
for (const auto& entry : *dir_content) {
if (test::DirExists(entry)) {
EXPECT_TRUE(test::RemoveDir(entry))
<< "Failed to remove sub directory: " << entry;
} else if (test::FileExists(entry)) {
EXPECT_TRUE(test::RemoveFile(entry))
<< "Failed to remove file: " << entry;
} else {
FAIL() << "Can't remove unknown file type: " << entry;
}
}
}
EXPECT_TRUE(test::RemoveDir(dir)) << "Failed to remove directory: " << dir;
}
class PeerConnectionE2EQualityTestTest : public Test {
protected:
~PeerConnectionE2EQualityTestTest() override = default;
void SetUp() override {
// Create an empty temporary directory for this test.
test_directory_ = test::JoinFilename(
test::OutputPath(),
"TestDir_PeerConnectionE2EQualityTestTest_" +
std::string(
testing::UnitTest::GetInstance()->current_test_info()->name()));
test::CreateDir(test_directory_);
}
void TearDown() override {
CleanDir(test_directory_, expected_output_files_count_);
}
void ExpectOutputFilesCount(size_t count) {
expected_output_files_count_ = count;
}
std::string test_directory_;
size_t expected_output_files_count_ = 0;
};
TEST_F(PeerConnectionE2EQualityTestTest, OutputVideoIsDumpedWhenRequested) {
std::unique_ptr<NetworkEmulationManager> network_emulation =
CreateNetworkEmulationManager(TimeMode::kSimulated);
PeerConnectionE2EQualityTest fixture(
"test_case", *network_emulation->time_controller(),
/*audio_quality_analyzer=*/nullptr, /*video_quality_analyzer=*/nullptr,
test::GetGlobalMetricsLogger());
EmulatedEndpoint* alice_endpoint =
network_emulation->CreateEndpoint(EmulatedEndpointConfig());
EmulatedEndpoint* bob_endpoint =
network_emulation->CreateEndpoint(EmulatedEndpointConfig());
network_emulation->CreateRoute(
alice_endpoint, {network_emulation->CreateUnconstrainedEmulatedNode()},
bob_endpoint);
network_emulation->CreateRoute(
bob_endpoint, {network_emulation->CreateUnconstrainedEmulatedNode()},
alice_endpoint);
EmulatedNetworkManagerInterface* alice_network =
network_emulation->CreateEmulatedNetworkManagerInterface(
{alice_endpoint});
EmulatedNetworkManagerInterface* bob_network =
network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint});
VideoConfig alice_video("alice_video", 320, 180, 15);
alice_video.output_dump_options = VideoDumpOptions(test_directory_);
PeerConfigurer alice(alice_network->network_dependencies());
alice.SetName("alice");
alice.AddVideoConfig(std::move(alice_video));
fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(alice)));
PeerConfigurer bob(bob_network->network_dependencies());
bob.SetName("bob");
fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(bob)));
fixture.Run(RunParams(TimeDelta::Seconds(2)));
auto frame_reader = test::CreateY4mFrameReader(
test::JoinFilename(test_directory_, "alice_video_bob_320x180_15.y4m"));
EXPECT_THAT(frame_reader->num_frames(), Eq(31)); // 2 seconds 15 fps + 1
ExpectOutputFilesCount(1);
}
} // namespace
} // namespace webrtc_pc_e2e
} // namespace webrtc