Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: remoting/host/audio_capturer_util.cc

Issue 10820059: Not streaming packets of silence. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698