peerconnection_quality_test_fixture.h (4705B)
1 /* 2 * Copyright (c) 2018 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 */ 10 #ifndef API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ 11 #define API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ 12 13 #include <stddef.h> 14 15 #include <functional> 16 #include <memory> 17 18 #include "absl/strings/string_view.h" 19 #include "api/test/pclf/media_quality_test_params.h" 20 #include "api/test/pclf/peer_configurer.h" 21 #include "api/test/stats_observer_interface.h" 22 #include "api/test/track_id_stream_info_map.h" 23 #include "api/units/time_delta.h" 24 25 namespace webrtc { 26 namespace webrtc_pc_e2e { 27 28 // API is in development. Can be changed/removed without notice. 29 class PeerConnectionE2EQualityTestFixture { 30 public: 31 // Represent an entity that will report quality metrics after test. 32 class QualityMetricsReporter : public StatsObserverInterface { 33 public: 34 virtual ~QualityMetricsReporter() = default; 35 36 // Invoked by framework after peer connection factory and peer connection 37 // itself will be created but before offer/answer exchange will be started. 38 // `test_case_name` is name of test case, that should be used to report all 39 // metrics. 40 // `reporter_helper` is a pointer to a class that will allow track_id to 41 // stream_id matching. The caller is responsible for ensuring the 42 // TrackIdStreamInfoMap will be valid from Start() to 43 // StopAndReportResults(). 44 virtual void Start(absl::string_view test_case_name, 45 const TrackIdStreamInfoMap* reporter_helper) = 0; 46 47 // Invoked by framework after call is ended and peer connection factory and 48 // peer connection are destroyed. 49 virtual void StopAndReportResults() = 0; 50 }; 51 52 // Represents single participant in call and can be used to perform different 53 // in-call actions. Might be extended in future. 54 class PeerHandle { 55 public: 56 virtual ~PeerHandle() = default; 57 }; 58 59 virtual ~PeerConnectionE2EQualityTestFixture() = default; 60 61 // Add activity that will be executed on the best effort at least after 62 // `target_time_since_start` after call will be set up (after offer/answer 63 // exchange, ICE gathering will be done and ICE candidates will passed to 64 // remote side). `func` param is amount of time spent from the call set up. 65 virtual void ExecuteAt(TimeDelta target_time_since_start, 66 std::function<void(TimeDelta)> func) = 0; 67 // Add activity that will be executed every `interval` with first execution 68 // on the best effort at least after `initial_delay_since_start` after call 69 // will be set up (after all participants will be connected). `func` param is 70 // amount of time spent from the call set up. 71 virtual void ExecuteEvery(TimeDelta initial_delay_since_start, 72 TimeDelta interval, 73 std::function<void(TimeDelta)> func) = 0; 74 75 // Add stats reporter entity to observe the test. 76 virtual void AddQualityMetricsReporter( 77 std::unique_ptr<QualityMetricsReporter> quality_metrics_reporter) = 0; 78 79 // Add a new peer to the call and return an object through which caller 80 // can configure peer's behavior. 81 // `network_dependencies` are used to provide networking for peer's peer 82 // connection. Members must be non-null. 83 // `configurer` function will be used to configure peer in the call. 84 virtual PeerHandle* AddPeer(std::unique_ptr<PeerConfigurer> configurer) = 0; 85 86 // Runs the media quality test, which includes setting up the call with 87 // configured participants, running it according to provided `run_params` and 88 // terminating it properly at the end. During call duration media quality 89 // metrics are gathered, which are then reported to stdout and (if configured) 90 // to the json/protobuf output file through the WebRTC perf test results 91 // reporting system. 92 virtual void Run(RunParams run_params) = 0; 93 94 // Returns real test duration - the time of test execution measured during 95 // test. Client must call this method only after test is finished (after 96 // Run(...) method returned). Test execution time is time from end of call 97 // setup (offer/answer, ICE candidates exchange done and ICE connected) to 98 // start of call tear down (PeerConnection closed). 99 virtual TimeDelta GetRealTestDuration() const = 0; 100 }; 101 102 } // namespace webrtc_pc_e2e 103 } // namespace webrtc 104 105 #endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_