Commit graph

815 commits

Author SHA1 Message Date
Evan Shrubsole
84afe46549 Don't await adaptation after deg-pref change
Now we only await a previous adaptation if the degradataion
preference is the same as our current degradation preference.
Without this guard we can get stuck as detailed in the attached bug.

Bug: webrtc:11562
Change-Id: I91be48546446ef8d01fe901bc6889201a5b97ba6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174805
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31236}
2020-05-13 12:14:36 +00:00
Evan Shrubsole
95d40ee0df Remove unused VideoStream::balanced_settings()
R=hbos@webrtc.org

Bug: None
Change-Id: I86bc1040f1e8197ce14c16ad7cb7e18dd643b456
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175002
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31234}
2020-05-13 10:06:42 +00:00
Henrik Boström
381d10963a [Adaptation] Move adaptation logic to a separate task queue.
This CL unblocks future Call-Level Mitigation strategies by moving the
ResourceAdaptationProcessor to a separate task queue. This signifies a
major milestone in the new resource adaptation architecture because
with this CL the threading model is in place and moving the Processor
to the Call and increasing its responsibilities is made possible.

In this CL, we still have one Processor per VideoStreamEncoder and the
VideoStreamEncoder is responsible for the creation and the destruction
of its Processor and that Processor's task queue. But the PostTasks are
in place and the decision-making is executed on a separate queue.

This CL:
- Moves ResourceAdaptationProcessor to an adaptation task queue.
  It continues to be entirely single-threaded, but now operates on a
  separate task queue.
- Makes Resources thread-safe: Interaction with the Processor, i.e.
  OnResourceUsageStateMeasured() and IsAdaptationUpAllowed(), happens
  on the adaptation task queue. State updates are pushed from the
  encoder task queue with PostTasks.
- QualityScalerResource operates on both task queues; the QP usage
  callbacks are invoked asynchronously.
- The VideoStreamEncoderResourceManager operates on the encoder task
  queue with the following exceptions:
  1) Its resources are accessible on any thread (using a mutex). This
     is OK because resources are reference counted and thread safe.
     This aids adding and removing resources to the Processor on the
     adaptation task queue.
  2) |active_counts_| is moved to the adaptation task queue. This makes
     it possible for PreventAdaptUpDueToActiveCounts to run
     IsAdaptationUpAllowed() on the adaptation task queue.
     A side-effect of this is that some stats reporting now happen on
     the adaptation task queue, but that is OK because
     VideoStreamEncoderObserver is thread-safe.

The Manager is updated to take the new threading model into account:
- OnFrameDroppedDueToSize() posts to the adaptation task queue to
  invoke the Processor.
- OnVideoSourceRestrictionsUpdated(), now invoked on the adaptation
  task queue, updates |active_counts_| synchronously but posts to the
  encoder task queue to update video source restrictions (which it
  only uses to calculate target frame rate).
- MaybePerformQualityRampupExperiment() posts to the adaptation task
  queue to maybe reset video source restrictions on the Processor.
  |quality_rampup_done_| is made std::atomic.

Bug: webrtc:11542, webrtc:11520
Change-Id: I1cfd76e0cd42f006a6d2527f5aa2aeb5266ba6d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174441
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31231}
2020-05-13 08:21:23 +00:00
Henrik Boström
c55516dd55 [Adaptation] Make Resources reference counted and add more DCHECKs.
In a future CL, adaptation processing and stream encoder resource
management will happen on different task queues. When this is the case,
asynchronous tasks will be posted in both directions and some resources
will have internal states used on multiple threads.

This CL makes the Resource class reference counted in order to support
posting tasks to a different threads without risk of use-after-free
when a posted task is executed with a delay. This is preferred over
WeakPtr strategies because WeakPtrs are single-threaded and preferred
over raw pointer usage because the reference counted approach enables
more compile-time and run-time assurance. This is also "future proof";
when resources can be injected through public APIs, ownership needs to
be shared between libwebrtc and the application (e.g. Chrome).

To reduce the risk of making mistakes in the future CL, sequence
checkers and task queue DCHECKs are added as well as other DCHECKs to
make sure things have been cleaned up before destruction, e.g:
- Processor gets a sequence checker. It is entirely single-threaded.
- Processor must not have any attached listeners or resources on
  destruction.
- Resources must not have any listeners on destruction.
- The Manager, EncodeUsageResource and QualityScalerResource DCHECKs
  they are running on the encoder queue.
- TODOs are added illustrating where we want to add PostTasks in the
  future CL.

Lastly, upon VideoStreamEncoder::Stop() we delete the
ResourceAdaptationProcessor. Because the Processor is already used in
posted tasks, some if statements are added to ensure the Processor is
not used after destruction.

Bug: webrtc:11542, webrtc:11520
Change-Id: Ibaa8a61d86d87a71f477d1075a117c28d9d2d285
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174760
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31217}
2020-05-11 20:35:30 +00:00
Erik Språng
bf46cfef22 Refactors send rate statistics in RtpSenderEgress
When FEC generation is moved to egress, we'll need to poll bitrates from
there instead of the RtpVideoSender. In preparation, refactoring some
getter methods.

