Add UnwrapForward and UnwrapBackwards to SeqNumUnwrapper.
Bug: webrtc:12979 Change-Id: I4c3b3f5e1ff70ae528cfd73a34baafc75cccf481 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226462 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34505}
This commit is contained in:
@ -109,6 +109,28 @@ class SeqNumUnwrapper {
|
||||
return last_unwrapped_;
|
||||
}
|
||||
|
||||
int64_t UnwrapForward(T value) {
|
||||
if (!last_value_) {
|
||||
last_unwrapped_ = {value};
|
||||
} else {
|
||||
last_unwrapped_ += ForwardDiff<T, M>(*last_value_, value);
|
||||
}
|
||||
|
||||
last_value_ = value;
|
||||
return last_unwrapped_;
|
||||
}
|
||||
|
||||
int64_t UnwrapBackwards(T value) {
|
||||
if (!last_value_) {
|
||||
last_unwrapped_ = {value};
|
||||
} else {
|
||||
last_unwrapped_ -= ReverseDiff<T, M>(*last_value_, value);
|
||||
}
|
||||
|
||||
last_value_ = value;
|
||||
return last_unwrapped_;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t last_unwrapped_ = 0;
|
||||
absl::optional<T> last_value_;
|
||||
|
||||
Reference in New Issue
Block a user