Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: webrtc/api/test/peerconnectiontestwrapper.h

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 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 WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
12 #define WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
13
14 #include <memory>
15
16 #include "webrtc/api/peerconnectioninterface.h"
17 #include "webrtc/api/test/fakeaudiocapturemodule.h"
18 #include "webrtc/api/test/fakeconstraints.h"
19 #include "webrtc/api/test/fakevideotrackrenderer.h"
20 #include "webrtc/base/sigslot.h"
21
22 class PeerConnectionTestWrapper
23 : public webrtc::PeerConnectionObserver,
24 public webrtc::CreateSessionDescriptionObserver,
25 public sigslot::has_slots<> {
26 public:
27 // We need these using declarations because there are two versions of each of
28 // the below methods and we only override one of them.
29 // TODO(deadbeef): Remove once there's only one version of the methods.
30 using PeerConnectionObserver::OnAddStream;
31 using PeerConnectionObserver::OnRemoveStream;
32 using PeerConnectionObserver::OnDataChannel;
33
34 static void Connect(PeerConnectionTestWrapper* caller,
35 PeerConnectionTestWrapper* callee);
36
37 PeerConnectionTestWrapper(const std::string& name,
38 rtc::Thread* network_thread,
39 rtc::Thread* worker_thread);
40 virtual ~PeerConnectionTestWrapper();
41
42 bool CreatePc(
43 const webrtc::MediaConstraintsInterface* constraints,
44 const webrtc::PeerConnectionInterface::RTCConfiguration& config);
45
46 webrtc::PeerConnectionInterface* pc() { return peer_connection_.get(); }
47
48 rtc::scoped_refptr<webrtc::DataChannelInterface> CreateDataChannel(
49 const std::string& label,
50 const webrtc::DataChannelInit& init);
51
52 // Implements PeerConnectionObserver.
53 virtual void OnSignalingChange(
54 webrtc::PeerConnectionInterface::SignalingState new_state) {}
55 virtual void OnStateChange(
56 webrtc::PeerConnectionObserver::StateType state_changed) {}
57 virtual void OnAddStream(
58 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
59 virtual void OnRemoveStream(
60 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {}
61 virtual void OnDataChannel(
62 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
63 virtual void OnRenegotiationNeeded() {}
64 virtual void OnIceConnectionChange(
65 webrtc::PeerConnectionInterface::IceConnectionState new_state) {}
66 virtual void OnIceGatheringChange(
67 webrtc::PeerConnectionInterface::IceGatheringState new_state) {}
68 virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate);
69 virtual void OnIceComplete() {}
70
71 // Implements CreateSessionDescriptionObserver.
72 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc);
73 virtual void OnFailure(const std::string& error) {}
74
75 void CreateOffer(const webrtc::MediaConstraintsInterface* constraints);
76 void CreateAnswer(const webrtc::MediaConstraintsInterface* constraints);
77 void ReceiveOfferSdp(const std::string& sdp);
78 void ReceiveAnswerSdp(const std::string& sdp);
79 void AddIceCandidate(const std::string& sdp_mid, int sdp_mline_index,
80 const std::string& candidate);
81 void WaitForCallEstablished();
82 void WaitForConnection();
83 void WaitForAudio();
84 void WaitForVideo();
85 void GetAndAddUserMedia(
86 bool audio, const webrtc::FakeConstraints& audio_constraints,
87 bool video, const webrtc::FakeConstraints& video_constraints);
88
89 // sigslots
90 sigslot::signal1<std::string*> SignalOnIceCandidateCreated;
91 sigslot::signal3<const std::string&,
92 int,
93 const std::string&> SignalOnIceCandidateReady;
94 sigslot::signal1<std::string*> SignalOnSdpCreated;
95 sigslot::signal1<const std::string&> SignalOnSdpReady;
96 sigslot::signal1<webrtc::DataChannelInterface*> SignalOnDataChannel;
97
98 private:
99 void SetLocalDescription(const std::string& type, const std::string& sdp);
100 void SetRemoteDescription(const std::string& type, const std::string& sdp);
101 bool CheckForConnection();
102 bool CheckForAudio();
103 bool CheckForVideo();
104 rtc::scoped_refptr<webrtc::MediaStreamInterface> GetUserMedia(
105 bool audio, const webrtc::FakeConstraints& audio_constraints,
106 bool video, const webrtc::FakeConstraints& video_constraints);
107
108 std::string name_;
109 rtc::Thread* const network_thread_;
110 rtc::Thread* const worker_thread_;
111 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
112 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
113 peer_connection_factory_;
114 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
115 std::unique_ptr<webrtc::FakeVideoTrackRenderer> renderer_;
116 };
117
118 #endif // WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
OLDNEW
« no previous file with comments | « webrtc/api/test/mockpeerconnectionobservers.h ('k') | webrtc/api/test/peerconnectiontestwrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698