OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/media/cast_rtp_stream.h" | 5 #include "chrome/renderer/media/cast_rtp_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 base::Bind(&CastRtpStream::DidEncounterError, | 503 base::Bind(&CastRtpStream::DidEncounterError, |
504 weak_factory_.GetWeakPtr())); | 504 weak_factory_.GetWeakPtr())); |
505 start_callback.Run(); | 505 start_callback.Run(); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 void CastRtpStream::Stop() { | 509 void CastRtpStream::Stop() { |
510 VLOG(1) << "CastRtpStream::Stop = " << (IsAudio() ? "audio" : "video"); | 510 VLOG(1) << "CastRtpStream::Stop = " << (IsAudio() ? "audio" : "video"); |
511 audio_sink_.reset(); | 511 audio_sink_.reset(); |
512 video_sink_.reset(); | 512 video_sink_.reset(); |
513 stop_callback_.Run(); | 513 if (!stop_callback_.is_null()) |
| 514 stop_callback_.Run(); |
514 } | 515 } |
515 | 516 |
516 void CastRtpStream::ToggleLogging(bool enable) { | 517 void CastRtpStream::ToggleLogging(bool enable) { |
517 cast_session_->ToggleLogging(IsAudio(), enable); | 518 cast_session_->ToggleLogging(IsAudio(), enable); |
518 } | 519 } |
519 | 520 |
520 void CastRtpStream::GetRawEvents( | 521 void CastRtpStream::GetRawEvents( |
521 const base::Callback<void(scoped_ptr<base::BinaryValue>)>& callback, | 522 const base::Callback<void(scoped_ptr<base::BinaryValue>)>& callback, |
522 const std::string& extra_data) { | 523 const std::string& extra_data) { |
523 cast_session_->GetEventLogsAndReset(IsAudio(), extra_data, callback); | 524 cast_session_->GetEventLogsAndReset(IsAudio(), extra_data, callback); |
524 } | 525 } |
525 | 526 |
526 void CastRtpStream::GetStats( | 527 void CastRtpStream::GetStats( |
527 const base::Callback<void(scoped_ptr<base::DictionaryValue>)>& callback) { | 528 const base::Callback<void(scoped_ptr<base::DictionaryValue>)>& callback) { |
528 cast_session_->GetStatsAndReset(IsAudio(), callback); | 529 cast_session_->GetStatsAndReset(IsAudio(), callback); |
529 } | 530 } |
530 | 531 |
531 bool CastRtpStream::IsAudio() const { | 532 bool CastRtpStream::IsAudio() const { |
532 return track_.source().type() == blink::WebMediaStreamSource::TypeAudio; | 533 return track_.source().type() == blink::WebMediaStreamSource::TypeAudio; |
533 } | 534 } |
534 | 535 |
535 void CastRtpStream::DidEncounterError(const std::string& message) { | 536 void CastRtpStream::DidEncounterError(const std::string& message) { |
536 // Save the WeakPtr first because the error callback might delete this object. | 537 // Save the WeakPtr first because the error callback might delete this object. |
537 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 538 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
538 error_callback_.Run(message); | 539 error_callback_.Run(message); |
539 content::RenderThread::Get()->GetMessageLoop()->PostTask( | 540 content::RenderThread::Get()->GetMessageLoop()->PostTask( |
540 FROM_HERE, | 541 FROM_HERE, |
541 base::Bind(&CastRtpStream::Stop, ptr)); | 542 base::Bind(&CastRtpStream::Stop, ptr)); |
542 } | 543 } |
OLD | NEW |