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

Side by Side Diff: webrtc/media/base/videocapturer.h

Issue 2017443003: Implement timestamp translation/filter in VideoCapturer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix offset update equation, and nits. Created 4 years, 6 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 /* 1 /*
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; 218 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
219 219
220 protected: 220 protected:
221 // OnSinkWantsChanged can be overridden to change the default behavior 221 // OnSinkWantsChanged can be overridden to change the default behavior
222 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. 222 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink.
223 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); 223 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants);
224 224
225 // Reports the appropriate frame size after adaptation. Returns true 225 // Reports the appropriate frame size after adaptation. Returns true
226 // if a frame is wanted. Returns false if there are no interested 226 // if a frame is wanted. Returns false if there are no interested
227 // sinks, or if the VideoAdapter decides to drop the frame. 227 // sinks, or if the VideoAdapter decides to drop the frame.
228 // |capture_time_ns| is the camera's timestamp, using an arbitrary
229 // offset and possibly slightly off frequency. |time_us| is the
230 // timestamp translated into the same scale as rtc::TimeMicros.
pthatcher1 2016/05/27 22:47:44 Then why not call it capture_time_us? And why r
nisse-webrtc 2016/05/30 08:57:29 The nanosecond unit on the input argument, |captur
228 bool AdaptFrame(int width, 231 bool AdaptFrame(int width,
229 int height, 232 int height,
230 int64_t capture_time_ns, 233 int64_t capture_time_ns,
231 int* out_width, 234 int* out_width,
232 int* out_height, 235 int* out_height,
233 int* crop_width, 236 int* crop_width,
234 int* crop_height, 237 int* crop_height,
235 int* crop_x, 238 int* crop_x,
236 int* crop_y); 239 int* crop_y,
240 int64_t* time_us);
237 241
238 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. 242 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called.
239 void OnFrameCaptured(VideoCapturer* video_capturer, 243 void OnFrameCaptured(VideoCapturer* video_capturer,
240 const CapturedFrame* captured_frame); 244 const CapturedFrame* captured_frame);
241 245
242 // Called when a frame has been captured and converted to a 246 // Called when a frame has been captured and converted to a
243 // VideoFrame. OnFrame can be called directly by an implementation 247 // VideoFrame. OnFrame can be called directly by an implementation
244 // that does not use SignalFrameCaptured or OnFrameCaptured. The 248 // that does not use SignalFrameCaptured or OnFrameCaptured. The
245 // orig_width and orig_height are used only to produce stats. 249 // orig_width and orig_height are used only to produce stats.
246 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); 250 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height);
(...skipping 30 matching lines...) Expand all
277 std::string ToString(const CapturedFrame* frame) const; 281 std::string ToString(const CapturedFrame* frame) const;
278 282
279 // Updates filtered_supported_formats_ so that it contains the formats in 283 // Updates filtered_supported_formats_ so that it contains the formats in
280 // supported_formats_ that fulfill all applied restrictions. 284 // supported_formats_ that fulfill all applied restrictions.
281 void UpdateFilteredSupportedFormats(); 285 void UpdateFilteredSupportedFormats();
282 // Returns true if format doesn't fulfill all applied restrictions. 286 // Returns true if format doesn't fulfill all applied restrictions.
283 bool ShouldFilterFormat(const VideoFormat& format) const; 287 bool ShouldFilterFormat(const VideoFormat& format) const;
284 288
285 void UpdateInputSize(int width, int height); 289 void UpdateInputSize(int width, int height);
286 290
291 void UpdateOffset(int64_t capture_time_us);
pthatcher1 2016/05/27 22:47:44 This method could use a comment explaining what it
nisse-webrtc 2016/05/30 08:57:29 Since it's a private method, I put the explanatory
292
287 rtc::ThreadChecker thread_checker_; 293 rtc::ThreadChecker thread_checker_;
288 std::string id_; 294 std::string id_;
289 CaptureState capture_state_; 295 CaptureState capture_state_;
290 std::unique_ptr<VideoFrameFactory> frame_factory_; 296 std::unique_ptr<VideoFrameFactory> frame_factory_;
291 std::unique_ptr<VideoFormat> capture_format_; 297 std::unique_ptr<VideoFormat> capture_format_;
292 std::vector<VideoFormat> supported_formats_; 298 std::vector<VideoFormat> supported_formats_;
293 std::unique_ptr<VideoFormat> max_format_; 299 std::unique_ptr<VideoFormat> max_format_;
294 std::vector<VideoFormat> filtered_supported_formats_; 300 std::vector<VideoFormat> filtered_supported_formats_;
295 301
296 bool enable_camera_list_; 302 bool enable_camera_list_;
297 int scaled_width_; // Current output size from ComputeScale. 303 int scaled_width_; // Current output size from ComputeScale.
298 int scaled_height_; 304 int scaled_height_;
299 305
300 rtc::VideoBroadcaster broadcaster_; 306 rtc::VideoBroadcaster broadcaster_;
301 bool enable_video_adapter_; 307 bool enable_video_adapter_;
302 VideoAdapter video_adapter_; 308 VideoAdapter video_adapter_;
303 309
304 rtc::CriticalSection frame_stats_crit_; 310 rtc::CriticalSection frame_stats_crit_;
305 // The captured frame size before potential adapation. 311 // The captured frame size before potential adapation.
306 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false; 312 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false;
307 int input_width_ GUARDED_BY(frame_stats_crit_); 313 int input_width_ GUARDED_BY(frame_stats_crit_);
308 int input_height_ GUARDED_BY(frame_stats_crit_); 314 int input_height_ GUARDED_BY(frame_stats_crit_);
309 315
310 // Whether capturer should apply rotation to the frame before signaling it. 316 // Whether capturer should apply rotation to the frame before signaling it.
311 bool apply_rotation_; 317 bool apply_rotation_;
312 318
319 // State for the timestamp translation.
320 unsigned frames_seen_;
321 int64_t offset_us_;
pthatcher1 2016/05/27 22:47:44 This could use a little more clarity on what it me
nisse-webrtc 2016/05/30 08:57:29 I'm adding a short comment.
322
313 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); 323 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer);
314 }; 324 };
315 325
316 } // namespace cricket 326 } // namespace cricket
317 327
318 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ 328 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698