1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker #ifndef API_TEST_PCLF_MEDIA_CONFIGURATION_H_ 11*d9f75844SAndroid Build Coastguard Worker #define API_TEST_PCLF_MEDIA_CONFIGURATION_H_ 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #include <stddef.h> 14*d9f75844SAndroid Build Coastguard Worker #include <stdint.h> 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker #include <functional> 17*d9f75844SAndroid Build Coastguard Worker #include <map> 18*d9f75844SAndroid Build Coastguard Worker #include <memory> 19*d9f75844SAndroid Build Coastguard Worker #include <string> 20*d9f75844SAndroid Build Coastguard Worker #include <utility> 21*d9f75844SAndroid Build Coastguard Worker #include <vector> 22*d9f75844SAndroid Build Coastguard Worker 23*d9f75844SAndroid Build Coastguard Worker #include "absl/memory/memory.h" 24*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h" 25*d9f75844SAndroid Build Coastguard Worker #include "absl/types/optional.h" 26*d9f75844SAndroid Build Coastguard Worker #include "api/array_view.h" 27*d9f75844SAndroid Build Coastguard Worker #include "api/async_resolver_factory.h" 28*d9f75844SAndroid Build Coastguard Worker #include "api/audio/audio_mixer.h" 29*d9f75844SAndroid Build Coastguard Worker #include "api/audio_options.h" 30*d9f75844SAndroid Build Coastguard Worker #include "api/call/call_factory_interface.h" 31*d9f75844SAndroid Build Coastguard Worker #include "api/fec_controller.h" 32*d9f75844SAndroid Build Coastguard Worker #include "api/function_view.h" 33*d9f75844SAndroid Build Coastguard Worker #include "api/media_stream_interface.h" 34*d9f75844SAndroid Build Coastguard Worker #include "api/peer_connection_interface.h" 35*d9f75844SAndroid Build Coastguard Worker #include "api/rtc_event_log/rtc_event_log_factory_interface.h" 36*d9f75844SAndroid Build Coastguard Worker #include "api/rtp_parameters.h" 37*d9f75844SAndroid Build Coastguard Worker #include "api/task_queue/task_queue_factory.h" 38*d9f75844SAndroid Build Coastguard Worker #include "api/test/audio_quality_analyzer_interface.h" 39*d9f75844SAndroid Build Coastguard Worker #include "api/test/frame_generator_interface.h" 40*d9f75844SAndroid Build Coastguard Worker #include "api/test/peer_network_dependencies.h" 41*d9f75844SAndroid Build Coastguard Worker #include "api/test/simulated_network.h" 42*d9f75844SAndroid Build Coastguard Worker #include "api/test/stats_observer_interface.h" 43*d9f75844SAndroid Build Coastguard Worker #include "api/test/track_id_stream_info_map.h" 44*d9f75844SAndroid Build Coastguard Worker #include "api/test/video/video_frame_writer.h" 45*d9f75844SAndroid Build Coastguard Worker #include "api/test/video_quality_analyzer_interface.h" 46*d9f75844SAndroid Build Coastguard Worker #include "api/transport/network_control.h" 47*d9f75844SAndroid Build Coastguard Worker #include "api/units/time_delta.h" 48*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/video_decoder_factory.h" 49*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/video_encoder.h" 50*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/video_encoder_factory.h" 51*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_processing/include/audio_processing.h" 52*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h" 53*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/network.h" 54*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/rtc_certificate_generator.h" 55*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/ssl_certificate.h" 56*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/thread.h" 57*d9f75844SAndroid Build Coastguard Worker 58*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 59*d9f75844SAndroid Build Coastguard Worker namespace webrtc_pc_e2e { 60*d9f75844SAndroid Build Coastguard Worker 61*d9f75844SAndroid Build Coastguard Worker constexpr size_t kDefaultSlidesWidth = 1850; 62*d9f75844SAndroid Build Coastguard Worker constexpr size_t kDefaultSlidesHeight = 1110; 63*d9f75844SAndroid Build Coastguard Worker 64*d9f75844SAndroid Build Coastguard Worker // The index of required capturing device in OS provided list of video 65*d9f75844SAndroid Build Coastguard Worker // devices. On Linux and Windows the list will be obtained via 66*d9f75844SAndroid Build Coastguard Worker // webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via 67*d9f75844SAndroid Build Coastguard Worker // [RTCCameraVideoCapturer captureDevices]. 68*d9f75844SAndroid Build Coastguard Worker enum class CapturingDeviceIndex : size_t {}; 69*d9f75844SAndroid Build Coastguard Worker 70*d9f75844SAndroid Build Coastguard Worker // Contains parameters for screen share scrolling. 71*d9f75844SAndroid Build Coastguard Worker // 72*d9f75844SAndroid Build Coastguard Worker // If scrolling is enabled, then it will be done by putting sliding window 73*d9f75844SAndroid Build Coastguard Worker // on source video and moving this window from top left corner to the 74*d9f75844SAndroid Build Coastguard Worker // bottom right corner of the picture. 75*d9f75844SAndroid Build Coastguard Worker // 76*d9f75844SAndroid Build Coastguard Worker // In such case source dimensions must be greater or equal to the sliding 77*d9f75844SAndroid Build Coastguard Worker // window dimensions. So `source_width` and `source_height` are the dimensions 78*d9f75844SAndroid Build Coastguard Worker // of the source frame, while `VideoConfig::width` and `VideoConfig::height` 79*d9f75844SAndroid Build Coastguard Worker // are the dimensions of the sliding window. 80*d9f75844SAndroid Build Coastguard Worker // 81*d9f75844SAndroid Build Coastguard Worker // Because `source_width` and `source_height` are dimensions of the source 82*d9f75844SAndroid Build Coastguard Worker // frame, they have to be width and height of videos from 83*d9f75844SAndroid Build Coastguard Worker // `ScreenShareConfig::slides_yuv_file_names`. 84*d9f75844SAndroid Build Coastguard Worker // 85*d9f75844SAndroid Build Coastguard Worker // Because scrolling have to be done on single slide it also requires, that 86*d9f75844SAndroid Build Coastguard Worker // `duration` must be less or equal to 87*d9f75844SAndroid Build Coastguard Worker // `ScreenShareConfig::slide_change_interval`. 88*d9f75844SAndroid Build Coastguard Worker struct ScrollingParams { 89*d9f75844SAndroid Build Coastguard Worker // Duration of scrolling. 90*d9f75844SAndroid Build Coastguard Worker TimeDelta duration; 91*d9f75844SAndroid Build Coastguard Worker // Width of source slides video. 92*d9f75844SAndroid Build Coastguard Worker size_t source_width = kDefaultSlidesWidth; 93*d9f75844SAndroid Build Coastguard Worker // Height of source slides video. 94*d9f75844SAndroid Build Coastguard Worker size_t source_height = kDefaultSlidesHeight; 95*d9f75844SAndroid Build Coastguard Worker }; 96*d9f75844SAndroid Build Coastguard Worker 97*d9f75844SAndroid Build Coastguard Worker // Contains screen share video stream properties. 98*d9f75844SAndroid Build Coastguard Worker struct ScreenShareConfig { 99*d9f75844SAndroid Build Coastguard Worker explicit ScreenShareConfig(TimeDelta slide_change_interval); 100*d9f75844SAndroid Build Coastguard Worker 101*d9f75844SAndroid Build Coastguard Worker // Shows how long one slide should be presented on the screen during 102*d9f75844SAndroid Build Coastguard Worker // slide generation. 103*d9f75844SAndroid Build Coastguard Worker TimeDelta slide_change_interval; 104*d9f75844SAndroid Build Coastguard Worker // If true, slides will be generated programmatically. No scrolling params 105*d9f75844SAndroid Build Coastguard Worker // will be applied in such case. 106*d9f75844SAndroid Build Coastguard Worker bool generate_slides = false; 107*d9f75844SAndroid Build Coastguard Worker // If present scrolling will be applied. Please read extra requirement on 108*d9f75844SAndroid Build Coastguard Worker // `slides_yuv_file_names` for scrolling. 109*d9f75844SAndroid Build Coastguard Worker absl::optional<ScrollingParams> scrolling_params; 110*d9f75844SAndroid Build Coastguard Worker // Contains list of yuv files with slides. 111*d9f75844SAndroid Build Coastguard Worker // 112*d9f75844SAndroid Build Coastguard Worker // If empty, default set of slides will be used. In such case 113*d9f75844SAndroid Build Coastguard Worker // `VideoConfig::width` must be equal to `kDefaultSlidesWidth` and 114*d9f75844SAndroid Build Coastguard Worker // `VideoConfig::height` must be equal to `kDefaultSlidesHeight` or if 115*d9f75844SAndroid Build Coastguard Worker // `scrolling_params` are specified, then `ScrollingParams::source_width` 116*d9f75844SAndroid Build Coastguard Worker // must be equal to `kDefaultSlidesWidth` and 117*d9f75844SAndroid Build Coastguard Worker // `ScrollingParams::source_height` must be equal to `kDefaultSlidesHeight`. 118*d9f75844SAndroid Build Coastguard Worker std::vector<std::string> slides_yuv_file_names; 119*d9f75844SAndroid Build Coastguard Worker }; 120*d9f75844SAndroid Build Coastguard Worker 121*d9f75844SAndroid Build Coastguard Worker // Config for Vp8 simulcast or non-standard Vp9 SVC testing. 122*d9f75844SAndroid Build Coastguard Worker // 123*d9f75844SAndroid Build Coastguard Worker // To configure standard SVC setting, use `scalability_mode` in the 124*d9f75844SAndroid Build Coastguard Worker // `encoding_params` array. 125*d9f75844SAndroid Build Coastguard Worker // This configures Vp9 SVC by requesting simulcast layers, the request is 126*d9f75844SAndroid Build Coastguard Worker // internally converted to a request for SVC layers. 127*d9f75844SAndroid Build Coastguard Worker // 128*d9f75844SAndroid Build Coastguard Worker // SVC support is limited: 129*d9f75844SAndroid Build Coastguard Worker // During SVC testing there is no SFU, so framework will try to emulate SFU 130*d9f75844SAndroid Build Coastguard Worker // behavior in regular p2p call. Because of it there are such limitations: 131*d9f75844SAndroid Build Coastguard Worker // * if `target_spatial_index` is not equal to the highest spatial layer 132*d9f75844SAndroid Build Coastguard Worker // then no packet/frame drops are allowed. 133*d9f75844SAndroid Build Coastguard Worker // 134*d9f75844SAndroid Build Coastguard Worker // If there will be any drops, that will affect requested layer, then 135*d9f75844SAndroid Build Coastguard Worker // WebRTC SVC implementation will continue decoding only the highest 136*d9f75844SAndroid Build Coastguard Worker // available layer and won't restore lower layers, so analyzer won't 137*d9f75844SAndroid Build Coastguard Worker // receive required data which will cause wrong results or test failures. 138*d9f75844SAndroid Build Coastguard Worker struct VideoSimulcastConfig { 139*d9f75844SAndroid Build Coastguard Worker explicit VideoSimulcastConfig(int simulcast_streams_count); 140*d9f75844SAndroid Build Coastguard Worker 141*d9f75844SAndroid Build Coastguard Worker // Specified amount of simulcast streams/SVC layers, depending on which 142*d9f75844SAndroid Build Coastguard Worker // encoder is used. 143*d9f75844SAndroid Build Coastguard Worker int simulcast_streams_count; 144*d9f75844SAndroid Build Coastguard Worker }; 145*d9f75844SAndroid Build Coastguard Worker 146*d9f75844SAndroid Build Coastguard Worker // Configuration for the emulated Selective Forward Unit (SFU) 147*d9f75844SAndroid Build Coastguard Worker // 148*d9f75844SAndroid Build Coastguard Worker // The framework can optionally filter out frames that are decoded 149*d9f75844SAndroid Build Coastguard Worker // using an emulated SFU. 150*d9f75844SAndroid Build Coastguard Worker // When using simulcast or SVC, it's not always desirable to receive 151*d9f75844SAndroid Build Coastguard Worker // all frames. In a real world call, a SFU will only forward a subset 152*d9f75844SAndroid Build Coastguard Worker // of the frames. 153*d9f75844SAndroid Build Coastguard Worker // The emulated SFU is not able to change its configuration dynamically, 154*d9f75844SAndroid Build Coastguard Worker // if adaptation happens during the call, layers may be dropped and the 155*d9f75844SAndroid Build Coastguard Worker // analyzer won't receive the required data which will cause wrong results or 156*d9f75844SAndroid Build Coastguard Worker // test failures. 157*d9f75844SAndroid Build Coastguard Worker struct EmulatedSFUConfig { 158*d9f75844SAndroid Build Coastguard Worker EmulatedSFUConfig() = default; 159*d9f75844SAndroid Build Coastguard Worker explicit EmulatedSFUConfig(int target_layer_index); 160*d9f75844SAndroid Build Coastguard Worker EmulatedSFUConfig(absl::optional<int> target_layer_index, 161*d9f75844SAndroid Build Coastguard Worker absl::optional<int> target_temporal_index); 162*d9f75844SAndroid Build Coastguard Worker 163*d9f75844SAndroid Build Coastguard Worker // Specifies simulcast or spatial index of the video stream to analyze. 164*d9f75844SAndroid Build Coastguard Worker // There are 2 cases: 165*d9f75844SAndroid Build Coastguard Worker // 1. simulcast encoding is used: 166*d9f75844SAndroid Build Coastguard Worker // in such case `target_layer_index` will specify the index of 167*d9f75844SAndroid Build Coastguard Worker // simulcast stream, that should be analyzed. Other streams will be 168*d9f75844SAndroid Build Coastguard Worker // dropped. 169*d9f75844SAndroid Build Coastguard Worker // 2. SVC encoding is used: 170*d9f75844SAndroid Build Coastguard Worker // in such case `target_layer_index` will specify the top interesting 171*d9f75844SAndroid Build Coastguard Worker // spatial layer and all layers below, including target one will be 172*d9f75844SAndroid Build Coastguard Worker // processed. All layers above target one will be dropped. 173*d9f75844SAndroid Build Coastguard Worker // If not specified then all streams will be received and analyzed. 174*d9f75844SAndroid Build Coastguard Worker // When set, it instructs the framework to create an emulated Selective 175*d9f75844SAndroid Build Coastguard Worker // Forwarding Unit (SFU) that will propagate only the requested layers. 176*d9f75844SAndroid Build Coastguard Worker absl::optional<int> target_layer_index; 177*d9f75844SAndroid Build Coastguard Worker // Specifies the index of the maximum temporal unit to keep. 178*d9f75844SAndroid Build Coastguard Worker // If not specified then all temporal layers will be received and analyzed. 179*d9f75844SAndroid Build Coastguard Worker // When set, it instructs the framework to create an emulated Selective 180*d9f75844SAndroid Build Coastguard Worker // Forwarding Unit (SFU) that will propagate only up to the requested layer. 181*d9f75844SAndroid Build Coastguard Worker absl::optional<int> target_temporal_index; 182*d9f75844SAndroid Build Coastguard Worker }; 183*d9f75844SAndroid Build Coastguard Worker 184*d9f75844SAndroid Build Coastguard Worker class VideoResolution { 185*d9f75844SAndroid Build Coastguard Worker public: 186*d9f75844SAndroid Build Coastguard Worker // Determines special resolutions, which can't be expressed in terms of 187*d9f75844SAndroid Build Coastguard Worker // width, height and fps. 188*d9f75844SAndroid Build Coastguard Worker enum class Spec { 189*d9f75844SAndroid Build Coastguard Worker // No extra spec set. It describes a regular resolution described by 190*d9f75844SAndroid Build Coastguard Worker // width, height and fps. 191*d9f75844SAndroid Build Coastguard Worker kNone, 192*d9f75844SAndroid Build Coastguard Worker // Describes resolution which contains max value among all sender's 193*d9f75844SAndroid Build Coastguard Worker // video streams in each dimension (width, height, fps). 194*d9f75844SAndroid Build Coastguard Worker kMaxFromSender 195*d9f75844SAndroid Build Coastguard Worker }; 196*d9f75844SAndroid Build Coastguard Worker 197*d9f75844SAndroid Build Coastguard Worker VideoResolution(size_t width, size_t height, int32_t fps); 198*d9f75844SAndroid Build Coastguard Worker explicit VideoResolution(Spec spec = Spec::kNone); 199*d9f75844SAndroid Build Coastguard Worker 200*d9f75844SAndroid Build Coastguard Worker bool operator==(const VideoResolution& other) const; 201*d9f75844SAndroid Build Coastguard Worker bool operator!=(const VideoResolution& other) const; 202*d9f75844SAndroid Build Coastguard Worker width()203*d9f75844SAndroid Build Coastguard Worker size_t width() const { return width_; } set_width(size_t width)204*d9f75844SAndroid Build Coastguard Worker void set_width(size_t width) { width_ = width; } height()205*d9f75844SAndroid Build Coastguard Worker size_t height() const { return height_; } set_height(size_t height)206*d9f75844SAndroid Build Coastguard Worker void set_height(size_t height) { height_ = height; } fps()207*d9f75844SAndroid Build Coastguard Worker int32_t fps() const { return fps_; } set_fps(int32_t fps)208*d9f75844SAndroid Build Coastguard Worker void set_fps(int32_t fps) { fps_ = fps; } 209*d9f75844SAndroid Build Coastguard Worker 210*d9f75844SAndroid Build Coastguard Worker // Returns if it is a regular resolution or not. The resolution is regular 211*d9f75844SAndroid Build Coastguard Worker // if it's spec is `Spec::kNone`. 212*d9f75844SAndroid Build Coastguard Worker bool IsRegular() const; 213*d9f75844SAndroid Build Coastguard Worker 214*d9f75844SAndroid Build Coastguard Worker std::string ToString() const; 215*d9f75844SAndroid Build Coastguard Worker 216*d9f75844SAndroid Build Coastguard Worker private: 217*d9f75844SAndroid Build Coastguard Worker size_t width_ = 0; 218*d9f75844SAndroid Build Coastguard Worker size_t height_ = 0; 219*d9f75844SAndroid Build Coastguard Worker int32_t fps_ = 0; 220*d9f75844SAndroid Build Coastguard Worker Spec spec_ = Spec::kNone; 221*d9f75844SAndroid Build Coastguard Worker }; 222*d9f75844SAndroid Build Coastguard Worker 223*d9f75844SAndroid Build Coastguard Worker class VideoDumpOptions { 224*d9f75844SAndroid Build Coastguard Worker public: 225*d9f75844SAndroid Build Coastguard Worker static constexpr int kDefaultSamplingModulo = 1; 226*d9f75844SAndroid Build Coastguard Worker 227*d9f75844SAndroid Build Coastguard Worker // output_directory - the output directory where stream will be dumped. The 228*d9f75844SAndroid Build Coastguard Worker // output files' names will be constructed as 229*d9f75844SAndroid Build Coastguard Worker // <stream_name>_<receiver_name>_<resolution>.<extension> for output dumps 230*d9f75844SAndroid Build Coastguard Worker // and <stream_name>_<resolution>.<extension> for input dumps. 231*d9f75844SAndroid Build Coastguard Worker // By default <extension> is "y4m". Resolution is in the format 232*d9f75844SAndroid Build Coastguard Worker // <width>x<height>_<fps>. 233*d9f75844SAndroid Build Coastguard Worker // sampling_modulo - the module for the video frames to be dumped. Modulo 234*d9f75844SAndroid Build Coastguard Worker // equals X means every Xth frame will be written to the dump file. The 235*d9f75844SAndroid Build Coastguard Worker // value must be greater than 0. (Default: 1) 236*d9f75844SAndroid Build Coastguard Worker // export_frame_ids - specifies if frame ids should be exported together 237*d9f75844SAndroid Build Coastguard Worker // with content of the stream. If true, an output file with the same name as 238*d9f75844SAndroid Build Coastguard Worker // video dump and suffix ".frame_ids.txt" will be created. It will contain 239*d9f75844SAndroid Build Coastguard Worker // the frame ids in the same order as original frames in the output 240*d9f75844SAndroid Build Coastguard Worker // file with stream content. File will contain one frame id per line. 241*d9f75844SAndroid Build Coastguard Worker // (Default: false) 242*d9f75844SAndroid Build Coastguard Worker // `video_frame_writer_factory` - factory function to create a video frame 243*d9f75844SAndroid Build Coastguard Worker // writer for input and output video files. (Default: Y4M video writer 244*d9f75844SAndroid Build Coastguard Worker // factory). 245*d9f75844SAndroid Build Coastguard Worker explicit VideoDumpOptions( 246*d9f75844SAndroid Build Coastguard Worker absl::string_view output_directory, 247*d9f75844SAndroid Build Coastguard Worker int sampling_modulo = kDefaultSamplingModulo, 248*d9f75844SAndroid Build Coastguard Worker bool export_frame_ids = false, 249*d9f75844SAndroid Build Coastguard Worker std::function<std::unique_ptr<test::VideoFrameWriter>( 250*d9f75844SAndroid Build Coastguard Worker absl::string_view file_name_prefix, 251*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution)> video_frame_writer_factory = 252*d9f75844SAndroid Build Coastguard Worker Y4mVideoFrameWriterFactory); 253*d9f75844SAndroid Build Coastguard Worker VideoDumpOptions(absl::string_view output_directory, bool export_frame_ids); 254*d9f75844SAndroid Build Coastguard Worker 255*d9f75844SAndroid Build Coastguard Worker VideoDumpOptions(const VideoDumpOptions&) = default; 256*d9f75844SAndroid Build Coastguard Worker VideoDumpOptions& operator=(const VideoDumpOptions&) = default; 257*d9f75844SAndroid Build Coastguard Worker VideoDumpOptions(VideoDumpOptions&&) = default; 258*d9f75844SAndroid Build Coastguard Worker VideoDumpOptions& operator=(VideoDumpOptions&&) = default; 259*d9f75844SAndroid Build Coastguard Worker output_directory()260*d9f75844SAndroid Build Coastguard Worker std::string output_directory() const { return output_directory_; } sampling_modulo()261*d9f75844SAndroid Build Coastguard Worker int sampling_modulo() const { return sampling_modulo_; } export_frame_ids()262*d9f75844SAndroid Build Coastguard Worker bool export_frame_ids() const { return export_frame_ids_; } 263*d9f75844SAndroid Build Coastguard Worker 264*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<test::VideoFrameWriter> CreateInputDumpVideoFrameWriter( 265*d9f75844SAndroid Build Coastguard Worker absl::string_view stream_label, 266*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 267*d9f75844SAndroid Build Coastguard Worker 268*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<test::VideoFrameWriter> CreateOutputDumpVideoFrameWriter( 269*d9f75844SAndroid Build Coastguard Worker absl::string_view stream_label, 270*d9f75844SAndroid Build Coastguard Worker absl::string_view receiver, 271*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 272*d9f75844SAndroid Build Coastguard Worker 273*d9f75844SAndroid Build Coastguard Worker std::string ToString() const; 274*d9f75844SAndroid Build Coastguard Worker 275*d9f75844SAndroid Build Coastguard Worker private: 276*d9f75844SAndroid Build Coastguard Worker static std::unique_ptr<test::VideoFrameWriter> Y4mVideoFrameWriterFactory( 277*d9f75844SAndroid Build Coastguard Worker absl::string_view file_name_prefix, 278*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution); 279*d9f75844SAndroid Build Coastguard Worker std::string GetInputDumpFileName(absl::string_view stream_label, 280*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 281*d9f75844SAndroid Build Coastguard Worker // Returns file name for input frame ids dump if `export_frame_ids()` is 282*d9f75844SAndroid Build Coastguard Worker // true, absl::nullopt otherwise. 283*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> GetInputFrameIdsDumpFileName( 284*d9f75844SAndroid Build Coastguard Worker absl::string_view stream_label, 285*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 286*d9f75844SAndroid Build Coastguard Worker std::string GetOutputDumpFileName(absl::string_view stream_label, 287*d9f75844SAndroid Build Coastguard Worker absl::string_view receiver, 288*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 289*d9f75844SAndroid Build Coastguard Worker // Returns file name for output frame ids dump if `export_frame_ids()` is 290*d9f75844SAndroid Build Coastguard Worker // true, absl::nullopt otherwise. 291*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> GetOutputFrameIdsDumpFileName( 292*d9f75844SAndroid Build Coastguard Worker absl::string_view stream_label, 293*d9f75844SAndroid Build Coastguard Worker absl::string_view receiver, 294*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution) const; 295*d9f75844SAndroid Build Coastguard Worker 296*d9f75844SAndroid Build Coastguard Worker std::string output_directory_; 297*d9f75844SAndroid Build Coastguard Worker int sampling_modulo_ = 1; 298*d9f75844SAndroid Build Coastguard Worker bool export_frame_ids_ = false; 299*d9f75844SAndroid Build Coastguard Worker std::function<std::unique_ptr<test::VideoFrameWriter>( 300*d9f75844SAndroid Build Coastguard Worker absl::string_view file_name_prefix, 301*d9f75844SAndroid Build Coastguard Worker const VideoResolution& resolution)> 302*d9f75844SAndroid Build Coastguard Worker video_frame_writer_factory_; 303*d9f75844SAndroid Build Coastguard Worker }; 304*d9f75844SAndroid Build Coastguard Worker 305*d9f75844SAndroid Build Coastguard Worker // Contains properties of single video stream. 306*d9f75844SAndroid Build Coastguard Worker struct VideoConfig { 307*d9f75844SAndroid Build Coastguard Worker explicit VideoConfig(const VideoResolution& resolution); 308*d9f75844SAndroid Build Coastguard Worker VideoConfig(size_t width, size_t height, int32_t fps); 309*d9f75844SAndroid Build Coastguard Worker VideoConfig(std::string stream_label, 310*d9f75844SAndroid Build Coastguard Worker size_t width, 311*d9f75844SAndroid Build Coastguard Worker size_t height, 312*d9f75844SAndroid Build Coastguard Worker int32_t fps); 313*d9f75844SAndroid Build Coastguard Worker 314*d9f75844SAndroid Build Coastguard Worker // Video stream width. 315*d9f75844SAndroid Build Coastguard Worker size_t width; 316*d9f75844SAndroid Build Coastguard Worker // Video stream height. 317*d9f75844SAndroid Build Coastguard Worker size_t height; 318*d9f75844SAndroid Build Coastguard Worker int32_t fps; GetResolutionVideoConfig319*d9f75844SAndroid Build Coastguard Worker VideoResolution GetResolution() const { 320*d9f75844SAndroid Build Coastguard Worker return VideoResolution(width, height, fps); 321*d9f75844SAndroid Build Coastguard Worker } 322*d9f75844SAndroid Build Coastguard Worker 323*d9f75844SAndroid Build Coastguard Worker // Have to be unique among all specified configs for all peers in the call. 324*d9f75844SAndroid Build Coastguard Worker // Will be auto generated if omitted. 325*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> stream_label; 326*d9f75844SAndroid Build Coastguard Worker // Will be set for current video track. If equals to kText or kDetailed - 327*d9f75844SAndroid Build Coastguard Worker // screencast in on. 328*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoTrackInterface::ContentHint> content_hint; 329*d9f75844SAndroid Build Coastguard Worker // If presented video will be transfered in simulcast/SVC mode depending on 330*d9f75844SAndroid Build Coastguard Worker // which encoder is used. 331*d9f75844SAndroid Build Coastguard Worker // 332*d9f75844SAndroid Build Coastguard Worker // Simulcast is supported only from 1st added peer. For VP8 simulcast only 333*d9f75844SAndroid Build Coastguard Worker // without RTX is supported so it will be automatically disabled for all 334*d9f75844SAndroid Build Coastguard Worker // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX, 335*d9f75844SAndroid Build Coastguard Worker // but only on non-lossy networks. See more in documentation to 336*d9f75844SAndroid Build Coastguard Worker // VideoSimulcastConfig. 337*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoSimulcastConfig> simulcast_config; 338*d9f75844SAndroid Build Coastguard Worker // Configuration for the emulated Selective Forward Unit (SFU). 339*d9f75844SAndroid Build Coastguard Worker absl::optional<EmulatedSFUConfig> emulated_sfu_config; 340*d9f75844SAndroid Build Coastguard Worker // Encoding parameters for both singlecast and per simulcast layer. 341*d9f75844SAndroid Build Coastguard Worker // If singlecast is used, if not empty, a single value can be provided. 342*d9f75844SAndroid Build Coastguard Worker // If simulcast is used, if not empty, `encoding_params` size have to be 343*d9f75844SAndroid Build Coastguard Worker // equal to `simulcast_config.simulcast_streams_count`. Will be used to set 344*d9f75844SAndroid Build Coastguard Worker // transceiver send encoding params for each layer. 345*d9f75844SAndroid Build Coastguard Worker // RtpEncodingParameters::rid may be changed by fixture implementation to 346*d9f75844SAndroid Build Coastguard Worker // ensure signaling correctness. 347*d9f75844SAndroid Build Coastguard Worker std::vector<RtpEncodingParameters> encoding_params; 348*d9f75844SAndroid Build Coastguard Worker // Count of temporal layers for video stream. This value will be set into 349*d9f75844SAndroid Build Coastguard Worker // each RtpEncodingParameters of RtpParameters of corresponding 350*d9f75844SAndroid Build Coastguard Worker // RtpSenderInterface for this video stream. 351*d9f75844SAndroid Build Coastguard Worker absl::optional<int> temporal_layers_count; 352*d9f75844SAndroid Build Coastguard Worker // If specified defines how input should be dumped. It is actually one of 353*d9f75844SAndroid Build Coastguard Worker // the test's output file, which contains copy of what was captured during 354*d9f75844SAndroid Build Coastguard Worker // the test for this video stream on sender side. It is useful when 355*d9f75844SAndroid Build Coastguard Worker // generator is used as input. 356*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoDumpOptions> input_dump_options; 357*d9f75844SAndroid Build Coastguard Worker // If specified defines how output should be dumped on the receiver side for 358*d9f75844SAndroid Build Coastguard Worker // this stream. The produced files contain what was rendered for this video 359*d9f75844SAndroid Build Coastguard Worker // stream on receiver side per each receiver. 360*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoDumpOptions> output_dump_options; 361*d9f75844SAndroid Build Coastguard Worker // If set to true uses fixed frame rate while dumping output video to the 362*d9f75844SAndroid Build Coastguard Worker // file. Requested `VideoSubscription::fps()` will be used as frame rate. 363*d9f75844SAndroid Build Coastguard Worker bool output_dump_use_fixed_framerate = false; 364*d9f75844SAndroid Build Coastguard Worker // If true will display input and output video on the user's screen. 365*d9f75844SAndroid Build Coastguard Worker bool show_on_screen = false; 366*d9f75844SAndroid Build Coastguard Worker // If specified, determines a sync group to which this video stream belongs. 367*d9f75844SAndroid Build Coastguard Worker // According to bugs.webrtc.org/4762 WebRTC supports synchronization only 368*d9f75844SAndroid Build Coastguard Worker // for pair of single audio and single video stream. 369*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> sync_group; 370*d9f75844SAndroid Build Coastguard Worker // If specified, it will be set into RtpParameters of corresponding 371*d9f75844SAndroid Build Coastguard Worker // RtpSenderInterface for this video stream. 372*d9f75844SAndroid Build Coastguard Worker // Note that this setting takes precedence over `content_hint`. 373*d9f75844SAndroid Build Coastguard Worker absl::optional<DegradationPreference> degradation_preference; 374*d9f75844SAndroid Build Coastguard Worker }; 375*d9f75844SAndroid Build Coastguard Worker 376*d9f75844SAndroid Build Coastguard Worker // Contains properties for audio in the call. 377*d9f75844SAndroid Build Coastguard Worker struct AudioConfig { 378*d9f75844SAndroid Build Coastguard Worker enum Mode { 379*d9f75844SAndroid Build Coastguard Worker kGenerated, 380*d9f75844SAndroid Build Coastguard Worker kFile, 381*d9f75844SAndroid Build Coastguard Worker }; 382*d9f75844SAndroid Build Coastguard Worker 383*d9f75844SAndroid Build Coastguard Worker AudioConfig() = default; 384*d9f75844SAndroid Build Coastguard Worker explicit AudioConfig(std::string stream_label); 385*d9f75844SAndroid Build Coastguard Worker 386*d9f75844SAndroid Build Coastguard Worker // Have to be unique among all specified configs for all peers in the call. 387*d9f75844SAndroid Build Coastguard Worker // Will be auto generated if omitted. 388*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> stream_label; 389*d9f75844SAndroid Build Coastguard Worker Mode mode = kGenerated; 390*d9f75844SAndroid Build Coastguard Worker // Have to be specified only if mode = kFile 391*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> input_file_name; 392*d9f75844SAndroid Build Coastguard Worker // If specified the input stream will be also copied to specified file. 393*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> input_dump_file_name; 394*d9f75844SAndroid Build Coastguard Worker // If specified the output stream will be copied to specified file. 395*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> output_dump_file_name; 396*d9f75844SAndroid Build Coastguard Worker 397*d9f75844SAndroid Build Coastguard Worker // Audio options to use. 398*d9f75844SAndroid Build Coastguard Worker cricket::AudioOptions audio_options; 399*d9f75844SAndroid Build Coastguard Worker // Sampling frequency of input audio data (from file or generated). 400*d9f75844SAndroid Build Coastguard Worker int sampling_frequency_in_hz = 48000; 401*d9f75844SAndroid Build Coastguard Worker // If specified, determines a sync group to which this audio stream belongs. 402*d9f75844SAndroid Build Coastguard Worker // According to bugs.webrtc.org/4762 WebRTC supports synchronization only 403*d9f75844SAndroid Build Coastguard Worker // for pair of single audio and single video stream. 404*d9f75844SAndroid Build Coastguard Worker absl::optional<std::string> sync_group; 405*d9f75844SAndroid Build Coastguard Worker }; 406*d9f75844SAndroid Build Coastguard Worker 407*d9f75844SAndroid Build Coastguard Worker struct VideoCodecConfig { 408*d9f75844SAndroid Build Coastguard Worker explicit VideoCodecConfig(std::string name); 409*d9f75844SAndroid Build Coastguard Worker VideoCodecConfig(std::string name, 410*d9f75844SAndroid Build Coastguard Worker std::map<std::string, std::string> required_params); 411*d9f75844SAndroid Build Coastguard Worker // Next two fields are used to specify concrete video codec, that should be 412*d9f75844SAndroid Build Coastguard Worker // used in the test. Video code will be negotiated in SDP during offer/ 413*d9f75844SAndroid Build Coastguard Worker // answer exchange. 414*d9f75844SAndroid Build Coastguard Worker // Video codec name. You can find valid names in 415*d9f75844SAndroid Build Coastguard Worker // media/base/media_constants.h 416*d9f75844SAndroid Build Coastguard Worker std::string name; 417*d9f75844SAndroid Build Coastguard Worker // Map of parameters, that have to be specified on SDP codec. Each parameter 418*d9f75844SAndroid Build Coastguard Worker // is described by key and value. Codec parameters will match the specified 419*d9f75844SAndroid Build Coastguard Worker // map if and only if for each key from `required_params` there will be 420*d9f75844SAndroid Build Coastguard Worker // a parameter with name equal to this key and parameter value will be equal 421*d9f75844SAndroid Build Coastguard Worker // to the value from `required_params` for this key. 422*d9f75844SAndroid Build Coastguard Worker // If empty then only name will be used to match the codec. 423*d9f75844SAndroid Build Coastguard Worker std::map<std::string, std::string> required_params; 424*d9f75844SAndroid Build Coastguard Worker }; 425*d9f75844SAndroid Build Coastguard Worker 426*d9f75844SAndroid Build Coastguard Worker // Subscription to the remote video streams. It declares which remote stream 427*d9f75844SAndroid Build Coastguard Worker // peer should receive and in which resolution (width x height x fps). 428*d9f75844SAndroid Build Coastguard Worker class VideoSubscription { 429*d9f75844SAndroid Build Coastguard Worker public: 430*d9f75844SAndroid Build Coastguard Worker // Returns the resolution constructed as maximum from all resolution 431*d9f75844SAndroid Build Coastguard Worker // dimensions: width, height and fps. 432*d9f75844SAndroid Build Coastguard Worker static absl::optional<VideoResolution> GetMaxResolution( 433*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const VideoConfig> video_configs); 434*d9f75844SAndroid Build Coastguard Worker static absl::optional<VideoResolution> GetMaxResolution( 435*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const VideoResolution> resolutions); 436*d9f75844SAndroid Build Coastguard Worker 437*d9f75844SAndroid Build Coastguard Worker bool operator==(const VideoSubscription& other) const; 438*d9f75844SAndroid Build Coastguard Worker bool operator!=(const VideoSubscription& other) const; 439*d9f75844SAndroid Build Coastguard Worker 440*d9f75844SAndroid Build Coastguard Worker // Subscribes receiver to all streams sent by the specified peer with 441*d9f75844SAndroid Build Coastguard Worker // specified resolution. It will override any resolution that was used in 442*d9f75844SAndroid Build Coastguard Worker // `SubscribeToAll` independently from methods call order. 443*d9f75844SAndroid Build Coastguard Worker VideoSubscription& SubscribeToPeer( 444*d9f75844SAndroid Build Coastguard Worker absl::string_view peer_name, 445*d9f75844SAndroid Build Coastguard Worker VideoResolution resolution = 446*d9f75844SAndroid Build Coastguard Worker VideoResolution(VideoResolution::Spec::kMaxFromSender)); 447*d9f75844SAndroid Build Coastguard Worker 448*d9f75844SAndroid Build Coastguard Worker // Subscribes receiver to the all sent streams with specified resolution. 449*d9f75844SAndroid Build Coastguard Worker // If any stream was subscribed to with `SubscribeTo` method that will 450*d9f75844SAndroid Build Coastguard Worker // override resolution passed to this function independently from methods 451*d9f75844SAndroid Build Coastguard Worker // call order. 452*d9f75844SAndroid Build Coastguard Worker VideoSubscription& SubscribeToAllPeers( 453*d9f75844SAndroid Build Coastguard Worker VideoResolution resolution = 454*d9f75844SAndroid Build Coastguard Worker VideoResolution(VideoResolution::Spec::kMaxFromSender)); 455*d9f75844SAndroid Build Coastguard Worker 456*d9f75844SAndroid Build Coastguard Worker // Returns resolution for specific sender. If no specific resolution was 457*d9f75844SAndroid Build Coastguard Worker // set for this sender, then will return resolution used for all streams. 458*d9f75844SAndroid Build Coastguard Worker // If subscription doesn't subscribe to all streams, `absl::nullopt` will be 459*d9f75844SAndroid Build Coastguard Worker // returned. 460*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoResolution> GetResolutionForPeer( 461*d9f75844SAndroid Build Coastguard Worker absl::string_view peer_name) const; 462*d9f75844SAndroid Build Coastguard Worker 463*d9f75844SAndroid Build Coastguard Worker // Returns a maybe empty list of senders for which peer explicitly 464*d9f75844SAndroid Build Coastguard Worker // subscribed to with specific resolution. 465*d9f75844SAndroid Build Coastguard Worker std::vector<std::string> GetSubscribedPeers() const; 466*d9f75844SAndroid Build Coastguard Worker 467*d9f75844SAndroid Build Coastguard Worker std::string ToString() const; 468*d9f75844SAndroid Build Coastguard Worker 469*d9f75844SAndroid Build Coastguard Worker private: 470*d9f75844SAndroid Build Coastguard Worker absl::optional<VideoResolution> default_resolution_ = absl::nullopt; 471*d9f75844SAndroid Build Coastguard Worker std::map<std::string, VideoResolution> peers_resolution_; 472*d9f75844SAndroid Build Coastguard Worker }; 473*d9f75844SAndroid Build Coastguard Worker 474*d9f75844SAndroid Build Coastguard Worker // Contains configuration for echo emulator. 475*d9f75844SAndroid Build Coastguard Worker struct EchoEmulationConfig { 476*d9f75844SAndroid Build Coastguard Worker // Delay which represents the echo path delay, i.e. how soon rendered signal 477*d9f75844SAndroid Build Coastguard Worker // should reach capturer. 478*d9f75844SAndroid Build Coastguard Worker TimeDelta echo_delay = TimeDelta::Millis(50); 479*d9f75844SAndroid Build Coastguard Worker }; 480*d9f75844SAndroid Build Coastguard Worker 481*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc_pc_e2e 482*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 483*d9f75844SAndroid Build Coastguard Worker 484*d9f75844SAndroid Build Coastguard Worker #endif // API_TEST_PCLF_MEDIA_CONFIGURATION_H_ 485