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

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: Add missing include of math.h. 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
« no previous file with comments | « webrtc/base/timestampaligner_unittest.cc ('k') | webrtc/media/base/videocapturer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 // Declaration of abstract class VideoCapturer 11 // Declaration of abstract class VideoCapturer
12 12
13 #ifndef WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ 13 #ifndef WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_
14 #define WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ 14 #define WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <memory> 17 #include <memory>
18 #include <string> 18 #include <string>
19 #include <vector> 19 #include <vector>
20 20
21 #include "webrtc/base/basictypes.h" 21 #include "webrtc/base/basictypes.h"
22 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
23 #include "webrtc/base/criticalsection.h" 23 #include "webrtc/base/criticalsection.h"
24 #include "webrtc/media/base/videosourceinterface.h" 24 #include "webrtc/media/base/videosourceinterface.h"
25 #include "webrtc/base/sigslot.h" 25 #include "webrtc/base/sigslot.h"
26 #include "webrtc/base/thread_checker.h" 26 #include "webrtc/base/thread_checker.h"
27 #include "webrtc/base/timestampaligner.h"
27 #include "webrtc/media/base/videoadapter.h" 28 #include "webrtc/media/base/videoadapter.h"
28 #include "webrtc/media/base/videobroadcaster.h" 29 #include "webrtc/media/base/videobroadcaster.h"
29 #include "webrtc/media/base/videocommon.h" 30 #include "webrtc/media/base/videocommon.h"
30 #include "webrtc/media/base/videoframefactory.h" 31 #include "webrtc/media/base/videoframefactory.h"
31 32
32 33
33 namespace cricket { 34 namespace cricket {
34 35
35 // Current state of the capturer. 36 // Current state of the capturer.
36 enum CaptureState { 37 enum CaptureState {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; 219 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
219 220
220 protected: 221 protected:
221 // OnSinkWantsChanged can be overridden to change the default behavior 222 // OnSinkWantsChanged can be overridden to change the default behavior
222 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. 223 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink.
223 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); 224 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants);
224 225
225 // Reports the appropriate frame size after adaptation. Returns true 226 // Reports the appropriate frame size after adaptation. Returns true
226 // if a frame is wanted. Returns false if there are no interested 227 // if a frame is wanted. Returns false if there are no interested
227 // sinks, or if the VideoAdapter decides to drop the frame. 228 // sinks, or if the VideoAdapter decides to drop the frame.
229
230 // This function also implements timestamp translation/filtering.
231 // |camera_time_ns| is the camera's timestamp for the captured
232 // frame; it is expected to have good accuracy, but it may use an
233 // arbitrary epoch and a small possibly free-running with a frequency
234 // slightly different from the system clock. |system_time_us| is the
235 // monotonic system time (in the same scale as rtc::TimeMicros) when
236 // the frame was captured; the application is expected to read the
237 // system time as soon as possible after frame capture, but it may
238 // suffer scheduling jitter or poor system clock resolution. The
239 // output |translated_camera_time_us| is a combined timestamp,
240 // taking advantage of the supposedly higher accuracy in the camera
241 // timestamp, but using the same epoch and frequency as system time.
228 bool AdaptFrame(int width, 242 bool AdaptFrame(int width,
229 int height, 243 int height,
230 int64_t capture_time_ns, 244 int64_t camera_time_us,
245 int64_t system_time_us,
231 int* out_width, 246 int* out_width,
232 int* out_height, 247 int* out_height,
233 int* crop_width, 248 int* crop_width,
234 int* crop_height, 249 int* crop_height,
235 int* crop_x, 250 int* crop_x,
236 int* crop_y); 251 int* crop_y,
252 int64_t* translated_camera_time_us);
237 253
238 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. 254 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called.
239 void OnFrameCaptured(VideoCapturer* video_capturer, 255 void OnFrameCaptured(VideoCapturer* video_capturer,
240 const CapturedFrame* captured_frame); 256 const CapturedFrame* captured_frame);
241 257
242 // Called when a frame has been captured and converted to a 258 // Called when a frame has been captured and converted to a
243 // VideoFrame. OnFrame can be called directly by an implementation 259 // VideoFrame. OnFrame can be called directly by an implementation
244 // that does not use SignalFrameCaptured or OnFrameCaptured. The 260 // that does not use SignalFrameCaptured or OnFrameCaptured. The
245 // orig_width and orig_height are used only to produce stats. 261 // orig_width and orig_height are used only to produce stats.
246 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); 262 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 319
304 rtc::CriticalSection frame_stats_crit_; 320 rtc::CriticalSection frame_stats_crit_;
305 // The captured frame size before potential adapation. 321 // The captured frame size before potential adapation.
306 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false; 322 bool input_size_valid_ GUARDED_BY(frame_stats_crit_) = false;
307 int input_width_ GUARDED_BY(frame_stats_crit_); 323 int input_width_ GUARDED_BY(frame_stats_crit_);
308 int input_height_ GUARDED_BY(frame_stats_crit_); 324 int input_height_ GUARDED_BY(frame_stats_crit_);
309 325
310 // Whether capturer should apply rotation to the frame before signaling it. 326 // Whether capturer should apply rotation to the frame before signaling it.
311 bool apply_rotation_; 327 bool apply_rotation_;
312 328
329 // State for the timestamp translation.
330 rtc::TimestampAligner timestamp_aligner_;
313 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); 331 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer);
314 }; 332 };
315 333
316 } // namespace cricket 334 } // namespace cricket
317 335
318 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ 336 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_
OLDNEW
« no previous file with comments | « webrtc/base/timestampaligner_unittest.cc ('k') | webrtc/media/base/videocapturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698