Commit graph

149 commits

Author SHA1 Message Date
Florent Castelli
8037fc6ffa Migrate absl::optional to std::optional
Bug: webrtc:342905193
No-Try: True
Change-Id: Icc968be43b8830038ea9a1f5f604307220457807
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361021
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42911}
2024-09-02 12:16:47 +00:00
Tommi
c3b7a50720 Use webrtc::TaskQueueBase type instead of rtc::Thread
...for signaling and worker thread members in BaseChannel classes.

Bug: webrtc:15099
Change-Id: I83611ed2564e143aca19d0f12ce060b77eb9d2a7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325260
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41041}
2023-10-30 14:43:46 +00:00
Harald Alvestrand
ecc38d8d29 Take out callback that modifies voice receive codec based on send codec
No functionality that depends on this information has been identified; no tests break when it is taken out.

Bug: webrtc:15224
Change-Id: I37298479c6b8a4acb82f59d32130c105371936b4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/324760
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41037}
2023-10-30 12:36:29 +00:00
Harald Alvestrand
ff281aa328 Convert signals in rtp_transport_internal.h to CallbackList
Bug: webrtc:11943
Change-Id: I8e0839363712d9d8b49c2f6cbdb5f3ac59d79219
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318882
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40700}
2023-09-05 11:37:32 +00:00
Philipp Hancke
5866e1a0ed Rename Set(Send|Recv)Parameters Set(Sender|Receiver)Parameters
following the previous change to rename the classes derived from
  cricket::RtpParameters

Also rename ChangedRecvParameters to ChangedReceiveParameters.

BUG=webrtc:13931

Change-Id: Ia51dd39905a5cbb98162c3948930e43ccaf3786d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/314500
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40677}
2023-09-01 08:12:55 +00:00
Philipp Hancke
a9d5141367 Rename cricket::RtpParameters and derived classes
Renames
  cricket::RtpParameters
to
  cricket::MediaChannelParameters
in order to distinguish it better from webrtc::RtpParameters.
This involves renaming
  RtpSendParameters -> SenderParameters
  AudioSendParameters -> AudioSenderParameters
  AudioRecvParameters -> AudioReceiverParameters
  VideoSendParameters -> VideoSenderParameters
  VideoRecvParameters -> VideoReceiverParameters

BUG=webrtc:13931

Change-Id: I664595ee3863418c0c6ca092ca77127be0f9498f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/314360
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#40497}
2023-08-01 08:55:02 +00:00
Florent Castelli
d797cb6ca7 Remove all split channels related code
Bug: webrtc:13931
Change-Id: I93b8ca0ba1ec15bf260236bbc914b41fbb30aa58
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/310680
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40376}
2023-06-29 09:32:04 +00:00
Harald Alvestrand
847208e9d6 Remove transitional shim classes
Bug: webrtc:13931
Change-Id: Iaeb0b892aca4b4d64d13a025adc7564e572e0f26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307940
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40232}
2023-06-06 11:58:29 +00:00
Harald Alvestrand
4ad141e69b Add callback for send codec in audio too
It turns out there's a similar linkage as the one for video.
Tests are coming in https://webrtc-review.googlesource.com/c/src/+/307461

Bug: webrtc:13931
Change-Id: I638d1a1907116a71481aa88dce932492323ae5b7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307463
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40206}
2023-06-02 11:31:00 +00:00
Harald Alvestrand
2f55370634 Reland "Use two MediaChannels for 2 directions."
This reverts commit 18c869bc36.

Reason for revert: Added a field trial that allows landing the code without affecting performance in prod.

This CL also incorporates subsequent CLs that also had to be reverted.

Original change's description:
> Revert "Use two MediaChannels for 2 directions."
>
> This reverts commit 8981a6fac3.
>
> Reason for revert: Quality regression detected.
>
> Original change's description:
> > Use two MediaChannels for 2 directions.
> >
> > This CL separates the two directions of MediaChannel into two separate objects that do not couple with each other.
> >
> > The notable API change is that receiver local SSRC now has to be set explicitly - before, it was done implicitly when the send-side MediaChannel had a stream added to it.
> >
> > Bug: webrtc:13931
> > Change-Id: I83c2e3c8e79f89872d5adda1bc2899f7049748b3
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288400
> > Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> > Reviewed-by: Henrik Boström <hbos@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#39340}
>
> No-Try: true
> Bug: webrtc:13931
> Change-Id: I791997ad9eff75c3ac9cd2e4bbacf5bc6c3a3a79
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295663
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#39445}

