xref: /aosp_15_r20/external/webrtc/test/pc/e2e/analyzer_helper.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2019 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 
11*d9f75844SAndroid Build Coastguard Worker #ifndef TEST_PC_E2E_ANALYZER_HELPER_H_
12*d9f75844SAndroid Build Coastguard Worker #define TEST_PC_E2E_ANALYZER_HELPER_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <map>
15*d9f75844SAndroid Build Coastguard Worker #include <string>
16*d9f75844SAndroid Build Coastguard Worker 
17*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h"
18*d9f75844SAndroid Build Coastguard Worker #include "absl/types/optional.h"
19*d9f75844SAndroid Build Coastguard Worker #include "api/sequence_checker.h"
20*d9f75844SAndroid Build Coastguard Worker #include "api/test/track_id_stream_info_map.h"
21*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/thread_annotations.h"
22*d9f75844SAndroid Build Coastguard Worker 
23*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
24*d9f75844SAndroid Build Coastguard Worker namespace webrtc_pc_e2e {
25*d9f75844SAndroid Build Coastguard Worker 
26*d9f75844SAndroid Build Coastguard Worker // This class is a utility that provides bookkeeping capabilities that
27*d9f75844SAndroid Build Coastguard Worker // are useful to associate stats reports track_ids to the remote stream info.
28*d9f75844SAndroid Build Coastguard Worker // The framework will populate an instance of this class and it will pass
29*d9f75844SAndroid Build Coastguard Worker // it to the Start method of Media Quality Analyzers.
30*d9f75844SAndroid Build Coastguard Worker // An instance of AnalyzerHelper must only be accessed from a single
31*d9f75844SAndroid Build Coastguard Worker // thread and since stats collection happens on the signaling thread,
32*d9f75844SAndroid Build Coastguard Worker // AddTrackToStreamMapping, GetStreamLabelFromTrackId and
33*d9f75844SAndroid Build Coastguard Worker // GetSyncGroupLabelFromTrackId must be invoked from the signaling thread. Get
34*d9f75844SAndroid Build Coastguard Worker // methods should be invoked only after all data is added. Mixing Get methods
35*d9f75844SAndroid Build Coastguard Worker // with adding new data may lead to undefined behavior.
36*d9f75844SAndroid Build Coastguard Worker class AnalyzerHelper : public TrackIdStreamInfoMap {
37*d9f75844SAndroid Build Coastguard Worker  public:
38*d9f75844SAndroid Build Coastguard Worker   AnalyzerHelper();
39*d9f75844SAndroid Build Coastguard Worker 
40*d9f75844SAndroid Build Coastguard Worker   void AddTrackToStreamMapping(absl::string_view track_id,
41*d9f75844SAndroid Build Coastguard Worker                                absl::string_view receiver_peer,
42*d9f75844SAndroid Build Coastguard Worker                                absl::string_view stream_label,
43*d9f75844SAndroid Build Coastguard Worker                                absl::optional<std::string> sync_group);
44*d9f75844SAndroid Build Coastguard Worker   void AddTrackToStreamMapping(std::string track_id, std::string stream_label);
45*d9f75844SAndroid Build Coastguard Worker   void AddTrackToStreamMapping(std::string track_id,
46*d9f75844SAndroid Build Coastguard Worker                                std::string stream_label,
47*d9f75844SAndroid Build Coastguard Worker                                std::string sync_group);
48*d9f75844SAndroid Build Coastguard Worker 
49*d9f75844SAndroid Build Coastguard Worker   StreamInfo GetStreamInfoFromTrackId(
50*d9f75844SAndroid Build Coastguard Worker       absl::string_view track_id) const override;
51*d9f75844SAndroid Build Coastguard Worker 
52*d9f75844SAndroid Build Coastguard Worker  private:
53*d9f75844SAndroid Build Coastguard Worker   SequenceChecker signaling_sequence_checker_;
54*d9f75844SAndroid Build Coastguard Worker   std::map<std::string, StreamInfo> track_to_stream_map_
55*d9f75844SAndroid Build Coastguard Worker       RTC_GUARDED_BY(signaling_sequence_checker_);
56*d9f75844SAndroid Build Coastguard Worker };
57*d9f75844SAndroid Build Coastguard Worker 
58*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc_pc_e2e
59*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
60*d9f75844SAndroid Build Coastguard Worker 
61*d9f75844SAndroid Build Coastguard Worker #endif  // TEST_PC_E2E_ANALYZER_HELPER_H_
62