1 /*
2  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_LOUDEST_FILTER_H_
12 #define WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_LOUDEST_FILTER_H_
13 
14 #include <map>
15 #include "webrtc/base/timeutils.h"
16 #include "webrtc/common_types.h"
17 
18 namespace voetest {
19 
20 class LoudestFilter {
21  public:
22   /* ForwardThisPacket()
23    * Decide whether to forward a RTP packet, given its header.
24    *
25    * Input:
26    *   rtp_header : Header of the RTP packet of interest.
27    */
28   bool ForwardThisPacket(const webrtc::RTPHeader& rtp_header);
29 
30  private:
31   struct Status {
SetStatus32     void Set(int audio_level, uint32_t last_time_ms) {
33       this->audio_level = audio_level;
34       this->last_time_ms = last_time_ms;
35     }
36     int audio_level;
37     uint32_t last_time_ms;
38   };
39 
40   void RemoveTimeoutStreams(uint32_t time_ms);
41   unsigned int FindQuietestStream();
42 
43   // Keeps the streams being forwarded in pair<SSRC, Status>.
44   std::map<unsigned int, Status> stream_levels_;
45 
46   const int32_t kStreamTimeOutMs = 5000;
47   const size_t kMaxMixSize = 3;
48   const int kInvalidAudioLevel = 128;
49 };
50 
51 
52 }  // namespace voetest
53 
54 #endif  // WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_LOUDEST_FILTER_H_
55