OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/audio_capturer_linux.h" | 5 #include "remoting/host/audio_capturer_linux.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 pipe_reader_->AddObserver(this); | 52 pipe_reader_->AddObserver(this); |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 void AudioCapturerLinux::OnDataRead( | 56 void AudioCapturerLinux::OnDataRead( |
57 scoped_refptr<base::RefCountedString> data) { | 57 scoped_refptr<base::RefCountedString> data) { |
58 DCHECK(!callback_.is_null()); | 58 DCHECK(!callback_.is_null()); |
59 | 59 |
60 if (silence_detector_.IsSilence( | 60 if (silence_detector_.IsSilence( |
61 reinterpret_cast<const int16_t*>(data->data().data()), | 61 reinterpret_cast<const int16_t*>(data->data().data()), |
62 data->data().size() / sizeof(int16_t))) { | 62 data->data().size() / sizeof(int16_t) / AudioPipeReader::kChannels)) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 std::unique_ptr<AudioPacket> packet(new AudioPacket()); | 66 std::unique_ptr<AudioPacket> packet(new AudioPacket()); |
67 packet->add_data(data->data()); | 67 packet->add_data(data->data()); |
68 packet->set_encoding(AudioPacket::ENCODING_RAW); | 68 packet->set_encoding(AudioPacket::ENCODING_RAW); |
69 packet->set_sampling_rate(AudioPipeReader::kSamplingRate); | 69 packet->set_sampling_rate(AudioPipeReader::kSamplingRate); |
70 packet->set_bytes_per_sample(AudioPipeReader::kBytesPerSample); | 70 packet->set_bytes_per_sample(AudioPipeReader::kBytesPerSample); |
71 packet->set_channels(AudioPipeReader::kChannels); | 71 packet->set_channels(AudioPipeReader::kChannels); |
72 callback_.Run(std::move(packet)); | 72 callback_.Run(std::move(packet)); |
73 } | 73 } |
74 | 74 |
75 bool AudioCapturer::IsSupported() { | 75 bool AudioCapturer::IsSupported() { |
76 return g_pulseaudio_pipe_sink_reader.Get().get() != nullptr; | 76 return g_pulseaudio_pipe_sink_reader.Get().get() != nullptr; |
77 } | 77 } |
78 | 78 |
79 std::unique_ptr<AudioCapturer> AudioCapturer::Create() { | 79 std::unique_ptr<AudioCapturer> AudioCapturer::Create() { |
80 scoped_refptr<AudioPipeReader> reader = | 80 scoped_refptr<AudioPipeReader> reader = |
81 g_pulseaudio_pipe_sink_reader.Get(); | 81 g_pulseaudio_pipe_sink_reader.Get(); |
82 if (!reader.get()) | 82 if (!reader.get()) |
83 return nullptr; | 83 return nullptr; |
84 return base::WrapUnique(new AudioCapturerLinux(reader)); | 84 return base::WrapUnique(new AudioCapturerLinux(reader)); |
85 } | 85 } |
86 | 86 |
87 } // namespace remoting | 87 } // namespace remoting |
OLD | NEW |