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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "remoting/protocol/webrtc_video_capturer_adapter.h" | 24 #include "remoting/protocol/webrtc_video_capturer_adapter.h" |
25 #include "remoting/protocol/webrtc_video_stream.h" | 25 #include "remoting/protocol/webrtc_video_stream.h" |
26 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 26 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
27 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" | 27 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" |
28 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" | 28 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" |
29 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" | 29 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" |
30 | 30 |
31 namespace remoting { | 31 namespace remoting { |
32 namespace protocol { | 32 namespace protocol { |
33 | 33 |
34 const char kStreamLabel[] = "screen_stream"; | |
35 const char kVideoLabel[] = "screen_video"; | |
36 | |
37 // 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. |
38 // | 35 // |
39 // 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 |
40 // thread as a worker thread. | 37 // thread as a worker thread. |
41 WebrtcConnectionToClient::WebrtcConnectionToClient( | 38 WebrtcConnectionToClient::WebrtcConnectionToClient( |
42 scoped_ptr<protocol::Session> session, | 39 scoped_ptr<protocol::Session> session, |
43 scoped_refptr<protocol::TransportContext> transport_context) | 40 scoped_refptr<protocol::TransportContext> transport_context) |
44 : transport_(jingle_glue::JingleThreadWrapper::current(), | 41 : transport_(jingle_glue::JingleThreadWrapper::current(), |
45 transport_context, | 42 transport_context, |
46 this), | 43 this), |
(...skipping 25 matching lines...) Expand all Loading... |
72 session_->Close(error); | 69 session_->Close(error); |
73 } | 70 } |
74 | 71 |
75 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { | 72 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { |
76 DCHECK(thread_checker_.CalledOnValidThread()); | 73 DCHECK(thread_checker_.CalledOnValidThread()); |
77 event_handler_->OnInputEventReceived(this, timestamp); | 74 event_handler_->OnInputEventReceived(this, timestamp); |
78 } | 75 } |
79 | 76 |
80 scoped_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( | 77 scoped_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( |
81 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { | 78 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { |
82 scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( | 79 scoped_ptr<WebrtcVideoStream> stream(new WebrtcVideoStream()); |
83 new WebrtcVideoCapturerAdapter(std::move(desktop_capturer))); | 80 if (!stream->Start(std::move(desktop_capturer), transport_.peer_connection(), |
84 | 81 transport_.peer_connection_factory())) { |
85 // Set video stream constraints. | |
86 webrtc::FakeConstraints video_constraints; | |
87 video_constraints.AddMandatory( | |
88 webrtc::MediaConstraintsInterface::kMinFrameRate, 5); | |
89 | |
90 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = | |
91 transport_.peer_connection_factory()->CreateVideoTrack( | |
92 kVideoLabel, | |
93 transport_.peer_connection_factory()->CreateVideoSource( | |
94 video_capturer_adapter.release(), &video_constraints)); | |
95 | |
96 rtc::scoped_refptr<webrtc::MediaStreamInterface> video_stream = | |
97 transport_.peer_connection_factory()->CreateLocalMediaStream( | |
98 kStreamLabel); | |
99 | |
100 if (!video_stream->AddTrack(video_track) || | |
101 !transport_.peer_connection()->AddStream(video_stream)) { | |
102 return nullptr; | 82 return nullptr; |
103 } | 83 } |
| 84 return std::move(stream); |
104 | 85 |
105 return make_scoped_ptr( | |
106 new WebrtcVideoStream(transport_.peer_connection(), video_stream)); | |
107 } | 86 } |
108 | 87 |
109 AudioStub* WebrtcConnectionToClient::audio_stub() { | 88 AudioStub* WebrtcConnectionToClient::audio_stub() { |
110 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
111 return nullptr; | 90 return nullptr; |
112 } | 91 } |
113 | 92 |
114 // Return pointer to ClientStub. | 93 // Return pointer to ClientStub. |
115 ClientStub* WebrtcConnectionToClient::client_stub() { | 94 ClientStub* WebrtcConnectionToClient::client_stub() { |
116 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ErrorCode error) { | 167 ErrorCode error) { |
189 DCHECK(thread_checker_.CalledOnValidThread()); | 168 DCHECK(thread_checker_.CalledOnValidThread()); |
190 | 169 |
191 LOG(ERROR) << "Failed to connect channel " | 170 LOG(ERROR) << "Failed to connect channel " |
192 << channel_dispatcher->channel_name(); | 171 << channel_dispatcher->channel_name(); |
193 Disconnect(error); | 172 Disconnect(error); |
194 } | 173 } |
195 | 174 |
196 } // namespace protocol | 175 } // namespace protocol |
197 } // namespace remoting | 176 } // namespace remoting |
OLD | NEW |