| 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 21 matching lines...) Expand all Loading... |
| 32 #include <map> | 32 #include <map> |
| 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 |
| 42 class MessageLoopProxy; | 43 class MessageLoopProxy; |
| 43 } | 44 |
| 45 } // namespace base |
| 46 |
| 47 namespace gpu { |
| 48 |
| 49 class MailboxHolder; |
| 50 |
| 51 } // namespace gpu |
| 44 | 52 |
| 45 namespace content { | 53 namespace content { |
| 46 | 54 |
| 47 class CONTENT_EXPORT VideoCaptureImpl | 55 class CONTENT_EXPORT VideoCaptureImpl |
| 48 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { | 56 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { |
| 49 public: | 57 public: |
| 50 VideoCaptureImpl(media::VideoCaptureSessionId session_id, | 58 VideoCaptureImpl(media::VideoCaptureSessionId session_id, |
| 51 VideoCaptureMessageFilter* filter); | 59 VideoCaptureMessageFilter* filter); |
| 52 virtual ~VideoCaptureImpl(); | 60 virtual ~VideoCaptureImpl(); |
| 53 | 61 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 84 void StartCaptureOnIOThread( | 92 void StartCaptureOnIOThread( |
| 85 media::VideoCapture::EventHandler* handler, | 93 media::VideoCapture::EventHandler* handler, |
| 86 const media::VideoCaptureParams& params); | 94 const media::VideoCaptureParams& params); |
| 87 void StopCaptureOnIOThread(media::VideoCapture::EventHandler* handler); | 95 void StopCaptureOnIOThread(media::VideoCapture::EventHandler* handler); |
| 88 | 96 |
| 89 // VideoCaptureMessageFilter::Delegate interface. | 97 // VideoCaptureMessageFilter::Delegate interface. |
| 90 virtual void OnBufferCreated(base::SharedMemoryHandle handle, | 98 virtual void OnBufferCreated(base::SharedMemoryHandle handle, |
| 91 int length, | 99 int length, |
| 92 int buffer_id) OVERRIDE; | 100 int buffer_id) OVERRIDE; |
| 93 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; | 101 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; |
| 94 virtual void OnBufferReceived( | 102 virtual void OnBufferReceived(int buffer_id, |
| 95 int buffer_id, | 103 const media::VideoCaptureFormat& format, |
| 96 base::TimeTicks timestamp, | 104 base::TimeTicks) OVERRIDE; |
| 97 const media::VideoCaptureFormat& format) OVERRIDE; | 105 virtual void OnMailboxBufferReceived(int buffer_id, |
| 106 const gpu::MailboxHolder& mailbox_holder, |
| 107 const media::VideoCaptureFormat& format, |
| 108 base::TimeTicks timestamp) OVERRIDE; |
| 109 OVERRIDE; |
| 98 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; | 110 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; |
| 99 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; | 111 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; |
| 100 | 112 |
| 101 // Sends an IPC message to browser process when all clients are done with the | 113 // Sends an IPC message to browser process when all clients are done with the |
| 102 // buffer. | 114 // buffer. |
| 103 void OnClientBufferFinished( | 115 void OnClientBufferFinished(int buffer_id, |
| 104 int buffer_id, | 116 const scoped_refptr<ClientBuffer>& buffer, |
| 105 const scoped_refptr<ClientBuffer>& buffer); | 117 const gpu::MailboxHolder* mailbox_holder); |
| 106 | 118 |
| 107 void StopDevice(); | 119 void StopDevice(); |
| 108 void RestartCapture(); | 120 void RestartCapture(); |
| 109 void StartCaptureInternal(); | 121 void StartCaptureInternal(); |
| 110 virtual void Send(IPC::Message* message); | 122 virtual void Send(IPC::Message* message); |
| 111 | 123 |
| 112 // Helpers. | 124 // Helpers. |
| 113 bool RemoveClient(media::VideoCapture::EventHandler* handler, | 125 bool RemoveClient(media::VideoCapture::EventHandler* handler, |
| 114 ClientInfo* clients); | 126 ClientInfo* clients); |
| 115 | 127 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 143 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 155 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
| 144 // in |client_buffers_|. | 156 // in |client_buffers_|. |
| 145 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; | 157 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; |
| 146 | 158 |
| 147 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 159 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 148 }; | 160 }; |
| 149 | 161 |
| 150 } // namespace content | 162 } // namespace content |
| 151 | 163 |
| 152 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 164 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |