• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include "test/pc/e2e/analyzer_helper.h"
12 
13 #include <string>
14 #include <utility>
15 
16 namespace webrtc {
17 namespace webrtc_pc_e2e {
18 
AnalyzerHelper()19 AnalyzerHelper::AnalyzerHelper() {
20   signaling_sequence_checker_.Detach();
21 }
22 
AddTrackToStreamMapping(absl::string_view track_id,absl::string_view receiver_peer,absl::string_view stream_label,absl::optional<std::string> sync_group)23 void AnalyzerHelper::AddTrackToStreamMapping(
24     absl::string_view track_id,
25     absl::string_view receiver_peer,
26     absl::string_view stream_label,
27     absl::optional<std::string> sync_group) {
28   RTC_DCHECK_RUN_ON(&signaling_sequence_checker_);
29   track_to_stream_map_.insert(
30       {std::string(track_id),
31        StreamInfo{.receiver_peer = std::string(receiver_peer),
32                   .stream_label = std::string(stream_label),
33                   .sync_group = sync_group.has_value()
34                                     ? *sync_group
35                                     : std::string(stream_label)}});
36 }
37 
AddTrackToStreamMapping(std::string track_id,std::string stream_label)38 void AnalyzerHelper::AddTrackToStreamMapping(std::string track_id,
39                                              std::string stream_label) {
40   RTC_DCHECK_RUN_ON(&signaling_sequence_checker_);
41   track_to_stream_map_.insert(
42       {std::move(track_id), StreamInfo{stream_label, stream_label}});
43 }
44 
AddTrackToStreamMapping(std::string track_id,std::string stream_label,std::string sync_group)45 void AnalyzerHelper::AddTrackToStreamMapping(std::string track_id,
46                                              std::string stream_label,
47                                              std::string sync_group) {
48   RTC_DCHECK_RUN_ON(&signaling_sequence_checker_);
49   track_to_stream_map_.insert(
50       {std::move(track_id),
51        StreamInfo{std::move(stream_label), std::move(sync_group)}});
52 }
53 
GetStreamInfoFromTrackId(absl::string_view track_id) const54 AnalyzerHelper::StreamInfo AnalyzerHelper::GetStreamInfoFromTrackId(
55     absl::string_view track_id) const {
56   RTC_DCHECK_RUN_ON(&signaling_sequence_checker_);
57   auto track_to_stream_pair = track_to_stream_map_.find(std::string(track_id));
58   RTC_CHECK(track_to_stream_pair != track_to_stream_map_.end());
59   return track_to_stream_pair->second;
60 }
61 
62 }  // namespace webrtc_pc_e2e
63 }  // namespace webrtc
64