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

Side by Side Diff: content/browser/renderer_host/video_capture_host.h

Issue 7002027: VideoCaptureHost (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 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
(Empty)
1 // Copyright (c) 2011 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.
4 //
5 // VideoCaptureHost serves video capture related requests from VideCaptureImpl
wjia(left Chromium) 2011/05/11 23:23:31 The counterpart of VideoCaptureHost is VideoCaptur
Per K 2011/05/16 11:49:39 Done.
6 // which lives inside the render process and provide access to video capture
7 // hardware.
8 //
9 // This class is owned by BrowserRenderProcessHost, and instantiated on UI
10 // thread, but all other operations and method calls happen on IO thread.
11 //
12 // Here's an example of a typical IPC dialog for video capture:
13 //
14 // Renderer VideoCaptureHost
15 // | |
16 // | VideoCaptureHostMsg_Start > |
17 // | < VideoCaptureMsg_DeviceInfo |
18 // | |
19 // | < VideoCaptureMsg_StateChanged |
20 // | (kStarted) |
21 // | < VideoCaptureMsg_BufferReady |
22 // | ... |
23 // | < VideoCaptureMsg_BufferReady |
24 // | ... |
25 // | VideoCaptureHostMsg_BufferReady > |
26 // | VideoCaptureHostMsg_BufferReady > |
27 // | |
28 // | ... |
29 // | |
30 // | < VideoCaptureMsg_BufferReady |
31 // | VideoCaptureHostMsg_Stop > |
32 // | VideoCaptureHostMsg_BufferReady > |
33 // | < VideoCaptureMsg_StateChanged |
34 // | (kStopped) |
35 // v v
36
37 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
38 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
39
40 #include <list>
41 #include <map>
42
43 #include "content/browser/browser_message_filter.h"
44 #include "content/browser/renderer_host/video_capture_memory.h"
45 #include "ipc/ipc_message.h"
46 #include "media/video/capture/video_capture.h"
47
48 class VideoCaptureHost : public BrowserMessageFilter,
49 public VideoCaptureMemory::EventHandler {
50 public:
51 VideoCaptureHost();
52
53 // BrowserMessageFilter implementation.
54 virtual void OnChannelClosing();
55 virtual void OnDestruct() const;
56 virtual bool OnMessageReceived(const IPC::Message& message,
57 bool* message_was_ok);
58
59 // VideoCaptureMemory::EventHandler implementation.
60 virtual void OnError(VideoCaptureMemory::VCEntryId entry);
61 virtual void OnBufferReady(VideoCaptureMemory::VCEntryId entry,
62 TransportDIB::Handle handle,
63 base::Time timestamp);
64 virtual void OnFrameInfo(VideoCaptureMemory::VCEntryId entry,
65 int width,
66 int height,
67 int frame_per_second);
68
69 private:
70 friend class BrowserThread;
71 friend class DeleteTask<VideoCaptureHost>;
72 friend class MockVideoCaptureHost;
73 friend class VideoCaptureHostTest;
74
75 typedef std::map<int, VideoCaptureMemory*> VCEntryMap;
76
77 virtual ~VideoCaptureHost();
78
79 // IPC message: Start capture on the VideoCaptureDevice referenced by
80 // VideoCaptureParams::session_id.
81 // device_id is an id created by VideoCaptureImpl to identify a session
82 // between a VideoCaptureImpl and a VideoCaptureHost.
83 void OnStartCapture(const IPC::Message& msg, int device_id,
84 const media::VideoCaptureParams& params);
85
86 // IPC message: Stop capture on device referenced by device_id.
87 void OnStopCapture(const IPC::Message& msg, int device_id);
88
89 // IPC message: Pause capture on device referenced by device_id.
90 void OnPauseCapture(const IPC::Message& msg, int device_id);
91
92 // IPC message: Receive an empty buffer from renderer. Send it to device
93 // referenced by |device_id|.
94 void OnReceiveEmptyBuffer(const IPC::Message& msg,
95 int device_id,
96 TransportDIB::Handle handle);
97
98 // Called by VideoCaptureManager when a device have been stopped.
99 void OnDeviceStoped(int device_id);
wjia(left Chromium) 2011/05/11 23:23:31 OnDeviceStopped
Per K 2011/05/16 11:49:39 Done.
100
101 // Removed the VideoCaptureMemory from the list of started devices.
102 // Called on the IO thread when OnDeviceStoped have been called
103 // by the VideoCaptureManager.
104 void DoDeviceStoped(int device_id);
wjia(left Chromium) 2011/05/11 23:23:31 ditto
Per K 2011/05/16 11:49:39 Done.
105
106 // Send a filled buffer to the VideoCaptureMessageFilter.
107 void DoSendFilledBuffer(VideoCaptureMemory::VCEntryId entry,
108 TransportDIB::Handle handle,
109 base::Time timestamp);
110
111 // Send a information about frame resolution and frame rate
112 // to the VideoCaptureMessageFilter.
113 void DoSendFrameInfo(VideoCaptureMemory::VCEntryId entry,
114 int width,
115 int height,
116 int frame_per_second);
117
118 // Handle error coming from VideoCaptureDevice.
119 void DoHandleError(VideoCaptureMemory::VCEntryId entry);
120
121 // Sends the new state to the VideoCaptureImpl.
122 void SendDeviceStopped(int32 render_view_id, int device_id);
123
124 // Send an error message to the renderer.
125 void SendErrorMessage(int32 render_view_id, int device_id);
126
127 // Stop the related VideCaptureDevice.
128 void StopVideoCapture(VideoCaptureMemory::VCEntryId entry);
129
130 // A helper method to look up a VideoCaptureMemory. Returns NULL if not found.
131 VideoCaptureMemory* LookupStartedDevicesById(int device_id);
132 VideoCaptureMemory* LookupStopedDevicesById(int device_id);
wjia(left Chromium) 2011/05/11 23:23:31 ditto
Per K 2011/05/16 11:49:39 Done.
133
134 // A map of device_id to VideoCaptureMemory objects that is currently
135 // capturing.
136 VCEntryMap vc_entries_;
137 // A map of device_id to VideoCaptureMemory objects that have been stopped
138 // but not all transport dibs have been returned by VideoCaptureImpl.
139 VCEntryMap vc_stoped_entries_;
wjia(left Chromium) 2011/05/11 23:23:31 ditto
Per K 2011/05/16 11:49:39 Done.
140
141 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost);
142 };
143
144 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698