Chromium Code Reviews| Index: content/renderer/media/video_capture_message_filter.cc |
| diff --git a/content/renderer/media/video_capture_message_filter.cc b/content/renderer/media/video_capture_message_filter.cc |
| index 4d59729ba75b1854f680113db4c65fffa9c89940..4eac2379cedcc89b9fcedfd36eee6525303d7f8d 100644 |
| --- a/content/renderer/media/video_capture_message_filter.cc |
| +++ b/content/renderer/media/video_capture_message_filter.cc |
| @@ -4,6 +4,7 @@ |
| #include "content/renderer/media/video_capture_message_filter.h" |
| +#include "content/common/media/encoded_video_source_messages.h" |
| #include "content/common/media/video_capture_messages.h" |
| #include "content/common/view_messages.h" |
| @@ -61,7 +62,17 @@ bool VideoCaptureMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| IPC_MESSAGE_HANDLER(VideoCaptureMsg_StateChanged, OnDeviceStateChanged) |
| IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer, OnBufferCreated) |
| IPC_MESSAGE_HANDLER(VideoCaptureMsg_DeviceInfo, OnDeviceInfoReceived) |
| - IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_MESSAGE_HANDLER(EncodedVideoSourceMsg_CapabilitiesAvailable, |
| + OnCapabilitiesAvailable) |
| + IPC_MESSAGE_HANDLER(EncodedVideoSourceMsg_BitstreamOpened, |
| + OnBitstreamOpened) |
| + IPC_MESSAGE_HANDLER(EncodedVideoSourceMsg_BitstreamClosed, |
| + OnBitstreamClosed) |
| + IPC_MESSAGE_HANDLER(EncodedVideoSourceMsg_BitstreamConfigChanged, |
| + OnBitstreamConfigChanged) |
| + IPC_MESSAGE_HANDLER(EncodedVideoSourceMsg_BitstreamReady, |
| + OnBitstreamReady); |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| } |
| @@ -90,15 +101,20 @@ void VideoCaptureMessageFilter::OnChannelClosing() { |
| VideoCaptureMessageFilter::~VideoCaptureMessageFilter() {} |
| +VideoCaptureMessageFilter::Delegate* VideoCaptureMessageFilter::find_delegate( |
|
Ami GONE FROM CHROMIUM
2013/06/12 01:44:06
This pattern of demultiplexing messages from a sin
hshi1
2013/06/12 17:52:39
There's no good reason; the existing messages are
sheu
2013/06/12 22:35:05
I believe it's due to the fact that routing IDs ar
|
| + int device_id) const { |
| + VideoCaptureMessageFilter::Delegate* delegate = NULL; |
| + if (delegates_.find(device_id) != delegates_.end()) |
| + delegate = delegates_.find(device_id)->second; |
| + return delegate; |
| +} |
| + |
| void VideoCaptureMessageFilter::OnBufferCreated( |
| int device_id, |
| base::SharedMemoryHandle handle, |
| int length, |
| int buffer_id) { |
| - Delegate* delegate = NULL; |
| - if (delegates_.find(device_id) != delegates_.end()) |
| - delegate = delegates_.find(device_id)->second; |
| - |
| + Delegate* delegate = find_delegate(device_id); |
| if (!delegate) { |
| DLOG(WARNING) << "OnBufferCreated: Got video frame buffer for a " |
| "non-existent or removed video capture."; |
| @@ -117,10 +133,7 @@ void VideoCaptureMessageFilter::OnBufferReceived( |
| int device_id, |
| int buffer_id, |
| base::Time timestamp) { |
| - Delegate* delegate = NULL; |
| - if (delegates_.find(device_id) != delegates_.end()) |
| - delegate = delegates_.find(device_id)->second; |
| - |
| + Delegate* delegate = find_delegate(device_id); |
| if (!delegate) { |
| DLOG(WARNING) << "OnBufferReceived: Got video frame buffer for a " |
| "non-existent or removed video capture."; |
| @@ -137,9 +150,7 @@ void VideoCaptureMessageFilter::OnBufferReceived( |
| void VideoCaptureMessageFilter::OnDeviceStateChanged( |
| int device_id, |
| VideoCaptureState state) { |
| - Delegate* delegate = NULL; |
| - if (delegates_.find(device_id) != delegates_.end()) |
| - delegate = delegates_.find(device_id)->second; |
| + Delegate* delegate = find_delegate(device_id); |
| if (!delegate) { |
| DLOG(WARNING) << "OnDeviceStateChanged: Got video capture event for a " |
| "non-existent or removed video capture."; |
| @@ -151,9 +162,7 @@ void VideoCaptureMessageFilter::OnDeviceStateChanged( |
| void VideoCaptureMessageFilter::OnDeviceInfoReceived( |
| int device_id, |
| const media::VideoCaptureParams& params) { |
| - Delegate* delegate = NULL; |
| - if (delegates_.find(device_id) != delegates_.end()) |
| - delegate = delegates_.find(device_id)->second; |
| + Delegate* delegate = find_delegate(device_id); |
| if (!delegate) { |
| DLOG(WARNING) << "OnDeviceInfoReceived: Got video capture event for a " |
| "non-existent or removed video capture."; |
| @@ -162,4 +171,65 @@ void VideoCaptureMessageFilter::OnDeviceInfoReceived( |
| delegate->OnDeviceInfoReceived(params); |
| } |
| +void VideoCaptureMessageFilter::OnCapabilitiesAvailable( |
| + int device_id, |
| + media::VideoEncodingCapabilities capabilities) { |
| + Delegate* delegate = find_delegate(device_id); |
| + if (!delegate) { |
| + DLOG(WARNING) << "OnCapabilitiesAvailable: Got video capture event for a " |
| + "non-existent or removed video capture."; |
| + return; |
| + } |
| + delegate->OnCapabilitiesAvailable(capabilities); |
| +} |
| + |
| +void VideoCaptureMessageFilter::OnBitstreamOpened( |
| + int device_id, |
| + media::VideoEncodingParameters params, |
| + std::map<int, base::SharedMemoryHandle> buffers) { |
|
Ami GONE FROM CHROMIUM
2013/06/12 01:44:06
.h file passes this as const& but here it's passed
hshi1
2013/06/12 17:52:39
No the .h passes this as a copy for VCMessageFilte
|
| + Delegate* delegate = find_delegate(device_id); |
| + if (!delegate) { |
| + DLOG(WARNING) << "OnBitstreamOpened: Got video capture event for a " |
| + "non-existent or removed video capture."; |
| + return; |
| + } |
| + delegate->OnBitstreamOpened(params, buffers); |
| +} |
| + |
| +void VideoCaptureMessageFilter::OnBitstreamClosed(int device_id) { |
| + Delegate* delegate = find_delegate(device_id); |
| + if (!delegate) { |
| + DLOG(WARNING) << "OnBitstreamClosed: Got video capture event for a " |
| + "non-existent or removed video capture."; |
| + return; |
| + } |
| + delegate->OnBitstreamClosed(); |
| +} |
| + |
| +void VideoCaptureMessageFilter::OnBitstreamConfigChanged( |
| + int device_id, |
| + media::RuntimeVideoEncodingParameters params) { |
| + Delegate* delegate = find_delegate(device_id); |
| + if (!delegate) { |
| + DLOG(WARNING) << "OnBitstreamConfigChanged: Got video capture event for a " |
| + "non-existent or removed video capture."; |
| + return; |
| + } |
| + delegate->OnBitstreamConfigChanged(params); |
| +} |
| + |
| +void VideoCaptureMessageFilter::OnBitstreamReady( |
| + int device_id, |
| + int buffer_id, |
| + size_t size, |
| + media::BufferEncodingMetadata metadata) { |
| + Delegate* delegate = find_delegate(device_id); |
| + if (!delegate) { |
| + DLOG(WARNING) << "OnBitstreamReady: Got video capture event for a " |
| + "non-existent or removed video capture."; |
| + return; |
| + } |
| + delegate->OnBitstreamReady(buffer_id, size, metadata); |
| +} |
| + |
| } // namespace content |