| OLD | NEW |
| 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 <string> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 14 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 15 #include "crypto/hmac.h" | 17 #include "crypto/hmac.h" |
| 16 #include "remoting/protocol/transport.h" | 18 #include "remoting/protocol/transport.h" |
| 17 #include "remoting/protocol/webrtc_data_stream_adapter.h" | 19 #include "remoting/protocol/webrtc_data_stream_adapter.h" |
| 20 #include "remoting/protocol/webrtc_video_encoder.h" |
| 18 #include "remoting/signaling/signal_strategy.h" | 21 #include "remoting/signaling/signal_strategy.h" |
| 19 #include "third_party/webrtc/api/peerconnectioninterface.h" | 22 #include "third_party/webrtc/api/peerconnectioninterface.h" |
| 20 | 23 |
| 21 namespace webrtc { | 24 namespace webrtc { |
| 22 class FakeAudioDeviceModule; | 25 class FakeAudioDeviceModule; |
| 23 } // namespace webrtc | 26 } // namespace webrtc |
| 24 | 27 |
| 25 namespace remoting { | 28 namespace remoting { |
| 26 namespace protocol { | 29 namespace protocol { |
| 27 | 30 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 58 scoped_refptr<TransportContext> transport_context, | 61 scoped_refptr<TransportContext> transport_context, |
| 59 EventHandler* event_handler); | 62 EventHandler* event_handler); |
| 60 ~WebrtcTransport() override; | 63 ~WebrtcTransport() override; |
| 61 | 64 |
| 62 webrtc::PeerConnectionInterface* peer_connection() { | 65 webrtc::PeerConnectionInterface* peer_connection() { |
| 63 return peer_connection_; | 66 return peer_connection_; |
| 64 } | 67 } |
| 65 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | 68 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { |
| 66 return peer_connection_factory_; | 69 return peer_connection_factory_; |
| 67 } | 70 } |
| 71 remoting::WebRtcVideoEncoderFactory* video_encoder_factory() { |
| 72 return video_encoder_factory_; |
| 73 } |
| 68 | 74 |
| 69 // Factories for outgoing and incoming data channels. Must be used only after | 75 // Factories for outgoing and incoming data channels. Must be used only after |
| 70 // the transport is connected. | 76 // the transport is connected. |
| 71 MessageChannelFactory* outgoing_channel_factory() { | 77 MessageChannelFactory* outgoing_channel_factory() { |
| 72 return &outgoing_data_stream_adapter_; | 78 return &outgoing_data_stream_adapter_; |
| 73 } | 79 } |
| 74 MessageChannelFactory* incoming_channel_factory() { | 80 MessageChannelFactory* incoming_channel_factory() { |
| 75 return &incoming_data_stream_adapter_; | 81 return &incoming_data_stream_adapter_; |
| 76 } | 82 } |
| 77 | 83 |
| 78 // Transport interface. | 84 // Transport interface. |
| 79 void Start(Authenticator* authenticator, | 85 void Start(Authenticator* authenticator, |
| 80 SendTransportInfoCallback send_transport_info_callback) override; | 86 SendTransportInfoCallback send_transport_info_callback) override; |
| 81 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | 87 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; |
| 88 void Close(ErrorCode error); |
| 82 | 89 |
| 83 private: | 90 private: |
| 84 void OnLocalSessionDescriptionCreated( | 91 void OnLocalSessionDescriptionCreated( |
| 85 scoped_ptr<webrtc::SessionDescriptionInterface> description, | 92 scoped_ptr<webrtc::SessionDescriptionInterface> description, |
| 86 const std::string& error); | 93 const std::string& error); |
| 87 void OnLocalDescriptionSet(bool success, const std::string& error); | 94 void OnLocalDescriptionSet(bool success, const std::string& error); |
| 88 void OnRemoteDescriptionSet(bool send_answer, | 95 void OnRemoteDescriptionSet(bool send_answer, |
| 89 bool success, | 96 bool success, |
| 90 const std::string& error); | 97 const std::string& error); |
| 91 | 98 |
| 92 // webrtc::PeerConnectionObserver interface. | 99 // webrtc::PeerConnectionObserver interface. |
| 93 void OnSignalingChange( | 100 void OnSignalingChange( |
| 94 webrtc::PeerConnectionInterface::SignalingState new_state) override; | 101 webrtc::PeerConnectionInterface::SignalingState new_state) override; |
| 95 void OnAddStream(webrtc::MediaStreamInterface* stream) override; | 102 void OnAddStream(webrtc::MediaStreamInterface* stream) override; |
| 96 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override; | 103 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override; |
| 97 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override; | 104 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override; |
| 98 void OnRenegotiationNeeded() override; | 105 void OnRenegotiationNeeded() override; |
| 99 void OnIceConnectionChange( | 106 void OnIceConnectionChange( |
| 100 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; | 107 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; |
| 101 void OnIceGatheringChange( | 108 void OnIceGatheringChange( |
| 102 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; | 109 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; |
| 103 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; | 110 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; |
| 104 | 111 |
| 105 void RequestNegotiation(); | 112 void RequestNegotiation(); |
| 106 void SendOffer(); | 113 void SendOffer(); |
| 107 void EnsurePendingTransportInfoMessage(); | 114 void EnsurePendingTransportInfoMessage(); |
| 108 void SendTransportInfo(); | 115 void SendTransportInfo(); |
| 109 void AddPendingCandidatesIfPossible(); | 116 void AddPendingCandidatesIfPossible(); |
| 110 | 117 |
| 111 void Close(ErrorCode error); | |
| 112 | |
| 113 base::ThreadChecker thread_checker_; | 118 base::ThreadChecker thread_checker_; |
| 114 | 119 |
| 115 rtc::Thread* worker_thread_; | 120 rtc::Thread* worker_thread_; |
| 116 scoped_refptr<TransportContext> transport_context_; | 121 scoped_refptr<TransportContext> transport_context_; |
| 117 EventHandler* event_handler_ = nullptr; | 122 EventHandler* event_handler_ = nullptr; |
| 118 SendTransportInfoCallback send_transport_info_callback_; | 123 SendTransportInfoCallback send_transport_info_callback_; |
| 119 | 124 |
| 120 crypto::HMAC handshake_hmac_; | 125 crypto::HMAC handshake_hmac_; |
| 121 | 126 |
| 122 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; | 127 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; |
| 123 | 128 |
| 124 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 129 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
| 125 peer_connection_factory_; | 130 peer_connection_factory_; |
| 126 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 131 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 127 | 132 |
| 133 remoting::WebRtcVideoEncoderFactory* video_encoder_factory_; |
| 134 |
| 128 bool negotiation_pending_ = false; | 135 bool negotiation_pending_ = false; |
| 129 | 136 |
| 130 bool connected_ = false; | 137 bool connected_ = false; |
| 131 | 138 |
| 132 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; | 139 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; |
| 133 base::OneShotTimer transport_info_timer_; | 140 base::OneShotTimer transport_info_timer_; |
| 134 | 141 |
| 135 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; | 142 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; |
| 136 | 143 |
| 137 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; | 144 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; |
| 138 WebrtcDataStreamAdapter incoming_data_stream_adapter_; | 145 WebrtcDataStreamAdapter incoming_data_stream_adapter_; |
| 139 | 146 |
| 140 base::WeakPtrFactory<WebrtcTransport> weak_factory_; | 147 base::WeakPtrFactory<WebrtcTransport> weak_factory_; |
| 141 | 148 |
| 142 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); | 149 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); |
| 143 }; | 150 }; |
| 144 | 151 |
| 145 } // namespace protocol | 152 } // namespace protocol |
| 146 } // namespace remoting | 153 } // namespace remoting |
| 147 | 154 |
| 148 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 155 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
| OLD | NEW |