Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: content/renderer/media/video_capture_impl.h

Issue 23551011: From Video Capture, abolish OnFrameInfo and enable resolution changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes from bbudge Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 relays
10 // relays operation of capture device to browser process and receives response 10 // operation of a capture device to the browser process and receives responses
11 // from browser process. 11 // from browser process.
12 12
13 // The media::VideoCapture and VideoCaptureMessageFilter::Delegate are 13 // The media::VideoCapture and VideoCaptureMessageFilter::Delegate are
14 // asynchronous interfaces, which means callers can call those interfaces 14 // asynchronous interfaces, which means callers can call those interfaces
15 // from any threads without worrying about thread safety. 15 // from any threads without worrying about thread safety.
16 // The |capture_message_loop_proxy_| is the working thread of VideoCaptureImpl. 16 // The |capture_message_loop_proxy_| is the working thread of VideoCaptureImpl.
17 // All non-const members are accessed only on that working thread. 17 // All non-const members are accessed only on that working thread.
18 // 18 //
19 // Implementation note: tasks are posted bound to Unretained(this) to both the 19 // Implementation note: tasks are posted bound to Unretained(this) to both the
20 // I/O and Capture threads and this is safe (even though the I/O thread is 20 // I/O and Capture threads and this is safe (even though the I/O thread is
(...skipping 24 matching lines...) Expand all
45 } 45 }
46 46
47 namespace content { 47 namespace content {
48 48
49 class CONTENT_EXPORT VideoCaptureImpl 49 class CONTENT_EXPORT VideoCaptureImpl
50 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { 50 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate {
51 public: 51 public:
52 // media::VideoCapture interface. 52 // media::VideoCapture interface.
53 virtual void StartCapture( 53 virtual void StartCapture(
54 media::VideoCapture::EventHandler* handler, 54 media::VideoCapture::EventHandler* handler,
55 const media::VideoCaptureCapability& capability) 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 CaptureWidth() OVERRIDE;
59 virtual int CaptureHeight() OVERRIDE;
60 virtual int CaptureFrameRate() OVERRIDE; 58 virtual int CaptureFrameRate() OVERRIDE;
61 59
62 // VideoCaptureMessageFilter::Delegate interface. 60 // VideoCaptureMessageFilter::Delegate interface.
63 virtual void OnBufferCreated(base::SharedMemoryHandle handle, 61 virtual void OnBufferCreated(base::SharedMemoryHandle handle,
64 int length, int buffer_id) OVERRIDE; 62 int length,
65 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE; 63 int buffer_id) OVERRIDE;
64 virtual void OnBufferDestroyed(int buffer_id) OVERRIDE;
65 virtual void OnBufferReceived(
66 int buffer_id,
67 base::Time timestamp,
68 const media::VideoCaptureFormat& format) OVERRIDE;
66 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; 69 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE;
67 virtual void OnDeviceInfoReceived(
68 const media::VideoCaptureParams& device_info) OVERRIDE;
69 virtual void OnDeviceInfoChanged(
70 const media::VideoCaptureParams& device_info) OVERRIDE;
71 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; 70 virtual void OnDelegateAdded(int32 device_id) OVERRIDE;
72 71
73 // Stop/resume delivering video frames to clients, based on flag |suspend|. 72 // Stop/resume delivering video frames to clients, based on flag |suspend|.
74 virtual void SuspendCapture(bool suspend); 73 virtual void SuspendCapture(bool suspend);
75 74
76 private: 75 private:
77 friend class VideoCaptureImplManager; 76 friend class VideoCaptureImplManager;
78 friend class VideoCaptureImplTest; 77 friend class VideoCaptureImplTest;
79 friend class MockVideoCaptureImpl; 78 friend class MockVideoCaptureImpl;
80 79
81 class ClientBuffer; 80 class ClientBuffer;
82 typedef std::map<media::VideoCapture::EventHandler*, 81 typedef std::map<media::VideoCapture::EventHandler*,
83 media::VideoCaptureCapability> ClientInfo; 82 media::VideoCaptureParams> ClientInfo;
84 83
85 VideoCaptureImpl(media::VideoCaptureSessionId id, 84 VideoCaptureImpl(media::VideoCaptureSessionId session_id,
86 base::MessageLoopProxy* capture_message_loop_proxy, 85 base::MessageLoopProxy* capture_message_loop_proxy,
87 VideoCaptureMessageFilter* filter); 86 VideoCaptureMessageFilter* filter);
88 virtual ~VideoCaptureImpl(); 87 virtual ~VideoCaptureImpl();
89 88
90 void DoStartCaptureOnCaptureThread( 89 void DoStartCaptureOnCaptureThread(
91 media::VideoCapture::EventHandler* handler, 90 media::VideoCapture::EventHandler* handler,
92 const media::VideoCaptureCapability& capability); 91 const media::VideoCaptureParams& params);
93 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler); 92 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler);
94 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, 93 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle,
95 int length, int buffer_id); 94 int length,
96 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp); 95 int buffer_id);
96 void DoBufferDestroyedOnCaptureThread(int buffer_id);
97 void DoBufferReceivedOnCaptureThread(
98 int buffer_id,
99 base::Time timestamp,
100 const media::VideoCaptureFormat& format);
97 void DoClientBufferFinishedOnCaptureThread( 101 void DoClientBufferFinishedOnCaptureThread(
98 int buffer_id, 102 int buffer_id,
99 const scoped_refptr<ClientBuffer>& buffer); 103 const scoped_refptr<ClientBuffer>& buffer);
100 void DoStateChangedOnCaptureThread(VideoCaptureState state); 104 void DoStateChangedOnCaptureThread(VideoCaptureState state);
101 void DoDeviceInfoReceivedOnCaptureThread(
102 const media::VideoCaptureParams& device_info);
103 void DoDeviceInfoChangedOnCaptureThread(
104 const media::VideoCaptureParams& device_info);
105 void DoDelegateAddedOnCaptureThread(int32 device_id); 105 void DoDelegateAddedOnCaptureThread(int32 device_id);
106 106
107 void DoSuspendCaptureOnCaptureThread(bool suspend); 107 void DoSuspendCaptureOnCaptureThread(bool suspend);
108 108
109 void Init(); 109 void Init();
110 void DeInit(base::Closure task); 110 void DeInit(base::Closure task);
111 void DoDeInitOnCaptureThread(base::Closure task); 111 void DoDeInitOnCaptureThread(base::Closure task);
112 void StopDevice(); 112 void StopDevice();
113 void RestartCapture(); 113 void RestartCapture();
114 void StartCaptureInternal(); 114 void StartCaptureInternal();
115 void AddDelegateOnIOThread(); 115 void AddDelegateOnIOThread();
116 void RemoveDelegateOnIOThread(base::Closure task); 116 void RemoveDelegateOnIOThread(base::Closure task);
117 virtual void Send(IPC::Message* message); 117 virtual void Send(IPC::Message* message);
118 118
119 // Helpers. 119 // Helpers.
120 bool RemoveClient(media::VideoCapture::EventHandler* handler, 120 bool RemoveClient(media::VideoCapture::EventHandler* handler,
121 ClientInfo* clients); 121 ClientInfo* clients);
122 122
123 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; 123 const scoped_refptr<VideoCaptureMessageFilter> message_filter_;
124 const scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_; 124 const scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_;
125 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 125 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
126 int device_id_; 126 int device_id_;
127 const int session_id_;
127 128
128 // Buffers available for sending to the client. 129 // Buffers available for sending to the client.
129 typedef std::map<int32, scoped_refptr<ClientBuffer> > ClientBufferMap; 130 typedef std::map<int32, scoped_refptr<ClientBuffer> > ClientBufferMap;
130 ClientBufferMap client_buffers_; 131 ClientBufferMap client_buffers_;
131 // WeakPtrFactory pointing back to |this| object, for use with 132 // WeakPtrFactory pointing back to |this| object, for use with
132 // media::VideoFrames constructed in OnBufferReceived() from buffers cached 133 // media::VideoFrames constructed in OnBufferReceived() from buffers cached
133 // in |client_buffers_|. 134 // in |client_buffers_|.
134 base::WeakPtrFactory<VideoCaptureImpl> client_buffer_weak_this_factory_; 135 base::WeakPtrFactory<VideoCaptureImpl> client_buffer_weak_this_factory_;
135 136
136 ClientInfo clients_; 137 ClientInfo clients_;
137 138
138 ClientInfo clients_pending_on_filter_; 139 ClientInfo clients_pending_on_filter_;
139 ClientInfo clients_pending_on_restart_; 140 ClientInfo clients_pending_on_restart_;
140 141
141 media::VideoPixelFormat video_type_; 142 // Member params_ represents the video format requested by the
142 143 // client to this class via DoStartCaptureOnCaptureThread.
143 // Member capture_format_ represents the video format requested by the client 144 media::VideoCaptureParams params_;
144 // to this class via DoStartCaptureOnCaptureThread.
145 media::VideoCaptureCapability capture_format_;
146 145
147 // The device's video capture format sent from browser process side. 146 // The device's video capture format sent from browser process side.
148 media::VideoCaptureParams device_info_; 147 media::VideoCaptureFormat last_frame_format_;
149 bool device_info_available_;
150 148
151 bool suspended_; 149 bool suspended_;
152 VideoCaptureState state_; 150 VideoCaptureState state_;
153 151
154 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 152 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
155 }; 153 };
156 154
157 } // namespace content 155 } // namespace content
158 156
159 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 157 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_capturer.cc ('k') | content/renderer/media/video_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698