Adds infinite addition and subtraction to time units.

This prepares for allowing use making arithmetic operators constexpr.

This also makes it easier to use for comparisons with offsets.
Now a > b + 10 ms works even if b is infinite.

Bug: webrtc:9574
Change-Id: Ie36092b72c2ec0f0c541641199a39155f5a796f3
Reviewed-on: https://webrtc-review.googlesource.com/96820
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24530}
diff --git a/api/units/timestamp.h b/api/units/timestamp.h
index 6e5e392..d7e6a8d 100644
--- a/api/units/timestamp.h
+++ b/api/units/timestamp.h
@@ -162,17 +162,23 @@
     return TimeDelta::us(us() - other.us());
   }
   Timestamp operator-(const TimeDelta& delta) const {
+    RTC_DCHECK(!delta.IsPlusInfinity());
+    if (IsInfinite() || delta.IsMinusInfinity())
+      return Infinity();
     return Timestamp::us(us() - delta.us());
   }
   Timestamp operator+(const TimeDelta& delta) const {
+    RTC_DCHECK(!delta.IsMinusInfinity());
+    if (IsInfinite() || delta.IsPlusInfinity())
+      return Infinity();
     return Timestamp::us(us() + delta.us());
   }
   Timestamp& operator-=(const TimeDelta& other) {
-    microseconds_ -= other.us();
+    *this = *this - other;
     return *this;
   }
   Timestamp& operator+=(const TimeDelta& other) {
-    microseconds_ += other.us();
+    *this = *this + other;
     return *this;
   }
   constexpr bool operator==(const Timestamp& other) const {