Add DTLSTransport info into sender/receiver state.

This is in preparation for letting Chrome extract DTLSTransport
information after SLD/SRD instead of doing it on-demand.

Bug: chromium:907849
Change-Id: Iac6b174c98d3d14136e1fd25bce4a9292f6c8b41
Reviewed-on: https://webrtc-review.googlesource.com/c/116984
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26289}
diff --git a/api/dtls_transport_interface.h b/api/dtls_transport_interface.h
index abe7378..1faf3f5 100644
--- a/api/dtls_transport_interface.h
+++ b/api/dtls_transport_interface.h
@@ -23,7 +23,9 @@
   kConnecting,  // In the process of negotiating a secure connection.
   kConnected,   // Completed negotiation and verified fingerprints.
   kClosed,      // Intentionally closed.
-  kFailed  // Failure due to an error or failing to verify a remote fingerprint.
+  kFailed,      // Failure due to an error or failing to verify a remote
+                // fingerprint.
+  kNumValues
 };
 
 // This object gives snapshot information about the changeable state of a
diff --git a/api/rtp_receiver_interface.cc b/api/rtp_receiver_interface.cc
index d8bb3d3..52f72df 100644
--- a/api/rtp_receiver_interface.cc
+++ b/api/rtp_receiver_interface.cc
@@ -53,4 +53,9 @@
   return nullptr;
 }
 
+rtc::scoped_refptr<DtlsTransportInterface>
+RtpReceiverInterface::dtls_transport() const {
+  return nullptr;
+}
+
 }  // namespace webrtc
diff --git a/api/rtp_receiver_interface.h b/api/rtp_receiver_interface.h
index 12c9d95..e7fa0bf 100644
--- a/api/rtp_receiver_interface.h
+++ b/api/rtp_receiver_interface.h
@@ -18,6 +18,7 @@
 #include <vector>
 
 #include "api/crypto/frame_decryptor_interface.h"
+#include "api/dtls_transport_interface.h"
 #include "api/media_stream_interface.h"
 #include "api/media_types.h"
 #include "api/proxy.h"
@@ -92,6 +93,13 @@
 class RtpReceiverInterface : public rtc::RefCountInterface {
  public:
   virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
+
+  // The dtlsTransport attribute exposes the DTLS transport on which the
+  // media is received. It may be null.
+  // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-transport
+  // TODO(https://bugs.webrtc.org/907849) remove default implementation
+  virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const;
+
   // The list of streams that |track| is associated with. This is the same as
   // the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
   // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
@@ -146,6 +154,7 @@
 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver)
 PROXY_SIGNALING_THREAD_DESTRUCTOR()
 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
+PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
 PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
 PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<MediaStreamInterface>>,
                    streams)
diff --git a/api/rtp_sender_interface.cc b/api/rtp_sender_interface.cc
index 68747ea..d23fd18 100644
--- a/api/rtp_sender_interface.cc
+++ b/api/rtp_sender_interface.cc
@@ -25,4 +25,9 @@
   return {};
 }
 
+rtc::scoped_refptr<DtlsTransportInterface> RtpSenderInterface::dtls_transport()
+    const {
+  return nullptr;
+}
+
 }  // namespace webrtc
diff --git a/api/rtp_sender_interface.h b/api/rtp_sender_interface.h
index c1dc716..6397938 100644
--- a/api/rtp_sender_interface.h
+++ b/api/rtp_sender_interface.h
@@ -18,6 +18,7 @@
 #include <vector>
 
 #include "api/crypto/frame_encryptor_interface.h"
+#include "api/dtls_transport_interface.h"
 #include "api/dtmf_sender_interface.h"
 #include "api/media_stream_interface.h"
 #include "api/media_types.h"
@@ -36,6 +37,12 @@
   virtual bool SetTrack(MediaStreamTrackInterface* track) = 0;
   virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
 
+  // The dtlsTransport attribute exposes the DTLS transport on which the
+  // media is sent. It may be null.
+  // https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-transport
+  // TODO(https://bugs.webrtc.org/907849) remove default implementation
+  virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const;
+
   // Returns primary SSRC used by this sender for sending media.
   // Returns 0 if not yet determined.
   // TODO(deadbeef): Change to absl::optional.
@@ -91,6 +98,7 @@
 PROXY_SIGNALING_THREAD_DESTRUCTOR()
 PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*)
 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
+PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
 PROXY_CONSTMETHOD0(uint32_t, ssrc)
 PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
 PROXY_CONSTMETHOD0(std::string, id)