Move video-related MediaTransport interfaces to their own file and target

Bug: webrtc:9719
Change-Id: I2cf4a8520ce5c07c76ab0310cf7ab0ab285d9e0c
Reviewed-on: https://webrtc-review.googlesource.com/c/122504
Reviewed-by: Peter Slatala <psla@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26702}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index aacc1e4..ed3c708 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -133,6 +133,7 @@
     "transport:bitrate_settings",
     "transport:network_control",
     "transport/media:audio_interfaces",
+    "transport/media:video_interfaces",
     "units:data_rate",
     "video:encoded_image",
     "video:video_frame",
diff --git a/api/media_transport_interface.cc b/api/media_transport_interface.cc
index 4b68b4c..de04e19 100644
--- a/api/media_transport_interface.cc
+++ b/api/media_transport_interface.cc
@@ -30,38 +30,6 @@
 MediaTransportSettings::~MediaTransportSettings() = default;
 
 
-MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame() = default;
-
-MediaTransportEncodedVideoFrame::~MediaTransportEncodedVideoFrame() = default;
-
-MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
-    int64_t frame_id,
-    std::vector<int64_t> referenced_frame_ids,
-    int payload_type,
-    const webrtc::EncodedImage& encoded_image)
-    : payload_type_(payload_type),
-      encoded_image_(encoded_image),
-      frame_id_(frame_id),
-      referenced_frame_ids_(std::move(referenced_frame_ids)) {}
-
-MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
-    const MediaTransportEncodedVideoFrame&) = default;
-
-MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
-    MediaTransportEncodedVideoFrame&&) = default;
-
-MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
-    const MediaTransportEncodedVideoFrame& o)
-    : MediaTransportEncodedVideoFrame() {
-  *this = o;
-}
-
-MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
-    MediaTransportEncodedVideoFrame&& o)
-    : MediaTransportEncodedVideoFrame() {
-  *this = std::move(o);
-}
-
 SendDataParams::SendDataParams() = default;
 SendDataParams::SendDataParams(const SendDataParams&) = default;
 
diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h
index c289d99..2f5431f 100644
--- a/api/media_transport_interface.h
+++ b/api/media_transport_interface.h
@@ -21,14 +21,13 @@
 #include <memory>
 #include <string>
 #include <utility>
-#include <vector>
 
 #include "absl/types/optional.h"
 #include "api/array_view.h"
 #include "api/rtc_error.h"
 #include "api/transport/media/audio_transport.h"
+#include "api/transport/media/video_transport.h"
 #include "api/units/data_rate.h"
-#include "api/video/encoded_image.h"
 #include "rtc_base/copy_on_write_buffer.h"
 #include "rtc_base/network_route.h"
 
@@ -88,80 +87,6 @@
       const rtc::NetworkRoute& new_network_route) = 0;
 };
 
