| 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 #include "remoting/host/cast_extension_session.h" | 5 #include "remoting/host/cast_extension_session.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 13 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
| 14 #include "remoting/host/client_session.h" | 16 #include "remoting/host/client_session.h" |
| 15 #include "remoting/proto/control.pb.h" | 17 #include "remoting/proto/control.pb.h" |
| 16 #include "remoting/protocol/chromium_port_allocator.h" | 18 #include "remoting/protocol/chromium_port_allocator.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 scoped_ptr<CastExtensionSession> cast_extension_session( | 177 scoped_ptr<CastExtensionSession> cast_extension_session( |
| 176 new CastExtensionSession(caller_task_runner, | 178 new CastExtensionSession(caller_task_runner, |
| 177 url_request_context_getter, | 179 url_request_context_getter, |
| 178 network_settings, | 180 network_settings, |
| 179 client_session_control, | 181 client_session_control, |
| 180 client_stub)); | 182 client_stub)); |
| 181 if (!cast_extension_session->WrapTasksAndSave() || | 183 if (!cast_extension_session->WrapTasksAndSave() || |
| 182 !cast_extension_session->InitializePeerConnection()) { | 184 !cast_extension_session->InitializePeerConnection()) { |
| 183 return nullptr; | 185 return nullptr; |
| 184 } | 186 } |
| 185 return cast_extension_session.Pass(); | 187 return cast_extension_session; |
| 186 } | 188 } |
| 187 | 189 |
| 188 void CastExtensionSession::OnCreateSessionDescription( | 190 void CastExtensionSession::OnCreateSessionDescription( |
| 189 webrtc::SessionDescriptionInterface* desc) { | 191 webrtc::SessionDescriptionInterface* desc) { |
| 190 if (!caller_task_runner_->BelongsToCurrentThread()) { | 192 if (!caller_task_runner_->BelongsToCurrentThread()) { |
| 191 caller_task_runner_->PostTask( | 193 caller_task_runner_->PostTask( |
| 192 FROM_HERE, | 194 FROM_HERE, |
| 193 base::Bind(&CastExtensionSession::OnCreateSessionDescription, | 195 base::Bind(&CastExtensionSession::OnCreateSessionDescription, |
| 194 base::Unretained(this), | 196 base::Unretained(this), |
| 195 desc)); | 197 desc)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 scoped_ptr<webrtc::DesktopCapturer>* capturer) { | 231 scoped_ptr<webrtc::DesktopCapturer>* capturer) { |
| 230 if (has_grabbed_capturer_) { | 232 if (has_grabbed_capturer_) { |
| 231 LOG(ERROR) << "The video pipeline was reset unexpectedly."; | 233 LOG(ERROR) << "The video pipeline was reset unexpectedly."; |
| 232 has_grabbed_capturer_ = false; | 234 has_grabbed_capturer_ = false; |
| 233 peer_connection_->RemoveStream(stream_.release()); | 235 peer_connection_->RemoveStream(stream_.release()); |
| 234 return; | 236 return; |
| 235 } | 237 } |
| 236 | 238 |
| 237 if (received_offer_) { | 239 if (received_offer_) { |
| 238 has_grabbed_capturer_ = true; | 240 has_grabbed_capturer_ = true; |
| 239 if (SetupVideoStream(capturer->Pass())) { | 241 if (SetupVideoStream(std::move(*capturer))) { |
| 240 peer_connection_->CreateAnswer(create_session_desc_observer_, nullptr); | 242 peer_connection_->CreateAnswer(create_session_desc_observer_, nullptr); |
| 241 } else { | 243 } else { |
| 242 has_grabbed_capturer_ = false; | 244 has_grabbed_capturer_ = false; |
| 243 // Ignore the received offer, since we failed to setup a video stream. | 245 // Ignore the received offer, since we failed to setup a video stream. |
| 244 received_offer_ = false; | 246 received_offer_ = false; |
| 245 } | 247 } |
| 246 return; | 248 return; |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 | 251 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { | 523 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { |
| 522 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 524 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 523 DCHECK(desktop_capturer); | 525 DCHECK(desktop_capturer); |
| 524 | 526 |
| 525 if (stream_) { | 527 if (stream_) { |
| 526 VLOG(1) << "Already added MediaStream. Aborting Setup."; | 528 VLOG(1) << "Already added MediaStream. Aborting Setup."; |
| 527 return false; | 529 return false; |
| 528 } | 530 } |
| 529 | 531 |
| 530 scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( | 532 scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( |
| 531 new WebrtcVideoCapturerAdapter(desktop_capturer.Pass())); | 533 new WebrtcVideoCapturerAdapter(std::move(desktop_capturer))); |
| 532 | 534 |
| 533 // Set video stream constraints. | 535 // Set video stream constraints. |
| 534 webrtc::FakeConstraints video_constraints; | 536 webrtc::FakeConstraints video_constraints; |
| 535 video_constraints.AddMandatory( | 537 video_constraints.AddMandatory( |
| 536 webrtc::MediaConstraintsInterface::kMinFrameRate, kMinFramesPerSecond); | 538 webrtc::MediaConstraintsInterface::kMinFrameRate, kMinFramesPerSecond); |
| 537 | 539 |
| 538 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = | 540 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = |
| 539 peer_conn_factory_->CreateVideoTrack( | 541 peer_conn_factory_->CreateVideoTrack( |
| 540 kVideoLabel, | 542 kVideoLabel, |
| 541 peer_conn_factory_->CreateVideoSource( | 543 peer_conn_factory_->CreateVideoSource( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 json.SetString(kWebRtcCandidate, candidate_str); | 647 json.SetString(kWebRtcCandidate, candidate_str); |
| 646 std::string json_str; | 648 std::string json_str; |
| 647 if (!base::JSONWriter::Write(json, &json_str)) { | 649 if (!base::JSONWriter::Write(json, &json_str)) { |
| 648 LOG(ERROR) << "Failed to serialize candidate message."; | 650 LOG(ERROR) << "Failed to serialize candidate message."; |
| 649 return; | 651 return; |
| 650 } | 652 } |
| 651 SendMessageToClient(kSubjectNewCandidate, json_str); | 653 SendMessageToClient(kSubjectNewCandidate, json_str); |
| 652 } | 654 } |
| 653 | 655 |
| 654 } // namespace remoting | 656 } // namespace remoting |
| OLD | NEW |