For context, see https://webrtc-review.googlesource.com/c/src/+/173708

Bug: webrtc:11340
Change-Id: Ibc27362361ee9640d9fce676fc8e1093a579344f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174202
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31214}
2020-05-11 17:14:33 +00:00
Ilya Nikolaevskiy
8e321cd690 [Adaptation] Make QuailtyScalerResourse to report underuse if quality scaling is off
Bug: chromium:1080789
Change-Id: I3aefb746fd6f4adae4b32db322af6b787e8ede1d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174804
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31213}
2020-05-11 14:10:08 +00:00
Tommi
822a874463 Switch CallStats to TQ interface + callbacks on the worker thread.
Bug: webrtc:11489
Change-Id: I08c4cd42dfa28d88ed9f0aa8c8b2cfb606bf00df
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174240
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31203}
2020-05-10 23:24:35 +00:00
Tommi
553c869c58 Start consolidating management/querying of stats on the Call thread.
Call is instantiated on what we traditionally call the 'worker thread'
in PeerConnection terms. Call statistics are however gathered, processed
and reported in a number of different ways, which results in a lot of
locking, which is also unpredictable due to the those actions themselves
contending with other parts of the system.

Designating the worker thread as the general owner of the stats, helps
us keeps things regular and avoids loading unrelated task queues/threads
with reporting things like histograms or locking up due to a call to
GetStats().

This is a reland of remaining changes from https://webrtc-review.googlesource.com/c/src/+/172847:
This applies the changes from the above CL to the forked files and
switches call.cc over to using the forked implementation.

Bug: webrtc:11489
Change-Id: I93ad560500806ddd0e6df1448b1bcf5a1aae7583
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174000
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31186}
2020-05-08 07:24:39 +00:00
Erik Språng
04e1bab1b3 Replaces OverheadObserver with simple getter.
This interface has a couple of issues. Primarily for me, it makes it
difficult work with the paced sender as we need to either temporarily
release a lock or force a thread-handover in order to avoid a cyclic
lock order.

For video in particular, its behavior is also falky since header sizes
can vary not only form frame to frame, but from packet to packet within
a frame (e.g. TimingInfo extension is only on the last packet, if set).
On bitrate allocation, the last reported value is picked, leading to
timing issues affecting the bitrate set.

This CL removes the callback interface and instead we simply poll the
RTP module for a packet overhead. This consists of an expected overhead
based on which non-volatile header extensions are registered (so for
instance AbsoluteCaptureTime is disregarded since it's only populated
once per second). The overhead estimation is a little less accurate but
instead simpler and deterministic.

Bug: webrtc:10809
Change-Id: I2c3d3fcca6ad35704c4c1b6b9e0a39227aada1ea
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173704
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31185}
2020-05-07 17:33:45 +00:00
Stephan Hartmann
03fade52da IWYU: uint32_t is defined in cstdint
This is required for gcc-10.

Bug: None
Change-Id: I0d04f720d09b42e1d54e058b897ddc047ef64bf6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174204
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31184}
2020-05-07 17:04:15 +00:00
Evan Shrubsole
3b6afeeed0 Add comparison methods for VideoSourceRestrictions
Bug: None
Change-Id: Ia67f39e9b17e37294462823dd6f6ca365c7fd46b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174700
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31182}
2020-05-07 13:27:13 +00:00
Evan Shrubsole
0dcb470cfe [Adaptation] Adapt up requires previous underuse
The problem is that a resource that signals Underuse would be
able to trigger an adapt up when it was never limited in the past.
This means that an underused resource would be able to negate the
adaptations made for an overused one.

For example, consider a fast CPU on a bad link. The QP for the image
is high but the CPU is underused. Without requiring previous underuse,
everytime the QP would signal overuse and trigger an adpatation down,
the CPU would signal underuse and trigger an adaptation up.

This works today as we want by using the active counts in the
VideoStreamEncoderResourceManager. This change
makes it a normal behaviour independant of active counts.
The problem with active counts is that is only works with 2 resources.
When resources are injectable it no longer works as expected.

Bug: webrtc:11522, webrtc:11523
Change-Id: I140636ce206d74e00a6b6f8558162bb8afffda1c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174482
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31181}
2020-05-07 12:22:10 +00:00
Henrik Boström
a0ff50c031 Reland "Improve outbound-rtp statistics for simulcast"
This reverts commit 9a925c9ce3.

Reason for revert: The original CL is updated in PS #2 to
fix the googRtt issue which was that when the legacy sender
stats were put in "aggregated_senders" we forgot to update
rtt_ms the same way that we do it for "senders".

