webrtc_m130/webrtc/base/timestampaligner.h
Magnus Jedvert 0bade0df3b AVFoundation Video Capturer: Remove thread jump when delivering frames
WebRTC no longer has any restriction on what thread frames should be
delivered on. One possible problem with this CL is that NV21->I420
conversion and scaling is done on the thread that delivers frames, which
might cause fps regressions.

R=nisse@webrtc.org, perkj@webrtc.org, tkchin@webrtc.org

Review URL: https://codereview.webrtc.org/2137503003 .

Cr-Commit-Position: refs/heads/master@{#14021}
2016-09-01 13:15:12 +00:00

50 lines
1.5 KiB
C++

/*
* Copyright (c) 2016 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_BASE_TIMESTAMPALIGNER_H_
#define WEBRTC_BASE_TIMESTAMPALIGNER_H_
#include "webrtc/base/basictypes.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/optional.h"
namespace rtc {
// This class is not thread safe, so all calls to it must be synchronized
// externally.
class TimestampAligner {
public:
TimestampAligner();
~TimestampAligner();
public:
// Update the estimated offset between camera time and system monotonic time.
int64_t UpdateOffset(int64_t camera_time_us, int64_t system_time_us);
int64_t ClipTimestamp(int64_t filtered_time_us, int64_t system_time_us);
private:
// State for the timestamp translation.
int frames_seen_;
// Estimated offset between camera time and system monotonic time.
int64_t offset_us_;
// State for timestamp clipping, applied after the filter, to ensure
// that translated timestamps are monotonic and not in the future.
// Subtracted from the translated timestamps.
int64_t clip_bias_us_;
rtc::Optional<int64_t> prev_translated_time_us_;
RTC_DISALLOW_COPY_AND_ASSIGN(TimestampAligner);
};
} // namespace rtc
#endif // WEBRTC_BASE_TIMESTAMPALIGNER_H_