1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_
10 #include "base/memory/weak_ptr.h"
11 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
12 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
13 #include "webkit/plugins/ppapi/plugin_delegate.h"
17 class PepperDeviceEnumerationEventHandler
18 : public MediaStreamDispatcherEventHandler
,
19 public base::SupportsWeakPtr
<PepperDeviceEnumerationEventHandler
> {
21 PepperDeviceEnumerationEventHandler();
22 virtual ~PepperDeviceEnumerationEventHandler();
24 int RegisterEnumerateDevicesCallback(
25 const webkit::ppapi::PluginDelegate::EnumerateDevicesCallback
& callback
);
26 void UnregisterEnumerateDevicesCallback(int request_id
);
28 int RegisterOpenDeviceCallback(
29 const PepperPluginDelegateImpl::OpenDeviceCallback
& callback
);
31 // MediaStreamDispatcherEventHandler implementation.
32 virtual void OnStreamGenerated(
34 const std::string
& label
,
35 const StreamDeviceInfoArray
& audio_device_array
,
36 const StreamDeviceInfoArray
& video_device_array
) OVERRIDE
;
37 virtual void OnStreamGenerationFailed(int request_id
) OVERRIDE
;
38 virtual void OnDevicesEnumerated(
40 const StreamDeviceInfoArray
& device_array
) OVERRIDE
;
41 virtual void OnDevicesEnumerationFailed(int request_id
) OVERRIDE
;
42 virtual void OnDeviceOpened(
44 const std::string
& label
,
45 const StreamDeviceInfo
& device_info
) OVERRIDE
;
46 virtual void OnDeviceOpenFailed(int request_id
) OVERRIDE
;
48 // Stream type conversion.
49 static MediaStreamType
FromPepperDeviceType(PP_DeviceType_Dev type
);
50 static PP_DeviceType_Dev
FromMediaStreamType(MediaStreamType type
);
53 void NotifyDevicesEnumerated(
56 const StreamDeviceInfoArray
& device_array
);
58 void NotifyDeviceOpened(int request_id
,
60 const std::string
& label
);
65 webkit::ppapi::PluginDelegate::EnumerateDevicesCallback
>
67 EnumerateCallbackMap enumerate_callbacks_
;
69 typedef std::map
<int, PepperPluginDelegateImpl::OpenDeviceCallback
>
71 OpenCallbackMap open_callbacks_
;
73 DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationEventHandler
);
76 } // namespace content
78 #endif // CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_