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

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

Issue 242013002: Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged again :( Created 6 years, 8 months 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 | Annotate | Revision Log
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_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/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "media/video/capture/video_capture.h" 15 #include "content/common/media/video_capture.h"
15 #include "media/video/capture/video_capture_types.h" 16 #include "media/video/capture/video_capture_types.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace media {
20 class VideoCaptureHandlerProxy;
21 }
22
23 namespace content { 20 namespace content {
24 class PepperMediaDeviceManager; 21 class PepperMediaDeviceManager;
25 class PepperVideoCaptureHost; 22 class PepperVideoCaptureHost;
26 class RenderViewImpl; 23 class RenderViewImpl;
27 class VideoCaptureHandle;
28 24
29 class PepperPlatformVideoCapture 25 // This is an render thread only object. All methods must be accessed on
Ami GONE FROM CHROMIUM 2014/04/24 21:04:31 s/an/a/
Alpha Left Google 2014/04/24 22:50:34 Done.
30 : public media::VideoCapture, 26 // the render thread including cosntructor and destructor.
Ami GONE FROM CHROMIUM 2014/04/24 21:04:31 optional: could DCHECK this in the public methods.
Alpha Left Google 2014/04/24 22:50:34 Done.
31 public base::RefCounted<PepperPlatformVideoCapture>, 27 class PepperPlatformVideoCapture {
32 public media::VideoCapture::EventHandler {
33 public: 28 public:
34 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, 29 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view,
35 const std::string& device_id, 30 const std::string& device_id,
36 const GURL& document_url, 31 const GURL& document_url,
37 PepperVideoCaptureHost* handler); 32 PepperVideoCaptureHost* handler);
33 virtual ~PepperPlatformVideoCapture();
38 34
39 // Detaches the event handler and stops sending notifications to it. 35 // Detaches the event handler and stops sending notifications to it.
40 void DetachEventHandler(); 36 void DetachEventHandler();
41 37
42 // media::VideoCapture implementation. 38 void StartCapture(const media::VideoCaptureParams& params);
43 virtual void StartCapture(media::VideoCapture::EventHandler* handler, 39 void StopCapture();
44 const media::VideoCaptureParams& params) OVERRIDE;
45 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE;
46 virtual bool CaptureStarted() OVERRIDE;
47 virtual int CaptureFrameRate() OVERRIDE;
48 virtual void GetDeviceSupportedFormats(const DeviceFormatsCallback& callback)
49 OVERRIDE;
50 virtual void GetDeviceFormatsInUse(const DeviceFormatsInUseCallback& callback)
51 OVERRIDE;
52
53 // media::VideoCapture::EventHandler implementation
54 virtual void OnStarted(VideoCapture* capture) OVERRIDE;
55 virtual void OnStopped(VideoCapture* capture) OVERRIDE;
56 virtual void OnPaused(VideoCapture* capture) OVERRIDE;
57 virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE;
58 virtual void OnRemoved(VideoCapture* capture) OVERRIDE;
59 virtual void OnFrameReady(VideoCapture* capture,
60 const scoped_refptr<media::VideoFrame>& frame)
61 OVERRIDE;
62
63 protected:
64 friend class base::RefCounted<PepperPlatformVideoCapture>;
65 virtual ~PepperPlatformVideoCapture();
66 40
67 private: 41 private:
68 void Initialize();
69
70 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); 42 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label);
43 void OnStateUpdate(VideoCaptureState state);
44 void OnFrameReady(
45 const scoped_refptr<media::VideoFrame>& frame,
46 const media::VideoCaptureFormat& format,
47 const base::TimeTicks& timestamp);
71 48
72 PepperMediaDeviceManager* GetMediaDeviceManager(); 49 PepperMediaDeviceManager* GetMediaDeviceManager();
73 50
74 base::WeakPtr<RenderViewImpl> render_view_; 51 base::WeakPtr<RenderViewImpl> render_view_;
75 52
76 std::string device_id_; 53 std::string device_id_;
77 std::string label_; 54 std::string label_;
78 int session_id_; 55 int session_id_;
79 56 base::Closure release_device_cb_;
80 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; 57 base::Closure stop_capture_cb_;
81 58
82 PepperVideoCaptureHost* handler_; 59 PepperVideoCaptureHost* handler_;
83 60
84 scoped_ptr<VideoCaptureHandle> video_capture_;
85
86 // StartCapture() must be balanced by StopCapture(), otherwise this object
87 // will leak.
88 bool unbalanced_start_;
89
90 // Whether we have a pending request to open a device. We have to make sure 61 // Whether we have a pending request to open a device. We have to make sure
91 // there isn't any pending request before this object goes away. 62 // there isn't any pending request before this object goes away.
92 bool pending_open_device_; 63 bool pending_open_device_;
93 int pending_open_device_id_; 64 int pending_open_device_id_;
94 65
66 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_;
67
95 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); 68 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture);
96 }; 69 };
97 70
98 } // namespace content 71 } // namespace content
99 72
100 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ 73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698