RtpTransceiverInterface: add header_extensions_to_offer()

This change adds exposure of a new transceiver method for getting
the total set of supported extensions stored as an attribute,
and their direction. If the direction is kStopped, the extension
is not signalled in Unified Plan SDP negotiation.

Note: SDP negotiation is not modified by this change.

Changes:
- RtpHeaderExtensionCapability gets a new RtpTransceiverDirection,
  indicating either kStopped (extension available but not signalled),
  or other (extension signalled).
- RtpTransceiver gets the new method as described above. The
  default value of the attribute comes from the voice and video
  engines as before.

https://chromestatus.com/feature/5680189201711104.
go/rtp-header-extension-ip
Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/65YdUi02yZk

Bug: chromium:1051821
Change-Id: I440443b474db5b1cfe8c6b25b6c10a3ff9c21a8c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170235
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30800}
diff --git a/api/rtp_parameters.h b/api/rtp_parameters.h
index a22f764..ee51b01 100644
--- a/api/rtp_parameters.h
+++ b/api/rtp_parameters.h
@@ -19,6 +19,7 @@
 
 #include "absl/types/optional.h"
 #include "api/media_types.h"
+#include "api/rtp_transceiver_direction.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
@@ -200,7 +201,8 @@
   bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
 };
 
-// Used in RtpCapabilities; represents the capabilities/preferences of an
+// Used in RtpCapabilities and RtpTransceiverInterface's header extensions query
+// and setup methods; represents the capabilities/preferences of an
 // implementation for a header extension.
 //
 // Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was
@@ -210,7 +212,7 @@
 // Note that ORTC includes a "kind" field, but we omit this because it's
 // redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)",
 // you know you're getting audio capabilities.
-struct RtpHeaderExtensionCapability {
+struct RTC_EXPORT RtpHeaderExtensionCapability {
   // URI of this extension, as defined in RFC8285.
   std::string uri;
 
@@ -221,15 +223,23 @@
   // TODO(deadbeef): Not implemented.
   bool preferred_encrypt = false;
 
+  // The direction of the extension. The kStopped value is only used with
+  // RtpTransceiverInterface::header_extensions_offered() and
+  // SetOfferedRtpHeaderExtensions().
+  RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv;
+
   // Constructors for convenience.
   RtpHeaderExtensionCapability();
   explicit RtpHeaderExtensionCapability(const std::string& uri);
   RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
+  RtpHeaderExtensionCapability(const std::string& uri,
+                               int preferred_id,
+                               RtpTransceiverDirection direction);
   ~RtpHeaderExtensionCapability();
 
   bool operator==(const RtpHeaderExtensionCapability& o) const {
     return uri == o.uri && preferred_id == o.preferred_id &&
-           preferred_encrypt == o.preferred_encrypt;
+           preferred_encrypt == o.preferred_encrypt && direction == o.direction;
   }
   bool operator!=(const RtpHeaderExtensionCapability& o) const {
     return !(*this == o);