Bug: webrtc:13931
Change-Id: I1318910a685188e2b846c9040e1efc04c2c894ac
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/296080
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39494}
2023-03-07 12:57:35 +00:00
Harald Alvestrand
18c869bc36 Revert "Use two MediaChannels for 2 directions."
This reverts commit 8981a6fac3.

Reason for revert: Quality regression detected.

Original change's description:
> Use two MediaChannels for 2 directions.
>
> This CL separates the two directions of MediaChannel into two separate objects that do not couple with each other.
>
> The notable API change is that receiver local SSRC now has to be set explicitly - before, it was done implicitly when the send-side MediaChannel had a stream added to it.
>
> Bug: webrtc:13931
> Change-Id: I83c2e3c8e79f89872d5adda1bc2899f7049748b3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288400
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#39340}

No-Try: true
Bug: webrtc:13931
Change-Id: I791997ad9eff75c3ac9cd2e4bbacf5bc6c3a3a79
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295663
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39445}
2023-03-01 15:57:55 +00:00
Harald Alvestrand
8981a6fac3 Use two MediaChannels for 2 directions.
This CL separates the two directions of MediaChannel into two separate objects that do not couple with each other.

The notable API change is that receiver local SSRC now has to be set explicitly - before, it was done implicitly when the send-side MediaChannel had a stream added to it.

Bug: webrtc:13931
Change-Id: I83c2e3c8e79f89872d5adda1bc2899f7049748b3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288400
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39340}
2023-02-19 10:34:42 +00:00
Harald Alvestrand
1251c6418e Split stats generation for MediaChannel into sender and receiver APIs
This is in preparation for splitting MediaChannel into sender and
receiver channels, with independent objects.

Bug: webrtc:13931
Change-Id: I8e34b0c80b4d76132394efcda658a8face3ab873
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288750
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38998}
2023-01-04 14:17:20 +00:00
Harald Alvestrand
50454ef84a Apply PIMPL pattern to MediaSender and Receiver objects
This detaches the implementation (which is still merged)
from the objects used to interface to it.

Bug: webrtc:13931
Change-Id: I872ee10e4ed9fa432bfa231f723af1d3989d79d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288080
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38906}
2022-12-16 09:23:14 +00:00
Harald Alvestrand
c0d44d9d63 Split audio and video channels into Send and Receive APIs.
The implementation here has a number of changes that force the callers
that called the "channel" functions into specific interfaces rather than
just letting C++ take care of it; this should go away once there stops
being a common implementation class for those interfaces.

Bug: webrtc:13931
Change-Id: Ic4e279528a341bc0a0e88d2e1e76c90bc43a1035
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287640
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38888}
2022-12-14 11:00:17 +00:00
Harald Alvestrand
36fafc8827 Split MediaChannel class to sender and receiver
This allows callers to differentiate on whether they need the
channel for sending or receiving purposes.

Note: This CL is incomplete, in that many places cast the pointers
to the concrete subclasses "VideoMediaChannel" and "AudioMediaChannel", which are not split into sending and receiving APIs.

The long term goal is to make two MediaChannel-like class APIs, with distinct implementations, and let the RtpSender and RtpReceiver manage those objects, rather than keeping them in the RtpTransceiver.

Bug: webrtc:13931
Change-Id: I8d56defe2287bd6552b71571cc6a5ec842927fa4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287040
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38844}
2022-12-08 10:51:52 +00:00
Artem Titov
c374d11fac Move to_queued_task.h and pending_task_safety_flag.h into public API
Bug: b/235812579
Change-Id: I9fa3dc4a65044df8b44fff4e9bfeac7233fa381c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266080
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37248}
2022-06-17 09:20:39 +00:00
Harald Alvestrand
8f42992787 Move channel creation functions into RtpTransceiver
This breaks the link from sdp_offer_answer.cc to channel.h.

Bug: webrtc:13931
Change-Id: I75608f75713bf4e69013ac5f5b17c19e53d07519
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261060
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36757}
2022-05-04 11:57:50 +00:00
Harald Alvestrand
25adc8e36b Eliminate channel.h from rtp_transmission_manager.cc
This also hides the existence of the classes VideoChannel and
VoiceChannel from anything that does not include "channel.h".

Bug: webrtc:13931
Change-Id: I080a692b6acfd5d2d0401ec20d59c3a684eddb05
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260944
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36746}
2022-05-03 14:46:36 +00:00
Harald Alvestrand
9a743179cf Eliminate need for stats to know of channel.h
Also eliminate FillBitrateInfo from the Channel object.

Bug: webrtc:13931
Change-Id: I5265b7629413a1ed04898272adf26708e2ee9b8d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260469
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36744}
2022-05-03 12:06:56 +00:00
Harald Alvestrand
c367346a75 Apply include reduction to channel.h and channel_manager.h
(tools_webrtc/iwyu/apply-iwyu -r)

This breaks the circular dependency between channel_manager.h and
media_session.h

Bug: webrtc:13805
Change-Id: I34c09e752b4110988ad8e0473de5d88605b5e6fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255961
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36233}
2022-03-17 12:13:04 +00:00
Harald Alvestrand
c24a2189d7 Update IWYU tool with a mapping file
Also apply IWYU to all .cc files in pc/, and correct BUILD file to match.
Note: Some files came out wrong when iwyu was applied. These are not included.

Bug: none
Change-Id: Ib5ea46b8fcc505414d0447cca7218ad3afc2e321
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252280
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36064}
2022-02-24 11:05:06 +00:00
Tommi
2195d54a5c Report an error if applying the demuxer criteria fails.
This is a follow-up to CL [1] to restore the check of whether updating
the demuxer criteria in the channel classes succeeded or failed.

[1] https://webrtc-review.googlesource.com/c/src/+/244700

Bug: webrtc:13536
Change-Id: If0e986bd4e4799e20be2b49f80abcc5a3e6825fa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249940
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@google.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35862}
2022-02-01 06:43:58 +00:00
Tomas Gunnarsson
5411b174c8 Add a channel factory interface.
The interface is implemented by the ChannelManager and contains methods
to create and destroy media channel objects as used by a transceiver.

This will subsequently allow us to delete the channel objects from
the transceiver class where ownership really lies rather than from
the outside - which is currently required by some tests that keep
channel objects on the stack. We'll furthermore be able to do the
destruction asynchronously without additional Invoke()s as we do now
which will remove an Invoke when making sdp changes.

With introducing the interface, the following simplifications were made:
* ChannelManager constructed on the signaling thread.
  Before, there was an Invoke in the context class, which existed
  for the purposes of calling MediaEngine::Init() (which in turn is
  only needed for the VoiceEngine). This Invoke has now been moved
  into the CM (more tbd).
* The CM now has a pointer to the signaling thread (since that's the
  construction thread). That allows us to remove the signaling thread
  parameter from the CreateFooChannel methods.
* The ssrc_generator (UniqueRandomIdGenerator) instance for SSRCs moved
  from SdpOfferAnswerHandler to the CM, as it's always used in
  combination with the CM. This simplifies the CreateFooChannel methods
  as well as a couple of other classes that have a CM dependency.
* Removed DestroyFooChannel related code from SdpOfferAnswerHandler since
  the channel type detail can be taken care of by the CM.

Bug: webrtc:11992, webrtc:13540
Change-Id: I04938a803734de8489ba31e6212d9eaecc244126
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247904
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35766}
2022-01-24 08:50:30 +00:00
Tomas Gunnarsson
4f8a58c3d2 Remove 2 Invokes to the network thread when creating a channel.
...and one when destroying a channel object.

This CL removes Init_n() and Deinit_n() from the BaseChannel class.
Channel classes now use SetRtpTransport to do initialization and
uninitialization on the network thread.

Notably if an implementation has called SetRtpTransport() with a valid
transport pointer, it is required that SetRtpTransport be called again
with a nullptr before the channel object can be deleted.

In situations where multiple channels are created, this can mean
a substantial reduction in thread hops. We still hop to the worker
in order to construct the objects - this can probably be avoided
and SetChannel() is still a synchronous operation for the transceivers.
Furthermore, teardown of channel objects also still happens
synchronously and across network/worker/signaling threads.

