Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: content/renderer/pepper/pepper_media_device_manager.h

Issue 2490653002: Make Pepper use Mojo-based support for media-device enumeration and monitoring. (Closed)
Patch Set: address bbudge's comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string>
10 #include <vector>
9 11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "content/common/media/media_devices.h"
15 #include "content/common/media/media_devices.mojom.h"
12 #include "content/public/renderer/render_frame_observer.h" 16 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_frame_observer_tracker.h" 17 #include "content/public/renderer/render_frame_observer_tracker.h"
14 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" 18 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
15 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" 19 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
16 20
17 namespace content { 21 namespace content {
18 class MediaStreamDispatcher; 22 class MediaStreamDispatcher;
19 23
20 class PepperMediaDeviceManager 24 class PepperMediaDeviceManager
21 : public MediaStreamDispatcherEventHandler, 25 : public MediaStreamDispatcherEventHandler,
22 public PepperDeviceEnumerationHostHelper::Delegate, 26 public PepperDeviceEnumerationHostHelper::Delegate,
23 public RenderFrameObserver, 27 public RenderFrameObserver,
24 public RenderFrameObserverTracker<PepperMediaDeviceManager>, 28 public RenderFrameObserverTracker<PepperMediaDeviceManager>,
25 public base::SupportsWeakPtr<PepperMediaDeviceManager> { 29 public base::SupportsWeakPtr<PepperMediaDeviceManager> {
26 public: 30 public:
27 static base::WeakPtr<PepperMediaDeviceManager> GetForRenderFrame( 31 static base::WeakPtr<PepperMediaDeviceManager> GetForRenderFrame(
28 RenderFrame* render_frame); 32 RenderFrame* render_frame);
29 ~PepperMediaDeviceManager() override; 33 ~PepperMediaDeviceManager() override;
30 34
31 // PepperDeviceEnumerationHostHelper::Delegate implementation: 35 // PepperDeviceEnumerationHostHelper::Delegate implementation:
32 int EnumerateDevices(PP_DeviceType_Dev type, 36 void EnumerateDevices(PP_DeviceType_Dev type,
33 const GURL& document_url, 37 const GURL& document_url,
34 const EnumerateDevicesCallback& callback) override; 38 const DevicesCallback& callback) override;
35 void StopEnumerateDevices(int request_id) override; 39 uint32_t StartMonitoringDevices(PP_DeviceType_Dev type,
40 const GURL& document_url,
41 const DevicesCallback& callback) override;
42 void StopMonitoringDevices(PP_DeviceType_Dev type,
43 uint32_t subscription_id) override;
36 44
37 typedef base::Callback<void(int /* request_id */, 45 typedef base::Callback<void(int /* request_id */,
38 bool /* succeeded */, 46 bool /* succeeded */,
39 const std::string& /* label */)> 47 const std::string& /* label */)>
40 OpenDeviceCallback; 48 OpenDeviceCallback;
41 49
42 // Opens the specified device. The request ID passed into the callback will be 50 // Opens the specified device. The request ID passed into the callback will be
43 // the same as the return value. If successful, the label passed into the 51 // the same as the return value. If successful, the label passed into the
44 // callback identifies a audio/video steam, which can be used to call 52 // callback identifies a audio/video steam, which can be used to call
45 // CloseDevice() and GetSesssionID(). 53 // CloseDevice() and GetSesssionID().
(...skipping 23 matching lines...) Expand all
69 void OnDevicesEnumerated(int request_id, 77 void OnDevicesEnumerated(int request_id,
70 const StreamDeviceInfoArray& device_array) override; 78 const StreamDeviceInfoArray& device_array) override;
71 void OnDeviceOpened(int request_id, 79 void OnDeviceOpened(int request_id,
72 const std::string& label, 80 const std::string& label,
73 const StreamDeviceInfo& device_info) override; 81 const StreamDeviceInfo& device_info) override;
74 void OnDeviceOpenFailed(int request_id) override; 82 void OnDeviceOpenFailed(int request_id) override;
75 void OnDevicesChanged() override; 83 void OnDevicesChanged() override;
76 84
77 // Stream type conversion. 85 // Stream type conversion.
78 static MediaStreamType FromPepperDeviceType(PP_DeviceType_Dev type); 86 static MediaStreamType FromPepperDeviceType(PP_DeviceType_Dev type);
79 static PP_DeviceType_Dev FromMediaStreamType(MediaStreamType type);
80 87
81 private: 88 private:
82 explicit PepperMediaDeviceManager(RenderFrame* render_frame); 89 explicit PepperMediaDeviceManager(RenderFrame* render_frame);
83 90
84 // RenderFrameObserver implementation. 91 // RenderFrameObserver implementation.
85 void OnDestruct() override; 92 void OnDestruct() override;
86 93
87 // Called by StopEnumerateDevices() after returing to the event loop, to avoid 94 // Called by StopEnumerateDevices() after returing to the event loop, to avoid
88 // a reentrancy problem. 95 // a reentrancy problem.
89 void StopEnumerateDevicesDelayed(int request_id); 96 void StopEnumerateDevicesDelayed(int request_id);
90 97
91 void NotifyDeviceOpened(int request_id, 98 void NotifyDeviceOpened(int request_id,
92 bool succeeded, 99 bool succeeded,
93 const std::string& label); 100 const std::string& label);
94 101
102 void DevicesEnumerated(const DevicesCallback& callback,
103 MediaDeviceType type,
104 const std::vector<MediaDeviceInfoArray>& enumeration);
105
106 void DevicesChanged(const DevicesCallback& callback,
107 MediaDeviceType type,
108 const MediaDeviceInfoArray& enumeration);
95 109
96 MediaStreamDispatcher* GetMediaStreamDispatcher() const; 110 MediaStreamDispatcher* GetMediaStreamDispatcher() const;
111 const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher();
97 112
98 int next_id_; 113 int next_id_;
99 114
100 typedef std::map<int, EnumerateDevicesCallback> EnumerateCallbackMap;
101 EnumerateCallbackMap enumerate_callbacks_;
102
103 typedef std::map<int, OpenDeviceCallback> OpenCallbackMap; 115 typedef std::map<int, OpenDeviceCallback> OpenCallbackMap;
104 OpenCallbackMap open_callbacks_; 116 OpenCallbackMap open_callbacks_;
105 117
118 ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher_;
119
106 DISALLOW_COPY_AND_ASSIGN(PepperMediaDeviceManager); 120 DISALLOW_COPY_AND_ASSIGN(PepperMediaDeviceManager);
107 }; 121 };
108 122
109 } // namespace content 123 } // namespace content
110 124
111 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_ 125 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_DEVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698