-// Represents encoded video frame, along with the codec information.
-class MediaTransportEncodedVideoFrame final {
- public:
-  MediaTransportEncodedVideoFrame(int64_t frame_id,
-                                  std::vector<int64_t> referenced_frame_ids,
-                                  int payload_type,
-                                  const webrtc::EncodedImage& encoded_image);
-  ~MediaTransportEncodedVideoFrame();
-  MediaTransportEncodedVideoFrame(const MediaTransportEncodedVideoFrame&);
-  MediaTransportEncodedVideoFrame& operator=(
-      const MediaTransportEncodedVideoFrame& other);
-  MediaTransportEncodedVideoFrame& operator=(
-      MediaTransportEncodedVideoFrame&& other);
-  MediaTransportEncodedVideoFrame(MediaTransportEncodedVideoFrame&&);
-
-  int payload_type() const { return payload_type_; }
-  const webrtc::EncodedImage& encoded_image() const { return encoded_image_; }
-
-  int64_t frame_id() const { return frame_id_; }
-  const std::vector<int64_t>& referenced_frame_ids() const {
-    return referenced_frame_ids_;
-  }
-
-  // Hack to workaround lack of ownership of the EncodedImage buffer. If we
-  // don't already own the underlying data, make a copy.
-  void Retain() { encoded_image_.Retain(); }
-
- private:
-  MediaTransportEncodedVideoFrame();
-
-  int payload_type_;
-
-  // The buffer is not always 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
-  // deliver it asynchronously.
-  webrtc::EncodedImage encoded_image_;
-
-  // Frame id uniquely identifies a frame in a stream. It needs to be unique in
-  // a given time window (i.e. technically unique identifier for the lifetime of
-  // the connection is not needed, but you need to guarantee that remote side
-  // got rid of the previous frame_id if you plan to reuse it).
-  //
-  // It is required by a remote jitter buffer, and is the same as
-  // EncodedFrame::id::picture_id.
-  //
-  // This data must be opaque to the media transport, and media transport should
-  // itself not make any assumptions about what it is and its uniqueness.
-  int64_t frame_id_;
-
-  // A single frame might depend on other frames. This is set of identifiers on
-  // which the current frame depends.
-  std::vector<int64_t> referenced_frame_ids_;
-};
-
-// Interface for receiving encoded video frames from MediaTransportInterface
-// implementations.
-class MediaTransportVideoSinkInterface {
- public:
-  virtual ~MediaTransportVideoSinkInterface() = default;
-
-  // Called when new encoded video frame is received.
-  virtual void OnData(uint64_t channel_id,
-                      MediaTransportEncodedVideoFrame frame) = 0;
-};
-
-// Interface for video sender to be notified of received key frame request.
-class MediaTransportKeyFrameRequestCallback {
- public:
-  virtual ~MediaTransportKeyFrameRequestCallback() = default;
-
-  // Called when a key frame request is received on the transport.
-  virtual void OnKeyFrameRequested(uint64_t channel_id) = 0;
-};
-
 // State of the media transport.  Media transport begins in the pending state.
 // It transitions to writable when it is ready to send media.  It may transition
 // back to pending if the connection is blocked.  It may transition to closed at
diff --git a/api/transport/media/BUILD.gn b/api/transport/media/BUILD.gn
index aca8803..f338021 100644
--- a/api/transport/media/BUILD.gn
+++ b/api/transport/media/BUILD.gn
@@ -18,3 +18,14 @@
     "../..:array_view",
   ]
 }
