15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/system_monitor/system_monitor.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/threading/thread_checker.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace { 13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class DeviceMonitorMacImpl; 14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)} 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Class to track audio/video devices removal or addition via callback to 19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// base::SystemMonitor ProcessDevicesChanged(). A single object of this class 20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// is created from the browser main process and lives as long as this one. 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DeviceMonitorMac { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DeviceMonitorMac(); 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~DeviceMonitorMac(); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Registers the observers for the audio/video device removal, connection and 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // suspension. The AVFoundation library is also loaded and initialised if the 285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // OS supports it. The |device_task_runner| argument represents the thread on 295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // which device enumeration will occur. 305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu void StartMonitoring( 315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner); 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Method called by the internal DeviceMonitorMacImpl object 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // |device_monitor_impl_| when a device of type |type| has been added to or 35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // removed from the system. This code executes in the notification thread 36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // (QTKit or AVFoundation). 370f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) void NotifyDeviceChanged(base::SystemMonitor::DeviceType type); 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) private: 40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<DeviceMonitorMacImpl> device_monitor_impl_; 41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |thread_checker_| is used to check that constructor and StartMonitoring() 435c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // are called in the correct thread, the UI thread, that also owns the object. 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::ThreadChecker thread_checker_; 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac); 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ 52