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

Side by Side Diff: remoting/protocol/webrtc_transport.h

Issue 1521883006: Add TransportContext class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « remoting/protocol/transport_context.cc ('k') | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "remoting/protocol/port_allocator_factory.h" 15 #include "remoting/protocol/port_allocator_factory.h"
16 #include "remoting/protocol/transport.h" 16 #include "remoting/protocol/transport.h"
17 #include "remoting/protocol/webrtc_data_stream_adapter.h" 17 #include "remoting/protocol/webrtc_data_stream_adapter.h"
18 #include "remoting/signaling/signal_strategy.h" 18 #include "remoting/signaling/signal_strategy.h"
19 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h " 19 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h "
20 20
21 namespace webrtc { 21 namespace webrtc {
22 class FakeAudioDeviceModule; 22 class FakeAudioDeviceModule;
23 } // namespace webrtc 23 } // namespace webrtc
24 24
25 namespace remoting { 25 namespace remoting {
26 namespace protocol { 26 namespace protocol {
27 27
28 class TransportContext;
29
28 class WebrtcTransport : public Transport, 30 class WebrtcTransport : public Transport,
29 public webrtc::PeerConnectionObserver { 31 public webrtc::PeerConnectionObserver {
30 public: 32 public:
31 WebrtcTransport(rtc::Thread* worker_thread, 33 WebrtcTransport(rtc::Thread* worker_thread,
32 PortAllocatorFactory* port_allocator_factory, 34 scoped_refptr<TransportContext> transport_context);
33 TransportRole role);
34 ~WebrtcTransport() override; 35 ~WebrtcTransport() override;
35 36
36 webrtc::PeerConnectionInterface* peer_connection() { 37 webrtc::PeerConnectionInterface* peer_connection() {
37 return peer_connection_; 38 return peer_connection_;
38 } 39 }
39 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { 40 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() {
40 return peer_connection_factory_; 41 return peer_connection_factory_;
41 } 42 }
42 43
43 // Transport interface. 44 // Transport interface.
44 void Start(EventHandler* event_handler, 45 void Start(EventHandler* event_handler,
45 Authenticator* authenticator) override; 46 Authenticator* authenticator) override;
46 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; 47 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
47 StreamChannelFactory* GetStreamChannelFactory() override; 48 StreamChannelFactory* GetStreamChannelFactory() override;
48 StreamChannelFactory* GetMultiplexedChannelFactory() override; 49 StreamChannelFactory* GetMultiplexedChannelFactory() override;
49 WebrtcTransport* AsWebrtcTransport() override; 50 WebrtcTransport* AsWebrtcTransport() override;
50 51
51 private: 52 private:
53 void OnPortAllocatorCreated(
54 scoped_ptr<cricket::PortAllocator> port_allocator);
55
52 void OnLocalSessionDescriptionCreated( 56 void OnLocalSessionDescriptionCreated(
53 scoped_ptr<webrtc::SessionDescriptionInterface> description, 57 scoped_ptr<webrtc::SessionDescriptionInterface> description,
54 const std::string& error); 58 const std::string& error);
55 void OnLocalDescriptionSet(bool success, const std::string& error); 59 void OnLocalDescriptionSet(bool success, const std::string& error);
56 void OnRemoteDescriptionSet(bool send_answer, 60 void OnRemoteDescriptionSet(bool send_answer,
57 bool success, 61 bool success,
58 const std::string& error); 62 const std::string& error);
59 63
60 // webrtc::PeerConnectionObserver interface. 64 // webrtc::PeerConnectionObserver interface.
61 void OnSignalingChange( 65 void OnSignalingChange(
(...skipping 11 matching lines...) Expand all
73 void RequestNegotiation(); 77 void RequestNegotiation();
74 void SendOffer(); 78 void SendOffer();
75 void EnsurePendingTransportInfoMessage(); 79 void EnsurePendingTransportInfoMessage();
76 void SendTransportInfo(); 80 void SendTransportInfo();
77 void AddPendingCandidatesIfPossible(); 81 void AddPendingCandidatesIfPossible();
78 82
79 void Close(ErrorCode error); 83 void Close(ErrorCode error);
80 84
81 base::ThreadChecker thread_checker_; 85 base::ThreadChecker thread_checker_;
82 86
83 PortAllocatorFactory* port_allocator_factory_; 87 scoped_refptr<TransportContext> transport_context_;
84 TransportRole role_;
85 EventHandler* event_handler_ = nullptr; 88 EventHandler* event_handler_ = nullptr;
86 rtc::Thread* worker_thread_; 89 rtc::Thread* worker_thread_;
87 90
88 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; 91 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_;
89 92
90 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> 93 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
91 peer_connection_factory_; 94 peer_connection_factory_;
92 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 95 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
93 96
94 bool negotiation_pending_ = false; 97 bool negotiation_pending_ = false;
95 98
96 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; 99 scoped_ptr<buzz::XmlElement> pending_transport_info_message_;
97 base::OneShotTimer transport_info_timer_; 100 base::OneShotTimer transport_info_timer_;
98 101
99 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; 102 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
100 103
101 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> 104 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>>
102 unclaimed_streams_; 105 unclaimed_streams_;
103 106
104 WebrtcDataStreamAdapter data_stream_adapter_; 107 WebrtcDataStreamAdapter data_stream_adapter_;
105 108
106 base::WeakPtrFactory<WebrtcTransport> weak_factory_; 109 base::WeakPtrFactory<WebrtcTransport> weak_factory_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); 111 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport);
109 }; 112 };
110 113
111 class WebrtcTransportFactory : public TransportFactory { 114 class WebrtcTransportFactory : public TransportFactory {
112 public: 115 public:
113 WebrtcTransportFactory( 116 WebrtcTransportFactory(rtc::Thread* worker_thread,
114 rtc::Thread* worker_thread, 117 scoped_refptr<TransportContext> transport_context);
115 SignalStrategy* signal_strategy,
116 scoped_ptr<PortAllocatorFactory> port_allocator_factory,
117 TransportRole role);
118 ~WebrtcTransportFactory() override; 118 ~WebrtcTransportFactory() override;
119 119
120 // TransportFactory interface. 120 // TransportFactory interface.
121 scoped_ptr<Transport> CreateTransport() override; 121 scoped_ptr<Transport> CreateTransport() override;
122 122
123 private: 123 private:
124 rtc::Thread* worker_thread_; 124 rtc::Thread* worker_thread_;
125 SignalStrategy* signal_strategy_; 125 scoped_refptr<TransportContext> transport_context_;
126 scoped_ptr<PortAllocatorFactory> port_allocator_factory_;
127 TransportRole role_;
128 126
129 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory); 127 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory);
130 }; 128 };
131 129
132 } // namespace protocol 130 } // namespace protocol
133 } // namespace remoting 131 } // namespace remoting
134 132
135 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 133 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
OLDNEW
« no previous file with comments | « remoting/protocol/transport_context.cc ('k') | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698