Original change's description:
> Revert "Improve outbound-rtp statistics for simulcast"
>
> This reverts commit da6cda839d.
>
> Reason for revert: Breaks googRtt in legacy getStats API
>
> Original change's description:
> > Improve outbound-rtp statistics for simulcast
> >
> > Bug: webrtc:9547
> > Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120
> > Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Reviewed-by: Henrik Boström <hbos@webrtc.org>
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Eldar Rello <elrello@microsoft.com>
> > Cr-Commit-Position: refs/heads/master@{#31097}
>
> TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: webrtc:9547
> Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31165}

TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com

# Not skipping CQ checks because this is a reland.

Bug: webrtc:9547
Change-Id: I723744c496c3c65f95ab6a8940862c8b9f544338
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174480
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31169}
2020-05-05 20:22:19 +00:00
Erik Språng
421088815f Refactors FEC in preparation for deferred packet generation.
RtpVideoSender now stores fec type and overhead instead of querying the
generator all the time. Setting of protection parameters and asking for
current bitrate is also now handled just by the VideoFecGenerator
instance, instead of going via RtpVideoSender.
Finally, adds method to query for RtpState in VideoFecGenerator
interface. This avoids an ugly cast that would have been even more
trouble after moving fec generation.

For context, see https://webrtc-review.googlesource.com/c/src/+/173708

Bug: webrtc:11340
Change-Id: Ia5e6cd919e71850c9cc5ed5a4f4417338d577162
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174203
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31166}
2020-05-05 13:59:14 +00:00
Henrik Boström
9a925c9ce3 Revert "Improve outbound-rtp statistics for simulcast"
This reverts commit da6cda839d.

Reason for revert: Breaks googRtt in legacy getStats API

Original change's description:
> Improve outbound-rtp statistics for simulcast
> 
> Bug: webrtc:9547
> Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Eldar Rello <elrello@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#31097}

TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:9547
Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31165}
2020-05-05 13:38:51 +00:00
Marina Ciocea
1148fd5cef Define MockFrameTransformer in test/.
Add MockFrameTransformer to test/, and remove definitions from unit test
files.

Bug: webrtc:11380
Change-Id: Ia709883e8d000852e3f71e7bfb87877072e22aeb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174001
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31151}
2020-05-04 13:45:22 +00:00
Henrik Boström
3745d3fc93 [Adaptation] Use ResourceAdaptationProcessorInterface* instead of impl.
This replaces references to the ResourceAdaptationProcessor with
references to its interface. This would make it possible to have
alternative implementations or inject fake/mock implementations for
testing.

The VideoStreamAdapter is still responsible for constructing the
ResourceAdaptationProcessor, but beyond construction it is agnostic
towards the implementation.

With this CL, I claim https://crbug.com/webrtc/11222 complete.

TBR=ilnik@webrtc.org

Bug: webrtc:11222
Change-Id: I6e7a73bf1d0b5e97bc694f66180a747b27ffb018
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174160
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31148}
2020-04-30 09:16:41 +00:00
Henrik Boström
722fa4d509 [Adaptation] Misc tests for processor, input provider and restrictions.
This CL adds miscellaneous unit tests for the
ResourceAdaptationProcessor, the VideoSourceRestrictions comparators and
the VideoStreamInputStateProvider.

Bug: webrtc:11172
Change-Id: If95f69644aaf2b43e3b19d5729bedef0b438c77b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174101
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31147}
2020-04-29 15:59:14 +00:00
Henrik Boström
91aa73255e [Adaptation] Add OnAdaptationApplied(), remove ResourceListenerResponse.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The ResourceListenerResponse was used to make the QualityScaler
not clear QP samples and instead increase its frequency of checking for
QP under certain circumstances, see enum description:
https://webrtc.googlesource.com/src.git/+/c70b1028d47c1aee4892545190cd66e97d09cd55/call/adaptation/resource.h#33

Because the QualityScaler depends on whether and how adaptation
happened it should listen to adaptation happening.

This CL moves the logic that was previously in VideoStreamAdapter closer
to the QualityScaler: QualityScalerResource::OnAdaptationApplied().

This would allow the VideoStreamAdapter to operate on a separate task
queue in the future, with no dependencies on any stream-specific
resources that might operate on other task queues.

Bug: webrtc:11172, webrtc:11521
Change-Id: I07971a8a5fab5715f4ccb7d2c63f1b92bd47170f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173090
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31143}
2020-04-29 09:08:46 +00:00
Mirko Bonadei
62a0d647d9 Remove deprecated constant.
Bug: None
Change-Id: I45957ad5e0f5fe0fd129bbae7aaef40a23142374
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173980
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31137}
2020-04-27 10:32:45 +00:00
Per Åhgren
cc73ed3e70 APM: Add build flag to allow building WebRTC without APM
This CL adds a build flag to allow building the non-test parts
of WebRTC without the audio processing module.
The CL also ensures that the WebRTC code correctly handles
the case when no APM is available.

