Chromium Code Reviews| Index: remoting/host/audio_capturer.cc |
| diff --git a/remoting/host/audio_capturer.cc b/remoting/host/audio_capturer.cc |
| index 8828475de5f1be97c1334da6b4bd8310757b023e..28ec1b19a0b287a735a790a5517fe9f8b9165f46 100644 |
| --- a/remoting/host/audio_capturer.cc |
| +++ b/remoting/host/audio_capturer.cc |
| @@ -4,10 +4,19 @@ |
| #include "remoting/host/audio_capturer.h" |
| +#include <math.h> |
|
Sergey Ulanov
2012/07/27 22:46:51
abs() is in stdlib.h
kxing
2012/07/30 16:55:18
Done.
|
| + |
| +#include "base/basictypes.h" |
| #include "remoting/proto/audio.pb.h" |
| +namespace { |
| +const int kBytesPerSample = 2; |
| +const int kSilenceThreshold = 2; |
| +} // namespace |
| + |
| namespace remoting { |
| +// static |
| bool AudioCapturer::IsValidSampleRate(int sample_rate) { |
| switch (sample_rate) { |
| case AudioPacket::SAMPLING_RATE_44100: |
| @@ -18,4 +27,16 @@ bool AudioCapturer::IsValidSampleRate(int sample_rate) { |
| } |
| } |
| +// static |
| +bool AudioCapturer::IsPacketOfSilence(const AudioPacket* packet) { |
| + const int16* data = reinterpret_cast<const int16*>(packet->data().data()); |
| + int number_of_samples = packet->data().size() / kBytesPerSample; |
| + |
| + for (int i = 0; i < number_of_samples; i++) { |
| + if (std::abs(data[i]) > kSilenceThreshold) |
|
Sergey Ulanov
2012/07/27 22:46:51
I think using memchr() to verify that the data is
Sergey Ulanov
2012/07/27 22:46:51
abs() without std::
kxing
2012/07/30 16:55:18
Done.
kxing
2012/07/30 16:55:18
Windows can give samples such as [0, 0, 0, 1, -1,
Sergey Ulanov
2012/07/30 17:53:48
Hm. that is strange. Then it looks like this parti
kxing
2012/07/30 20:21:36
Done.
|
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| } // namespace remoting |