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 | |
9 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 scoped_ptr<media::AudioBus> audio_bus = | 430 scoped_ptr<media::AudioBus> audio_bus = |
431 media::AudioBus::Create(output_channels_, converter_->ChunkSize()); | 431 media::AudioBus::Create(output_channels_, converter_->ChunkSize()); |
432 // AudioConverter will call ProvideInput() to fetch from |current_data_|. | 432 // AudioConverter will call ProvideInput() to fetch from |current_data_|. |
433 current_input_bus_ = &input_bus; | 433 current_input_bus_ = &input_bus; |
434 converter_->Convert(audio_bus.get()); | 434 converter_->Convert(audio_bus.get()); |
435 DCHECK(!current_input_bus_); // ProvideInput() called exactly once? | 435 DCHECK(!current_input_bus_); // ProvideInput() called exactly once? |
436 | 436 |
437 sample_frames_in_ += input_params_.frames_per_buffer(); | 437 sample_frames_in_ += input_params_.frames_per_buffer(); |
438 sample_frames_out_ += audio_bus->frames(); | 438 sample_frames_out_ += audio_bus->frames(); |
439 | 439 |
440 frame_input_->InsertAudio(audio_bus.Pass(), | 440 frame_input_->InsertAudio(std::move(audio_bus), |
441 capture_time_of_first_converted_sample); | 441 capture_time_of_first_converted_sample); |
442 } | 442 } |
443 | 443 |
444 // Called on real-time audio thread. | 444 // Called on real-time audio thread. |
445 void OnSetFormat(const media::AudioParameters& params) override { | 445 void OnSetFormat(const media::AudioParameters& params) override { |
446 if (input_params_.Equals(params)) | 446 if (input_params_.Equals(params)) |
447 return; | 447 return; |
448 input_params_ = params; | 448 input_params_ = params; |
449 | 449 |
450 DVLOG(1) << "Setting up audio resampling: {" | 450 DVLOG(1) << "Setting up audio resampling: {" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 DCHECK(content::RenderThread::Get()); | 627 DCHECK(content::RenderThread::Get()); |
628 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " | 628 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " |
629 << (IsAudio() ? "audio" : "video"); | 629 << (IsAudio() ? "audio" : "video"); |
630 // Save the WeakPtr first because the error callback might delete this object. | 630 // Save the WeakPtr first because the error callback might delete this object. |
631 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 631 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
632 error_callback_.Run(message); | 632 error_callback_.Run(message); |
633 base::ThreadTaskRunnerHandle::Get()->PostTask( | 633 base::ThreadTaskRunnerHandle::Get()->PostTask( |
634 FROM_HERE, | 634 FROM_HERE, |
635 base::Bind(&CastRtpStream::Stop, ptr)); | 635 base::Bind(&CastRtpStream::Stop, ptr)); |
636 } | 636 } |
OLD | NEW |