Bug: webrtc:5298
Change-Id: I5c8b5d1f7115e5cce2af4c2b5ff701fa1c54e49e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171509
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31133}
2020-04-26 23:06:44 +00:00
Henrik Boström
dc4f75f7ee [Adaptation] Make ResourceUsageState nullable, remove kStable.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The ResourceUsageState was written as: {kOveruse, kStable, kUnderuse}.
The assumption was that if a resource neither wanted to adapt up or
down it would report kStable. But with the addition of
Resource::IsAdaptationUpAllowed() (prior CL) the notion of being
"stable" was already captured outside of ResourceUsageState.
Furthermore, kStable failed to capture what IsAdaptationUpAllowed() did
not: whether we can go up depends on the resulting resolution or frame
rate (restrictions_after). Perhaps we can go up a little, but not a lot.

This CL also adds Resource::ClearUsageState(). After applying an
adaptation, all usage states become invalidated (new measurements are
needed to know if we are still over- or underusing). This was always
the case, but prior to this CL this was not accurately reflected in the
Resource::usage_state() in-between measurements.

Bug: webrtc:11172
Change-Id: I140ff3114025b7732e530564690783e168d2509b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173088
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31110}
2020-04-20 10:54:53 +00:00
Danil Chapovalov
4c3a7dbe14 Remove RtpVideoHeader::discardable flag.
Calculate it when used instead

Bug: webrtc:11358
Change-Id: Ib79a4ce5e48a1a5244925471c005f96c5ec5dfd0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173702
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31109}
2020-04-20 10:25:43 +00:00
Erik Språng
cbc0cbaaec Updates RtpVideoSender to populate RtpRtcp::Config.field_trials
This caused at least one trial in RTPSender not to be properly parsed.

This CL also updates RtpVideoSender and RtpPayloadParams to use
WebRtcKeyValueConfig instead of the static field_trial methods, in
order to facilitate injectable behavior in the future.

Bug: webrtc:11508
Change-Id: I995939bd3e7c2f81e5050383c3e4daf933498520
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173705
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31108}
2020-04-20 09:53:58 +00:00
Henrik Boström
87eece9421 [Adaptation] Introducing call/adaptation/ResourceAdaptationProcessor.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

This gets to the heart of unblocking call-level adaptation, largely
made possible due to the previous CLs in the chain.

The parts of the code that are responsible for responding to resource
usage signals, obtaining adaptations and applying them are moved to
ResourceAdaptationProcessor in call/adaptation/.

The parts of the code that are responsible for managing
VideoStreamEncoder-specific resources stay inside the
VideoStreamEncoderResourceManager class in video/adaptation/.

After this CL lands it should soon be possible to move the Processor
over to a separate task queue and let the Manager stay on the encoder
queue if PostTasks are added for communication between the two objects.

Bug: webrtc:11172
Change-Id: Ifa212467b4afd16e7ebfb9adfe17d2dca1cb7d67
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173021
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31105}
2020-04-17 16:39:21 +00:00
Henrik Boström
d2930c6c2b [Adaptation] Report AdaptationCounters OnVideoSourceRestrictionsUpdated.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

By pushing VideoAdaptationCounters updates on VideoSourceRestrictions
changes, alongside the Resource* that triggered the adaptation, we are
able to update |active_counts_| without an explicit dependency on the
VideoStreamAdapter. This allows a future CL to split up "processor"
logic from "video stream encoder resource and active counts" logic,
which will ultimately be necessary in order to do processing on a
"processing queue" and encoder and stats logic on the "encoder queue".

If the restrictions got cleared by an API call
(ResetVideoSourceRestrictions() or SetDegradationPreference()) we pass
null as the "reason_resource". This allows is to clear the
active_counts_, and the code that invokes
OnVideoSourceRestrictionsUpdated() does not have to be aware of
active_counts_ (needed to split the processor module in two).

Bug: webrtc:11172
Change-Id: Icab6d5121c0ebd27d2a00f1bffc8191f8f05f562
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173000
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31103}
2020-04-17 15:10:15 +00:00
Henrik Boström
1d76654e21 [Adaptation] Move VideoStreamAdapter to call/adaptation/.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

This is a pure move CL. In the future, the Processor will live in
call/adaptation/. This prevents circular dependencies.

Bug: webrtc:11172
Change-Id: Ib72503cc20e27ab6425538e3d55930c65e0b4a90
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172931
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31100}
2020-04-17 13:23:42 +00:00
Henrik Boström
b613e3ab6b [Adaptation] Resource::IsAdaptationUpAllowed() for IsBitrateConstrained.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The VideoStreamAdapter is currently responsible for aborting and not
providing adaptations if we are bitrate constrained
(kIsBitrateConstrained). Whether or not we are bitrate constrained is
clearly a resource question and should be phrased as such. By moving
this logic to Resource::IsAdaptationUpAllowed(), the VideoStreamAdapter
can continue to be thread-agnostic when a future CL introduces a
"processing queue", and the VideoStreamAdapter can be simplified: it
returns Adaptations even if we are constrained (but we refuse to Apply
them any resource rejects it).

