1 // Copyright 2015 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_PLATFORM_CAMERA_DEVICE_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_CAMERA_DEVICE_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h"
16 #include "content/common/media/video_capture.h"
17 #include "media/base/video_capture_types.h"
22 class PepperMediaDeviceManager
;
23 class PepperCameraDeviceHost
;
25 // This object must only be used on the thread it's constructed on.
26 class PepperPlatformCameraDevice
{
28 PepperPlatformCameraDevice(int render_frame_id
,
29 const std::string
& device_id
,
30 const GURL
& document_url
,
31 PepperCameraDeviceHost
* handler
);
32 ~PepperPlatformCameraDevice();
34 // Detaches the event handler and stops sending notifications to it.
35 void DetachEventHandler();
37 void GetSupportedVideoCaptureFormats();
40 void OnDeviceOpened(int request_id
, bool succeeded
, const std::string
& label
);
42 // Called by VideoCaptureImplManager.
43 void OnDeviceSupportedFormatsEnumerated(
44 const media::VideoCaptureFormats
& formats
);
46 // Can return NULL if the RenderFrame referenced by |render_frame_id_| has
48 PepperMediaDeviceManager
* GetMediaDeviceManager();
50 const int render_frame_id_
;
51 const std::string device_id_
;
55 base::Closure release_device_cb_
;
57 PepperCameraDeviceHost
* handler_
;
59 // Whether we have a pending request to open a device. We have to make sure
60 // there isn't any pending request before this object goes away.
61 bool pending_open_device_
;
62 int pending_open_device_id_
;
64 base::ThreadChecker thread_checker_
;
66 base::WeakPtrFactory
<PepperPlatformCameraDevice
> weak_factory_
;
68 DISALLOW_COPY_AND_ASSIGN(PepperPlatformCameraDevice
);
71 } // namespace content
73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_CAMERA_DEVICE_H_