Commit graph

30 commits

Author SHA1 Message Date
Sebastian Jansson
bae12756da Using unit types in TransportFeedbackAdapter.
Bug: webrtc:9883
Change-Id: I6d7d653079bb969fa3bc6f62fd35f2aa870edab6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158792
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29705}
2019-11-06 12:25:00 +00:00
Mirko Bonadei
86d053c2db Use source_sets in component builds and static_library in release builds.
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}
2019-10-17 21:17:18 +00:00
Jonas Olsson
a4d873786f Format almost everything.
This CL was generated by running

git ls-files | grep -P "(\.h|\.cc)$" | grep -v 'sdk/' | grep -v 'rtc_base/ssl_' | \
grep -v 'fake_rtc_certificate_generator.h' | grep -v 'modules/audio_device/win/' | \
grep -v 'system_wrappers/source/clock.cc' | grep -v 'rtc_base/trace_event.h' | \
grep -v 'modules/audio_coding/codecs/ilbc/' | grep -v 'screen_capturer_mac.h' | \
grep -v 'spl_inl_mips.h' | grep -v 'data_size_unittest.cc' | grep -v 'timestamp_unittest.cc' \
| xargs clang-format -i ; git cl format

Most of these changes are clang-format grouping and reordering includes
differently.

Bug: webrtc:9340
Change-Id: Ic83ddbc169bfacd21883e381b5181c3dd4fe8a63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144051
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28505}
2019-07-08 13:45:15 +00:00
Sebastian Jansson
cf41eb1ce1 Reland "Cleanup of video packet overhead calculation."
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}
2019-06-10 15:47:48 +00:00
Sebastian Jansson
26b5e35276 Adds Frequency unit type.
Bug: webrtc:10674
Change-Id: Ic0ddca46d8522d994bbeba072a73836b506fe40f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/138261
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28192}
2019-06-07 09:54:02 +00:00
Sebastian Jansson
9930929303 Adds srte@ as OWNER of units.
Bug: webrtc:9883
Change-Id: I003a459ba5c37b7fe844a0aff7178c2fd8b2de81
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139247
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28171}
2019-06-05 15:08:57 +00:00
Sebastian Jansson
b113862ccd Allow log print of data units.
Bug: webrtc:9709
Change-Id: I5987a9779e645115dc1893944302a73d540bcf2f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125680
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27578}
2019-04-12 07:36:49 +00:00
Sebastian Jansson
bd7ed4bd5e Include sign for infinity in ToString for data units.
Bug: webrtc:9709
Change-Id: I8a4ee0797dca25dc7c3c414f24ada34c8bcbd7f8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125660
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26966}
2019-03-05 09:42:08 +00:00
Sebastian Jansson
8fe7995045 Adds bytes per second to DataType class.
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}
2019-01-31 11:31:55 +00:00
Sebastian Jansson
0c3f4d3709 Friendlier error messages from data unit classes.
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}
2018-11-30 09:40:44 +00:00
Yves Gerey
3e70781361 [Cleanup] Add missing #include. Remove useless ones. IWYU part 2.
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}
2018-11-28 18:25:07 +00:00
Sebastian Jansson
72bba625d5 Adds shared base class for data units.
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}
2018-11-19 12:41:33 +00:00
Sebastian Jansson
0a8bd9cdc9 Adds clamping to TimeDelta.
Bug: webrtc:9709
Change-Id: I6447d8b0ac55b38eaa187b4d44426ec95c377ffb
Reviewed-on: https://webrtc-review.googlesource.com/c/110787
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25681}
2018-11-19 09:34:09 +00:00
Sebastian Jansson
b5f82011ba Adds scalar division to DataRate.
Bug: webrtc:9709
Change-Id: I73eac1d2f27bd0f30a7b1ca075009a6aece08b03
Reviewed-on: https://webrtc-review.googlesource.com/c/110786
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25680}
2018-11-19 09:22:05 +00:00
Yves Gerey
988cc0870b [Cleanup] Add missing #include. Remove useless ones.
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}
2018-10-23 11:32:56 +00:00
Sebastian Jansson
0753675a3e Using more specific dependencies in rtc_base.
Bug: webrtc:9718, webrtc:9838
Change-Id: I604c8fea574aabb795da7d5bba3ea751f87acb4c
Reviewed-on: https://webrtc-review.googlesource.com/c/106300
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25206}
2018-10-16 12:00:09 +00:00
Mirko Bonadei
38537edf59 Fix visibility of api/units build targets.
Bug: None
Change-Id: Ie5f44ba9f5565b1a51175de2f4514829edb3dd03
Reviewed-on: https://webrtc-review.googlesource.com/c/104161
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25032}
2018-10-08 07:27:30 +00:00
Sebastian Jansson
6c19decc14 Adds Clamping functions for DataRate.
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}
2018-10-05 15:06:17 +00:00
Jonas Olsson
941a07cca3 Remove all remaining non-test uses of std::stringstream.
Bug: webrtc:8982
Change-Id: I635a8545c46dc8c89663d64af351e22e65cbcb33
Reviewed-on: https://webrtc-review.googlesource.com/98880
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24715}
2018-09-13 08:52:05 +00:00
Sebastian Jansson
af21eab531 Adds arithmetic support to DataRate.
Bug: webrtc:9709
Change-Id: Id3fde2b7bbc63c6372cadc76b92c4568665b17f9
Reviewed-on: https://webrtc-review.googlesource.com/97702
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24562}
2018-09-05 08:07:09 +00:00
Sebastian Jansson
9de4ef4b24 Adds signed infinity to timestamps.
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}
2018-09-04 17:14:05 +00:00
Sebastian Jansson
88c1a9ecbc 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}
2018-09-03 09:12:10 +00:00
Sebastian Jansson
2afd281ec4 Adds debug printing of units in unit tests.
Bug: webrtc:9656
Change-Id: I643b79bc214643f47b2b64967ce713665dbef5c9
Reviewed-on: https://webrtc-review.googlesource.com/95652
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24436}
2018-08-27 08:28:12 +00:00
Sebastian Jansson
c1c8b8e836 Adds constexpr create functions for units.
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}
2018-08-08 07:38:14 +00:00
Sebastian Jansson
8e06419ee9 Makes units constexpr when possible.
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}
2018-08-07 11:30:21 +00:00
Jonas Olsson
0d4070a18c Remove incorrect test from api/units/
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}
2018-06-28 11:37:20 +00:00
Sebastian Jansson
942b360d82 Add conversions to and from double for units.
Bug: webrtc:8415
Change-Id: I6b1f7afb163daa327e45c51f1a3fb7cafbb1444e
Reviewed-on: https://webrtc-review.googlesource.com/78183
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23451}
2018-05-30 14:34:02 +00:00
Sebastian Jansson
ec2eb2218f Enables comparison with infinite timestamps.
Bug: webrtc:8415
Change-Id: Ia96c7a537d994c281d8b24e648dbb2e17de3ed4a
Reviewed-on: https://webrtc-review.googlesource.com/78182
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23383}
2018-05-24 12:45:21 +00:00
Sebastian Jansson
5f83cf0c6d Replacing rtc::TimeDelta with webrtc::TimeDelta.
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}
2018-05-08 13:22:53 +00:00
Sebastian Jansson
6fae6ec2ee Moves network unit types to API.
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}
2018-05-08 11:46:22 +00:00