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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void CastExtensionSession::OnCreateSessionDescriptionFailure( | 227 void CastExtensionSession::OnCreateSessionDescriptionFailure( |
228 const std::string& error) { | 228 const std::string& error) { |
229 VLOG(1) << "Creating Session Description failed: " << error; | 229 VLOG(1) << "Creating Session Description failed: " << error; |
230 } | 230 } |
231 | 231 |
232 // TODO(aiguha): Support the case(s) where we've grabbed the capturer already, | 232 // TODO(aiguha): Support the case(s) where we've grabbed the capturer already, |
233 // but another extension reset the video pipeline. We should remove the | 233 // but another extension reset the video pipeline. We should remove the |
234 // stream from the peer connection here, and then attempt to re-setup the | 234 // stream from the peer connection here, and then attempt to re-setup the |
235 // peer connection in the OnRenegotiationNeeded() callback. | 235 // peer connection in the OnRenegotiationNeeded() callback. |
236 // See crbug.com/403843. | 236 // See crbug.com/403843. |
237 scoped_ptr<webrtc::DesktopCapturer> CastExtensionSession::OnCreateVideoCapturer( | 237 void CastExtensionSession::OnCreateVideoCapturer( |
238 scoped_ptr<webrtc::DesktopCapturer> capturer) { | 238 scoped_ptr<webrtc::DesktopCapturer>* capturer) { |
239 if (has_grabbed_capturer_) { | 239 if (has_grabbed_capturer_) { |
240 LOG(ERROR) << "The video pipeline was reset unexpectedly."; | 240 LOG(ERROR) << "The video pipeline was reset unexpectedly."; |
241 has_grabbed_capturer_ = false; | 241 has_grabbed_capturer_ = false; |
242 peer_connection_->RemoveStream(stream_.release()); | 242 peer_connection_->RemoveStream(stream_.release()); |
243 return capturer.Pass(); | 243 return; |
244 } | 244 } |
245 | 245 |
246 if (received_offer_) { | 246 if (received_offer_) { |
247 has_grabbed_capturer_ = true; | 247 has_grabbed_capturer_ = true; |
248 if (SetupVideoStream(capturer.Pass())) { | 248 if (SetupVideoStream(capturer->Pass())) { |
249 peer_connection_->CreateAnswer(create_session_desc_observer_, NULL); | 249 peer_connection_->CreateAnswer(create_session_desc_observer_, NULL); |
250 } else { | 250 } else { |
251 has_grabbed_capturer_ = false; | 251 has_grabbed_capturer_ = false; |
252 // Ignore the received offer, since we failed to setup a video stream. | 252 // Ignore the received offer, since we failed to setup a video stream. |
253 received_offer_ = false; | 253 received_offer_ = false; |
254 } | 254 } |
255 return scoped_ptr<webrtc::DesktopCapturer>(); | 255 return; |
256 } | 256 } |
257 | |
258 return capturer.Pass(); | |
259 } | 257 } |
260 | 258 |
261 bool CastExtensionSession::ModifiesVideoPipeline() const { | 259 bool CastExtensionSession::ModifiesVideoPipeline() const { |
262 return true; | 260 return true; |
263 } | 261 } |
264 | 262 |
265 // Returns true if the |message| is a Cast ExtensionMessage, even if | 263 // Returns true if the |message| is a Cast ExtensionMessage, even if |
266 // it was badly formed or a resulting action failed. This is done so that | 264 // it was badly formed or a resulting action failed. This is done so that |
267 // the host does not continue to attempt to pass |message| to other | 265 // the host does not continue to attempt to pass |message| to other |
268 // HostExtensionSessions. | 266 // HostExtensionSessions. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 json->SetString(kWebRtcCandidate, candidate_str); | 663 json->SetString(kWebRtcCandidate, candidate_str); |
666 std::string json_str; | 664 std::string json_str; |
667 if (!base::JSONWriter::Write(json.get(), &json_str)) { | 665 if (!base::JSONWriter::Write(json.get(), &json_str)) { |
668 LOG(ERROR) << "Failed to serialize candidate message."; | 666 LOG(ERROR) << "Failed to serialize candidate message."; |
669 return; | 667 return; |
670 } | 668 } |
671 SendMessageToClient(kSubjectNewCandidate, json_str); | 669 SendMessageToClient(kSubjectNewCandidate, json_str); |
672 } | 670 } |
673 | 671 |
674 } // namespace remoting | 672 } // namespace remoting |
675 | |
OLD | NEW |