Roll src/third_party/WebKit 9d2dfea:3aea697 (svn 201972:201973)
[chromium-blink-merge.git] / content / renderer / pepper / pepper_platform_video_capture.h
blobccf91d00de2f0a5eab0d61f0a86335d54b8d9a65
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_PLATFORM_VIDEO_CAPTURE_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_
8 #include <string>
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 "base/time/time.h"
17 #include "content/common/media/video_capture.h"
18 #include "media/base/video_capture_types.h"
20 class GURL;
22 namespace media {
23 class VideoFrame;
24 } // namespace media
26 namespace content {
27 class PepperMediaDeviceManager;
28 class PepperVideoCaptureHost;
30 // This object must only be used on the thread it's constructed on.
31 class PepperPlatformVideoCapture {
32 public:
33 PepperPlatformVideoCapture(int render_frame_id,
34 const std::string& device_id,
35 const GURL& document_url,
36 PepperVideoCaptureHost* handler);
37 virtual ~PepperPlatformVideoCapture();
39 // Detaches the event handler and stops sending notifications to it.
40 void DetachEventHandler();
42 void StartCapture(const media::VideoCaptureParams& params);
43 void StopCapture();
45 private:
46 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label);
47 void OnStateUpdate(VideoCaptureState state);
48 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame,
49 base::TimeTicks estimated_capture_time);
51 // Can return NULL if the RenderFrame referenced by |render_frame_id_| has
52 // gone away.
53 PepperMediaDeviceManager* GetMediaDeviceManager();
55 const int render_frame_id_;
56 const std::string device_id_;
58 std::string label_;
59 int session_id_;
60 base::Closure release_device_cb_;
61 base::Closure stop_capture_cb_;
63 PepperVideoCaptureHost* handler_;
65 // Whether we have a pending request to open a device. We have to make sure
66 // there isn't any pending request before this object goes away.
67 bool pending_open_device_;
68 int pending_open_device_id_;
70 base::ThreadChecker thread_checker_;
72 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_;
74 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture);
77 } // namespace content
79 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_