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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// 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_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_
#include <map>
#include "base/memory/weak_ptr.h"
#include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
#include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
namespace content {
class PepperDeviceEnumerationEventHandler
: public MediaStreamDispatcherEventHandler,
public base::SupportsWeakPtr<PepperDeviceEnumerationEventHandler> {
public:
PepperDeviceEnumerationEventHandler();
virtual ~PepperDeviceEnumerationEventHandler();
int RegisterEnumerateDevicesCallback(
const webkit::ppapi::PluginDelegate::EnumerateDevicesCallback& callback);
int RegisterOpenDeviceCallback(
const PepperPluginDelegateImpl::OpenDeviceCallback& callback);
// MediaStreamDispatcherEventHandler implementation.
virtual void OnStreamGenerated(
int request_id,
const std::string& label,
const media_stream::StreamDeviceInfoArray& audio_device_array,
const media_stream::StreamDeviceInfoArray& video_device_array) OVERRIDE;
virtual void OnStreamGenerationFailed(int request_id) OVERRIDE;
virtual void OnVideoDeviceFailed(const std::string& label,
int index) OVERRIDE;
virtual void OnAudioDeviceFailed(const std::string& label,
int index) OVERRIDE;
virtual void OnDevicesEnumerated(
int request_id,
const media_stream::StreamDeviceInfoArray& device_array) OVERRIDE;
virtual void OnDevicesEnumerationFailed(int request_id) OVERRIDE;
virtual void OnDeviceOpened(
int request_id,
const std::string& label,
const media_stream::StreamDeviceInfo& device_info) OVERRIDE;
virtual void OnDeviceOpenFailed(int request_id) OVERRIDE;
// Stream type conversion.
static media_stream::MediaStreamType FromPepperDeviceType(
PP_DeviceType_Dev type);
static PP_DeviceType_Dev FromMediaStreamType(
media_stream::MediaStreamType type);
private:
void NotifyDevicesEnumerated(
int request_id,
bool succeeded,
const media_stream::StreamDeviceInfoArray& device_array);
void NotifyDeviceOpened(int request_id,
bool succeeded,
const std::string& label);
int next_id_;
typedef std::map<int,
webkit::ppapi::PluginDelegate::EnumerateDevicesCallback>
EnumerateCallbackMap;
EnumerateCallbackMap enumerate_callbacks_;
typedef std::map<int, PepperPluginDelegateImpl::OpenDeviceCallback>
OpenCallbackMap;
OpenCallbackMap open_callbacks_;
DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationEventHandler);
};
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_EVENT_HANDLER_H_
|