Use opaque int as payload_type in MediaTransportInterface

Replaces enum VideoCodecType for video frames and uint8_t for audio
frames.

Also delete method
MediaTransportVideoSinkInterface::OnKeyFrameRequested; it needs to be
added as a send-side interface instead (for a later cl).

Bug: webrtc:9719
Change-Id: I2cfdbacc267afc75c448512e2cc6de0ec9966a2d
Reviewed-on: https://webrtc-review.googlesource.com/c/113180
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25918}
diff --git a/api/DEPS b/api/DEPS
index c4be2a3..29c213b 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -107,7 +107,8 @@
 
   "media_transport_interface\.h": [
     "+rtc_base/copyonwritebuffer.h",  # As used by datachannelinterface.h
-    "+rtc_base/networkroute.h"
+    "+rtc_base/networkroute.h",
+    "+rtc_base/deprecation.h",
   ],
 
   "peerconnectionfactoryproxy\.h": [
diff --git a/api/media_transport_interface.cc b/api/media_transport_interface.cc
index d4c925e..6b00f2c 100644
--- a/api/media_transport_interface.cc
+++ b/api/media_transport_interface.cc
@@ -37,7 +37,7 @@
     int samples_per_channel,
     int sequence_number,
     FrameType frame_type,
-    uint8_t payload_type,
+    int payload_type,
     std::vector<uint8_t> encoded_data)
     : sampling_rate_hz_(sampling_rate_hz),
       starting_sample_index_(starting_sample_index),
@@ -69,6 +69,18 @@
     VideoCodecType codec_type,
     const webrtc::EncodedImage& encoded_image)
     : codec_type_(codec_type),
+      payload_type_(0),
+      encoded_image_(encoded_image),
+      frame_id_(frame_id),
+      referenced_frame_ids_(std::move(referenced_frame_ids)) {}
+
+MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
+    int64_t frame_id,
+    std::vector<int64_t> referenced_frame_ids,
+    int payload_type,
+    const webrtc::EncodedImage& encoded_image)
+    : codec_type_(kVideoCodecGeneric),
+      payload_type_(payload_type),
       encoded_image_(encoded_image),
       frame_id_(frame_id),
       referenced_frame_ids_(std::move(referenced_frame_ids)) {}
@@ -76,6 +88,7 @@
 MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
     const MediaTransportEncodedVideoFrame& o) {
   codec_type_ = o.codec_type_;
+  payload_type_ = o.payload_type_;
   encoded_image_ = o.encoded_image_;
   encoded_data_ = o.encoded_data_;
   frame_id_ = o.frame_id_;
@@ -90,6 +103,7 @@
 MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
     MediaTransportEncodedVideoFrame&& o) {
   codec_type_ = o.codec_type_;
+  payload_type_ = o.payload_type_;
   encoded_image_ = o.encoded_image_;
   encoded_data_ = std::move(o.encoded_data_);
   frame_id_ = o.frame_id_;
diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h
index feebd88..6b461cf 100644
--- a/api/media_transport_interface.h
+++ b/api/media_transport_interface.h
@@ -28,6 +28,7 @@
 #include "api/rtcerror.h"
 #include "api/video/encoded_image.h"
 #include "rtc_base/copyonwritebuffer.h"
+#include "rtc_base/deprecation.h"
 #include "rtc_base/networkroute.h"
 
 namespace rtc {
@@ -97,7 +98,7 @@
       // Opaque payload type. In RTP codepath payload type is stored in RTP
       // header. In other implementations it should be simply passed through the
       // wire -- it's needed for decoder.
-      uint8_t payload_type,
+      int payload_type,
 
       // Vector with opaque encoded data.
       std::vector<uint8_t> encoded_data);
@@ -116,7 +117,7 @@
   int samples_per_channel() const { return samples_per_channel_; }
   int sequence_number() const { return sequence_number_; }
 
-  uint8_t payload_type() const { return payload_type_; }
+  int payload_type() const { return payload_type_; }
   FrameType frame_type() const { return frame_type_; }
 
   rtc::ArrayView<const uint8_t> encoded_data() const { return encoded_data_; }
@@ -132,9 +133,7 @@
 
   FrameType frame_type_;
 
-  // TODO(sukhanov): Consider enumerating allowed encodings and store enum
-  // instead of uint payload_type.
-  uint8_t payload_type_;
+  int payload_type_;
 
   std::vector<uint8_t> encoded_data_;
 };
