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 // MessageFilter that handles video capture messages and delegates them to | 5 // MessageFilter that handles video capture messages and delegates them to |
6 // video captures. VideoCaptureMessageFilter is operated on IO thread of | 6 // video captures. VideoCaptureMessageFilter is operated on IO thread of |
7 // render process. It intercepts video capture messages and process them on | 7 // render process. It intercepts video capture messages and process them on |
8 // IO thread since these messages are time critical. | 8 // IO thread since these messages are time critical. |
9 | 9 |
10 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ | 10 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ |
11 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ | 11 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 | 14 |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/media/video_capture.h" | 18 #include "content/common/media/video_capture.h" |
19 #include "ipc/message_filter.h" | 19 #include "ipc/message_filter.h" |
20 #include "media/base/video_capture_types.h" | 20 #include "media/base/video_capture_types.h" |
| 21 #include "ui/gfx/gpu_memory_buffer.h" |
21 | 22 |
22 struct VideoCaptureMsg_BufferReady_Params; | 23 struct VideoCaptureMsg_BufferReady_Params; |
23 | 24 |
24 namespace gpu { | 25 namespace gpu { |
25 struct MailboxHolder; | 26 struct MailboxHolder; |
26 } // namespace gpu | 27 } // namespace gpu |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 class CONTENT_EXPORT VideoCaptureMessageFilter : public IPC::MessageFilter { | 31 class CONTENT_EXPORT VideoCaptureMessageFilter : public IPC::MessageFilter { |
31 public: | 32 public: |
32 class CONTENT_EXPORT Delegate { | 33 class CONTENT_EXPORT Delegate { |
33 public: | 34 public: |
34 // Called when a video frame buffer is created in the browser process. | 35 // Called when a video frame buffer is created in the browser process. |
35 virtual void OnBufferCreated(base::SharedMemoryHandle handle, | 36 virtual void OnBufferCreated(base::SharedMemoryHandle handle, |
36 int length, | 37 int length, |
37 int buffer_id) = 0; | 38 int buffer_id) = 0; |
38 | 39 |
| 40 // Called when a GpuMemoryBuffer backed video frame buffer is created in the |
| 41 // browser process. |
| 42 virtual void OnBufferCreated2( |
| 43 const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
| 44 const gfx::Size& size, |
| 45 int buffer_id) = 0; |
| 46 |
39 virtual void OnBufferDestroyed(int buffer_id) = 0; | 47 virtual void OnBufferDestroyed(int buffer_id) = 0; |
40 | 48 |
41 // Called when a buffer referencing a captured VideoFrame is received from | 49 // Called when a buffer referencing a captured VideoFrame is received from |
42 // Browser process. | 50 // Browser process. |
43 virtual void OnBufferReceived(int buffer_id, | 51 virtual void OnBufferReceived( |
44 base::TimeTicks timestamp, | 52 int buffer_id, |
45 const base::DictionaryValue& metadata, | 53 base::TimeTicks timestamp, |
46 media::VideoPixelFormat pixel_format, | 54 const base::DictionaryValue& metadata, |
47 media::VideoFrame::StorageType storage_type, | 55 media::VideoPixelFormat pixel_format, |
48 const gfx::Size& coded_size, | 56 media::VideoFrame::StorageType storage_type, |
49 const gfx::Rect& visible_rect, | 57 const gfx::Size& coded_size, |
50 const gpu::MailboxHolder& mailbox_holder) = 0; | 58 const gfx::Rect& visible_rect, |
| 59 const gpu::MailboxHolder& mailbox_holder) = 0; |
51 | 60 |
52 // Called when state of a video capture device has changed in the browser | 61 // Called when state of a video capture device has changed in the browser |
53 // process. | 62 // process. |
54 virtual void OnStateChanged(VideoCaptureState state) = 0; | 63 virtual void OnStateChanged(VideoCaptureState state) = 0; |
55 | 64 |
56 // Called upon reception of device's supported formats back from browser. | 65 // Called upon reception of device's supported formats back from browser. |
57 virtual void OnDeviceSupportedFormatsEnumerated( | 66 virtual void OnDeviceSupportedFormatsEnumerated( |
58 const media::VideoCaptureFormats& supported_formats) = 0; | 67 const media::VideoCaptureFormats& supported_formats) = 0; |
59 | 68 |
60 // Called upon reception of format(s) in use by a device back from browser. | 69 // Called upon reception of format(s) in use by a device back from browser. |
(...skipping 30 matching lines...) Expand all Loading... |
91 | 100 |
92 private: | 101 private: |
93 typedef std::map<int32, Delegate*> Delegates; | 102 typedef std::map<int32, Delegate*> Delegates; |
94 | 103 |
95 // Receive a newly created buffer from browser process. | 104 // Receive a newly created buffer from browser process. |
96 void OnBufferCreated(int device_id, | 105 void OnBufferCreated(int device_id, |
97 base::SharedMemoryHandle handle, | 106 base::SharedMemoryHandle handle, |
98 int length, | 107 int length, |
99 int buffer_id); | 108 int buffer_id); |
100 | 109 |
| 110 // Receive a newly created GpuMemoryBuffer backed buffer from browser process. |
| 111 void OnBufferCreated2( |
| 112 int device_id, |
| 113 const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
| 114 const gfx::Size& size, |
| 115 int buffer_id); |
| 116 |
101 // Release a buffer received by OnBufferCreated. | 117 // Release a buffer received by OnBufferCreated. |
102 void OnBufferDestroyed(int device_id, | 118 void OnBufferDestroyed(int device_id, |
103 int buffer_id); | 119 int buffer_id); |
104 | 120 |
105 // Receive a filled buffer from browser process. | 121 // Receive a filled buffer from browser process. |
106 void OnBufferReceived(const VideoCaptureMsg_BufferReady_Params& params); | 122 void OnBufferReceived(const VideoCaptureMsg_BufferReady_Params& params); |
107 | 123 |
108 // State of browser process' video capture device has changed. | 124 // State of browser process' video capture device has changed. |
109 void OnDeviceStateChanged(int device_id, VideoCaptureState state); | 125 void OnDeviceStateChanged(int device_id, VideoCaptureState state); |
110 | 126 |
(...skipping 16 matching lines...) Expand all Loading... |
127 int32 last_device_id_; | 143 int32 last_device_id_; |
128 | 144 |
129 IPC::Sender* sender_; | 145 IPC::Sender* sender_; |
130 | 146 |
131 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMessageFilter); | 147 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMessageFilter); |
132 }; | 148 }; |
133 | 149 |
134 } // namespace content | 150 } // namespace content |
135 | 151 |
136 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ | 152 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MESSAGE_FILTER_H_ |
OLD | NEW |