These factories suppose to replace set of old constexpr factories that
takes parameter as template rather than function parameter,
as well as fix function naming to follow style guide of the second set
of factory functions.
Bug: None
Change-Id: Icd76302b821b2a4027f9d6765cf91bc9190f551c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167521
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30482}
Also adding kHz factory function for Frequency class.
Bug: webrtc:9883
Change-Id: Ide44910d50eb9616de2bb0c66b8c62493d2be92e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167725
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30416}
Since RTC_DCHECK was made constexpr compatible, we can now
make the unit classes fully constexpr.
Bug: webrtc:9883
Change-Id: I18973c2f318449869cf0bd45699c41be53fba806
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167722
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30403}
Static libraries don't guarantee that an exported symbol gets linked
into a shared library (and in order to support Chromium's component
build mode, WebRTC needs to be linked as a shared library).
Source sets always pass all the object files to the linker.
On the flip side, source_sets link more object files in release builds
and to avoid this, this CL introduces a the GN template "rtc_library" that
expands to static_library during release builds and to source_set during
component builds.
See: https://gn.googlesource.com/gn/+/master/docs/reference.md#func_source_set
Bug: webrtc:9419
Change-Id: I4667e820c2b3fcec417becbd2034acc13e4f04fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157168
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#29525}
This is a reland of 890bc3069c
Zero bitrate caused division by zero in DCHECK for max bitrate.
Added unit tests to ensure that setting zero bitrate does not crash.
> Original change's description:
> > Cleanup of video packet overhead calculation.
> >
> > This CL updates the video packet overhead calculation to make it more
> > clear. This prepares for future work on improving the accuracy of the
> > calculation.
> >
> > Bug: webrtc:9883
> > Change-Id: I1d623a3e0de45be7b6e4a1f9e3cbe54fd2b8a45a
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/138077
> > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#28040}
Bug: webrtc:10674
Change-Id: I156d1ee5546ede7e43ae1d9a298dcaba6071230f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140890
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28212}
This is useful for internal calculations in bitrate control code as we
can skip conversion constants.
DataRate Example(TimeDelta time, DataSize size) {
double time_seconds = time.seconds<double>();
double size_bytes = size.bytes<double>();
double rate_bytes_per_sec = size_bytes/time_seconds;
return DataRate::bytes_per_sec(std::max(0.0,rate_bytes_per_sec));
}
Bug: webrtc:9709
Change-Id: I8eefed578b6e8eee67fc36af723216407e0d0323
Reviewed-on: https://webrtc-review.googlesource.com/c/120720
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26488}
By explicitly checking that the template argument is arithmetic, we
avoid exposing internal implementation details in the error message.
Bug: webrtc:9709
Change-Id: Ib1c4b46076af36fe0c4aead968487bb441d03b9a
Reviewed-on: https://webrtc-review.googlesource.com/c/112422
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25853}
This is a follow-up to
https://webrtc-review.googlesource.com/c/src/+/106280.
This time the whole code base is covered.
Some files may have not been fixed though, whenever the IWYU tool
was breaking the build.
Bug: webrtc:8311
Change-Id: I2c31f552a87e887d33931d46e87b6208b1e483ef
Reviewed-on: https://webrtc-review.googlesource.com/c/111965
Commit-Queue: Yves Gerey <yvesg@google.com>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25830}
This reduces code duplication and ensures common behavior
between the unit classes.
Bug: webrtc:9709
Change-Id: I9529ef10b3f538355f53250a2b67c6b4e250cce8
Reviewed-on: https://webrtc-review.googlesource.com/c/110901
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25690}
This CL is the result of running include-what-you-use tool on part
of the code base (audio target and dependencies) plus manual fixes.
bug: webrtc:8311
Change-Id: I277d281ce943c3ecc1bd45fd8d83055931743604
Reviewed-on: https://webrtc-review.googlesource.com/c/106280
Commit-Queue: Yves Gerey <yvesg@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25311}
This is quite useful in many places where we need to restrict the range
of a DataRate. It makes it easier to read the intention than with:
value_ = std::max(some_lower_limit, std::min(value_, some_upper_limit));
The naming follows the naming for rtc::SafeClamp.
Bug: webrtc:9709
Change-Id: I08e05197acec325d85babd2a06806a8667f2fcb1
Reviewed-on: https://webrtc-review.googlesource.com/c/104040
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25023}
Negative infinity is useful in comparisons as it represents a value
guaranteed to be less than any other timestamp. This avoid using
Timestamp::ms(0) to represent such a value or having to use optional
for the special case of first time execution.
To avoid ambiguity, Timestamp::Infinity is renamed to PlusInfinity.
Bug: webrtc:9709
Change-Id: Ib2debff91036e94d1dc903ec0c6faae30febde4e
Reviewed-on: https://webrtc-review.googlesource.com/79440
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24556}
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}
This adds new constexpr create function for DataSize, DataRate,
TimeDelta and Timestamp. The names are capitalized to mirror the
naming scheme of the previously constexpr methods (Zero and
Infinity create functions). They are also kept longer since they
are not expected to be used in complex expressions.
Bug: webrtc:9574
Change-Id: I5950548718675050fc5d66699de295455c310861
Reviewed-on: https://webrtc-review.googlesource.com/91161
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24218}
This makes the constructor and the unchecked create functions
constexpr on the unit classes Timestamp, TimeDelta, Datarate and
DataSize. This allows using the units in constexpr constants.
Unchecked access methods are made constexpr as well. Making them
usable in static asserts.
Constexpr create functions for checked construction is added in
a separate CL.
Bug: webrtc:9574
Change-Id: I605ae2e8572195dbb2078c283056208be0f43333
Reviewed-on: https://webrtc-review.googlesource.com/91160
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24206}
The behavior of division-by-zero is undefined, so the DivisionByZeroFails test isn't correct. As we don't need any specific behavior on division-by-zero we leave the current code untouched.
Additionally, since the DivisionFailsOnLargeSize EXPECT_DEATH checks rely on DCHECKs, we only run those when DCHECKs are enabled.
Bug: webrtc:9443
Change-Id: I0fdd7be55a7bc76b4203b2f6d5cd0ed8ac5cc688
Reviewed-on: https://webrtc-review.googlesource.com/85362
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23767}
This removes the redundant type and replaces all usages. A slight change
in behavior is that we no longer get nanosecond resolution. This should
not matter since no current code requires nanosecond resolution.
Bug: webrtc:9155
Change-Id: I04334e08c686d95731621a6c8a7e40400d0ae3b2
Reviewed-on: https://webrtc-review.googlesource.com/71163
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23174}
This prepares for being able to inject network congestion controllers.
And makes it easier to use the units in other parts of the code.
Bug: webrtc:9155
Change-Id: Ib8f9c1c97b06d791a01c3376046933d576ae46f9
Reviewed-on: https://webrtc-review.googlesource.com/70201
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23168}