Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | |
| 6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/scoped_vector.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/threading/thread.h" | |
| 13 #include "base/timer/timer.h" | |
| 14 #include "remoting/protocol/transport.h" | |
| 15 #include "remoting/signaling/signal_strategy.h" | |
| 16 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h " | |
| 17 | |
| 18 namespace remoting { | |
| 19 namespace protocol { | |
| 20 | |
| 21 class WebrtcTransport : public Transport, | |
| 22 public webrtc::PeerConnectionObserver { | |
| 23 public: | |
| 24 WebrtcTransport( | |
| 25 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 26 port_allocator_factory, | |
| 27 TransportRole role, | |
| 28 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); | |
| 29 ~WebrtcTransport() override; | |
| 30 | |
| 31 // Transport interface. | |
| 32 void Start(EventHandler* event_handler, | |
|
kelvinp
2015/11/11 23:38:48
Is it guaranteed that the event_handler will alway
Sergey Ulanov
2015/11/17 01:40:32
Yes. Transport is a single-threaded interface that
| |
| 33 Authenticator* authenticator) override; | |
| 34 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | |
| 35 DatagramChannelFactory* GetDatagramChannelFactory() override; | |
| 36 StreamChannelFactory* GetStreamChannelFactory() override; | |
| 37 StreamChannelFactory* GetMultiplexedChannelFactory() override; | |
| 38 | |
| 39 private: | |
| 40 void DoStart(rtc::Thread* worker_thread); | |
| 41 void OnLocalSessionDescriptionCreated( | |
| 42 scoped_ptr<webrtc::SessionDescriptionInterface> description, | |
| 43 const std::string& error); | |
| 44 void OnLocalDescriptionSet(bool success, const std::string& error); | |
| 45 void OnRemoteDescriptionSet(bool success, const std::string& error); | |
| 46 | |
| 47 // webrtc::PeerConnectionObserver interface. | |
| 48 void OnSignalingChange( | |
| 49 webrtc::PeerConnectionInterface::SignalingState new_state) override; | |
| 50 void OnAddStream(webrtc::MediaStreamInterface* stream) override; | |
| 51 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override; | |
| 52 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override; | |
| 53 void OnRenegotiationNeeded() override; | |
| 54 void OnIceConnectionChange( | |
| 55 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; | |
| 56 void OnIceGatheringChange( | |
| 57 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; | |
| 58 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; | |
| 59 | |
| 60 void EnsurePendingTransportInfoMessage(); | |
| 61 void SendTransportInfo(); | |
| 62 void AddPendingCandidatesIfPossible(); | |
| 63 | |
| 64 void Close(ErrorCode error); | |
| 65 | |
| 66 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 67 port_allocator_factory_; | |
| 68 TransportRole role_; | |
| 69 EventHandler* event_handler_ = nullptr; | |
| 70 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | |
| 71 | |
| 72 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | |
| 73 peer_connection_factory_; | |
| 74 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | |
| 75 | |
| 76 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; | |
| 77 base::OneShotTimer transport_info_timer_; | |
| 78 | |
| 79 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; | |
| 80 | |
| 81 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> | |
| 82 unclaimed_streams_; | |
| 83 | |
| 84 base::WeakPtrFactory<WebrtcTransport> weak_factory_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); | |
| 87 }; | |
| 88 | |
| 89 class WebrtcTransportFactory : public TransportFactory { | |
| 90 public: | |
| 91 WebrtcTransportFactory( | |
| 92 SignalStrategy* signal_strategy, | |
| 93 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 94 port_allocator_factory, | |
| 95 TransportRole role); | |
| 96 ~WebrtcTransportFactory() override; | |
| 97 | |
| 98 // TransportFactory interface. | |
| 99 scoped_ptr<Transport> CreateTransport() override; | |
| 100 | |
| 101 private: | |
| 102 SignalStrategy* signal_strategy_; | |
| 103 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 104 port_allocator_factory_; | |
| 105 TransportRole role_; | |
| 106 | |
| 107 base::Thread worker_thread_; | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory); | |
| 110 }; | |
| 111 | |
| 112 } // namespace protocol | |
| 113 } // namespace remoting | |
| 114 | |
| 115 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | |
| OLD | NEW |