This CL adds new Resource classes as inner classes of
ResourceAdaptationProcessor that take on the responsibility of
kIsBitrateConstrained logic:
PreventIncreaseResolutionDueToBitrateResource and
PreventAdaptUpInBalancedResource.

A third class, PreventAdaptUpDueToActiveCounts, also allows us to move
adaptation-aborting logic. This piece of code appears to be about not
adapting up if we’re already at the highest setting, which would be
VideoStreamAdapter responsibility (covered by
Adaptation::Status::kLimitReached), but it is actually more complicated
than that: the active_counts_ care about "reason", so it is really about
"is this resource type OK with you adapting up?". We should probably
rewrite this code in the future, but for now it is moved to an inner
class of ResourceAdaptationProcessor.

Other misc changes:
- ApplyDegradationPreference is moved to video_stream_adapter.[h/cc]
  and renamed "Filter".
- OnResourceOveruse/Underuse now use Resource* as the reason instead of
  AdaptReason. In a future CL, the processor will be split into a
  "processor" part and a "video stream encoder resource manager" part.
  Only the manager needs to know about AdaptReason since this is only
  used for |active_counts_| and we want to get rid of it as much as
  possible as it is not future-proof.

Bug: webrtc:11172
Change-Id: I2eba9ec3d717f7024c451aeb14635fe759551318
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172930
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31099}
2020-04-17 12:35:18 +00:00
Henrik Boström
d516b25852 [Adaptation] Introduce VideoStreamInputState and its Provider.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The "input state" of a VideoStream, needed for adaptation and
decision-making, are: source resolution and frame rate, codec type and
min pixels per frame (based on encoder scaling settings). These values
are modified on the encoder queue of the VideoStreamEncoder.

But in order to unblock call-level adaptation processing, where
adaptation and decision making happens off the encoder queue, a snapshot
of the input states need to be available at point of processing:
introducing the VideoStreamInputState.

In this CL, the VideoStreamInputStateProvider is added to provide input
state snapshots across threads based on input from VideoStreamEncoder
and VideoStreamEncoderObserver.

The input state's HasInputFrameSizeAndFramesPerSecond() can now be
DCHECKed inside the VideoStreamAdapter in favor of having less
Adaptation::Status codes. Whether input is "sufficient" for adaptation
is now the responsibility of the Processor. (Goal: adapter is purely a
Adaptation generator and apply-er.)

Somewhat tangental, this CL also deletes VideoStreamEncoder-specific
methods from ResourceAdaptationProcessorInterface making them an
implementation detail of ResourceAdaptationProcessor. In a future CL,
the "processor" will be split up into a "processor" part and a "video
stream encoder resource manager" part - more on that later.

Bug: webrtc:11172
Change-Id: Id9b158f569db0140b75360aaf0f7e2e28fb924f4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172928
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31098}
2020-04-17 11:45:50 +00:00
Eldar Rello
da6cda839d Improve outbound-rtp statistics for simulcast
Bug: webrtc:9547
Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Eldar Rello <elrello@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#31097}
2020-04-17 11:28:00 +00:00
Henrik Boström
67402f8114 [Adaptation] Delete Processor Proof-of-Concept.
This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The POC was used to demo the new design but was never used outside of
unit tests. The plan being to iteratively improve the
ResourceAdaptationProcessor rather than to replace it, we delete the POC
classes to avoid bloat and conflicts.

Bug: webrtc:11172
Change-Id: Ic49afdc471d2d774541f8ef3316b4c6d0a9b8a14
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172923
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31094}
2020-04-17 09:11:47 +00:00
Mirko Bonadei
ee1e6bcb02 Remove deprecated VideoSendStream::StreamStats data members.
Bug: webrtc:10198
Change-Id: Ie48727acc6d1c9af42f3a997c98d9fdab4675d4a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173622
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31080}
2020-04-16 09:31:21 +00:00
Tommi
3c9bcc1f7a Reland of the test portion of:
https://webrtc-review.googlesource.com/c/src/+/172847

------------ original description --------------

Preparation for ReceiveStatisticsProxy lock reduction.

Update tests to call VideoReceiveStream::GetStats() in the same or at
least similar way it gets called in production (construction thread,
same TQ/thread).

Mapped out threads and context for ReceiveStatisticsProxy,
VideoQualityObserver and VideoReceiveStream. Added
follow-up TODOs for webrtc:11489.

One functional change in ReceiveStatisticsProxy is that when sender
side RtcpPacketTypesCounterUpdated calls are made, the counter is
updated asynchronously since the sender calls the method on a different
thread than the receiver.

Make CallClient::SendTask public to allow tests to run tasks in the
right context. CallClient already does this internally for GetStats.

Remove 10 sec sleep in StopSendingKeyframeRequestsForInactiveStream.