+
+rtc_source_set("video_interfaces") {
+  visibility = [ "*" ]
+  sources = [
+    "video_transport.cc",
+    "video_transport.h",
+  ]
+  deps = [
+    "../../video:encoded_image",
+  ]
+}
diff --git a/api/transport/media/video_transport.cc b/api/transport/media/video_transport.cc
new file mode 100644
index 0000000..1831991
--- /dev/null
+++ b/api/transport/media/video_transport.cc
@@ -0,0 +1,56 @@
+/*
+ *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+// This is EXPERIMENTAL interface for media transport.
+//
+// The goal is to refactor WebRTC code so that audio and video frames
+// are sent / received through the media transport interface. This will
+// enable different media transport implementations, including QUIC-based
+// media transport.
+
+#include <utility>
+
+#include "api/transport/media/video_transport.h"
+
+namespace webrtc {
+
+MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame() = default;
+
+MediaTransportEncodedVideoFrame::~MediaTransportEncodedVideoFrame() = default;
+
+MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
+    int64_t frame_id,
+    std::vector<int64_t> referenced_frame_ids,
+    int payload_type,
+    const webrtc::EncodedImage& encoded_image)
+    : payload_type_(payload_type),
+      encoded_image_(encoded_image),
+      frame_id_(frame_id),
+      referenced_frame_ids_(std::move(referenced_frame_ids)) {}
+
+MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
+    const MediaTransportEncodedVideoFrame&) = default;
+
+MediaTransportEncodedVideoFrame& MediaTransportEncodedVideoFrame::operator=(
+    MediaTransportEncodedVideoFrame&&) = default;
+
+MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
+    const MediaTransportEncodedVideoFrame& o)
+    : MediaTransportEncodedVideoFrame() {
+  *this = o;
+}
+
+MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame(
+    MediaTransportEncodedVideoFrame&& o)
+    : MediaTransportEncodedVideoFrame() {
+  *this = std::move(o);
+}
+
+}  // namespace webrtc
diff --git a/api/transport/media/video_transport.h b/api/transport/media/video_transport.h
new file mode 100644
index 0000000..affd2e0
--- /dev/null
+++ b/api/transport/media/video_transport.h
@@ -0,0 +1,101 @@
+/* Copyright 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+// This is EXPERIMENTAL interface for media transport.
+//
+// The goal is to refactor WebRTC code so that audio and video frames
+// are sent / received through the media transport interface. This will
+// enable different media transport implementations, including QUIC-based
+// media transport.
+
+#ifndef API_TRANSPORT_MEDIA_VIDEO_TRANSPORT_H_
+#define API_TRANSPORT_MEDIA_VIDEO_TRANSPORT_H_
+
+#include <vector>
+
+#include "api/video/encoded_image.h"
+
+namespace webrtc {
+
+// Represents encoded video frame, along with the codec information.
+class MediaTransportEncodedVideoFrame final {
+ public:
+  MediaTransportEncodedVideoFrame(int64_t frame_id,
+                                  std::vector<int64_t> referenced_frame_ids,
+                                  int payload_type,
+                                  const webrtc::EncodedImage& encoded_image);
+  ~MediaTransportEncodedVideoFrame();
+  MediaTransportEncodedVideoFrame(const MediaTransportEncodedVideoFrame&);
+  MediaTransportEncodedVideoFrame& operator=(
+      const MediaTransportEncodedVideoFrame& other);
+  MediaTransportEncodedVideoFrame& operator=(
+      MediaTransportEncodedVideoFrame&& other);
+  MediaTransportEncodedVideoFrame(MediaTransportEncodedVideoFrame&&);
+
+  int payload_type() const { return payload_type_; }
+  const webrtc::EncodedImage& encoded_image() const { return encoded_image_; }
+
+  int64_t frame_id() const { return frame_id_; }
+  const std::vector<int64_t>& referenced_frame_ids() const {
+    return referenced_frame_ids_;
+  }
+
+  // Hack to workaround lack of ownership of the EncodedImage buffer. If we
+  // don't already own the underlying data, make a copy.
+  void Retain() { encoded_image_.Retain(); }
+
+ private:
+  MediaTransportEncodedVideoFrame();
+
+  int payload_type_;
+
+  // The buffer is not always 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
+  // deliver it asynchronously.
+  webrtc::EncodedImage encoded_image_;
+
+  // Frame id uniquely identifies a frame in a stream. It needs to be unique in
+  // a given time window (i.e. technically unique identifier for the lifetime of
+  // the connection is not needed, but you need to guarantee that remote side
+  // got rid of the previous frame_id if you plan to reuse it).
+  //
+  // It is required by a remote jitter buffer, and is the same as
+  // EncodedFrame::id::picture_id.
+  //
+  // This data must be opaque to the media transport, and media transport should
+  // itself not make any assumptions about what it is and its uniqueness.
+  int64_t frame_id_;
+
+  // A single frame might depend on other frames. This is set of identifiers on
+  // which the current frame depends.
+  std::vector<int64_t> referenced_frame_ids_;
+};
+
+// Interface for receiving encoded video frames from MediaTransportInterface
+// implementations.
+class MediaTransportVideoSinkInterface {
+ public:
+  virtual ~MediaTransportVideoSinkInterface() = default;
+
+  // Called when new encoded video frame is received.
+  virtual void OnData(uint64_t channel_id,
+                      MediaTransportEncodedVideoFrame frame) = 0;
+};
+
+// Interface for video sender to be notified of received key frame request.
+class MediaTransportKeyFrameRequestCallback {
+ public:
+  virtual ~MediaTransportKeyFrameRequestCallback() = default;
+
+  // Called when a key frame request is received on the transport.
+  virtual void OnKeyFrameRequested(uint64_t channel_id) = 0;
+};
+
+}  // namespace webrtc
+#endif  // API_TRANSPORT_MEDIA_VIDEO_TRANSPORT_H_