blob: 3d0c2d68013034352e3bffe7fa51e4c4b506cf38 [file] [log] [blame]
Mirko Bonadei12ae4f42019-02-26 15:19:07 +01001/*
2 * Copyright (c) 2019 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
11#ifndef TEST_PC_E2E_STATS_POLLER_H_
12#define TEST_PC_E2E_STATS_POLLER_H_
13
14#include <map>
15#include <string>
16#include <utility>
17#include <vector>
18
19#include "api/peer_connection_interface.h"
Artem Titovd57628f2019-03-22 12:34:25 +010020#include "api/test/stats_observer_interface.h"
Mirko Bonadei12ae4f42019-02-26 15:19:07 +010021#include "test/pc/e2e/test_peer.h"
22
23namespace webrtc {
Artem Titov0b443142019-03-20 11:11:08 +010024namespace webrtc_pc_e2e {
Mirko Bonadei12ae4f42019-02-26 15:19:07 +010025
26// Helper class that will notify all the webrtc::test::StatsObserverInterface
27// objects subscribed.
28class InternalStatsObserver : public StatsObserver {
29 public:
30 InternalStatsObserver(std::string pc_label,
31 TestPeer* peer,
32 std::vector<StatsObserverInterface*> observers)
33 : pc_label_(std::move(pc_label)),
34 peer_(peer),
35 observers_(std::move(observers)) {}
36
37 void PollStats();
38
39 void OnComplete(const StatsReports& reports) override;
40
41 private:
42 std::string pc_label_;
43 TestPeer* peer_;
44 std::vector<StatsObserverInterface*> observers_;
45};
46
47// Helper class to invoke GetStats on a PeerConnection by passing a
48// webrtc::StatsObserver that will notify all the
49// webrtc::test::StatsObserverInterface subscribed.
50class StatsPoller {
51 public:
52 StatsPoller(std::vector<StatsObserverInterface*> observers,
53 std::map<std::string, TestPeer*> peers_to_observe);
54
55 void PollStatsAndNotifyObservers();
56
57 private:
58 std::vector<rtc::scoped_refptr<InternalStatsObserver>> pollers_;
59};
60
Artem Titov0b443142019-03-20 11:11:08 +010061} // namespace webrtc_pc_e2e
Mirko Bonadei12ae4f42019-02-26 15:19:07 +010062} // namespace webrtc
63
64#endif // TEST_PC_E2E_STATS_POLLER_H_