@@ -163,9 +162,15 @@
 // Represents encoded video frame, along with the codec information.
 class MediaTransportEncodedVideoFrame final {
  public:
+  // TODO(bugs.webrtc.org/9719): Switch to payload_type
+  RTC_DEPRECATED MediaTransportEncodedVideoFrame(
+      int64_t frame_id,
+      std::vector<int64_t> referenced_frame_ids,
+      VideoCodecType codec_type,
+      const webrtc::EncodedImage& encoded_image);
   MediaTransportEncodedVideoFrame(int64_t frame_id,
                                   std::vector<int64_t> referenced_frame_ids,
-                                  VideoCodecType codec_type,
+                                  int payload_type,
                                   const webrtc::EncodedImage& encoded_image);
   ~MediaTransportEncodedVideoFrame();
   MediaTransportEncodedVideoFrame(const MediaTransportEncodedVideoFrame&);
@@ -175,7 +180,9 @@
       MediaTransportEncodedVideoFrame&& other);
   MediaTransportEncodedVideoFrame(MediaTransportEncodedVideoFrame&&);
 
-  VideoCodecType codec_type() const { return codec_type_; }
+  // TODO(bugs.webrtc.org/9719): Switch to payload_type
+  RTC_DEPRECATED VideoCodecType codec_type() const { return codec_type_; }
+  int payload_type() const { return payload_type_; }
   const webrtc::EncodedImage& encoded_image() const { return encoded_image_; }
 
   int64_t frame_id() const { return frame_id_; }
@@ -191,6 +198,7 @@
   MediaTransportEncodedVideoFrame();
 
   VideoCodecType codec_type_;
+  int payload_type_;
 
   // The buffer is not owned by the encoded image. On the sender it means that
   // it will need to make a copy using the Retain() method, if it wants to
@@ -227,8 +235,8 @@
   virtual void OnData(uint64_t channel_id,
                       MediaTransportEncodedVideoFrame frame) = 0;
 
-  // Called when the request for keyframe is received.
-  virtual void OnKeyFrameRequested(uint64_t channel_id) = 0;
+  // TODO(bugs.webrtc.org/9719): Belongs on send side, not receive side.
+  RTC_DEPRECATED virtual void OnKeyFrameRequested(uint64_t channel_id) {}
 };
 
 // State of the media transport.  Media transport begins in the pending state.
diff --git a/api/test/loopback_media_transport_unittest.cc b/api/test/loopback_media_transport_unittest.cc
index ef4bbf4..a1b13ec 100644
--- a/api/test/loopback_media_transport_unittest.cc
+++ b/api/test/loopback_media_transport_unittest.cc
@@ -50,7 +50,7 @@
   static constexpr int kSamplingRateHz = 48000;
   static constexpr int kStartingSampleIndex = 0;
   static constexpr int kSamplesPerChannel = 480;
-  static constexpr uint8_t kPayloadType = 17;
+  static constexpr int kPayloadType = 17;
 
   return MediaTransportEncodedAudioFrame(
       kSamplingRateHz, kStartingSampleIndex, kSamplesPerChannel,
@@ -61,8 +61,9 @@
 MediaTransportEncodedVideoFrame CreateVideoFrame(
     int frame_id,
     const webrtc::EncodedImage& encoded_image) {
+  static constexpr int kPayloadType = 18;
   return MediaTransportEncodedVideoFrame(frame_id, /*referenced_frame_ids=*/{},
-                                         kVideoCodecVP8, encoded_image);
+                                         kPayloadType, encoded_image);
 }
 
 }  // namespace