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

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

Issue 7101001: move EventHandler out of VideoCaptureController to make VS2005 happy (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 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 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 #include "content/browser/renderer_host/video_capture_host.h" 5 #include "content/browser/renderer_host/video_capture_host.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "content/common/video_capture_messages.h" 9 #include "content/common/video_capture_messages.h"
10 10
(...skipping 13 matching lines...) Expand all
24 NewRunnableMethod(this, &VideoCaptureHost::OnReadyToDelete, it->first)); 24 NewRunnableMethod(this, &VideoCaptureHost::OnReadyToDelete, it->first));
25 } 25 }
26 } 26 }
27 27
28 void VideoCaptureHost::OnDestruct() const { 28 void VideoCaptureHost::OnDestruct() const {
29 BrowserThread::DeleteOnIOThread::Destruct(this); 29 BrowserThread::DeleteOnIOThread::Destruct(this);
30 } 30 }
31 31
32 /////////////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////////////
33 33
34 // Implements VideoCaptureController::EventHandler. 34 // Implements VideoCaptureControllerEventHandler.
35 void VideoCaptureHost::OnError(VideoCaptureController::ControllerId id) { 35 void VideoCaptureHost::OnError(VideoCaptureControllerId id) {
36 BrowserThread::PostTask( 36 BrowserThread::PostTask(
37 BrowserThread::IO, FROM_HERE, 37 BrowserThread::IO, FROM_HERE,
38 NewRunnableMethod(this, &VideoCaptureHost::DoHandleError, id.first, 38 NewRunnableMethod(this, &VideoCaptureHost::DoHandleError, id.first,
39 id.second)); 39 id.second));
40 } 40 }
41 41
42 void VideoCaptureHost::OnBufferReady( 42 void VideoCaptureHost::OnBufferReady(
43 VideoCaptureController::ControllerId id, 43 VideoCaptureControllerId id,
44 TransportDIB::Handle handle, 44 TransportDIB::Handle handle,
45 base::Time timestamp) { 45 base::Time timestamp) {
46 BrowserThread::PostTask( 46 BrowserThread::PostTask(
47 BrowserThread::IO, FROM_HERE, 47 BrowserThread::IO, FROM_HERE,
48 NewRunnableMethod(this, &VideoCaptureHost::DoSendFilledBuffer, id.first, 48 NewRunnableMethod(this, &VideoCaptureHost::DoSendFilledBuffer, id.first,
49 id.second, handle, timestamp)); 49 id.second, handle, timestamp));
50 } 50 }
51 51
52 void VideoCaptureHost::OnFrameInfo(VideoCaptureController::ControllerId id, 52 void VideoCaptureHost::OnFrameInfo(VideoCaptureControllerId id,
53 int width, 53 int width,
54 int height, 54 int height,
55 int frame_per_second) { 55 int frame_per_second) {
56 BrowserThread::PostTask( 56 BrowserThread::PostTask(
57 BrowserThread::IO, FROM_HERE, 57 BrowserThread::IO, FROM_HERE,
58 NewRunnableMethod(this, &VideoCaptureHost::DoSendFrameInfo, id.first, 58 NewRunnableMethod(this, &VideoCaptureHost::DoSendFrameInfo, id.first,
59 id.second, width, height, frame_per_second)); 59 id.second, width, height, frame_per_second));
60 } 60 }
61 61
62 void VideoCaptureHost::OnReadyToDelete( 62 void VideoCaptureHost::OnReadyToDelete(
63 VideoCaptureController::ControllerId id) { 63 VideoCaptureControllerId id) {
64 BrowserThread::PostTask( 64 BrowserThread::PostTask(
65 BrowserThread::IO, FROM_HERE, 65 BrowserThread::IO, FROM_HERE,
66 NewRunnableMethod(this, &VideoCaptureHost::DoDeleteVideoCaptureController, 66 NewRunnableMethod(this, &VideoCaptureHost::DoDeleteVideoCaptureController,
67 id)); 67 id));
68 } 68 }
69 69
70 void VideoCaptureHost::DoSendFilledBuffer(int32 routing_id, 70 void VideoCaptureHost::DoSendFilledBuffer(int32 routing_id,
71 int device_id, 71 int device_id,
72 TransportDIB::Handle handle, 72 TransportDIB::Handle handle,
73 base::Time timestamp) { 73 base::Time timestamp) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
75 75
76 Send(new VideoCaptureMsg_BufferReady(routing_id, device_id, handle, 76 Send(new VideoCaptureMsg_BufferReady(routing_id, device_id, handle,
77 timestamp)); 77 timestamp));
78 } 78 }
79 79
80 void VideoCaptureHost::DoHandleError(int32 routing_id, int device_id) { 80 void VideoCaptureHost::DoHandleError(int32 routing_id, int device_id) {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
82 82
83 Send(new VideoCaptureMsg_StateChanged(routing_id, device_id, 83 Send(new VideoCaptureMsg_StateChanged(routing_id, device_id,
84 media::VideoCapture::kError)); 84 media::VideoCapture::kError));
85 85
86 VideoCaptureController::ControllerId id(routing_id, device_id); 86 VideoCaptureControllerId id(routing_id, device_id);
87 EntryMap::iterator it = entries_.find(id); 87 EntryMap::iterator it = entries_.find(id);
88 if (it != entries_.end()) { 88 if (it != entries_.end()) {
89 VideoCaptureController* controller = it->second; 89 VideoCaptureController* controller = it->second;
90 controller->StopCapture(NULL); 90 controller->StopCapture(NULL);
91 } 91 }
92 } 92 }
93 93
94 void VideoCaptureHost::DoSendFrameInfo(int32 routing_id, 94 void VideoCaptureHost::DoSendFrameInfo(int32 routing_id,
95 int device_id, 95 int device_id,
96 int width, 96 int width,
(...skipping 23 matching lines...) Expand all
120 IPC_MESSAGE_UNHANDLED(handled = false) 120 IPC_MESSAGE_UNHANDLED(handled = false)
121 IPC_END_MESSAGE_MAP_EX() 121 IPC_END_MESSAGE_MAP_EX()
122 122
123 return handled; 123 return handled;
124 } 124 }
125 125
126 void VideoCaptureHost::OnStartCapture(const IPC::Message& msg, int device_id, 126 void VideoCaptureHost::OnStartCapture(const IPC::Message& msg, int device_id,
127 const media::VideoCaptureParams& params) { 127 const media::VideoCaptureParams& params) {
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
129 129
130 VideoCaptureController::ControllerId controller_id(msg.routing_id(), 130 VideoCaptureControllerId controller_id(msg.routing_id(), device_id);
131 device_id);
132 131
133 DCHECK(entries_.find(controller_id) == entries_.end()); 132 DCHECK(entries_.find(controller_id) == entries_.end());
134 133
135 scoped_refptr<VideoCaptureController> controller = 134 scoped_refptr<VideoCaptureController> controller =
136 new VideoCaptureController(controller_id, peer_handle(), this); 135 new VideoCaptureController(controller_id, peer_handle(), this);
137 entries_.insert(std::make_pair(controller_id, controller)); 136 entries_.insert(std::make_pair(controller_id, controller));
138 controller->StartCapture(params); 137 controller->StartCapture(params);
139 } 138 }
140 139
141 void VideoCaptureHost::OnStopCapture(const IPC::Message& msg, int device_id) { 140 void VideoCaptureHost::OnStopCapture(const IPC::Message& msg, int device_id) {
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
143 142
144 VideoCaptureController::ControllerId controller_id(msg.routing_id(), 143 VideoCaptureControllerId controller_id(msg.routing_id(), device_id);
145 device_id);
146 EntryMap::iterator it = entries_.find(controller_id); 144 EntryMap::iterator it = entries_.find(controller_id);
147 if (it != entries_.end()) { 145 if (it != entries_.end()) {
148 scoped_refptr<VideoCaptureController> controller = it->second; 146 scoped_refptr<VideoCaptureController> controller = it->second;
149 controller->StopCapture(NULL); 147 controller->StopCapture(NULL);
150 } else { 148 } else {
151 // It does not exist so it must have been stopped already. 149 // It does not exist so it must have been stopped already.
152 Send(new VideoCaptureMsg_StateChanged(msg.routing_id(), device_id, 150 Send(new VideoCaptureMsg_StateChanged(msg.routing_id(), device_id,
153 media::VideoCapture::kStopped)); 151 media::VideoCapture::kStopped));
154 } 152 }
155 } 153 }
156 154
157 void VideoCaptureHost::OnPauseCapture(const IPC::Message& msg, int device_id) { 155 void VideoCaptureHost::OnPauseCapture(const IPC::Message& msg, int device_id) {
158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
159 // Not used. 157 // Not used.
160 Send(new VideoCaptureMsg_StateChanged(msg.routing_id(), device_id, 158 Send(new VideoCaptureMsg_StateChanged(msg.routing_id(), device_id,
161 media::VideoCapture::kError)); 159 media::VideoCapture::kError));
162 } 160 }
163 161
164 void VideoCaptureHost::OnReceiveEmptyBuffer(const IPC::Message& msg, 162 void VideoCaptureHost::OnReceiveEmptyBuffer(const IPC::Message& msg,
165 int device_id, 163 int device_id,
166 TransportDIB::Handle handle) { 164 TransportDIB::Handle handle) {
167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
168 166
169 VideoCaptureController::ControllerId controller_id(msg.routing_id(), 167 VideoCaptureControllerId controller_id(msg.routing_id(), device_id);
170 device_id);
171 EntryMap::iterator it = entries_.find(controller_id); 168 EntryMap::iterator it = entries_.find(controller_id);
172 if (it != entries_.end()) { 169 if (it != entries_.end()) {
173 scoped_refptr<VideoCaptureController> controller = it->second; 170 scoped_refptr<VideoCaptureController> controller = it->second;
174 controller->ReturnTransportDIB(handle); 171 controller->ReturnTransportDIB(handle);
175 } 172 }
176 } 173 }
177 174
178 void VideoCaptureHost::DoDeleteVideoCaptureController( 175 void VideoCaptureHost::DoDeleteVideoCaptureController(
179 VideoCaptureController::ControllerId id) { 176 VideoCaptureControllerId id) {
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
181 178
182 // Report that the device have successfully been stopped. 179 // Report that the device have successfully been stopped.
183 Send(new VideoCaptureMsg_StateChanged(id.first, id.second, 180 Send(new VideoCaptureMsg_StateChanged(id.first, id.second,
184 media::VideoCapture::kStopped)); 181 media::VideoCapture::kStopped));
185 entries_.erase(id); 182 entries_.erase(id);
186 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698