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

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

Issue 242013002: Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge again and again :( Created 6 years, 7 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_VIDEO_CAPTURE_HOST_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/media/video_capture.h"
10 #include "content/public/renderer/renderer_ppapi_host.h" 12 #include "content/public/renderer/renderer_ppapi_host.h"
11 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" 13 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
12 #include "content/renderer/pepper/ppb_buffer_impl.h" 14 #include "content/renderer/pepper/ppb_buffer_impl.h"
13 #include "media/video/capture/video_capture.h"
14 #include "media/video/capture/video_capture_types.h" 15 #include "media/video/capture/video_capture_types.h"
15 #include "ppapi/c/dev/ppp_video_capture_dev.h" 16 #include "ppapi/c/dev/ppp_video_capture_dev.h"
16 #include "ppapi/host/host_message_context.h" 17 #include "ppapi/host/host_message_context.h"
17 #include "ppapi/host/resource_host.h" 18 #include "ppapi/host/resource_host.h"
18 19
20 namespace media {
21 class VideoFrame;
22 } // namespace media
23
19 namespace content { 24 namespace content {
20 class PepperPlatformVideoCapture; 25 class PepperPlatformVideoCapture;
21 class RendererPpapiHostImpl; 26 class RendererPpapiHostImpl;
22 27
23 class PepperVideoCaptureHost : public ppapi::host::ResourceHost, 28 class PepperVideoCaptureHost : public ppapi::host::ResourceHost {
24 public media::VideoCapture::EventHandler {
25 public: 29 public:
26 PepperVideoCaptureHost(RendererPpapiHostImpl* host, 30 PepperVideoCaptureHost(RendererPpapiHostImpl* host,
27 PP_Instance instance, 31 PP_Instance instance,
28 PP_Resource resource); 32 PP_Resource resource);
29 33
30 virtual ~PepperVideoCaptureHost(); 34 virtual ~PepperVideoCaptureHost();
31 35
32 bool Init(); 36 bool Init();
33 37
34 virtual int32_t OnResourceMessageReceived( 38 virtual int32_t OnResourceMessageReceived(
35 const IPC::Message& msg, 39 const IPC::Message& msg,
36 ppapi::host::HostMessageContext* context) OVERRIDE; 40 ppapi::host::HostMessageContext* context) OVERRIDE;
37 41
38 void OnInitialized(media::VideoCapture* capture, bool succeeded); 42 // These methods are called by PepperPlatformVideoCapture only.
39 43
40 // media::VideoCapture::EventHandler 44 // Called when video capturing is initialized. We can start
bbudge 2014/04/25 23:18:58 s/capturing/capture here and below
Alpha Left Google 2014/04/25 23:33:23 Done.
41 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; 45 // video capturing if |succeeded| is true.
42 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; 46 void OnInitialized(bool succeeded);
43 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; 47
44 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; 48 // Called when video capturing has started successfully.
45 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; 49 void OnStarted();
46 virtual void OnFrameReady(media::VideoCapture* capture, 50
47 const scoped_refptr<media::VideoFrame>& frame) 51 // Called when video capturing has stopped. There will be no more
48 OVERRIDE; 52 // frame delivered.
bbudge 2014/04/25 23:18:58 s/frame/frames
Alpha Left Google 2014/04/25 23:33:23 Done.
53 void OnStopped();
54
55 // Called when video capturing has paused.
56 void OnPaused();
57
58 // Called when video capturing cannot be start because of an error.
bbudge 2014/04/25 23:18:58 s/start/started Is this comment true? It seems li
Alpha Left Google 2014/04/25 23:33:23 Realistically error only happens during start.
Alpha Left Google 2014/04/25 23:33:23 Done.
59 void OnError();
60
61 // Called when a video frame is ready.
62 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame,
63 media::VideoCaptureFormat format);
49 64
50 private: 65 private:
51 int32_t OnOpen(ppapi::host::HostMessageContext* context, 66 int32_t OnOpen(ppapi::host::HostMessageContext* context,
52 const std::string& device_id, 67 const std::string& device_id,
53 const PP_VideoCaptureDeviceInfo_Dev& requested_info, 68 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
54 uint32_t buffer_count); 69 uint32_t buffer_count);
55 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); 70 int32_t OnStartCapture(ppapi::host::HostMessageContext* context);
56 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, 71 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context,
57 uint32_t buffer); 72 uint32_t buffer);
58 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); 73 int32_t OnStopCapture(ppapi::host::HostMessageContext* context);
59 int32_t OnClose(ppapi::host::HostMessageContext* context); 74 int32_t OnClose(ppapi::host::HostMessageContext* context);
60 75
61 int32_t StopCapture(); 76 int32_t StopCapture();
62 int32_t Close(); 77 int32_t Close();
63 void PostErrorReply(); 78 void PostErrorReply();
64 void AllocBuffers(const gfx::Size& resolution, int frame_rate); 79 void AllocBuffers(const gfx::Size& resolution, int frame_rate);
65 void ReleaseBuffers(); 80 void ReleaseBuffers();
66 void SendStatus(); 81 void SendStatus();
67 82
68 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, 83 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info,
69 uint32_t buffer_count); 84 uint32_t buffer_count);
70 85
71 void DetachPlatformVideoCapture(); 86 void DetachPlatformVideoCapture();
72 87
73 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); 88 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced);
74 89
75 scoped_refptr<PepperPlatformVideoCapture> platform_video_capture_; 90 scoped_ptr<PepperPlatformVideoCapture> platform_video_capture_;
76 91
77 // Buffers of video frame. 92 // Buffers of video frame.
78 struct BufferInfo { 93 struct BufferInfo {
79 BufferInfo(); 94 BufferInfo();
80 ~BufferInfo(); 95 ~BufferInfo();
81 96
82 bool in_use; 97 bool in_use;
83 void* data; 98 void* data;
84 scoped_refptr<PPB_Buffer_Impl> buffer; 99 scoped_refptr<PPB_Buffer_Impl> buffer;
85 }; 100 };
(...skipping 11 matching lines...) Expand all
97 ppapi::host::ReplyMessageContext open_reply_context_; 112 ppapi::host::ReplyMessageContext open_reply_context_;
98 113
99 PepperDeviceEnumerationHostHelper enumeration_helper_; 114 PepperDeviceEnumerationHostHelper enumeration_helper_;
100 115
101 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); 116 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost);
102 }; 117 };
103 118
104 } // namespace content 119 } // namespace content
105 120
106 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ 121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698