| 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 // VideoCaptureImpl represents a capture device in renderer process. It provides | 5 // VideoCaptureImpl represents a capture device in renderer process. It provides |
| 6 // interfaces for clients to Start/Stop capture. It also communicates to clients | 6 // interfaces for clients to Start/Stop capture. It also communicates to clients |
| 7 // when buffer is ready, state of capture device is changed. | 7 // when buffer is ready, state of capture device is changed. |
| 8 | 8 |
| 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays | 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays |
| 10 // operation of a capture device to the browser process and receives responses | 10 // operation of a capture device to the browser process and receives responses |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "base/memory/weak_ptr.h" | 34 #include "base/memory/weak_ptr.h" |
| 35 #include "content/common/content_export.h" | 35 #include "content/common/content_export.h" |
| 36 #include "content/common/media/video_capture.h" | 36 #include "content/common/media/video_capture.h" |
| 37 #include "content/renderer/media/video_capture_message_filter.h" | 37 #include "content/renderer/media/video_capture_message_filter.h" |
| 38 #include "media/video/capture/video_capture.h" | 38 #include "media/video/capture/video_capture.h" |
| 39 #include "media/video/capture/video_capture_types.h" | 39 #include "media/video/capture/video_capture_types.h" |
| 40 | 40 |
| 41 namespace base { | 41 namespace base { |
| 42 class MessageLoopProxy; | 42 class MessageLoopProxy; |
| 43 } | 43 } // namespace base |
| 44 |
| 45 namespace gpu { |
| 46 struct MailboxHolder; |
| 47 } // namespace gpu |
| 44 | 48 |
| 45 namespace content { | 49 namespace content { |
| 46 | 50 |
| 47 class CONTENT_EXPORT VideoCaptureImpl | 51 class CONTENT_EXPORT VideoCaptureImpl |
| 48 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { | 52 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { |
| 49 public: | 53 public: |
| 50 VideoCaptureImpl(media::VideoCaptureSessionId session_id, | 54 VideoCaptureImpl(media::VideoCaptureSessionId session_id, |
| 51 VideoCaptureMessageFilter* filter); | 55 VideoCaptureMessageFilter* filter); |
| 52 virtual ~VideoCaptureImpl(); | 56 virtual ~VideoCaptureImpl(); |
| 53 | 57 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 void GetDeviceSupportedFormatsOnIOThread( | 96 void GetDeviceSupportedFormatsOnIOThread( |
| 93 const DeviceFormatsCallback& callback); | 97 const DeviceFormatsCallback& callback); |
| 94 void GetDeviceFormatsInUseOnIOThread( | 98 void GetDeviceFormatsInUseOnIOThread( |
| 95 const DeviceFormatsInUseCallback& callback); | 99 const DeviceFormatsInUseCallback& callback); |
| 96 | 100 |
| 97 // VideoCaptureMessageFilter::Delegate interface. | 101 // VideoCaptureMessageFilter::Delegate interface. |
| 98 virtual void OnBufferCreated(base::SharedMemoryHandle handle, | 102 virtual void OnBufferCreated(base::SharedMemoryHandle handle, |
| 99 int length, | 103 int length, |
| 100 int buffer_id) OVERRIDE; | 104 int buffer_id) OVERRIDE; |
| 101 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; | 105 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; |
| 102 virtual void OnBufferReceived( | 106 virtual void OnBufferReceived(int buffer_id, |
| 103 int buffer_id, | 107 const media::VideoCaptureFormat& format, |
| 104 base::TimeTicks timestamp, | 108 base::TimeTicks) OVERRIDE; |
| 105 const media::VideoCaptureFormat& format) OVERRIDE; | 109 virtual void OnMailboxBufferReceived(int buffer_id, |
| 110 const gpu::MailboxHolder& mailbox_holder, |
| 111 const media::VideoCaptureFormat& format, |
| 112 base::TimeTicks timestamp) OVERRIDE; |
| 106 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; | 113 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; |
| 107 virtual void OnDeviceSupportedFormatsEnumerated( | 114 virtual void OnDeviceSupportedFormatsEnumerated( |
| 108 const media::VideoCaptureFormats& supported_formats) OVERRIDE; | 115 const media::VideoCaptureFormats& supported_formats) OVERRIDE; |
| 109 virtual void OnDeviceFormatsInUseReceived( | 116 virtual void OnDeviceFormatsInUseReceived( |
| 110 const media::VideoCaptureFormats& formats_in_use) OVERRIDE; | 117 const media::VideoCaptureFormats& formats_in_use) OVERRIDE; |
| 111 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; | 118 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; |
| 112 | 119 |
| 113 // Sends an IPC message to browser process when all clients are done with the | 120 // Sends an IPC message to browser process when all clients are done with the |
| 114 // buffer. | 121 // buffer. |
| 115 void OnClientBufferFinished( | 122 void OnClientBufferFinished(int buffer_id, |
| 116 int buffer_id, | 123 const scoped_refptr<ClientBuffer>& buffer, |
| 117 const scoped_refptr<ClientBuffer>& buffer); | 124 scoped_ptr<gpu::MailboxHolder> mailbox_holder); |
| 118 | 125 |
| 119 void StopDevice(); | 126 void StopDevice(); |
| 120 void RestartCapture(); | 127 void RestartCapture(); |
| 121 void StartCaptureInternal(); | 128 void StartCaptureInternal(); |
| 122 | 129 |
| 123 virtual void Send(IPC::Message* message); | 130 virtual void Send(IPC::Message* message); |
| 124 | 131 |
| 125 // Helpers. | 132 // Helpers. |
| 126 bool RemoveClient(media::VideoCapture::EventHandler* handler, | 133 bool RemoveClient(media::VideoCapture::EventHandler* handler, |
| 127 ClientInfo* clients); | 134 ClientInfo* clients); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 170 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
| 164 // in |client_buffers_|. | 171 // in |client_buffers_|. |
| 165 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; | 172 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; |
| 166 | 173 |
| 167 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 174 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 168 }; | 175 }; |
| 169 | 176 |
| 170 } // namespace content | 177 } // namespace content |
| 171 | 178 |
| 172 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 179 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |