pc: Add asynchronous RtpSender::SetParameters() call

As the synchronous version only posts a task to recreate the encoder
later, it is not possible to catch errors and state changes that
could appear then.
The asynchronous version of SetParameters() aims to solve this by
providing a callback to wait for the completion of the encoder
reconfiguration, allowing any error to be propagate and subsequent
getParameters() call to have up to date information.

Bug: webrtc:11607
Change-Id: I5548e75aa14a97f8d9c0c94df1e72e9cd40887b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278420
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38627}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 3f44bc9..5874b95 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -193,6 +193,40 @@
   absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
 }
 
+rtc_library("dtmf_sender_interface") {
+  visibility = [ "*" ]
+
+  sources = [ "dtmf_sender_interface.h" ]
+  deps = [
+    ":media_stream_interface",
+    "../rtc_base:refcount",
+  ]
+}
+
+rtc_library("rtp_sender_interface") {
+  visibility = [ "*" ]
+
+  sources = [
+    "rtp_sender_interface.cc",
+    "rtp_sender_interface.h",
+  ]
+  deps = [
+    ":dtls_transport_interface",
+    ":dtmf_sender_interface",
+    ":frame_transformer_interface",
+    ":media_stream_interface",
+    ":rtc_error",
+    ":rtp_parameters",
+    ":scoped_refptr",
+    "../rtc_base:checks",
+    "../rtc_base:refcount",
+    "../rtc_base/system:rtc_export",
+    "crypto:frame_encryptor_interface",
+    "video_codecs:video_codecs_api",
+  ]
+  absl_deps = [ "//third_party/abseil-cpp/absl/functional:any_invocable" ]
+}
+
 rtc_library("libjingle_peerconnection_api") {
   visibility = [ "*" ]
   cflags = []
@@ -200,7 +234,6 @@
     "crypto_params.h",
     "data_channel_interface.cc",
     "data_channel_interface.h",
-    "dtmf_sender_interface.h",
     "jsep.cc",
     "jsep.h",
     "jsep_ice_candidate.cc",
@@ -212,7 +245,6 @@
     "peer_connection_interface.h",
     "rtp_receiver_interface.cc",
     "rtp_receiver_interface.h",
-    "rtp_sender_interface.h",
     "rtp_transceiver_interface.cc",
     "rtp_transceiver_interface.h",
     "sctp_transport_interface.cc",
@@ -221,6 +253,15 @@
     "set_remote_description_observer_interface.h",
     "uma_metrics.h",
     "video_track_source_proxy_factory.h",
+
+    # Remove when downstream has been updated
+    "dtmf_sender_interface.h",
+    "rtp_sender_interface.h",
+  ]
+  public_deps = [  # no-presubmit-check TODO(webrtc:8603)
+    # Remove when downstream has been updated
+    ":dtmf_sender_interface",
+    ":rtp_sender_interface",
   ]
   deps = [
     ":array_view",
@@ -244,6 +285,7 @@
     ":rtc_stats_api",
     ":rtp_packet_info",
     ":rtp_parameters",
+    ":rtp_sender_interface",
     ":rtp_transceiver_direction",
     ":scoped_refptr",
     ":sequence_checker",
@@ -294,6 +336,7 @@
   absl_deps = [
     "//third_party/abseil-cpp/absl/algorithm:container",
     "//third_party/abseil-cpp/absl/base:core_headers",
+    "//third_party/abseil-cpp/absl/functional:any_invocable",
     "//third_party/abseil-cpp/absl/memory",
     "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
@@ -1014,6 +1057,7 @@
     sources = [ "test/mock_dtmf_sender.h" ]
 
     deps = [
+      ":dtmf_sender_interface",
       ":libjingle_peerconnection_api",
       "../test:test_support",
     ]
@@ -1175,6 +1219,7 @@
 
     deps = [
       ":libjingle_peerconnection_api",
+      ":rtp_sender_interface",
       "../test:test_support",
     ]
   }