Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/host/audio_capturer_util.h" | |
| 6 | |
| 7 #include <stdlib.h> | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "remoting/proto/audio.pb.h" | |
| 11 | |
| 12 namespace { | |
| 13 const int kBytesPerSample = 2; | |
| 14 const int kSilenceThreshold = 2; | |
|
Sergey Ulanov
2012/07/30 18:02:56
Please add some comments to explain how that value
kxing
2012/07/30 20:21:36
Done.
| |
| 15 } // namespace | |
| 16 | |
| 17 namespace remoting { | |
| 18 | |
| 19 bool IsValidSampleRate(int sample_rate) { | |
| 20 switch (sample_rate) { | |
| 21 case AudioPacket::SAMPLING_RATE_44100: | |
| 22 case AudioPacket::SAMPLING_RATE_48000: | |
| 23 return true; | |
| 24 default: | |
| 25 return false; | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 bool IsPacketOfSilence(const AudioPacket* packet) { | |
| 30 const int16* data = reinterpret_cast<const int16*>(packet->data().data()); | |
|
Sergey Ulanov
2012/07/30 18:02:56
You assume here that the packet is always two byte
kxing
2012/07/30 20:21:36
Done.
| |
| 31 int number_of_samples = packet->data().size() / kBytesPerSample; | |
| 32 | |
| 33 for (int i = 0; i < number_of_samples; i++) { | |
| 34 if (abs(data[i]) > kSilenceThreshold) | |
| 35 return false; | |
| 36 } | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 } // namespace remoting | |
| OLD | NEW |