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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "remoting/codec/video_encoder.h" | 10 #include "remoting/codec/video_encoder.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 event_handler_->OnInputEventReceived(this, timestamp); | 67 event_handler_->OnInputEventReceived(this, timestamp); |
68 } | 68 } |
69 | 69 |
70 scoped_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( | 70 scoped_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( |
71 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { | 71 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { |
72 // TODO(sergeyu): Reconsider Transport interface and how it's used here. | 72 // TODO(sergeyu): Reconsider Transport interface and how it's used here. |
73 WebrtcTransport* transport = session_->GetTransport()->AsWebrtcTransport(); | 73 WebrtcTransport* transport = session_->GetTransport()->AsWebrtcTransport(); |
74 CHECK(transport); | 74 CHECK(transport); |
75 | 75 |
76 scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( | 76 scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( |
77 new WebrtcVideoCapturerAdapter(desktop_capturer.Pass())); | 77 new WebrtcVideoCapturerAdapter(std::move(desktop_capturer))); |
78 | 78 |
79 // Set video stream constraints. | 79 // Set video stream constraints. |
80 webrtc::FakeConstraints video_constraints; | 80 webrtc::FakeConstraints video_constraints; |
81 video_constraints.AddMandatory( | 81 video_constraints.AddMandatory( |
82 webrtc::MediaConstraintsInterface::kMinFrameRate, 5); | 82 webrtc::MediaConstraintsInterface::kMinFrameRate, 5); |
83 | 83 |
84 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = | 84 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = |
85 transport->peer_connection_factory()->CreateVideoTrack( | 85 transport->peer_connection_factory()->CreateVideoTrack( |
86 kVideoLabel, | 86 kVideoLabel, |
87 transport->peer_connection_factory()->CreateVideoSource( | 87 transport->peer_connection_factory()->CreateVideoSource( |
88 video_capturer_adapter.release(), &video_constraints)); | 88 video_capturer_adapter.release(), &video_constraints)); |
89 | 89 |
90 rtc::scoped_refptr<webrtc::MediaStreamInterface> video_stream = | 90 rtc::scoped_refptr<webrtc::MediaStreamInterface> video_stream = |
91 transport->peer_connection_factory()->CreateLocalMediaStream( | 91 transport->peer_connection_factory()->CreateLocalMediaStream( |
92 kStreamLabel); | 92 kStreamLabel); |
93 | 93 |
94 if (!video_stream->AddTrack(video_track) || | 94 if (!video_stream->AddTrack(video_track) || |
95 !transport->peer_connection()->AddStream(video_stream)) { | 95 !transport->peer_connection()->AddStream(video_stream)) { |
96 return nullptr; | 96 return nullptr; |
97 } | 97 } |
98 | 98 |
99 scoped_ptr<VideoStream> result( | 99 return make_scoped_ptr( |
100 new WebrtcVideoStream(transport->peer_connection(), video_stream)); | 100 new WebrtcVideoStream(transport->peer_connection(), video_stream)); |
101 return result.Pass(); | |
102 } | 101 } |
103 | 102 |
104 AudioStub* WebrtcConnectionToClient::audio_stub() { | 103 AudioStub* WebrtcConnectionToClient::audio_stub() { |
105 DCHECK(thread_checker_.CalledOnValidThread()); | 104 DCHECK(thread_checker_.CalledOnValidThread()); |
106 return nullptr; | 105 return nullptr; |
107 } | 106 } |
108 | 107 |
109 // Return pointer to ClientStub. | 108 // Return pointer to ClientStub. |
110 ClientStub* WebrtcConnectionToClient::client_stub() { | 109 ClientStub* WebrtcConnectionToClient::client_stub() { |
111 DCHECK(thread_checker_.CalledOnValidThread()); | 110 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ErrorCode error) { | 188 ErrorCode error) { |
190 DCHECK(thread_checker_.CalledOnValidThread()); | 189 DCHECK(thread_checker_.CalledOnValidThread()); |
191 | 190 |
192 LOG(ERROR) << "Failed to connect channel " | 191 LOG(ERROR) << "Failed to connect channel " |
193 << channel_dispatcher->channel_name(); | 192 << channel_dispatcher->channel_name(); |
194 session_->Close(CHANNEL_CONNECTION_ERROR); | 193 session_->Close(CHANNEL_CONNECTION_ERROR); |
195 } | 194 } |
196 | 195 |
197 } // namespace protocol | 196 } // namespace protocol |
198 } // namespace remoting | 197 } // namespace remoting |
OLD | NEW |