Bug: webrtc:11489
Change-Id: I491e13344b9fa714de0741dd927d907de7e39e83
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173583
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31077}
2020-04-15 16:09:44 +00:00
Marina Ciocea
dc69fd2b80 [InsertableStreams] Fix video sender simulcast.
The transformer was previously moved into the config of the first stream
which resulted in incorrect behavior for simulcast. Use the transformer
in all the streams.

Pass the sender's ssrc on registring the transformed frame callback, to
associate separate transformer sinks for each sender.

Bug: chromium:1065838
Change-Id: I5c52dacb241c68268681b85f875257b24987849e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173332
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31050}
2020-04-11 10:30:32 +00:00
Marina Ciocea
d03d968b75 Revert "[InsertableStreams] Fix simulcast: set frame transformer for all streams"
This reverts commit d926cf63b5.

Reason for revert: Breaks simulcast testing in Canary, to be relanded once the chrome part of the fix is landed as well.

Original change's description:
> [InsertableStreams] Fix simulcast: set frame transformer for all streams
> 
> The transformer was previously moved into the config of the first stream
> which resulted in incorrect behavior for simulcast. Use the transformer
> in all the streams.
> 
> Bug: chromium:1065838
> Change-Id: Iea340443da8cd4de32953bb24d3e6a07a275ae2a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173026
> Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
> Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31018}

TBR=mflodman@webrtc.org,marinaciocea@webrtc.org

Change-Id: Ib0f869ae617329eb2532b613741b6050bd3ba2a3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1065838
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173181
Reviewed-by: Marina Ciocea <marinaciocea@webrtc.org>
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31033}
2020-04-08 10:00:51 +00:00
Artem Titov
16cc9efd54 Revert "Preparation for ReceiveStatisticsProxy lock reduction."
This reverts commit 24eed2735b.

Reason for revert: Speculative revert: breaks downstream project

Original change's description:
> Preparation for ReceiveStatisticsProxy lock reduction.
> 
> Update tests to call VideoReceiveStream::GetStats() in the same or at
> least similar way it gets called in production (construction thread,
> same TQ/thread).
> 
> Mapped out threads and context for ReceiveStatisticsProxy,
> VideoQualityObserver and VideoReceiveStream. Added
> follow-up TODOs for webrtc:11489.
> 
> One functional change in ReceiveStatisticsProxy is that when sender
> side RtcpPacketTypesCounterUpdated calls are made, the counter is
> updated asynchronously since the sender calls the method on a different
> thread than the receiver.
> 
> Make CallClient::SendTask public to allow tests to run tasks in the
> right context. CallClient already does this internally for GetStats.
> 
> Remove 10 sec sleep in StopSendingKeyframeRequestsForInactiveStream.
> 
> Bug: webrtc:11489
> Change-Id: Ib45bfc59d8472e9c5ea556e6ecf38298b8f14921
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172847
> Commit-Queue: Tommi <tommi@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31008}

TBR=mbonadei@webrtc.org,henrika@webrtc.org,kwiberg@webrtc.org,tommi@webrtc.org,juberti@webrtc.org,mflodman@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:11489
Change-Id: I48b8359cdb791bf22b1a2c2c43d46263b01e0d65
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173082
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31023}
2020-04-07 19:50:20 +00:00
Marina Ciocea
d926cf63b5 [InsertableStreams] Fix simulcast: set frame transformer for all streams
The transformer was previously moved into the config of the first stream
which resulted in incorrect behavior for simulcast. Use the transformer
in all the streams.

Bug: chromium:1065838
Change-Id: Iea340443da8cd4de32953bb24d3e6a07a275ae2a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173026
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31018}
2020-04-07 18:51:18 +00:00
Tommi
24eed2735b Preparation for ReceiveStatisticsProxy lock reduction.
Update tests to call VideoReceiveStream::GetStats() in the same or at
least similar way it gets called in production (construction thread,
same TQ/thread).

Mapped out threads and context for ReceiveStatisticsProxy,
VideoQualityObserver and VideoReceiveStream. Added
follow-up TODOs for webrtc:11489.

One functional change in ReceiveStatisticsProxy is that when sender
side RtcpPacketTypesCounterUpdated calls are made, the counter is
updated asynchronously since the sender calls the method on a different
thread than the receiver.

Make CallClient::SendTask public to allow tests to run tasks in the
right context. CallClient already does this internally for GetStats.

Remove 10 sec sleep in StopSendingKeyframeRequestsForInactiveStream.

Bug: webrtc:11489
Change-Id: Ib45bfc59d8472e9c5ea556e6ecf38298b8f14921
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172847
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31008}
2020-04-06 14:34:38 +00:00
Mirko Bonadei
06d3559b79 Replace std::string::find() == 0 with absl::StartsWith (part 2).
This CL has been generated using clang-tidy [1] except for changes to
BUILD.gn files.

[1] - https://clang.llvm.org/extra/clang-tidy/checks/abseil-string-find-startswith.html

