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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 const media::VideoCaptureParams& params) OVERRIDE; | 55 const media::VideoCaptureParams& params) OVERRIDE; |
56 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; | 56 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; |
57 virtual bool CaptureStarted() OVERRIDE; | 57 virtual bool CaptureStarted() OVERRIDE; |
58 virtual int CaptureFrameRate() OVERRIDE; | 58 virtual int CaptureFrameRate() OVERRIDE; |
59 | 59 |
60 // VideoCaptureMessageFilter::Delegate interface. | 60 // VideoCaptureMessageFilter::Delegate interface. |
61 virtual void OnBufferCreated(base::SharedMemoryHandle handle, | 61 virtual void OnBufferCreated(base::SharedMemoryHandle handle, |
62 int length, | 62 int length, |
63 int buffer_id) OVERRIDE; | 63 int buffer_id) OVERRIDE; |
64 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; | 64 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE; |
65 virtual void OnBufferReceived( | 65 virtual void OnBufferReceived(int buffer_id, |
66 int buffer_id, | 66 base::TimeTicks timestamp, |
67 base::Time timestamp, | 67 const media::VideoCaptureFormat& format) |
68 const media::VideoCaptureFormat& format) OVERRIDE; | 68 OVERRIDE; |
69 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; | 69 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; |
70 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; | 70 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; |
71 | 71 |
72 // Stop/resume delivering video frames to clients, based on flag |suspend|. | 72 // Stop/resume delivering video frames to clients, based on flag |suspend|. |
73 virtual void SuspendCapture(bool suspend); | 73 virtual void SuspendCapture(bool suspend); |
74 | 74 |
75 private: | 75 private: |
76 friend class VideoCaptureImplManager; | 76 friend class VideoCaptureImplManager; |
77 friend class VideoCaptureImplTest; | 77 friend class VideoCaptureImplTest; |
78 friend class MockVideoCaptureImpl; | 78 friend class MockVideoCaptureImpl; |
79 | 79 |
80 class ClientBuffer; | 80 class ClientBuffer; |
81 typedef std::map<media::VideoCapture::EventHandler*, | 81 typedef std::map<media::VideoCapture::EventHandler*, |
82 media::VideoCaptureParams> ClientInfo; | 82 media::VideoCaptureParams> ClientInfo; |
83 | 83 |
84 VideoCaptureImpl(media::VideoCaptureSessionId session_id, | 84 VideoCaptureImpl(media::VideoCaptureSessionId session_id, |
85 base::MessageLoopProxy* capture_message_loop_proxy, | 85 base::MessageLoopProxy* capture_message_loop_proxy, |
86 VideoCaptureMessageFilter* filter); | 86 VideoCaptureMessageFilter* filter); |
87 virtual ~VideoCaptureImpl(); | 87 virtual ~VideoCaptureImpl(); |
88 | 88 |
89 void DoStartCaptureOnCaptureThread( | 89 void DoStartCaptureOnCaptureThread( |
90 media::VideoCapture::EventHandler* handler, | 90 media::VideoCapture::EventHandler* handler, |
91 const media::VideoCaptureParams& params); | 91 const media::VideoCaptureParams& params); |
92 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler); | 92 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler); |
93 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, | 93 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, |
94 int length, | 94 int length, |
95 int buffer_id); | 95 int buffer_id); |
96 void DoBufferDestroyedOnCaptureThread(int buffer_id); | 96 void DoBufferDestroyedOnCaptureThread(int buffer_id); |
97 void DoBufferReceivedOnCaptureThread( | 97 void DoBufferReceivedOnCaptureThread(int buffer_id, |
98 int buffer_id, | 98 base::TimeTicks timestamp, |
99 base::Time timestamp, | 99 const media::VideoCaptureFormat& format); |
100 const media::VideoCaptureFormat& format); | |
101 void DoClientBufferFinishedOnCaptureThread( | 100 void DoClientBufferFinishedOnCaptureThread( |
102 int buffer_id, | 101 int buffer_id, |
103 const scoped_refptr<ClientBuffer>& buffer); | 102 const scoped_refptr<ClientBuffer>& buffer); |
104 void DoStateChangedOnCaptureThread(VideoCaptureState state); | 103 void DoStateChangedOnCaptureThread(VideoCaptureState state); |
105 void DoDelegateAddedOnCaptureThread(int32 device_id); | 104 void DoDelegateAddedOnCaptureThread(int32 device_id); |
106 | 105 |
107 void DoSuspendCaptureOnCaptureThread(bool suspend); | 106 void DoSuspendCaptureOnCaptureThread(bool suspend); |
108 | 107 |
109 void Init(); | 108 void Init(); |
110 void DeInit(base::Closure task); | 109 void DeInit(base::Closure task); |
(...skipping 23 matching lines...) Expand all Loading... | |
134 ClientInfo clients_pending_on_filter_; | 133 ClientInfo clients_pending_on_filter_; |
135 ClientInfo clients_pending_on_restart_; | 134 ClientInfo clients_pending_on_restart_; |
136 | 135 |
137 // Member params_ represents the video format requested by the | 136 // Member params_ represents the video format requested by the |
138 // client to this class via DoStartCaptureOnCaptureThread. | 137 // client to this class via DoStartCaptureOnCaptureThread. |
139 media::VideoCaptureParams params_; | 138 media::VideoCaptureParams params_; |
140 | 139 |
141 // The device's video capture format sent from browser process side. | 140 // The device's video capture format sent from browser process side. |
142 media::VideoCaptureFormat last_frame_format_; | 141 media::VideoCaptureFormat last_frame_format_; |
143 | 142 |
143 // The device's last captured frame timestamp sent from browser process side. | |
144 base::TimeTicks last_frame_timestamp_; | |
miu
2014/01/06 22:39:37
This comment and member name are wrong. This look
sheu
2014/01/06 22:52:37
Heh yeah. I was not really paying enough attentio
| |
145 | |
144 bool suspended_; | 146 bool suspended_; |
145 VideoCaptureState state_; | 147 VideoCaptureState state_; |
146 | 148 |
147 // WeakPtrFactory pointing back to |this| object, for use with | 149 // WeakPtrFactory pointing back to |this| object, for use with |
148 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 150 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
149 // in |client_buffers_|. | 151 // in |client_buffers_|. |
150 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; | 152 base::WeakPtrFactory<VideoCaptureImpl> weak_this_factory_; |
151 | 153 |
152 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 154 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
153 }; | 155 }; |
154 | 156 |
155 } // namespace content | 157 } // namespace content |
156 | 158 |
157 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 159 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
OLD | NEW |