 Chromium Code Reviews
 Chromium Code Reviews Issue 2017443003:
  Implement timestamp translation/filter in VideoCapturer.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 2017443003:
  Implement timestamp translation/filter in VideoCapturer.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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. | |
| 
stefan-webrtc
2016/06/08 11:28:42
Comment on system_time_us to make it clear that it
 
nisse-webrtc
2016/06/09 10:02:58
I've expanded the comments here.
 | |
| 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_us, | 
| 234 int64_t system_time_us, | |
| 231 int* out_width, | 235 int* out_width, | 
| 232 int* out_height, | 236 int* out_height, | 
| 233 int* crop_width, | 237 int* crop_width, | 
| 234 int* crop_height, | 238 int* crop_height, | 
| 235 int* crop_x, | 239 int* crop_x, | 
| 236 int* crop_y); | 240 int* crop_y, | 
| 241 int64_t* time_us); | |
| 237 | 242 | 
| 238 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. | 243 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. | 
| 239 void OnFrameCaptured(VideoCapturer* video_capturer, | 244 void OnFrameCaptured(VideoCapturer* video_capturer, | 
| 240 const CapturedFrame* captured_frame); | 245 const CapturedFrame* captured_frame); | 
| 241 | 246 | 
| 242 // Called when a frame has been captured and converted to a | 247 // Called when a frame has been captured and converted to a | 
| 243 // VideoFrame. OnFrame can be called directly by an implementation | 248 // VideoFrame. OnFrame can be called directly by an implementation | 
| 244 // that does not use SignalFrameCaptured or OnFrameCaptured. The | 249 // that does not use SignalFrameCaptured or OnFrameCaptured. The | 
| 245 // orig_width and orig_height are used only to produce stats. | 250 // orig_width and orig_height are used only to produce stats. | 
| 246 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); | 251 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); | 
| (...skipping 30 matching lines...) Expand all Loading... | |
| 277 std::string ToString(const CapturedFrame* frame) const; | 282 std::string ToString(const CapturedFrame* frame) const; | 
| 278 | 283 | 
| 279 // Updates filtered_supported_formats_ so that it contains the formats in | 284 // Updates filtered_supported_formats_ so that it contains the formats in | 
| 280 // supported_formats_ that fulfill all applied restrictions. | 285 // supported_formats_ that fulfill all applied restrictions. | 
| 281 void UpdateFilteredSupportedFormats(); | 286 void UpdateFilteredSupportedFormats(); | 
| 282 // Returns true if format doesn't fulfill all applied restrictions. | 287 // Returns true if format doesn't fulfill all applied restrictions. | 
| 283 bool ShouldFilterFormat(const VideoFormat& format) const; | 288 bool ShouldFilterFormat(const VideoFormat& format) const; | 
| 284 | 289 | 
| 285 void UpdateInputSize(int width, int height); | 290 void UpdateInputSize(int width, int height); | 
| 286 | 291 | 
| 292 // Update the estimated offset between camera time and system monotonic time. | |
| 293 void UpdateOffset(int64_t camera_time_us, int64_t system_time_us); | |
| 294 | |
| 287 rtc::ThreadChecker thread_checker_; | 295 rtc::ThreadChecker thread_checker_; | 
| 288 std::string id_; | 296 std::string id_; | 
| 289 CaptureState capture_state_; | 297 CaptureState capture_state_; | 
| 290 std::unique_ptr<VideoFrameFactory> frame_factory_; | 298 std::unique_ptr<VideoFrameFactory> frame_factory_; | 
| 291 std::unique_ptr<VideoFormat> capture_format_; | 299 std::unique_ptr<VideoFormat> capture_format_; | 
| 292 std::vector<VideoFormat> supported_formats_; | 300 std::vector<VideoFormat> supported_formats_; | 
| 293 std::unique_ptr<VideoFormat> max_format_; | 301 std::unique_ptr<VideoFormat> max_format_; | 
| 294 std::vector<VideoFormat> filtered_supported_formats_; | 302 std::vector<VideoFormat> filtered_supported_formats_; | 
| 295 | 303 | 
| 296 bool enable_camera_list_; | 304 bool enable_camera_list_; | 
| 297 int scaled_width_; // Current output size from ComputeScale. | 305 int scaled_width_; // Current output size from ComputeScale. | 
| 298 int scaled_height_; | 306 int scaled_height_; | 
| 299 | 307 | 
| 300 rtc::VideoBroadcaster broadcaster_; | 308 rtc::VideoBroadcaster broadcaster_; | 
| 301 bool enable_video_adapter_; | 309 bool enable_video_adapter_; | 
| 302 VideoAdapter video_adapter_; | 310 VideoAdapter video_adapter_; | 
| 303 | 311 | 
| 304 rtc::CriticalSection frame_stats_crit_; | 312 rtc::CriticalSection frame_stats_crit_; | 
| 305 // The captured frame size before potential adapation. | 313 // The captured frame size before potential adapation. | 
| 306 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false; | 314 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false; | 
| 307 int input_width_ GUARDED_BY(frame_stats_crit_); | 315 int input_width_ GUARDED_BY(frame_stats_crit_); | 
| 308 int input_height_ GUARDED_BY(frame_stats_crit_); | 316 int input_height_ GUARDED_BY(frame_stats_crit_); | 
| 309 | 317 | 
| 310 // Whether capturer should apply rotation to the frame before signaling it. | 318 // Whether capturer should apply rotation to the frame before signaling it. | 
| 311 bool apply_rotation_; | 319 bool apply_rotation_; | 
| 312 | 320 | 
| 321 // State for the timestamp translation. | |
| 322 unsigned frames_seen_; | |
| 
stefan-webrtc
2016/06/08 11:28:42
int
 
nisse-webrtc
2016/06/09 10:02:58
Done.
 | |
| 323 // Estimated offset between camera time and system monotonic time. | |
| 324 int64_t offset_us_; | |
| 325 | |
| 313 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); | 326 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); | 
| 314 }; | 327 }; | 
| 315 | 328 | 
| 316 } // namespace cricket | 329 } // namespace cricket | 
| 317 | 330 | 
| 318 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 331 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 
| OLD | NEW |