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

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 messages from
6 // VideCaptureMessageFilter which lives inside the render process.
7 //
8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI
9 // thread, but all other operations and method calls happen on IO thread.
10 //
11 // Here's an example of a typical IPC dialog for video capture:
12 //
13 // Renderer VideoCaptureHost
14 // | |
15 // | VideoCaptureHostMsg_Start > |
16 // | < VideoCaptureMsg_DeviceInfo |
17 // | |
18 // | < VideoCaptureMsg_StateChanged |
19 // | (kStarted) |
20 // | < VideoCaptureMsg_BufferReady |
21 // | ... |
22 // | < VideoCaptureMsg_BufferReady |
23 // | ... |
24 // | VideoCaptureHostMsg_BufferReady > |
25 // | VideoCaptureHostMsg_BufferReady > |
26 // | |
27 // | ... |
28 // | |
29 // | < VideoCaptureMsg_BufferReady |
30 // | VideoCaptureHostMsg_Stop > |
31 // | VideoCaptureHostMsg_BufferReady > |
32 // | < VideoCaptureMsg_StateChanged |
33 // | (kStopped) |
34 // v v
35
36 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
37 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
38
39 #include <map>
40
41 #include "base/memory/ref_counted.h"
42 #include "content/browser/browser_message_filter.h"
43 #include "content/browser/renderer_host/video_capture_controller.h"
44 #include "ipc/ipc_message.h"
45
46 class VideoCaptureHost : public BrowserMessageFilter,
47 public VideoCaptureController::EventHandler {
48 public:
49 VideoCaptureHost();
50
51 // BrowserMessageFilter implementation.
52 virtual void OnChannelClosing();
53 virtual void OnDestruct() const;
54 virtual bool OnMessageReceived(const IPC::Message& message,
55 bool* message_was_ok);
56
57 // VideoCaptureController::EventHandler implementation.
58 virtual void OnError(VideoCaptureController::ControllerId id);
59 virtual void OnBufferReady(VideoCaptureController::ControllerId id,
60 TransportDIB::Handle handle,
61 base::Time timestamp);
62 virtual void OnFrameInfo(VideoCaptureController::ControllerId id,
63 int width,
64 int height,
65 int frame_per_second);
66 virtual void OnReadyToDelete(VideoCaptureController::ControllerId id);
67
68 private:
69 friend class BrowserThread;
70 friend class DeleteTask<VideoCaptureHost>;
71 friend class MockVideoCaptureHost;
72 friend class VideoCaptureHostTest;
73
74 virtual ~VideoCaptureHost();
75
76 // IPC message: Start capture on the VideoCaptureDevice referenced by
77 // VideoCaptureParams::session_id. device_id is an id created by
78 // VideCaptureMessageFilter to identify a session
79 // between a VideCaptureMessageFilter and a VideoCaptureHost.
80 void OnStartCapture(const IPC::Message& msg, int device_id,
81 const media::VideoCaptureParams& params);
82
83 // IPC message: Stop capture on device referenced by device_id.
84 void OnStopCapture(const IPC::Message& msg, int device_id);
85
86 // IPC message: Pause capture on device referenced by device_id.
87 void OnPauseCapture(const IPC::Message& msg, int device_id);
88
89 // IPC message: Receive an empty buffer from renderer. Send it to device
90 // referenced by |device_id|.
91 void OnReceiveEmptyBuffer(const IPC::Message& msg,
92 int device_id,
93 TransportDIB::Handle handle);
94
95
96 // Called on the IO thread when VideoCaptureController have
97 // reported that all DIBs have been returned.
98 void DoDeleteVideoCaptureController(VideoCaptureController::ControllerId id);
99
100 // Send a filled buffer to the VideoCaptureMessageFilter.
101 void DoSendFilledBuffer(int32 routing_id,
102 int device_id,
103 TransportDIB::Handle handle,
104 base::Time timestamp);
105
106 // Send a information about frame resolution and frame rate
107 // to the VideoCaptureMessageFilter.
108 void DoSendFrameInfo(int32 routing_id,
109 int device_id,
110 int width,
111 int height,
112 int frame_per_second);
113
114 // Handle error coming from VideoCaptureDevice.
115 void DoHandleError(int32 routing_id, int device_id);
116
117 typedef std::map<VideoCaptureController::ControllerId,
118 scoped_refptr<VideoCaptureController> >EntryMap;
119
120 // A map of VideoCaptureController::ControllerId to VideoCaptureController
121 // objects that is currently active.
122 EntryMap entries_;
123
124 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost);
125 };
126
127 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698