blob: 26212afc72866ed6dd4183c490b217fd245803f2 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander65c7f672016-02-12 00:05:01 -08002 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander65c7f672016-02-12 00:05:01 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_AUDIOMONITOR_H_
12#define PC_AUDIOMONITOR_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000014#include <vector>
terelius8c011e52016-04-26 05:28:11 -070015#include <utility>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "p2p/base/port.h"
18#include "rtc_base/sigslot.h"
19#include "rtc_base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000020
21namespace cricket {
22
23class VoiceChannel;
24
25struct AudioInfo {
26 int input_level;
27 int output_level;
Peter Boström0c4e06b2015-10-07 12:23:21 +020028 typedef std::vector<std::pair<uint32_t, int> > StreamList;
terelius8c011e52016-04-26 05:28:11 -070029 StreamList active_streams; // ssrcs contributing to output_level
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030};
31
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000032class AudioMonitor : public rtc::MessageHandler,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033 public sigslot::has_slots<> {
34 public:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000035 AudioMonitor(VoiceChannel* voice_channel, rtc::Thread *monitor_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036 ~AudioMonitor();
37
38 void Start(int cms);
39 void Stop();
40
41 VoiceChannel* voice_channel();
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000042 rtc::Thread *monitor_thread();
henrike@webrtc.org28e20752013-07-10 00:45:36 +000043
44 sigslot::signal2<AudioMonitor*, const AudioInfo&> SignalUpdate;
45
46 protected:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000047 void OnMessage(rtc::Message *message);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000048 void PollVoiceChannel();
49
50 AudioInfo audio_info_;
51 VoiceChannel* voice_channel_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000052 rtc::Thread* monitoring_thread_;
53 rtc::CriticalSection crit_;
Peter Boström0c4e06b2015-10-07 12:23:21 +020054 uint32_t rate_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055 bool monitoring_;
56};
57
terelius8c011e52016-04-26 05:28:11 -070058} // namespace cricket
henrike@webrtc.org28e20752013-07-10 00:45:36 +000059
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020060#endif // PC_AUDIOMONITOR_H_