henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 65c7f67 | 2016-02-12 00:05:01 -0800 | [diff] [blame] | 2 | * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 65c7f67 | 2016-02-12 00:05:01 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef PC_AUDIOMONITOR_H_ |
| 12 | #define PC_AUDIOMONITOR_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 14 | #include <vector> |
terelius | 8c011e5 | 2016-04-26 05:28:11 -0700 | [diff] [blame] | 15 | #include <utility> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "p2p/base/port.h" |
| 18 | #include "rtc_base/sigslot.h" |
| 19 | #include "rtc_base/thread.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 20 | |
| 21 | namespace cricket { |
| 22 | |
| 23 | class VoiceChannel; |
| 24 | |
| 25 | struct AudioInfo { |
| 26 | int input_level; |
| 27 | int output_level; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 28 | typedef std::vector<std::pair<uint32_t, int> > StreamList; |
terelius | 8c011e5 | 2016-04-26 05:28:11 -0700 | [diff] [blame] | 29 | StreamList active_streams; // ssrcs contributing to output_level |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 32 | class AudioMonitor : public rtc::MessageHandler, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | public sigslot::has_slots<> { |
| 34 | public: |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 35 | AudioMonitor(VoiceChannel* voice_channel, rtc::Thread *monitor_thread); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | ~AudioMonitor(); |
| 37 | |
| 38 | void Start(int cms); |
| 39 | void Stop(); |
| 40 | |
| 41 | VoiceChannel* voice_channel(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 42 | rtc::Thread *monitor_thread(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | |
| 44 | sigslot::signal2<AudioMonitor*, const AudioInfo&> SignalUpdate; |
| 45 | |
| 46 | protected: |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 47 | void OnMessage(rtc::Message *message); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 48 | void PollVoiceChannel(); |
| 49 | |
| 50 | AudioInfo audio_info_; |
| 51 | VoiceChannel* voice_channel_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 52 | rtc::Thread* monitoring_thread_; |
| 53 | rtc::CriticalSection crit_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 54 | uint32_t rate_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | bool monitoring_; |
| 56 | }; |
| 57 | |
terelius | 8c011e5 | 2016-04-26 05:28:11 -0700 | [diff] [blame] | 58 | } // namespace cricket |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 59 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 60 | #endif // PC_AUDIOMONITOR_H_ |