Bug: webrtc:11992
Change-Id: I68ca7596e181fc82996e3e290733d97381aa5e78
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246740
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35738}
2022-01-19 12:17:47 +00:00
Tomas Gunnarsson
1933d3b677 Move network thread invokes for initialization for media channels, out.
Remove Init_w and Deinit(), both of which were wrappers around Invoke()
calls from the worker thread to the network thread.

Instead, replace them with Init_n() and Deinit_n() that are currently*
required to be called by external code in order to associate/disassociate
the channels with the transport.

This CL mostly moves things around in order to prepare for upcoming
changes, but it does change channel destruction in the following way:
- When destroying channels, we don't block the worker thread anymore
  while uninitialization happens on the network thread. Previously
  both signal and worker threads were blocked during the
  uninitialization in the ChannelManager.

* In an upcoming CL, Init_n() and Deinit_n() will be called internally
  from a different method that's always called on the network thread
  when a channel is associated/disassociated with a transceiver. When
  we're there, we will have removed several invokes that currently are
  a part of constructing/destructing channel objects.

Bug: webrtc:11992
Change-Id: Ibc30447a40749ceb36d37834b0cfc5c5ea60e895
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246502
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35707}
2022-01-17 14:06:42 +00:00
Tomas Gunnarsson
cc9b7ec740 Add utility method for consistency checking in BaseChannel classes.
This is a simple check for upcoming changes for media channels to
be able to check if the state on the network thread is consistent.

Bug: webrtc:11992
Change-Id: I8ed2d091ecf3869a66970fc4733aebf209c4ef82
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246681
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35706}
2022-01-17 10:19:03 +00:00
Tomas Gunnarsson
c69453d93b Change SetLocalContent in channel classes to avoid Invoke.
With these changes, we now often have 0 invokes and at most 1 when
calling SetLocalContent on a channel. Before we had at least 1 and
typically 2.

Summary of changes.
* Updating RtpExtension::DeduplicateHeaderExtensions to return a sorted
  vector (+test) for easy detection of changes.
* Before updating the transport on the network thread, detect if
  actual changes to the demuxer criteria or changes to the rtp header
  extensions have been made.
* Consolidate both transport updates to a single call instead of two.
* Added DCHECK guards to catch regressions in number of invokes.

A possible upcoming improvement is to update the transport
asynchronously.

Bug: webrtc:13536
Change-Id: I71ef7b181635a796ffa1e3a02a0f661d28a4870c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244700
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35638}
2022-01-06 12:52:35 +00:00
Tomas Gunnarsson
ac72dda645 Code consolidation in BaseChannel and derived classes.
This is a bit of refactoring to clear the way for some more upcoming
changes and fix little oddities here and there that are basically
artifacts of many small incremental changes throughout the years.

* Remove the CryptoOptions member variable and instead only keep around
  the filter for rtp header extensions.
* Remove several member methods that only forwarded calls to
  media_channel() and effectively reduced readability.
* Consolidated quite a bit of code related to UpdateRemoteStreams_w
  and the copy/pasted code in the Video/Voice classes around calling it.
* UpdateRemoteStreams_w now returns an error when it's encountered.
  Before, an error would still be returned in those cases but all
  operations were unnecessarily performed.

Bug: none
Change-Id: I85a37b9e8f00584aa794abef11abfe89dec5d0a6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244098
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35637}
2022-01-06 12:10:45 +00:00
Tomas Gunnarsson
d908d74fac Make error param non-optional when setting local/remote content.
This is a slight refactoring while doing some other changes, so not
strictly necessary, but the error param is always supplied in practice
so it made sense to update the tests to reflect that, test that error
values are reported in (at least) some cases and remove the additional
code that checks for whether or not error information is requested.

Bug: none
Change-Id: Ia5739a18ea2beb6970eabf9d809c24dfa43466b1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244097
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35632}
2022-01-05 11:59:14 +00:00
Tomas Gunnarsson
b496c32901 Enhance thread checks in BaseChannel classes.
Improve consistency between using DCHECK checkers and compile time.
For virtual methods, we were sometimes using both and in other cases
we could be using compile time checks but were using runtime.

Added annotation for last_send_params_, last_recv_params_ in
audio/video channel classes.

Also removing redundant logging for when registration with the
transport fails. This is already being logged in the demuxer.

Bug: webrtc:12230
Change-Id: I48e156c9996dec26a990151301dabc06673541d0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244095
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35630}
2022-01-05 10:35:44 +00:00
Tomas Gunnarsson
9abd74dc1e Make RtpDemuxerCriteria's mid_ and rsid_ const.
Remove unnecessary optimization from BaseChannel,
previous_demuxer_criteria_, that I'm not seeing as providing value.

Previously it was used to avoid a thread hop if a reconfiguration
wasn't needed, but the way that was done, wasn't thread safe. So after
addressing that issue, the variable more represents increased complexity
in the code than runtime efficiency.

Bug: webrtc:11993, webrtc:12230
Change-Id: Ic8e3e1d2f57e669a168cc7b5cf5d407133976e3c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244093
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35628}
2022-01-05 08:51:44 +00:00
Tomas Gunnarsson
de6e1b4ffd Use demuxer_criteria_.mid() for content_name() in BaseChannel.
BaseChannel::content_name() is consistently used as the mid throughout
the code and the mid is stored in the demuxer criteria. Furthermore
there's a chance that the two variables might not be in sync if the
mid needs to be truncated, so it's better to use one source of truth.

Bug: webrtc:11993, webrtc:12230
Change-Id: Ia98443d8ee65fd0795651981acab27c29428ba0c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244092
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35622}
2022-01-04 14:06:43 +00:00
Tomas Gunnarsson
ddfbf6cc19 Restrict access to BaseChannel::previous_demuxer_criteria_.
Make sure previous_demuxer_criteria_ is only accessed on the network
thread and add annotation.

Bug: webrtc:11993, webrtc:12230
Change-Id: I4700fe41c947a3b1cce9649642dcd38ed62f873d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244087
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35618}
2022-01-03 22:31:42 +00:00
Tomas Gunnarsson
94f0194d5a Remove transport_name_ from Channel.
Because of this (seemingly simple) change, I had to change the return
type of transport_name from `const std::string&` to `absl::string_view`
to handle the case when there's no transport assigned.
That in turn caused an avalanche of required updates.

Bug: webrtc:12230, webrtc:11993
Change-Id: I16ec6c6a5fc2f5f7c7de572355a3c6ca924bb9d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244084
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35617}
2022-01-03 20:51:42 +00:00
Tomas Gunnarsson
f1ea4170ea Added annotation for BaseChannel members.
The thread access problems have been resolved.
Also removing unnecessary accessor for was_ever_writable_.

Bug: webrtc:12230
Change-Id: I4b4d2304f0c8ff5eea31da3734b0d492b2a8516f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244080
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35607}
2022-01-03 08:55:02 +00:00
Harald Alvestrand
0d018415d5 Revert "Remove code supporting the SDES crypto mode in SDP"
This reverts commit ee212a72f2.

Reason for revert: Don't remove until downstream issues resolved

Original change's description:
> Remove code supporting the SDES crypto mode in SDP
>
> Removes the ability to accept nonencrypted answers to encrypted offers.
> Fixes some logic around bundled sessions and requirement for
> transport parameters.
>
> Bug: webrtc:11066
> Change-Id: I56d8628d223614918a1e5260fdb8a117c8c02dbd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236344
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35298}

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

Bug: webrtc:11066
Change-Id: I0c400ceffe1b08e0be7b44abbb54c8a032128f05
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237223
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35312}
2021-11-04 14:46:27 +00:00
Harald Alvestrand
ee212a72f2 Remove code supporting the SDES crypto mode in SDP
Removes the ability to accept nonencrypted answers to encrypted offers.
Fixes some logic around bundled sessions and requirement for
transport parameters.

