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 #include "remoting/protocol/webrtc_connection_to_client.h" | 5 #include "remoting/protocol/webrtc_connection_to_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "jingle/glue/thread_wrapper.h" | 11 #include "jingle/glue/thread_wrapper.h" |
12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
13 #include "remoting/codec/video_encoder.h" | 13 #include "remoting/codec/video_encoder.h" |
14 #include "remoting/codec/webrtc_video_encoder_vpx.h" | 14 #include "remoting/codec/webrtc_video_encoder_vpx.h" |
15 #include "remoting/protocol/audio_source.h" | 15 #include "remoting/protocol/audio_source.h" |
16 #include "remoting/protocol/audio_stream.h" | 16 #include "remoting/protocol/audio_stream.h" |
17 #include "remoting/protocol/clipboard_stub.h" | 17 #include "remoting/protocol/clipboard_stub.h" |
18 #include "remoting/protocol/host_control_dispatcher.h" | 18 #include "remoting/protocol/host_control_dispatcher.h" |
19 #include "remoting/protocol/host_event_dispatcher.h" | 19 #include "remoting/protocol/host_event_dispatcher.h" |
20 #include "remoting/protocol/host_stub.h" | 20 #include "remoting/protocol/host_stub.h" |
21 #include "remoting/protocol/input_stub.h" | 21 #include "remoting/protocol/input_stub.h" |
22 #include "remoting/protocol/message_pipe.h" | 22 #include "remoting/protocol/message_pipe.h" |
23 #include "remoting/protocol/transport_context.h" | 23 #include "remoting/protocol/transport_context.h" |
24 #include "remoting/protocol/webrtc_audio_stream.h" | |
24 #include "remoting/protocol/webrtc_transport.h" | 25 #include "remoting/protocol/webrtc_transport.h" |
25 #include "remoting/protocol/webrtc_video_stream.h" | 26 #include "remoting/protocol/webrtc_video_stream.h" |
26 #include "third_party/webrtc/api/mediastreaminterface.h" | 27 #include "third_party/webrtc/api/mediastreaminterface.h" |
27 #include "third_party/webrtc/api/peerconnectioninterface.h" | 28 #include "third_party/webrtc/api/peerconnectioninterface.h" |
28 #include "third_party/webrtc/api/test/fakeconstraints.h" | 29 #include "third_party/webrtc/api/test/fakeconstraints.h" |
29 | 30 |
30 namespace remoting { | 31 namespace remoting { |
31 namespace protocol { | 32 namespace protocol { |
32 | 33 |
33 // Currently the network thread is also used as worker thread for webrtc. | 34 // Currently the network thread is also used as worker thread for webrtc. |
34 // | 35 // |
35 // TODO(sergeyu): Figure out if we would benefit from using a separate | 36 // TODO(sergeyu): Figure out if we would benefit from using a separate |
36 // thread as a worker thread. | 37 // thread as a worker thread. |
37 WebrtcConnectionToClient::WebrtcConnectionToClient( | 38 WebrtcConnectionToClient::WebrtcConnectionToClient( |
38 std::unique_ptr<protocol::Session> session, | 39 std::unique_ptr<protocol::Session> session, |
39 scoped_refptr<protocol::TransportContext> transport_context, | 40 scoped_refptr<protocol::TransportContext> transport_context, |
40 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) | 41 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
42 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) | |
41 : transport_( | 43 : transport_( |
42 new WebrtcTransport(jingle_glue::JingleThreadWrapper::current(), | 44 new WebrtcTransport(jingle_glue::JingleThreadWrapper::current(), |
43 transport_context, | 45 transport_context, |
44 this)), | 46 this)), |
45 session_(std::move(session)), | 47 session_(std::move(session)), |
46 video_encode_task_runner_(video_encode_task_runner), | 48 video_encode_task_runner_(video_encode_task_runner), |
49 audio_task_runner_(audio_task_runner), | |
47 control_dispatcher_(new HostControlDispatcher()), | 50 control_dispatcher_(new HostControlDispatcher()), |
48 event_dispatcher_(new HostEventDispatcher()), | 51 event_dispatcher_(new HostEventDispatcher()), |
49 weak_factory_(this) { | 52 weak_factory_(this) { |
50 session_->SetEventHandler(this); | 53 session_->SetEventHandler(this); |
51 session_->SetTransport(transport_.get()); | 54 session_->SetTransport(transport_.get()); |
52 } | 55 } |
53 | 56 |
54 WebrtcConnectionToClient::~WebrtcConnectionToClient() {} | 57 WebrtcConnectionToClient::~WebrtcConnectionToClient() {} |
55 | 58 |
56 void WebrtcConnectionToClient::SetEventHandler( | 59 void WebrtcConnectionToClient::SetEventHandler( |
(...skipping 20 matching lines...) Expand all Loading... | |
77 std::unique_ptr<WebrtcVideoStream> stream(new WebrtcVideoStream()); | 80 std::unique_ptr<WebrtcVideoStream> stream(new WebrtcVideoStream()); |
78 if (!stream->Start(std::move(desktop_capturer), transport_.get(), | 81 if (!stream->Start(std::move(desktop_capturer), transport_.get(), |
79 video_encode_task_runner_)) { | 82 video_encode_task_runner_)) { |
80 return nullptr; | 83 return nullptr; |
81 } | 84 } |
82 return std::move(stream); | 85 return std::move(stream); |
83 } | 86 } |
84 | 87 |
85 std::unique_ptr<AudioStream> WebrtcConnectionToClient::StartAudioStream( | 88 std::unique_ptr<AudioStream> WebrtcConnectionToClient::StartAudioStream( |
86 std::unique_ptr<AudioSource> audio_source) { | 89 std::unique_ptr<AudioSource> audio_source) { |
87 NOTIMPLEMENTED(); | 90 std::unique_ptr<WebrtcAudioStream> stream(new WebrtcAudioStream()); |
88 return nullptr; | 91 if (!stream->Start(audio_task_runner_, std::move(audio_source), |
92 transport_.get())) { | |
93 return nullptr; | |
Jamie
2016/10/04 23:36:06
Do we get an error log in Start()? If not then ple
Sergey Ulanov
2016/10/05 21:52:23
Actually Start() is not expected to fail. Updated
| |
94 } | |
95 return std::move(stream); | |
89 } | 96 } |
90 | 97 |
91 // Return pointer to ClientStub. | 98 // Return pointer to ClientStub. |
92 ClientStub* WebrtcConnectionToClient::client_stub() { | 99 ClientStub* WebrtcConnectionToClient::client_stub() { |
93 DCHECK(thread_checker_.CalledOnValidThread()); | 100 DCHECK(thread_checker_.CalledOnValidThread()); |
94 return control_dispatcher_.get(); | 101 return control_dispatcher_.get(); |
95 } | 102 } |
96 | 103 |
97 void WebrtcConnectionToClient::set_clipboard_stub( | 104 void WebrtcConnectionToClient::set_clipboard_stub( |
98 protocol::ClipboardStub* clipboard_stub) { | 105 protocol::ClipboardStub* clipboard_stub) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 Disconnect(INCOMPATIBLE_PROTOCOL); | 211 Disconnect(INCOMPATIBLE_PROTOCOL); |
205 } | 212 } |
206 | 213 |
207 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { | 214 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { |
208 DCHECK(thread_checker_.CalledOnValidThread()); | 215 DCHECK(thread_checker_.CalledOnValidThread()); |
209 event_handler_->OnInputEventReceived(timestamp); | 216 event_handler_->OnInputEventReceived(timestamp); |
210 } | 217 } |
211 | 218 |
212 } // namespace protocol | 219 } // namespace protocol |
213 } // namespace remoting | 220 } // namespace remoting |
OLD | NEW |