OLD | NEW |
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 #include "content/renderer/media/video_capture_message_filter.h" | 5 #include "content/renderer/media/video_capture_message_filter.h" |
6 | 6 |
7 #include "content/common/media/video_capture_messages.h" | 7 #include "content/common/media/video_capture_messages.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 return sender_->Send(message); | 55 return sender_->Send(message); |
56 } | 56 } |
57 | 57 |
58 bool VideoCaptureMessageFilter::OnMessageReceived(const IPC::Message& message) { | 58 bool VideoCaptureMessageFilter::OnMessageReceived(const IPC::Message& message) { |
59 bool handled = true; | 59 bool handled = true; |
60 IPC_BEGIN_MESSAGE_MAP(VideoCaptureMessageFilter, message) | 60 IPC_BEGIN_MESSAGE_MAP(VideoCaptureMessageFilter, message) |
61 IPC_MESSAGE_HANDLER(VideoCaptureMsg_BufferReady, OnBufferReceived) | 61 IPC_MESSAGE_HANDLER(VideoCaptureMsg_BufferReady, OnBufferReceived) |
62 IPC_MESSAGE_HANDLER(VideoCaptureMsg_StateChanged, OnDeviceStateChanged) | 62 IPC_MESSAGE_HANDLER(VideoCaptureMsg_StateChanged, OnDeviceStateChanged) |
63 IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer, OnBufferCreated) | 63 IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer, OnBufferCreated) |
| 64 IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer2, OnBufferCreated2) |
64 IPC_MESSAGE_HANDLER(VideoCaptureMsg_FreeBuffer, OnBufferDestroyed) | 65 IPC_MESSAGE_HANDLER(VideoCaptureMsg_FreeBuffer, OnBufferDestroyed) |
65 IPC_MESSAGE_HANDLER(VideoCaptureMsg_DeviceSupportedFormatsEnumerated, | 66 IPC_MESSAGE_HANDLER(VideoCaptureMsg_DeviceSupportedFormatsEnumerated, |
66 OnDeviceSupportedFormatsEnumerated) | 67 OnDeviceSupportedFormatsEnumerated) |
67 IPC_MESSAGE_HANDLER(VideoCaptureMsg_DeviceFormatsInUseReceived, | 68 IPC_MESSAGE_HANDLER(VideoCaptureMsg_DeviceFormatsInUseReceived, |
68 OnDeviceFormatsInUseReceived) | 69 OnDeviceFormatsInUseReceived) |
69 IPC_MESSAGE_UNHANDLED(handled = false) | 70 IPC_MESSAGE_UNHANDLED(handled = false) |
70 IPC_END_MESSAGE_MAP() | 71 IPC_END_MESSAGE_MAP() |
71 return handled; | 72 return handled; |
72 } | 73 } |
73 | 74 |
(...skipping 29 matching lines...) Expand all Loading... |
103 int length, | 104 int length, |
104 int buffer_id) { | 105 int buffer_id) { |
105 Delegate* const delegate = find_delegate(device_id); | 106 Delegate* const delegate = find_delegate(device_id); |
106 if (!delegate) { | 107 if (!delegate) { |
107 DLOG(WARNING) << "OnBufferCreated: Got video SHM buffer for a " | 108 DLOG(WARNING) << "OnBufferCreated: Got video SHM buffer for a " |
108 "non-existent or removed video capture."; | 109 "non-existent or removed video capture."; |
109 | 110 |
110 // Send the buffer back to Host in case it's waiting for all buffers | 111 // Send the buffer back to Host in case it's waiting for all buffers |
111 // to be returned. | 112 // to be returned. |
112 base::SharedMemory::CloseHandle(handle); | 113 base::SharedMemory::CloseHandle(handle); |
113 Send(new VideoCaptureHostMsg_BufferReady(device_id, buffer_id, 0, -1.0)); | 114 |
| 115 Send(new VideoCaptureHostMsg_BufferReady( |
| 116 device_id, buffer_id, 0 /* release_sync_point */, |
| 117 -1.0 /* consumer_resource_utilization */)); |
114 return; | 118 return; |
115 } | 119 } |
116 | 120 |
117 delegate->OnBufferCreated(handle, length, buffer_id); | 121 delegate->OnBufferCreated(handle, length, buffer_id); |
118 } | 122 } |
119 | 123 |
| 124 void VideoCaptureMessageFilter::OnBufferCreated2( |
| 125 int device_id, |
| 126 const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
| 127 const gfx::Size& size, |
| 128 int buffer_id) { |
| 129 Delegate* const delegate = find_delegate(device_id); |
| 130 if (!delegate) { |
| 131 DLOG(WARNING) << "OnBufferCreated: Got video GMB buffer for a " |
| 132 "non-existent or removed video capture."; |
| 133 Send(new VideoCaptureHostMsg_BufferReady( |
| 134 device_id, buffer_id, 0 /* release_sync_point */, |
| 135 -1.0 /* consumer_resource_utilization */)); |
| 136 return; |
| 137 } |
| 138 |
| 139 delegate->OnBufferCreated2(handles, size, buffer_id); |
| 140 } |
| 141 |
120 void VideoCaptureMessageFilter::OnBufferReceived( | 142 void VideoCaptureMessageFilter::OnBufferReceived( |
121 const VideoCaptureMsg_BufferReady_Params& params) { | 143 const VideoCaptureMsg_BufferReady_Params& params) { |
122 Delegate* const delegate = find_delegate(params.device_id); | 144 Delegate* const delegate = find_delegate(params.device_id); |
123 if (!delegate) { | 145 if (!delegate) { |
124 DLOG(WARNING) << "OnBufferReceived: Got video SHM buffer for a " | 146 DLOG(WARNING) << "OnBufferReceived: Got video SHM buffer for a " |
125 "non-existent or removed video capture."; | 147 "non-existent or removed video capture."; |
126 | 148 |
127 // Send the buffer back to Host in case it's waiting for all buffers | 149 // Send the buffer back to Host in case it's waiting for all buffers |
128 // to be returned. | 150 // to be returned. |
129 Send(new VideoCaptureHostMsg_BufferReady( | 151 Send(new VideoCaptureHostMsg_BufferReady( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const media::VideoCaptureFormats& formats_in_use) { | 203 const media::VideoCaptureFormats& formats_in_use) { |
182 Delegate* const delegate = find_delegate(device_id); | 204 Delegate* const delegate = find_delegate(device_id); |
183 if (!delegate) { | 205 if (!delegate) { |
184 DLOG(WARNING) << "OnDeviceFormatInUse: unknown device"; | 206 DLOG(WARNING) << "OnDeviceFormatInUse: unknown device"; |
185 return; | 207 return; |
186 } | 208 } |
187 delegate->OnDeviceFormatsInUseReceived(formats_in_use); | 209 delegate->OnDeviceFormatsInUseReceived(formats_in_use); |
188 } | 210 } |
189 | 211 |
190 } // namespace content | 212 } // namespace content |
OLD | NEW |