Add MediaTransportSettings struct for configuring media transport.

The struct is more generic and easier to extend than parameters to the
Factory. In addition, the list of parameters to the factory might grow,
making invocations awkward if not difficult to read.

Bug: webrtc:9719
Change-Id: I4b98e26f1f4c0d5ea840f9c28e7ed7abee072b74
Reviewed-on: https://webrtc-review.googlesource.com/c/107984
Commit-Queue: Peter Slatala <psla@webrtc.org>
Reviewed-by: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25413}
diff --git a/api/media_transport_interface.cc b/api/media_transport_interface.cc
index e4fbede..40dde2a 100644
--- a/api/media_transport_interface.cc
+++ b/api/media_transport_interface.cc
@@ -22,6 +22,9 @@
 
 namespace webrtc {
 
+MediaTransportSettings::MediaTransportSettings() = default;
+MediaTransportSettings::~MediaTransportSettings() = default;
+
 MediaTransportEncodedAudioFrame::~MediaTransportEncodedAudioFrame() {}
 
 MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
@@ -76,4 +79,20 @@
 MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
     MediaTransportEncodedVideoFrame&&) = default;
 
+RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
+MediaTransportFactory::CreateMediaTransport(
+    rtc::PacketTransportInternal* packet_transport,
+    rtc::Thread* network_thread,
+    bool is_caller) {
+  return std::unique_ptr<MediaTransportInterface>(nullptr);
+}
+
+RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
+MediaTransportFactory::CreateMediaTransport(
+    rtc::PacketTransportInternal* packet_transport,
+    rtc::Thread* network_thread,
+    const MediaTransportSettings settings) {
+  return std::unique_ptr<MediaTransportInterface>(nullptr);
+}
+
 }  // namespace webrtc
diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h
index fc0922c..b388ac9 100644
--- a/api/media_transport_interface.h
+++ b/api/media_transport_interface.h
@@ -18,9 +18,11 @@
 #define API_MEDIA_TRANSPORT_INTERFACE_H_
 
 #include <memory>
+#include <string>
 #include <utility>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/array_view.h"
 #include "api/rtcerror.h"
 #include "api/video/encoded_image.h"
@@ -33,6 +35,19 @@
 
 namespace webrtc {
 
+// A collection of settings for creation of media transport.
+struct MediaTransportSettings final {
+  MediaTransportSettings();
+  ~MediaTransportSettings();
+
+  // Group calls are not currently supported, in 1:1 call one side must set
+  // is_caller = true and another is_caller = false.
+  bool is_caller;
+
+  // Must be set if a pre-shared key is used for the call.
+  absl::optional<std::string> pre_shared_key;
+};
+
 // Represents encoded audio frame in any encoding (type of encoding is opaque).
 // To avoid copying of encoded data use move semantics when passing by value.
 class MediaTransportEncodedAudioFrame final {
@@ -244,10 +259,21 @@
   // - Does not take ownership of packet_transport or network_thread.
   // - Does not support group calls, in 1:1 call one side must set
   //   is_caller = true and another is_caller = false.
+  // TODO(bugs.webrtc.org/9938) This constructor will be removed and replaced
+  // with the one below.
   virtual RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
   CreateMediaTransport(rtc::PacketTransportInternal* packet_transport,
                        rtc::Thread* network_thread,
-                       bool is_caller) = 0;
+                       bool is_caller);
+
+  // Creates media transport.
+  // - Does not take ownership of packet_transport or network_thread.
+  // TODO(bugs.webrtc.org/9938): remove default implementation once all children
+  // override it.
+  virtual RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
+  CreateMediaTransport(rtc::PacketTransportInternal* packet_transport,
+                       rtc::Thread* network_thread,
+                       const MediaTransportSettings settings);
 };
 
 }  // namespace webrtc