| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HOST_CAST_EXTENSION_SESSION_H_ | 5 #ifndef REMOTING_HOST_CAST_EXTENSION_SESSION_H_ |
| 6 #define REMOTING_HOST_CAST_EXTENSION_SESSION_H_ | 6 #define REMOTING_HOST_CAST_EXTENSION_SESSION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "jingle/glue/thread_wrapper.h" | 16 #include "jingle/glue/thread_wrapper.h" |
| 17 #include "remoting/host/host_extension_session.h" | 17 #include "remoting/host/host_extension_session.h" |
| 18 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" | 18 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" |
| 19 #include "third_party/webrtc/base/scoped_ref_ptr.h" | 19 #include "third_party/webrtc/base/scoped_ref_ptr.h" |
| 20 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 20 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
| 24 class WaitableEvent; | 24 class WaitableEvent; |
| 25 } // namespace base | 25 } // namespace base |
| 26 | 26 |
| 27 namespace net { | |
| 28 class URLRequestContextGetter; | |
| 29 } // namespace net | |
| 30 | |
| 31 namespace webrtc { | 27 namespace webrtc { |
| 32 class MediaStreamInterface; | 28 class MediaStreamInterface; |
| 33 } // namespace webrtc | 29 } // namespace webrtc |
| 34 | 30 |
| 35 namespace remoting { | 31 namespace remoting { |
| 36 | 32 |
| 37 class CastCreateSessionDescriptionObserver; | 33 class CastCreateSessionDescriptionObserver; |
| 38 | 34 |
| 39 namespace protocol { | 35 namespace protocol { |
| 40 struct NetworkSettings; | 36 class TransportContext; |
| 41 } // namespace protocol | 37 } // namespace protocol |
| 42 | 38 |
| 43 // A HostExtensionSession implementation that enables WebRTC support using | 39 // A HostExtensionSession implementation that enables WebRTC support using |
| 44 // the PeerConnection native API. | 40 // the PeerConnection native API. |
| 45 class CastExtensionSession : public HostExtensionSession, | 41 class CastExtensionSession : public HostExtensionSession, |
| 46 public webrtc::PeerConnectionObserver { | 42 public webrtc::PeerConnectionObserver { |
| 47 public: | 43 public: |
| 48 ~CastExtensionSession() override; | 44 ~CastExtensionSession() override; |
| 49 | 45 |
| 50 // Creates and returns a CastExtensionSession object, after performing | 46 // Creates and returns a CastExtensionSession object, after performing |
| 51 // initialization steps on it. The caller must take ownership of the returned | 47 // initialization steps on it. The caller must take ownership of the returned |
| 52 // object. | 48 // object. |
| 53 static scoped_ptr<CastExtensionSession> Create( | 49 static scoped_ptr<CastExtensionSession> Create( |
| 54 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 50 scoped_refptr<protocol::TransportContext> transport_context, |
| 55 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | |
| 56 const protocol::NetworkSettings& network_settings, | |
| 57 ClientSessionControl* client_session_control, | 51 ClientSessionControl* client_session_control, |
| 58 protocol::ClientStub* client_stub); | 52 protocol::ClientStub* client_stub); |
| 59 | 53 |
| 60 // Called by webrtc::CreateSessionDescriptionObserver implementation. | 54 // Called by webrtc::CreateSessionDescriptionObserver implementation. |
| 61 void OnCreateSessionDescription(webrtc::SessionDescriptionInterface* desc); | 55 void OnCreateSessionDescription(webrtc::SessionDescriptionInterface* desc); |
| 62 void OnCreateSessionDescriptionFailure(const std::string& error); | 56 void OnCreateSessionDescriptionFailure(const std::string& error); |
| 63 | 57 |
| 64 // HostExtensionSession interface. | 58 // HostExtensionSession interface. |
| 65 void OnCreateVideoCapturer( | 59 void OnCreateVideoCapturer( |
| 66 scoped_ptr<webrtc::DesktopCapturer>* capturer) override; | 60 scoped_ptr<webrtc::DesktopCapturer>* capturer) override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 void OnRenegotiationNeeded() override; | 74 void OnRenegotiationNeeded() override; |
| 81 void OnIceConnectionChange( | 75 void OnIceConnectionChange( |
| 82 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; | 76 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; |
| 83 void OnIceGatheringChange( | 77 void OnIceGatheringChange( |
| 84 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; | 78 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; |
| 85 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; | 79 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; |
| 86 void OnIceComplete() override; | 80 void OnIceComplete() override; |
| 87 | 81 |
| 88 private: | 82 private: |
| 89 CastExtensionSession( | 83 CastExtensionSession( |
| 90 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 84 scoped_refptr<protocol::TransportContext> transport_context, |
| 91 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | |
| 92 const protocol::NetworkSettings& network_settings, | |
| 93 ClientSessionControl* client_session_control, | 85 ClientSessionControl* client_session_control, |
| 94 protocol::ClientStub* client_stub); | 86 protocol::ClientStub* client_stub); |
| 95 | 87 |
| 96 // Parses |message| for a Session Description and sets the remote | 88 // Parses |message| for a Session Description and sets the remote |
| 97 // description, returning true if successful. | 89 // description, returning true if successful. |
| 98 bool ParseAndSetRemoteDescription(base::DictionaryValue* message); | 90 bool ParseAndSetRemoteDescription(base::DictionaryValue* message); |
| 99 | 91 |
| 100 // Parses |message| for a PeerConnection ICE candidate and adds it to the | 92 // Parses |message| for a PeerConnection ICE candidate and adds it to the |
| 101 // Peer Connection, returning true if successful. | 93 // Peer Connection, returning true if successful. |
| 102 bool ParseAndAddICECandidate(base::DictionaryValue* message); | 94 bool ParseAndAddICECandidate(base::DictionaryValue* message); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 184 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 193 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | 185 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
| 194 | 186 |
| 195 // Objects related to the WebRTC PeerConnection. | 187 // Objects related to the WebRTC PeerConnection. |
| 196 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 188 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 197 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_conn_factory_; | 189 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_conn_factory_; |
| 198 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_; | 190 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_; |
| 199 rtc::scoped_refptr<CastCreateSessionDescriptionObserver> | 191 rtc::scoped_refptr<CastCreateSessionDescriptionObserver> |
| 200 create_session_desc_observer_; | 192 create_session_desc_observer_; |
| 201 | 193 |
| 202 // Parameters passed to ChromiumPortAllocator on creation. | 194 // TransportContext for P2P transport. |
| 203 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 195 scoped_refptr<protocol::TransportContext> transport_context_; |
| 204 const protocol::NetworkSettings& network_settings_; | |
| 205 | 196 |
| 206 // Interface to interact with ClientSession. | 197 // Interface to interact with ClientSession. |
| 207 ClientSessionControl* client_session_control_; | 198 ClientSessionControl* client_session_control_; |
| 208 | 199 |
| 209 // Interface through which messages can be sent to the client. | 200 // Interface through which messages can be sent to the client. |
| 210 protocol::ClientStub* client_stub_; | 201 protocol::ClientStub* client_stub_; |
| 211 | 202 |
| 212 // Used to track webrtc connection statistics. | 203 // Used to track webrtc connection statistics. |
| 213 rtc::scoped_refptr<webrtc::StatsObserver> stats_observer_; | 204 rtc::scoped_refptr<webrtc::StatsObserver> stats_observer_; |
| 214 | 205 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 233 | 224 |
| 234 // Worker thread that is wrapped to create |worker_thread_wrapper_|. | 225 // Worker thread that is wrapped to create |worker_thread_wrapper_|. |
| 235 base::Thread worker_thread_; | 226 base::Thread worker_thread_; |
| 236 | 227 |
| 237 DISALLOW_COPY_AND_ASSIGN(CastExtensionSession); | 228 DISALLOW_COPY_AND_ASSIGN(CastExtensionSession); |
| 238 }; | 229 }; |
| 239 | 230 |
| 240 } // namespace remoting | 231 } // namespace remoting |
| 241 | 232 |
| 242 #endif // REMOTING_HOST_CAST_EXTENSION_SESSION_H_ | 233 #endif // REMOTING_HOST_CAST_EXTENSION_SESSION_H_ |
| OLD | NEW |