Bug: webrtc:11066
Change-Id: I56d8628d223614918a1e5260fdb8a117c8c02dbd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236344
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35298}
2021-11-02 12:58:50 +00:00
Artem Titov
880fa8169b Reland "Use backticks not vertical bars to denote variables in comments for /pc"
Original change's description:
> Revert "Use backticks not vertical bars to denote variables in comments for /pc"
>
> This reverts commit 37ee0f5e59.
>
> Reason for revert: Revert in order to be able to revert https://webrtc-review.googlesource.com/c/src/+/225642
>
> Original change's description:
> > Use backticks not vertical bars to denote variables in comments for /pc
> >
> > Bug: webrtc:12338
> > Change-Id: I88cf10afa5fc810b95d2a585ab2e895dcc163b63
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226953
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Artem Titov <titovartem@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#34575}
>
> TBR=hta@webrtc.org,titovartem@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> Change-Id: I5eddd3a14e1f664bf831e5c294fbc4de5f6a88af
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:12338
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227082
> Reviewed-by: Björn Terelius <terelius@webrtc.org>
> Commit-Queue: Björn Terelius <terelius@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#34577}

Bug: webrtc:12338
Change-Id: I96bd229b73613c162d11d75fa4f5934e1b4295c7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227087
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34611}
2021-07-30 22:13:59 +00:00
Björn Terelius
fd05d6f504 Revert "Use backticks not vertical bars to denote variables in comments for /pc"
This reverts commit 37ee0f5e59.

Reason for revert: Revert in order to be able to revert https://webrtc-review.googlesource.com/c/src/+/225642

Original change's description:
> Use backticks not vertical bars to denote variables in comments for /pc
>
> Bug: webrtc:12338
> Change-Id: I88cf10afa5fc810b95d2a585ab2e895dcc163b63
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226953
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#34575}

TBR=hta@webrtc.org,titovartem@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5eddd3a14e1f664bf831e5c294fbc4de5f6a88af
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:12338
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227082
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34577}
2021-07-27 22:10:24 +00:00
Artem Titov
37ee0f5e59 Use backticks not vertical bars to denote variables in comments for /pc
Bug: webrtc:12338
Change-Id: I88cf10afa5fc810b95d2a585ab2e895dcc163b63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226953
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34575}
2021-07-27 20:52:02 +00:00
Lennart Grahl
0d0ed76ac1 Fix RTP header extension encryption
Reland of commit a743303211

Previously, RTP header extensions with encryption had been filtered
if the encryption had been activated (not the other way around) which
was likely an unintended logic inversion.

In addition, it ensures that encrypted RTP header extensions are only
negotiated if RTP header extension encryption is turned on. Formerly,
which extensions had been negotiated depended on the order in which
they were inserted, regardless of whether or not header encryption was
actually enabled, leading to no extensions being sent on the wire.

Further changes:

- If RTP header encryption enabled, prefer encrypted extensions over
  non-encrypted extensions
- Add most extensions to list of extensions supported for encryption
- Discard encrypted extensions in a session description in case encryption
  is not supported for that extension
- Mark FindHeaderExtensionByUri without filter argument as deprecated

Bug: webrtc:11713
Change-Id: I52a5ade1b94bc01d1c2a35cb56023684fcaf9982
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219081
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34129}
2021-05-26 09:42:09 +00:00
Tommi
cf2aeffdc2 Remove lock from MediaChannel
Pending messages on network thread for MediaChannel, will be dropped
when the MediaChannel object is deleted (without blocking).

Remove MessageHandler inheritance from Channel since Post-ing to the
network thread has been removed from there.

Copy/pasted code for SendRtp/SendRtcp in WebRtcVideoChannel and
WebRtcVoiceMediaChannel consolidated in MediaChannel.

Bug: webrtc:11993
Change-Id: I05320eb7f86b98adba50ca5eb8b76b78f4111263
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217720
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33955}
2021-05-07 18:01:54 +00:00
Tommi
cc7a36818f Move header negotiation state to transceivers.
The channel classes have stored the negotiated headers but a more
natural place to store them is in the RtpTransceiver class where
RtpHeaderExtension state is managed as well as the implementation of
the only method that depends on the stored state,
HeaderExtensionsNegotiated().

Also adding a TODO for further improvements where we're unnecessarily
storing state in the channel classes for the purposes of the transports.

Bug: webrtc:12726
Change-Id: If36668e3e49782ddeada23ebed126ee2c4935b8c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216691
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33917}
2021-05-04 13:52:35 +00:00
Tommi
99c8a80b8e Change the first-packet-received notification in Channel.
This changes the notification to a single std::function pointer
instead of being a sigslot::signal1<> collection.

