| 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 | 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which |
| 10 // relays operation of capture device to browser process and receives response | 10 // relays operation of capture device to browser process and receives response |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 // VideoCaptureMessageFilter::Delegate interface. | 51 // VideoCaptureMessageFilter::Delegate interface. |
| 52 virtual void OnBufferCreated(base::SharedMemoryHandle handle, | 52 virtual void OnBufferCreated(base::SharedMemoryHandle handle, |
| 53 int length, int buffer_id) OVERRIDE; | 53 int length, int buffer_id) OVERRIDE; |
| 54 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE; | 54 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE; |
| 55 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; | 55 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; |
| 56 virtual void OnDeviceInfoReceived( | 56 virtual void OnDeviceInfoReceived( |
| 57 const media::VideoCaptureParams& device_info) OVERRIDE; | 57 const media::VideoCaptureParams& device_info) OVERRIDE; |
| 58 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; | 58 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; |
| 59 | 59 |
| 60 // Stop/resume delivering video frames to clients, based on flag |suspend|. |
| 61 virtual void SuspendCapture(bool suspend); |
| 62 |
| 60 private: | 63 private: |
| 61 friend class VideoCaptureImplManager; | 64 friend class VideoCaptureImplManager; |
| 62 friend class VideoCaptureImplTest; | 65 friend class VideoCaptureImplTest; |
| 63 friend class MockVideoCaptureImpl; | 66 friend class MockVideoCaptureImpl; |
| 64 | 67 |
| 65 struct DIBBuffer; | 68 struct DIBBuffer; |
| 66 typedef std::map<media::VideoCapture::EventHandler*, | 69 typedef std::map<media::VideoCapture::EventHandler*, |
| 67 media::VideoCaptureCapability> ClientInfo; | 70 media::VideoCaptureCapability> ClientInfo; |
| 68 | 71 |
| 69 VideoCaptureImpl(media::VideoCaptureSessionId id, | 72 VideoCaptureImpl(media::VideoCaptureSessionId id, |
| 70 base::MessageLoopProxy* capture_message_loop_proxy, | 73 base::MessageLoopProxy* capture_message_loop_proxy, |
| 71 VideoCaptureMessageFilter* filter); | 74 VideoCaptureMessageFilter* filter); |
| 72 virtual ~VideoCaptureImpl(); | 75 virtual ~VideoCaptureImpl(); |
| 73 | 76 |
| 74 void DoStartCaptureOnCaptureThread( | 77 void DoStartCaptureOnCaptureThread( |
| 75 media::VideoCapture::EventHandler* handler, | 78 media::VideoCapture::EventHandler* handler, |
| 76 const media::VideoCaptureCapability& capability); | 79 const media::VideoCaptureCapability& capability); |
| 77 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler); | 80 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler); |
| 78 void DoFeedBufferOnCaptureThread(scoped_refptr<VideoFrameBuffer> buffer); | 81 void DoFeedBufferOnCaptureThread(scoped_refptr<VideoFrameBuffer> buffer); |
| 79 | 82 |
| 80 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, | 83 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, |
| 81 int length, int buffer_id); | 84 int length, int buffer_id); |
| 82 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp); | 85 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp); |
| 83 void DoStateChangedOnCaptureThread(VideoCaptureState state); | 86 void DoStateChangedOnCaptureThread(VideoCaptureState state); |
| 84 void DoDeviceInfoReceivedOnCaptureThread( | 87 void DoDeviceInfoReceivedOnCaptureThread( |
| 85 const media::VideoCaptureParams& device_info); | 88 const media::VideoCaptureParams& device_info); |
| 86 void DoDelegateAddedOnCaptureThread(int32 device_id); | 89 void DoDelegateAddedOnCaptureThread(int32 device_id); |
| 87 | 90 |
| 91 void DoSuspendCaptureOnCaptureThread(bool suspend); |
| 92 |
| 88 void Init(); | 93 void Init(); |
| 89 void DeInit(base::Closure task); | 94 void DeInit(base::Closure task); |
| 90 void DoDeInitOnCaptureThread(base::Closure task); | 95 void DoDeInitOnCaptureThread(base::Closure task); |
| 91 void StopDevice(); | 96 void StopDevice(); |
| 92 void RestartCapture(); | 97 void RestartCapture(); |
| 93 void StartCaptureInternal(); | 98 void StartCaptureInternal(); |
| 94 void AddDelegateOnIOThread(); | 99 void AddDelegateOnIOThread(); |
| 95 void RemoveDelegateOnIOThread(base::Closure task); | 100 void RemoveDelegateOnIOThread(base::Closure task); |
| 96 virtual void Send(IPC::Message* message); | 101 virtual void Send(IPC::Message* message); |
| 97 | 102 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 media::VideoCaptureCapability::Format video_type_; | 122 media::VideoCaptureCapability::Format video_type_; |
| 118 | 123 |
| 119 // The parameter is being used in current capture session. A capture session | 124 // The parameter is being used in current capture session. A capture session |
| 120 // starts with StartCapture and ends with StopCapture. | 125 // starts with StartCapture and ends with StopCapture. |
| 121 media::VideoCaptureParams current_params_; | 126 media::VideoCaptureParams current_params_; |
| 122 | 127 |
| 123 // The information about the device sent from browser process side. | 128 // The information about the device sent from browser process side. |
| 124 media::VideoCaptureParams device_info_; | 129 media::VideoCaptureParams device_info_; |
| 125 bool device_info_available_; | 130 bool device_info_available_; |
| 126 | 131 |
| 132 bool suspended_; |
| 127 VideoCaptureState state_; | 133 VideoCaptureState state_; |
| 128 | 134 |
| 129 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 135 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 } // namespace content | 138 } // namespace content |
| 133 | 139 |
| 134 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 140 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |