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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/timer/timer.h" | 22 #include "base/timer/timer.h" |
23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 24 #include "base/values.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/renderer/media/cast_session.h" | 26 #include "chrome/renderer/media/cast_session.h" |
26 #include "chrome/renderer/media/cast_udp_transport.h" | 27 #include "chrome/renderer/media/cast_udp_transport.h" |
27 #include "content/public/renderer/media_stream_audio_sink.h" | 28 #include "content/public/renderer/media_stream_audio_sink.h" |
28 #include "content/public/renderer/media_stream_utils.h" | 29 #include "content/public/renderer/media_stream_utils.h" |
29 #include "content/public/renderer/media_stream_video_sink.h" | 30 #include "content/public/renderer/media_stream_video_sink.h" |
30 #include "content/public/renderer/render_thread.h" | 31 #include "content/public/renderer/render_thread.h" |
31 #include "content/public/renderer/video_encode_accelerator.h" | 32 #include "content/public/renderer/video_encode_accelerator.h" |
32 #include "media/base/audio_bus.h" | 33 #include "media/base/audio_bus.h" |
33 #include "media/base/audio_converter.h" | 34 #include "media/base/audio_converter.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 base::ResetAndReturn(&stop_callback_).Run(); | 555 base::ResetAndReturn(&stop_callback_).Run(); |
555 } | 556 } |
556 | 557 |
557 void CastRtpStream::ToggleLogging(bool enable) { | 558 void CastRtpStream::ToggleLogging(bool enable) { |
558 DVLOG(1) << "CastRtpStream::ToggleLogging(" << enable | 559 DVLOG(1) << "CastRtpStream::ToggleLogging(" << enable |
559 << ") = " << (is_audio_ ? "audio" : "video"); | 560 << ") = " << (is_audio_ ? "audio" : "video"); |
560 cast_session_->ToggleLogging(is_audio_, enable); | 561 cast_session_->ToggleLogging(is_audio_, enable); |
561 } | 562 } |
562 | 563 |
563 void CastRtpStream::GetRawEvents( | 564 void CastRtpStream::GetRawEvents( |
564 const base::Callback<void(std::unique_ptr<base::BinaryValue>)>& callback, | 565 const base::Callback<void(std::unique_ptr<base::Value>)>& callback, |
565 const std::string& extra_data) { | 566 const std::string& extra_data) { |
566 DVLOG(1) << "CastRtpStream::GetRawEvents = " | 567 DVLOG(1) << "CastRtpStream::GetRawEvents = " |
567 << (is_audio_ ? "audio" : "video"); | 568 << (is_audio_ ? "audio" : "video"); |
568 cast_session_->GetEventLogsAndReset(is_audio_, extra_data, callback); | 569 cast_session_->GetEventLogsAndReset(is_audio_, extra_data, callback); |
569 } | 570 } |
570 | 571 |
571 void CastRtpStream::GetStats( | 572 void CastRtpStream::GetStats( |
572 const base::Callback<void(std::unique_ptr<base::DictionaryValue>)>& | 573 const base::Callback<void(std::unique_ptr<base::DictionaryValue>)>& |
573 callback) { | 574 callback) { |
574 DVLOG(1) << "CastRtpStream::GetStats = " << (is_audio_ ? "audio" : "video"); | 575 DVLOG(1) << "CastRtpStream::GetStats = " << (is_audio_ ? "audio" : "video"); |
575 cast_session_->GetStatsAndReset(is_audio_, callback); | 576 cast_session_->GetStatsAndReset(is_audio_, callback); |
576 } | 577 } |
577 | 578 |
578 void CastRtpStream::DidEncounterError(const std::string& message) { | 579 void CastRtpStream::DidEncounterError(const std::string& message) { |
579 DCHECK(content::RenderThread::Get()); | 580 DCHECK(content::RenderThread::Get()); |
580 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message | 581 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message |
581 << ") = " << (is_audio_ ? "audio" : "video"); | 582 << ") = " << (is_audio_ ? "audio" : "video"); |
582 // Save the WeakPtr first because the error callback might delete this object. | 583 // Save the WeakPtr first because the error callback might delete this object. |
583 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 584 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
584 error_callback_.Run(message); | 585 error_callback_.Run(message); |
585 base::ThreadTaskRunnerHandle::Get()->PostTask( | 586 base::ThreadTaskRunnerHandle::Get()->PostTask( |
586 FROM_HERE, | 587 FROM_HERE, |
587 base::Bind(&CastRtpStream::Stop, ptr)); | 588 base::Bind(&CastRtpStream::Stop, ptr)); |
588 } | 589 } |
OLD | NEW |