/* * Copyright (c) 2020 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/test_peer_factory.h"
using EmulatedSFUConfigMap =
::webrtc::webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap;
constexpr int16_t kGeneratedAudioMaxAmplitude = 32000;
constexpr int kDefaultSamplingFrequencyInHz = 48000;
// Sets mandatory entities in injectable components like `pcf_dependencies` // and `pc_dependencies` if they are omitted. Also setup required // dependencies, that won't be specially provided by factory and will be just // transferred to peer connection creation code. void SetMandatoryEntities(InjectableComponents* components) {
RTC_DCHECK(components->pcf_dependencies);
RTC_DCHECK(components->pc_dependencies);
// Returns mapping from stream label to optional spatial index. // If we have stream label "Foo" and mapping contains // 1. `std::nullopt` means all simulcast/SVC streams are required // 2. Concrete value means that particular simulcast/SVC stream have to be // analyzed.
EmulatedSFUConfigMap CalculateRequiredSpatialIndexPerStream( const std::vector<VideoConfig>& video_configs) {
EmulatedSFUConfigMap result; for (auto& video_config : video_configs) { // Stream label should be set by fixture implementation here.
RTC_DCHECK(video_config.stream_label); bool res = result
.insert({*video_config.stream_label,
video_config.emulated_sfu_config})
.second;
RTC_DCHECK(res) << "Duplicate video_config.stream_label="
<< *video_config.stream_label;
} return result;
}
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateAudioRenderer( const std::optional<RemotePeerAudioConfig>& config) { if (!config) { // Return default renderer because we always require some renderer. return TestAudioDeviceModule::CreateDiscardRenderer(
kDefaultSamplingFrequencyInHz);
} if (config->output_file_name) { return TestAudioDeviceModule::CreateBoundedWavFileWriter(
config->output_file_name.value(), config->sampling_frequency_in_hz);
} return TestAudioDeviceModule::CreateDiscardRenderer(
config->sampling_frequency_in_hz);
}
std::unique_ptr<TestAudioDeviceModule::Capturer> CreateAudioCapturer( const std::optional<AudioConfig>& audio_config) { if (!audio_config) { // If we have no audio config we still need to provide some audio device. // In such case use generated capturer. Despite of we provided audio here, // in test media setup audio stream won't be added into peer connection. return TestAudioDeviceModule::CreatePulsedNoiseCapturer(
kGeneratedAudioMaxAmplitude, kDefaultSamplingFrequencyInHz);
} if (audio_config->input_file_name) { return TestAudioDeviceModule::CreateWavFileReader(
*audio_config->input_file_name, /*repeat=*/true);
} else { return TestAudioDeviceModule::CreatePulsedNoiseCapturer(
kGeneratedAudioMaxAmplitude, audio_config->sampling_frequency_in_hz);
}
}
auto port_allocator = std::make_unique<cricket::BasicPortAllocator>(
pc_dependencies->network_manager, pc_dependencies->packet_socket_factory);
// This test does not support TCP by default. int flags =
cricket::kDefaultPortAllocatorFlags | cricket::PORTALLOCATOR_DISABLE_TCP; if (port_allocator_flags.has_value()) {
flags = *port_allocator_flags;
}
port_allocator->set_flags(port_allocator->flags() | flags);
pc_deps.allocator = std::move(port_allocator);
if (pc_dependencies->async_dns_resolver_factory != nullptr) {
pc_deps.async_dns_resolver_factory =
std::move(pc_dependencies->async_dns_resolver_factory);
} if (pc_dependencies->cert_generator != nullptr) {
pc_deps.cert_generator = std::move(pc_dependencies->cert_generator);
} if (pc_dependencies->tls_cert_verifier != nullptr) {
pc_deps.tls_cert_verifier = std::move(pc_dependencies->tls_cert_verifier);
} if (pc_dependencies->ice_transport_factory != nullptr) {
pc_deps.ice_transport_factory =
std::move(pc_dependencies->ice_transport_factory);
} return pc_deps;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.