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

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

Issue 2390103002: Reland: VideoCapture: migrate VideoCapture renderer-->host messages to mojo, part 1 (Closed)
Patch Set: Sorted out tests after linker collision. Rebase Created 4 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
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 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/media/video_capture.h" 17 #include "content/common/media/video_capture.h"
18 #include "content/common/video_capture.mojom.h"
18 #include "content/public/renderer/media_stream_video_sink.h" 19 #include "content/public/renderer/media_stream_video_sink.h"
19 #include "content/renderer/media/video_capture_message_filter.h" 20 #include "content/renderer/media/video_capture_message_filter.h"
20 #include "media/base/video_capture_types.h" 21 #include "media/base/video_capture_types.h"
21 22
22 namespace base { 23 namespace base {
23 class SingleThreadTaskRunner; 24 class SingleThreadTaskRunner;
24 } // namespace base 25 } // namespace base
25 26
26 namespace media { 27 namespace media {
27 class VideoFrame; 28 class VideoFrame;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Get capturing formats supported by this device. 77 // Get capturing formats supported by this device.
77 // |callback| will be invoked with the results. 78 // |callback| will be invoked with the results.
78 void GetDeviceSupportedFormats(const VideoCaptureDeviceFormatsCB& callback); 79 void GetDeviceSupportedFormats(const VideoCaptureDeviceFormatsCB& callback);
79 80
80 // Get capturing formats currently in use by this device. 81 // Get capturing formats currently in use by this device.
81 // |callback| will be invoked with the results. 82 // |callback| will be invoked with the results.
82 void GetDeviceFormatsInUse(const VideoCaptureDeviceFormatsCB& callback); 83 void GetDeviceFormatsInUse(const VideoCaptureDeviceFormatsCB& callback);
83 84
84 media::VideoCaptureSessionId session_id() const { return session_id_; } 85 media::VideoCaptureSessionId session_id() const { return session_id_; }
85 86
87 void SetVideoCaptureHostForTesting(mojom::VideoCaptureHost* service) {
88 video_capture_host_for_testing_ = service;
89 }
90
86 protected: 91 protected:
87 // Note: Overridden only by unit test subclasses. 92 // Note: Overridden only by unit test subclasses.
88 virtual void Send(IPC::Message* message); 93 virtual void Send(IPC::Message* message);
89 94
90 private: 95 private:
91 friend class VideoCaptureImplTest; 96 friend class VideoCaptureImplTest;
92 friend class MockVideoCaptureImpl; 97 friend class MockVideoCaptureImpl;
93 98
94 // Carries a shared memory for transferring video frames from browser to 99 // Carries a shared memory for transferring video frames from browser to
95 // renderer. 100 // renderer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const gpu::SyncToken& release_sync_token, 150 const gpu::SyncToken& release_sync_token,
146 double consumer_resource_utilization); 151 double consumer_resource_utilization);
147 152
148 void StopDevice(); 153 void StopDevice();
149 void RestartCapture(); 154 void RestartCapture();
150 void StartCaptureInternal(); 155 void StartCaptureInternal();
151 156
152 // Helpers. 157 // Helpers.
153 bool RemoveClient(int client_id, ClientInfoMap* clients); 158 bool RemoveClient(int client_id, ClientInfoMap* clients);
154 159
160 mojom::VideoCaptureHost* GetVideoCaptureHost();
161
155 // Called (by an unknown thread) when all consumers are done with a VideoFrame 162 // Called (by an unknown thread) when all consumers are done with a VideoFrame
156 // and its ref-count has gone to zero. This helper function grabs the 163 // and its ref-count has gone to zero. This helper function grabs the
157 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given 164 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given
158 // callback, to trampoline back to the IO thread with the values. 165 // callback, to trampoline back to the IO thread with the values.
159 static void DidFinishConsumingFrame( 166 static void DidFinishConsumingFrame(
160 const media::VideoFrameMetadata* metadata, 167 const media::VideoFrameMetadata* metadata,
161 std::unique_ptr<gpu::SyncToken> release_sync_token, 168 std::unique_ptr<gpu::SyncToken> release_sync_token,
162 const BufferFinishedCallback& callback_to_io_thread); 169 const BufferFinishedCallback& callback_to_io_thread);
163 170
164 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; 171 const scoped_refptr<VideoCaptureMessageFilter> message_filter_;
165 int device_id_; 172 int device_id_;
166 const int session_id_; 173 const int session_id_;
167 174
175 mojom::VideoCaptureHostAssociatedPtr video_capture_host_;
176 mojom::VideoCaptureHost* video_capture_host_for_testing_;
177
168 // Vector of callbacks to be notified of device format enumerations, used only 178 // Vector of callbacks to be notified of device format enumerations, used only
169 // on IO Thread. 179 // on IO Thread.
170 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; 180 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_;
171 // Vector of callbacks to be notified of a device's in use capture format(s), 181 // Vector of callbacks to be notified of a device's in use capture format(s),
172 // used only on IO Thread. 182 // used only on IO Thread.
173 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_; 183 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_;
174 184
175 // Buffers available for sending to the client. 185 // Buffers available for sending to the client.
176 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap; 186 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap;
177 ClientBufferMap client_buffers_; 187 ClientBufferMap client_buffers_;
(...skipping 23 matching lines...) Expand all
201 // in |client_buffers_|. 211 // in |client_buffers_|.
202 // NOTE: Weak pointers must be invalidated before all other member variables. 212 // NOTE: Weak pointers must be invalidated before all other member variables.
203 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; 213 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_;
204 214
205 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 215 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
206 }; 216 };
207 217
208 } // namespace content 218 } // namespace content
209 219
210 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 220 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW
« no previous file with comments | « content/public/app/mojo/content_browser_manifest.json ('k') | content/renderer/media/video_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698