• 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 #include "test/pc/e2e/test_peer.h"
11 
12 #include <string>
13 #include <utility>
14 
15 #include "absl/memory/memory.h"
16 #include "api/scoped_refptr.h"
17 #include "modules/audio_processing/include/audio_processing.h"
18 
19 namespace webrtc {
20 namespace webrtc_pc_e2e {
21 
AddIceCandidates(std::vector<std::unique_ptr<IceCandidateInterface>> candidates)22 bool TestPeer::AddIceCandidates(
23     std::vector<std::unique_ptr<IceCandidateInterface>> candidates) {
24   bool success = true;
25   for (auto& candidate : candidates) {
26     if (!pc()->AddIceCandidate(candidate.get())) {
27       std::string candidate_str;
28       bool res = candidate->ToString(&candidate_str);
29       RTC_CHECK(res);
30       RTC_LOG(LS_ERROR) << "Failed to add ICE candidate, candidate_str="
31                         << candidate_str;
32       success = false;
33     } else {
34       remote_ice_candidates_.push_back(std::move(candidate));
35     }
36   }
37   return success;
38 }
39 
TestPeer(rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,rtc::scoped_refptr<PeerConnectionInterface> pc,std::unique_ptr<MockPeerConnectionObserver> observer,std::unique_ptr<Params> params,std::vector<PeerConfigurerImpl::VideoSource> video_sources,rtc::scoped_refptr<AudioProcessing> audio_processing,std::unique_ptr<rtc::Thread> worker_thread)40 TestPeer::TestPeer(
41     rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
42     rtc::scoped_refptr<PeerConnectionInterface> pc,
43     std::unique_ptr<MockPeerConnectionObserver> observer,
44     std::unique_ptr<Params> params,
45     std::vector<PeerConfigurerImpl::VideoSource> video_sources,
46     rtc::scoped_refptr<AudioProcessing> audio_processing,
47     std::unique_ptr<rtc::Thread> worker_thread)
48     : worker_thread_(std::move(worker_thread)),
49       wrapper_(std::make_unique<PeerConnectionWrapper>(std::move(pc_factory),
50                                                        std::move(pc),
51                                                        std::move(observer))),
52       params_(std::move(params)),
53       video_sources_(std::move(video_sources)),
54       audio_processing_(audio_processing) {}
55 
56 }  // namespace webrtc_pc_e2e
57 }  // namespace webrtc
58