Introduce a callback mechanism to intercept and handle encoder switch
requests within the video media engine. This makes it so that codec
switch/fallback requests first go through the the RtpTransceiver on the
signaling thread. That is consistent with other parameter related
changes and allows the transceiver to update the sender object(s) before
the codec change is applied.
Specifically, the changes include:
* Define EncoderSwitchRequestCallback and EncoderSwitchRequestAction
in VideoMediaSendChannelInterface.
* Updating WebRtcVideoSendChannel to optionally use the callback
instead of posting directly to the worker thread when an encoder
switch is requested.
* Implementing GetEncoderSwitchRequestCallback in RtpTransceiver
to ensure that when a switch occurs, cached RTP parameters on the
signaling thread are cleared before the switch action is executed
on the worker thread.
* Updating RtpSender to support clearing cached parameters via
std::optional.
* Adding RTC_DCHECK to SafeTask and SafeInvocable to catch if
the provided safety flag is invalid, early.
Bug: b/478050997
Change-Id: Id81a219a0f3dab6a167248c21513723504fa6e79
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/454700
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Sameer Vijaykar <samvi@google.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#47148}
Introduce mechanisms within the Thread class to support cooperative
multitasking. This allows long-running tasks to voluntarily yield
execution to pending high-priority work, improving responsiveness and
mitigating latency issues like audio glitches that can occur during
heavy operations such as session negotiation.
Key modifications:
- Add IsYieldRequested() to allow tasks to check for pending yield
requests.
- Implement PostHighPriorityTask() to insert urgent tasks into a
dedicated queue and signal a yield request on the target thread.
- Track nested synchronous blocking calls to catch when yielding in
unsafe contexts, enforced via RTC_DCHECK.
- Ensure high-priority tasks are processed before regular tasks when the
thread resumes execution.
# no-try: persistent webrtc_linux_chromium infra failure
No-try: true
Bug: webrtc:42223005
Change-Id: I093b7e04d665baef19085e72bc0548447fd6768c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/450561
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#47056}
This change introduces specific priority levels for audio and
video tasks within the TaskQueueFactory to allow for better
platform-specific thread scheduling.
Changes:
* New field trial WebRTC-MediaTaskQueuePriorities that activates the
priority change.
* New Priority Enums: Added kVideo and kAudio to
TaskQueueFactory::Priority and corresponding kVideo and
kAudio to ThreadPriority.
* WebRTC platform thread implementation:
- Video priority initially maps to high priority.
- On Mac/iOS (GCD), both audio and video map to
DISPATCH_QUEUE_PRIORITY_HIGH because of API limitation.
* Task queue updates:
- Updated the audio encoder queue to use kAudio priority.
- Updated the video encoder & decoder, incoming video
stream, and video frame transformer queues to use kVideo priority.
* Queue renaming: Standardized several task queue names by
appending "Queue" (e.g., "AudioEncoder" became "AudioEncoderQueue").
Bug: chromium:470337728
Change-Id: I4790990340a72a54945750c2c4e1f97314edf375
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/436580
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46744}
We're about to add two new priorities. Ensure we're
respecting go/cstyle#Enumerator_Names before adding them.
WANT_LGTM=ANY
Bug: chromium:470337728
Change-Id: I01c6f237a7c67df6a3083f1165ee07bffc9d3523
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/443420
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46740}
This is a reland of commit 091aaa3655
The reland also checks for `!defined(WEBRTC_CHROMIUM_BUILD)`
Original change's description:
> Add test for QueueUserAPC compatibility
>
> This has always been supported in the default implementation but the
> Thread and stdlib thread implementations don't have this yet.
>
> Bug: none
> Change-Id: Ic82733d0d49267231404d5525bc49342eae83c09
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/428902
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#46357}
Bug: none
Change-Id: Ia2e4eb3e3bb926fe725057bc093338a3ce56b953
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/429662
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46480}
This reverts commit 091aaa3655.
Reason for revert: Broke chromium import.
https://ci.chromium.org/ui/p/chromium/builders/try/win-arm64-compile-dbg/662831/overview
Original change's description:
> Add test for QueueUserAPC compatibility
>
> This has always been supported in the default implementation but the
> Thread and stdlib thread implementations don't have this yet.
>
> Bug: none
> Change-Id: Ic82733d0d49267231404d5525bc49342eae83c09
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/428902
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#46357}
Bug: none
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I711065d4244f5f4b4c4bf30954ef5d64d036cf64
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/429661
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46363}
This has always been supported in the default implementation but the
Thread and stdlib thread implementations don't have this yet.
Bug: none
Change-Id: Ic82733d0d49267231404d5525bc49342eae83c09
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/428902
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46357}
This patch introduces a new test case, `CoroutineSynchronous`, to verify
the behavior of a coroutine that is intended to execute synchronously.
The coroutine, `ActuallySynchronous`, uses `co_await` to switch to the
already-current task queue. This specific usage should result in
immediate execution without introducing any asynchronous operations or
task posting, as the destination is already the current queue.
A related change is also included in the existing `Coroutine` test to
add an expectation that the coroutine's final callback is not invoked
immediately after the coroutine is launched, confirming its asynchronous
nature.
Bug: none
Change-Id: Ic9e122759029c8db077a6cafa925818e98e7da56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/424982
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46178}
Bug: none
No-Iwyu: Something is up with the iwyu bot.
Change-Id: Ie0106044e0705f812e7914eb96f3142a04345a6c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/424620
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46162}
This demonstrates use of a trampoline so that callers to sigslot
functions can use lambda functions without any other changes.
Bug: webrtc:42222066
Change-Id: I815d390b383f7a55a854ac5dc0b09f0a6b28414d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406060
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45433}
using
git ls-files | grep BUILD.gn | xargs gn format
which seems to induce a shorter notation for cases like
- "../../api/rtc_event_log:rtc_event_log",
+ "../../api/rtc_event_log",
now.
Bug: None
Change-Id: I362627095f3d0391603d9f642d14fdadba58ca66
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/402860
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45257}
Using public has additional unintential consequence of allowing transitive dependencies and should generally be avoided.
Bug: None
Change-Id: I7655c09e9e8ec49c33751db990428f5a95e15332
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/399260
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45096}
Poison concrete class for FieldTrials to prevent webrtc internal code create own field trials.
Poison task queue factory for ios and android as exception are now explicitly marked.
Bug: webrtc:42220378
Change-Id: I768fef6411c250075d4f4ac0292196f33cd018b4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/393563
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45084}
WebRTC has unified all namespaces to webrtc, and the rtc:: and cricket::
name specifiers need to be replaced with webrtc::. This was generated using
a combination of clang AST rewriting tools and sed.
This CL was uploaded by git cl split.
Bug: webrtc:42232595
Change-Id: Ie05cf23955a3417937fc1dd56d00dda679d1a59e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/386641
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44384}
using
find api/ -name "*.h" -o -name "*.cc" | grep -v priority.h | xargs tools_webrtc/iwyu/apply-include-cleaner
followed by
tools_webrtc/gn_check_autofix.py -C out/Default/
and git cl format
Manual changes:
- api/test/compile_all_headers.cc: add IWYU keep pragma
- api/video/nv12_buffer.cc: fix include part of libyuv/convert_from.h
- DEPS changes
priority.h is excluded as it is currently a header-only target. Will be fixed as a follow-up.
A generated histogram.pb.h is included from
api/test/metrics/chrome_perf_dashboard_metrics_exporter_test.cc
since it is not directly exported by catapult.
BUG=webrtc:42226242
Change-Id: Idce13d892c61ae71bf4f39bd5ffa4638a3d7f8fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/382120
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#44374}
absl::Nonnull -> absl_nonnull, absl::Nullable -> absl_nullable,
and absl::NullabilityUnknown -> absl_nullability_unknown.
The new macros are positioned as a qualifier on the affected type,
similar to const, rather than as a templated type wrapping the affected
type.
Bug: webrtc:407433459
No-Iwyu: No regressions introduced by this CL
Change-Id: Id6b1a58296d52c86db3ae44e90849affc904d335
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/384220
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44301}
which is now unused. Also remove libevent from DEPS and
generate_licenses.py
BUG=webrtc:42224654
Change-Id: I30aceaa304b4c6fb23e8485172f38bdaf18daf2f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/382581
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#44216}
Previous CLs that disabled the rtc_enable_libevent build flag
did not reveal issues. Now continue to remove the source code for
the task queue.
Bug: webrtc:42224654
Change-Id: I0866b4b56f0a8d8b56a5b604c31a426d77ab8d04
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370801
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43550}
as this includes the deprecated timeKillEvent symbol which leads
to runtime errors on platforms where this is already removed.
See discussion in
https://webrtc-review.googlesource.com/c/src/+/328860
for why this causes problems.
BUG=webrtc:15656
Change-Id: I95d07ceed105d35ac76fe97dbd1c454de398f52e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/333260
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41468}
This poison guards against accidental use of EnvironmentFactory and thus ensures low level WebRTC class would use utilities from propagated environment instead of accidentally using a default implementation.
This poison extends and thus replaces default task queue poison.
Bug: webrtc:15656
Change-Id: I577bef8af08b9c7dd649ad5a2284eb236e6f4a8f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/328380
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41247}
This reverts commit 8039cdbe48.
Reason for revert: remove functionality after measurement complete
Original change's description:
> Measure wall clock time of capture and encode processing.
>
> (NOTE: This and dependent CLs will be reverted in a few days after
> data collection from the field is complete.)
>
> This change introduces a new task queue concept, Voucher. They
> are associated with a currently running task tree. Whenever
> tasks are posted, the current voucher is inherited and set as
> current in the new task.
>
> The voucher exists for as long as there are direct and indirect
> tasks running that descend from the task where the voucher was
> created.
>
> Vouchers aggregate application-specific attachments, which perform
> logic unrelated to Voucher progression. This particular change adds
> an attachment that measures time from capture to all encode operations
> complete, and places it into the WebRTC.Video.CaptureToSendTimeMs UMA.
>
> An accompanying Chrome change crrev.com/c/4992282 ensures survival of
> vouchers across certain Mojo IPC.
>
> Bug: chromium:1498378
> Change-Id: I2a27800a4e5504f219d8b9d33c56a48904cf6dde
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325400
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Markus Handell <handellm@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#41061}
Bug: chromium:1498378
Change-Id: I9503575fbc52f1946ca26fc3c17b623ea75cd3c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/327023
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#41135}
(NOTE: This and dependent CLs will be reverted in a few days after
data collection from the field is complete.)
This change introduces a new task queue concept, Voucher. They
are associated with a currently running task tree. Whenever
tasks are posted, the current voucher is inherited and set as
current in the new task.
The voucher exists for as long as there are direct and indirect
tasks running that descend from the task where the voucher was
created.
Vouchers aggregate application-specific attachments, which perform
logic unrelated to Voucher progression. This particular change adds
an attachment that measures time from capture to all encode operations
complete, and places it into the WebRTC.Video.CaptureToSendTimeMs UMA.
An accompanying Chrome change crrev.com/c/4992282 ensures survival of
vouchers across certain Mojo IPC.
Bug: chromium:1498378
Change-Id: I2a27800a4e5504f219d8b9d33c56a48904cf6dde
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325400
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41061}
This CL completes migration to the new TaskQueueBase interface
permitting location tracing in Chrome.
Bug: chromium:1416199
Change-Id: Iff7ff5796752a1520384a3db0135a1d4b9438988
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294540
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39439}
This CL migrates unit tests to the new TaskQueueBase interface.
Bug: chromium:1416199
Change-Id: Ic15c694b28eb67450ac99fdd56754de1246a4d95
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295621
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39434}
This prepares TaskQueueBase sub classes to be able to migrate to
the location and traits-based API. It re-introduces a Location class
into the webrtc namespace, which is meant to be overridden by Chromium.
Bug: chromium:1416199
Change-Id: I712c7806a71b3b99b2a2bf95e555b357c21c15ae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294381
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39400}
This reverts commit e87ec28b80.
Reason for revert: Breaks upstream.
Original change's description:
> Add checks for api/test mocks to make sure they're complete
>
> Also unifies the mock inheritance if they inherited from a ref counted
> interface:
> - it should only inherit from the interface
> - it should use make_ref_counted
>
> Bug: webrtc:14594
> Change-Id: I7b0514b632ccd0798028b50f19812ac0a196e13c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262423
> Commit-Queue: Florent Castelli <orphis@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38602}
Bug: webrtc:14594
Change-Id: I9f2d9c3656b43e3006ec03ae7d792d0a53f47ebd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282940
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#38604}
Also unifies the mock inheritance if they inherited from a ref counted
interface:
- it should only inherit from the interface
- it should use make_ref_counted
Bug: webrtc:14594
Change-Id: I7b0514b632ccd0798028b50f19812ac0a196e13c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262423
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38602}
This reverts commit 83db78e854.
Reason for revert: Some tests in Chromium's blink no longer compile because of the change in the signature of the CreateDefaultTaskQueueFactory() function.
Original change's description:
> Add TaskQueueStdlib experiment.
>
> Bug: webrtc:14389
> Change-Id: I23c6e0ae675748ec35a99c334104dd2654995a33
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265802
> Commit-Queue: Ali Tofigh <alito@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37888}
Bug: webrtc:14389
Change-Id: If3e63d6b4ab9e838dc5020b88076a73fd29916e4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272920
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37902}