Summary:

* Remove SignalFirstPacketReceived_, the last sigslot member variable.
  (still inherits from sigslot::has_slots<>)
* BaseChannel doesn't post to the signaling thread anymore. The only
  reason that remains for the signaling_thread_ variable, is for
  thread checking.
* Remove BaseChannel's reliance on MessageHandlerAutoCleanup
  (still inherits from MessageHandler)

RtpTransceiver is the consumer of this event. That class is also the
class that sits between the PC classes and the channel object, holding
a pointer to the channel and managing calls that come in on the
signaling thread, such as SetChannel. The responsibility of delivering
the first packet received on the signaling thread is now with
RtpTransceiver:

* RtpTransceiver always requires a ChannelManager instance. Previously
  this variable was sometimes set, but it's now required.
* Updated tests in rtp_transceiver_unittest.cc to include a
  ChannelManager as well as fix them to include call expectations for
  mock sender and receivers.

Bug: webrtc:11993, webrtc:11988
Change-Id: If49d6be157cd7599fa6fe3a42cd0a363464e3a74
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215979
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33853}
2021-04-27 17:09:59 +00:00
Tommi
a63bee55f2 Remove Mutex from BaseChannel.
There's a bit of copy/pasted code in the channel code, which is
making moving network traffic consistently over to the network thread
a bit trickier than it needs to be, so I'm also updating variable
names used in Set[Local|Remote]Content_w to be more explicitly the same
and make it clear that the code is copy/pasted (and future updates can
consolidate more of it).

Also removing some code from the video/voice media channels that's
effectively dead code (vector + registration methods that aren't needed)

Bug: webrtc:12705
Change-Id: I2e14e69fbc489a64fc1e8899aaf1cfc979fe840b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215978
Reviewed-by: Sam Zackrisson <saza@google.com>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33847}
2021-04-27 12:46:10 +00:00
Tommi
1959f8fedc Make ChannelInterface::Enabled() be async.
* Changing return value from bool to void since the operation as async
  effects anyway.
* Removing the `enabled()` accessor due to potential threading issues
  and potential TOCTOU issues. It was only used in one place anyway.
* Applying thread restrictions to member variables.

Bug: none
Change-Id: I51949f5594339952d7b717cfd82f99b532e86b23
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216182
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33830}
2021-04-26 09:52:52 +00:00
Tomas Gunnarsson
eb9c3f237b Handle OnPacketSent on the network thread via MediaChannel.
* Adds a OnPacketSent callback to MediaChannel, which matches with
  MediaChannel::NetworkInterface::SendPacket.
* Moves the OnPacketSent handling to the media channel implementations
  (video/voice) and removes the PeerConnection/SdpOfferAnswerHandler
  layer from the call path.
* Call::OnSentPacket is called directly from the channels on the network
  thread. This eliminates a PostTask to the worker thread for every
  audio/video network packet.
* Remove sigslot dependency from MediaChannel (and derived).

Bug: webrtc:11993
Change-Id: I1f79a7aa60f05d47e1882f9be1c9323ea8fac5f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215403
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33777}
2021-04-19 16:59:48 +00:00
Tomas Gunnarsson
bfd9ba8802 Fix unsafe variable access in RTCStatsCollector
With this change, all production callers of BaseChannel::transport_name()
will be making the call from the right thread and we can safely delegate
the call to the transport itself. Some tests still need to be updated.
This facilitates the main goal of not needing synchronization inside
of the channel classes, being able to apply thread checks and eventually
remove thread hops from the channel classes.

A downside of this particular change is that a blocking call to the
network thread from the signaling thread inside of RTCStatsCollector
needs to be done. This is done once though and fixes a race.

Bug: webrtc:12601, webrtc:11687, webrtc:12644
Change-Id: I85f34f3341a06da9a9efd936b1d36722b10ec487
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213080
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33775}
2021-04-19 16:22:23 +00:00
Harald Alvestrand
7af57c6e48 Remove RTP data implementation
Bug: webrtc:6625
Change-Id: Ie68d7a938d8b7be95a01cca74a176104e4e44e1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215321
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33759}
2021-04-16 13:10:54 +00:00