| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PLATFORM_VIDEO_CAPTURE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/time/time.h" | |
| 17 #include "content/common/media/video_capture.h" | 16 #include "content/common/media/video_capture.h" |
| 18 #include "media/video/capture/video_capture_types.h" | 17 #include "media/video/capture/video_capture_types.h" |
| 19 | 18 |
| 20 class GURL; | 19 class GURL; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class PepperMediaDeviceManager; | 22 class PepperMediaDeviceManager; |
| 24 class PepperVideoCaptureHost; | 23 class PepperImageCaptureHost; |
| 25 | 24 |
| 26 // This object must only be used on the thread it's constructed on. | 25 // This object must only be used on the thread it's constructed on. |
| 27 class PepperPlatformVideoCapture { | 26 class PepperPlatformImageCapture { |
| 28 public: | 27 public: |
| 29 PepperPlatformVideoCapture(int render_frame_id, | 28 PepperPlatformImageCapture(int render_frame_id, |
| 30 const std::string& device_id, | 29 const std::string& device_id, |
| 31 const GURL& document_url, | 30 const GURL& document_url, |
| 32 PepperVideoCaptureHost* handler); | 31 PepperImageCaptureHost* handler); |
| 33 virtual ~PepperPlatformVideoCapture(); | 32 virtual ~PepperPlatformImageCapture(); |
| 34 | 33 |
| 35 // Detaches the event handler and stops sending notifications to it. | 34 // Detaches the event handler and stops sending notifications to it. |
| 36 void DetachEventHandler(); | 35 void DetachEventHandler(); |
| 37 | 36 |
| 38 void StartCapture(const media::VideoCaptureParams& params); | 37 void GetPreviewSizes(); |
| 39 void StopCapture(); | |
| 40 | |
| 41 private: | 38 private: |
| 42 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); | 39 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); |
| 43 void OnStateUpdate(VideoCaptureState state); | 40 |
| 44 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame, | 41 // Called by VideoCaptureImplManager. |
| 45 const media::VideoCaptureFormat& format, | 42 void OnDeviceSupportedFormatsEnumerated( |
| 46 const base::TimeTicks& estimated_capture_time); | 43 const media::VideoCaptureFormats& formats); |
| 47 | 44 |
| 48 // Can return NULL if the RenderFrame referenced by |render_frame_id_| has | 45 // Can return NULL if the RenderFrame referenced by |render_frame_id_| has |
| 49 // gone away. | 46 // gone away. |
| 50 PepperMediaDeviceManager* GetMediaDeviceManager(); | 47 PepperMediaDeviceManager* GetMediaDeviceManager(); |
| 51 | 48 |
| 52 const int render_frame_id_; | 49 const int render_frame_id_; |
| 53 const std::string device_id_; | 50 const std::string device_id_; |
| 54 | 51 |
| 55 std::string label_; | 52 std::string label_; |
| 56 int session_id_; | 53 int session_id_; |
| 57 base::Closure release_device_cb_; | 54 base::Closure release_device_cb_; |
| 58 base::Closure stop_capture_cb_; | |
| 59 | 55 |
| 60 PepperVideoCaptureHost* handler_; | 56 PepperImageCaptureHost* handler_; |
| 61 | 57 |
| 62 // Whether we have a pending request to open a device. We have to make sure | 58 // Whether we have a pending request to open a device. We have to make sure |
| 63 // there isn't any pending request before this object goes away. | 59 // there isn't any pending request before this object goes away. |
| 64 bool pending_open_device_; | 60 bool pending_open_device_; |
| 65 int pending_open_device_id_; | 61 int pending_open_device_id_; |
| 66 | 62 |
| 67 base::ThreadChecker thread_checker_; | 63 base::ThreadChecker thread_checker_; |
| 68 | 64 |
| 69 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_; | 65 base::WeakPtrFactory<PepperPlatformImageCapture> weak_factory_; |
| 70 | 66 |
| 71 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); | 67 DISALLOW_COPY_AND_ASSIGN(PepperPlatformImageCapture); |
| 72 }; | 68 }; |
| 73 | 69 |
| 74 } // namespace content | 70 } // namespace content |
| 75 | 71 |
| 76 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 72 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| OLD | NEW |