Bug: None
Change-Id: Ibf75601065a53bde28623b8eef57bec067235640
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172586
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30984}
2020-04-02 14:38:30 +00:00
Marina Ciocea
3e9af7fe05 Insert audio frame transformer between depacketizer and decoder.
The frame transformer is passed from RTPReceiverInterface through the
library to be eventually set in ChannelReceive, where the frame
transformation will occur in the follow-up CL.

Insertable Streams Web API explainer:
https://github.com/alvestrand/webrtc-media-streams/blob/master/explainer.md

Design doc for WebRTC library changes:
http://doc/1eiLkjNUkRy2FssCPLUp6eH08BZuXXoHfbbBP1ZN7EVk

Bug: webrtc:11380
Change-Id: I5af06d1431047ef50d00e304cf95e92a832b4220
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171872
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30956}
2020-04-01 08:15:53 +00:00
Guido Urdaneta
e1aa22f892 [InsertableStreams] Set video frame transformer if RTP stream already started.
Test in https://chromium-review.googlesource.com/c/chromium/src/+/2127927

Bug: chromium:1065836
Change-Id: Idf3f41285e23ac829f69f1bc95b1def3a73af8d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172400
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Marina Ciocea <marinaciocea@webrtc.org>
Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30948}
2020-03-31 14:07:29 +00:00
Marina Ciocea
d2aa8f97f1 Insert audio frame transformer between encoder and packetizer.
The frame transformer is passed from RTPSenderInterface through the
library to be eventually set in ChannelSend, where the frame
transformation will occur in the follow-up CL.

Insertable Streams Web API explainer:
https://github.com/alvestrand/webrtc-media-streams/blob/master/explainer.md

Design doc for WebRTC library changes:
http://doc/1eiLkjNUkRy2FssCPLUp6eH08BZuXXoHfbbBP1ZN7EVk

Bug: webrtc:11380
Change-Id: I01b2adc3c96b948d182d5401a9a4fe14cf5960a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171870
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30946}
2020-03-31 11:14:00 +00:00
Christoffer Rodbro
6404cddefb Allow setting a bandwidth cap for relayed connections.
For now the capping is experimental and applied via a field trial.

Bug: webrtc:11434
Change-Id: Id8e6e9b948f099a0940974a9a431b5b0a43c32f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171226
Commit-Queue: Christoffer Rodbro <crodbro@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30909}
2020-03-26 20:41:46 +00:00
Christoffer Rodbro
b0ca519c40 Handle extended route information in TransportFeedbackAdapter.
Instead of passing only the local- and remote network IDs the whole
NetworkRoute is forwarded to TransportFeedbackAdapter that can then
use more detailed information to distinguish routes.

Bug: webrtc:11434
Change-Id: I48f36aa1177822d20c2b556dcc2275f6145ed845
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171581
Commit-Queue: Christoffer Rodbro <crodbro@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30895}
2020-03-26 09:39:34 +00:00
Henrik Boström
f45ca3787f [Stats] Explicit RTP-RTX and RTP-FEC mappings. Unblocks simulcast stats.
--- Background ---
The webrtc::VideoSendStream::StreamStats are converted into
VideoSenderInfo objects which turn into "outbound-rtp" stats objects in
getStats() (or "ssrc" objects in legacy getStats()).

StreamStats are created for each type of substream: RTP media streams,
RTX streams and FlexFEC streams - each with individual packet counters.

The RTX stream is responsible for retransmissions of a referenced media
stream and the FlexFEC stream is responsible for FEC of a referenced
media stream. RTX/FEC streams do not show up as separate objects in
getStats(). Only the media streams become "outbound-rtp" objects, but
their packet and byte counters have to include the RTX and FEC counters.

--- Overview of this CL ---
This CL adds MergeInfoAboutOutboundRtpSubstreams(). It takes
StreamStats of all kinds as input, and outputs media-only StreamStats
- incorporating the RTX and FEC counters into the relevant media
StreamStats.

The merged StreamStats objects is a smaller set of objects than the
non-merged counterparts, but when aggregating all packet counters
together we end up with exact same packet and count as before.

Because WebRtcVideoSendStream::GetVideoSenderInfo() currently aggregates
the StreamStats into a single VideoSenderInfo (single "outbound-rtp"),
this CL should not have any observable side-effects. Prior to this CL:
aggregate StreamStats. After this CL: merge StreamStats and then
aggregate them.

However, when simulcast stats are implemented (WIP CL:
https://webrtc-review.googlesource.com/c/src/+/168120) each RTP media
stream should turn into an individual "outbound-rtp" object. We will
then no longer aggregate all StreamStats into a single "info". This CL
unblocks simulcast stats by providing StreamStats objects that could be
turned into individual VideoSenderInfos.

--- The Changes ---
1. Methods added to RtpConfig to be able to easily tell the relationship
   between RTP, RTX and FEC ssrcs.
2. StreamStats gets a StreamType (kMedia, kRtx or kFlexfec) that
   replaces the booleans (is_rtx, is_flexfec).
3. "referenced_media_ssrc" is added to StreamStats, making it possible
   to tell which kRtx/kFlexFec stream stats need to be merged with which
   kMedia StreamStats.
4. MergeInfoAboutOutboundRtpSubstreams() added and used.

Bug: webrtc:11439
Change-Id: Iaf9002041169a054ddfd32c7ea06bd1dc36c6bca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170826
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30869}
2020-03-24 13:31:54 +00:00
Jonas Oreland
5b6a4d8908 Only print route if it has changed
This is a follow up change to https://webrtc-review.googlesource.com/c/src/+/170628
and modifies code to only LOG if the route really has changed.

