summaryrefslogtreecommitdiffstats
path: root/content/browser/device_monitor_mac.h
blob: 52cbea17d4af68d7cc25e7dd1c00fdf83d1fcb36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_
#define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_

#include <IOKit/IOKitLib.h>

#include <vector>

#include "base/basictypes.h"
#include "base/system_monitor/system_monitor.h"

namespace content {

class DeviceMonitorMac {
 public:
  DeviceMonitorMac();
  ~DeviceMonitorMac();

 private:
  void RegisterAudioServices();
  void RegisterVideoServices();

  static void AudioDeviceCallback(void *context, io_iterator_t iterator);
  static void VideoDeviceCallback(void *context, io_iterator_t iterator);

  // Forward the notifications to system monitor.
  void NotifyDeviceChanged(base::SystemMonitor::DeviceType type);

  // Helper.
  void RegisterServices(CFMutableDictionaryRef dictionary,
                        IOServiceMatchingCallback callback);

  IONotificationPortRef notification_port_;
  std::vector<io_iterator_t*> notification_iterators_;

  DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac);
};

}  // namespace content

#endif  // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_