Existing code will LOG like this, which is slightly annoying. Notice that the same route change is LOG:ed twice.
03-23 13:28:49.281 17986 18850 I rtp_transport_controller_send.cc: [1183:590] [18850] (line 253): Network route changed on transport audio: new_route = [ connected: 1 local: [ 2/4 Wifi turn: 0 ] remote: [ 2/3 Wifi turn: 0 ] packet_overhead_bytes: 32 ]
03-23 13:28:49.281 17986 18850 I rtp_transport_controller_send.cc: [1183:590] [18850] (line 278): old_route = [ connected: 1 local: [ 2/4 Wifi turn: 1 ] remote: [ 2/3 Wifi turn: 0 ] packet_overhead_bytes: 28 ]
03-23 13:28:49.281 17986 18850 I rtp_transport_controller_send.cc: [1183:591] [18850] (line 253): Network route changed on transport audio: new_route = [ connected: 1 local: [ 2/4 Wifi turn: 0 ] remote: [ 2/3 Wifi turn: 0 ] packet_overhead_bytes: 32 ]
03-23 13:28:49.282 17986 18850 I rtp_transport_controller_send.cc: [1183:591] [18850] (line 278): old_route = [ connected: 1 local: [ 2/4 Wifi turn: 0 ] remote: [ 2/3 Wifi turn: 0 ] packet_overhead_bytes: 32 ]

The way this method is called twice with same argument is out of scope
for this change.

BUG: webrtc:11434
Change-Id: I052d089c59714513a09cbaed49f24c8f1300af58
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171460
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30865}
2020-03-24 11:48:42 +00:00
Jonas Oreland
c32c5dd61e Add terelius as OWNER in call/
BUG: None
Change-Id: Ib9ad583ae2dfa694114447a648b281a049ed4b59
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171223
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30853}
2020-03-23 09:55:34 +00:00
Jonas Oreland
71fda3613c Extend NetworkRoute with more info about local/remote endpoints
This patch extends the NetworkRoute struct with more information
about local/remote endpoints. It adds
- adapter type
- adapter id
- relay

(previously it was "only" network_id)

The patch leaves the {local/remote}_network_id fields
around and populated since downstream projects depend
on them. They will be removed once they have migrated.

OWNER: srte@ call/ test/
OWNER: asapersson@ video/
OWNER: hta@ p2p/ pc/ rtc_base/

BUG: webrtc:11434
Change-Id: I9bcec385b40d707db385fef40b2c7a315dd35dd0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170628
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30848}
2020-03-20 16:55:38 +00:00
Sebastian Jansson
89eb0bba0c Adds UpdateConfig to SimulatedNetwork
Bug: webrtc:9510
Change-Id: Ied0e5ff291021ba4f539eee9820b8490a7004882
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170462
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30803}
2020-03-16 15:58:43 +00:00
Henrik Boström
453953c9eb [Adaptation] Refactor AdaptationTarget. Peek next restrictions.
This CL introduces the Adaptation class used by VideoStreamRestrictor.
This refactors the AdaptationTarget, AdaptationTargetOrReason,
CannotAdaptReason and AdaptationAction.

What is publicly exposed is simply a Status code. If it's kValid then
we can adapt, otherwise the status code describes why we can't adapt
(just like CannotAdaptReason prior to this CL). This means
AdaptationTargetOrReason is no longer needed. Target+reason are merged.

The other classes are renamed and moved and put in the private
namespace of Adaptation: Only the VideoStreamAdapter (now a friend
class of Adaptation) and its inner class VideoSourceRestrictor needs to
know how to execute the adaptation.

Publicly, you can now tell the effects of the adaptation without
applying it with PeekNextRestrictions() - both current and next steps
are described in terms of VideoSourceRestrictions. The rest are hidden.

This would make it possible, in the future, for a Resource to accept or
reject a proposed Adaptation by examining the resulting frame rate and
resolution described by the resulting restrictions. E.g. even if we are
not overusing bandwidth at the moment, the BW resource can prevent us
from applying a restriction that would exceed the BW limit before we
apply it.

This CL also moves input to a SetInput() method, and Increase/Decrease
methods of VideoSourceRestrictor are made private in favor of
ApplyAdaptationSteps().

Bug: webrtc:11393
Change-Id: Ie5e2181836ab3713b8021c1a152694ca745aeb0d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170111
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#30794}
2020-03-14 11:29:03 +00:00