Move audio-related MediaTransport interfaces to their own file and target
Bug: webrtc:9719
Change-Id: I8bef979e4073d51be7cb93d38ee0e2ae22baef0e
Reviewed-on: https://webrtc-review.googlesource.com/c/121942
Reviewed-by: Peter Slatala <psla@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26594}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 52da137..a3e659c 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -134,6 +134,7 @@
"audio_codecs:audio_codecs_api",
"transport:bitrate_settings",
"transport:network_control",
+ "transport/media:audio_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 63d7ea1..4b68b4c 100644
--- a/api/media_transport_interface.cc
+++ b/api/media_transport_interface.cc
@@ -29,35 +29,6 @@
const MediaTransportSettings&) = default;
MediaTransportSettings::~MediaTransportSettings() = default;
-MediaTransportEncodedAudioFrame::~MediaTransportEncodedAudioFrame() {}
-
-MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
- int sampling_rate_hz,
- int starting_sample_index,
- int samples_per_channel,
- int sequence_number,
- FrameType frame_type,
- int payload_type,
- std::vector<uint8_t> encoded_data)
- : sampling_rate_hz_(sampling_rate_hz),
- starting_sample_index_(starting_sample_index),
- samples_per_channel_(samples_per_channel),
- sequence_number_(sequence_number),
- frame_type_(frame_type),
- payload_type_(payload_type),
- encoded_data_(std::move(encoded_data)) {}
-
-MediaTransportEncodedAudioFrame& MediaTransportEncodedAudioFrame::operator=(
- const MediaTransportEncodedAudioFrame&) = default;
-
-MediaTransportEncodedAudioFrame& MediaTransportEncodedAudioFrame::operator=(
- MediaTransportEncodedAudioFrame&&) = default;
-
-MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
- const MediaTransportEncodedAudioFrame&) = default;
-
-MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
- MediaTransportEncodedAudioFrame&&) = default;
MediaTransportEncodedVideoFrame::MediaTransportEncodedVideoFrame() = default;
diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h
index 5cd2923..c289d99 100644
--- a/api/media_transport_interface.h
+++ b/api/media_transport_interface.h
@@ -26,6 +26,7 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/rtc_error.h"
+#include "api/transport/media/audio_transport.h"
#include "api/units/data_rate.h"
#include "api/video/encoded_image.h"
#include "rtc_base/copy_on_write_buffer.h"
@@ -77,89 +78,6 @@
RtcEventLog* event_log = nullptr;
};
-// 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 {
- public:
- enum class FrameType {
- // Normal audio frame (equivalent to webrtc::kAudioFrameSpeech).
- kSpeech,
-
- // DTX frame (equivalent to webrtc::kAudioFrameCN).
- // DTX frame (equivalent to webrtc::kAudioFrameCN).
- kDiscontinuousTransmission,
- // TODO(nisse): Mis-spelled version, update users, then delete.
- kDiscountinuousTransmission = kDiscontinuousTransmission,
- };
-
- MediaTransportEncodedAudioFrame(
- // Audio sampling rate, for example 48000.
- int sampling_rate_hz,
-
- // Starting sample index of the frame, i.e. how many audio samples were
- // before this frame since the beginning of the call or beginning of time
- // in one channel (the starting point should not matter for NetEq). In
- // WebRTC it is used as a timestamp of the frame.
- // TODO(sukhanov): Starting_sample_index is currently adjusted on the
- // receiver side in RTP path. Non-RTP implementations should preserve it.
- // For NetEq initial offset should not matter so we should consider fixing
- // RTP path.
- int starting_sample_index,
-
- // Number of audio samples in audio frame in 1 channel.
- int samples_per_channel,
-
- // Sequence number of the frame in the order sent, it is currently
- // required by NetEq, but we can fix NetEq, because starting_sample_index
- // should be enough.
- int sequence_number,
-
- // If audio frame is a speech or discontinued transmission.
- FrameType frame_type,
-
- // 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.
- int payload_type,
-
- // Vector with opaque encoded data.
- std::vector<uint8_t> encoded_data);
-
- ~MediaTransportEncodedAudioFrame();
- MediaTransportEncodedAudioFrame(const MediaTransportEncodedAudioFrame&);
- MediaTransportEncodedAudioFrame& operator=(
- const MediaTransportEncodedAudioFrame& other);
- MediaTransportEncodedAudioFrame& operator=(
- MediaTransportEncodedAudioFrame&& other);
- MediaTransportEncodedAudioFrame(MediaTransportEncodedAudioFrame&&);
-
- // Getters.
- int sampling_rate_hz() const { return sampling_rate_hz_; }
- int starting_sample_index() const { return starting_sample_index_; }
- int samples_per_channel() const { return samples_per_channel_; }
- int sequence_number() const { return sequence_number_; }
-
- 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_; }
-
- private:
- int sampling_rate_hz_;
- int starting_sample_index_;
- int samples_per_channel_;
-
- // TODO(sukhanov): Refactor NetEq so we don't need sequence number.
- // Having sample_index and samples_per_channel should be enough.
- int sequence_number_;
-
- FrameType frame_type_;
-
- int payload_type_;
-
- std::vector<uint8_t> encoded_data_;
-};
-
// Callback to notify about network route changes.
class MediaTransportNetworkChangeCallback {
public:
@@ -170,17 +88,6 @@
const rtc::NetworkRoute& new_network_route) = 0;
};
-// Interface for receiving encoded audio frames from MediaTransportInterface
-// implementations.
-class MediaTransportAudioSinkInterface {
- public:
- virtual ~MediaTransportAudioSinkInterface() = default;
-
- // Called when new encoded audio frame is received.
- virtual void OnData(uint64_t channel_id,
- MediaTransportEncodedAudioFrame frame) = 0;
-};
-
// Represents encoded video frame, along with the codec information.
class MediaTransportEncodedVideoFrame final {
public:
diff --git a/api/transport/media/BUILD.gn b/api/transport/media/BUILD.gn
new file mode 100644
index 0000000..aca8803
--- /dev/null
+++ b/api/transport/media/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright (c) 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.
+
+import("../../../webrtc.gni")
+
+rtc_source_set("audio_interfaces") {
+ visibility = [ "*" ]
+ sources = [
+ "audio_transport.cc",
+ "audio_transport.h",
+ ]
+ deps = [
+ "../..:array_view",
+ ]
+}
diff --git a/api/transport/media/OWNERS b/api/transport/media/OWNERS
new file mode 100644
index 0000000..b353f12
--- /dev/null
+++ b/api/transport/media/OWNERS
@@ -0,0 +1,3 @@
+sukhanov@webrtc.org
+psla@webrtc.org
+mellem@webrtc.org
diff --git a/api/transport/media/audio_transport.cc b/api/transport/media/audio_transport.cc
new file mode 100644
index 0000000..7285ad4
--- /dev/null
+++ b/api/transport/media/audio_transport.cc
@@ -0,0 +1,54 @@
+/*
+ * 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/audio_transport.h"
+
+namespace webrtc {
+
+MediaTransportEncodedAudioFrame::~MediaTransportEncodedAudioFrame() {}
+
+MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
+ int sampling_rate_hz,
+ int starting_sample_index,
+ int samples_per_channel,
+ int sequence_number,
+ FrameType frame_type,
+ int payload_type,
+ std::vector<uint8_t> encoded_data)
+ : sampling_rate_hz_(sampling_rate_hz),
+ starting_sample_index_(starting_sample_index),
+ samples_per_channel_(samples_per_channel),
+ sequence_number_(sequence_number),
+ frame_type_(frame_type),
+ payload_type_(payload_type),
+ encoded_data_(std::move(encoded_data)) {}
+
+MediaTransportEncodedAudioFrame& MediaTransportEncodedAudioFrame::operator=(
+ const MediaTransportEncodedAudioFrame&) = default;
+
+MediaTransportEncodedAudioFrame& MediaTransportEncodedAudioFrame::operator=(
+ MediaTransportEncodedAudioFrame&&) = default;
+
+MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
+ const MediaTransportEncodedAudioFrame&) = default;
+
+MediaTransportEncodedAudioFrame::MediaTransportEncodedAudioFrame(
+ MediaTransportEncodedAudioFrame&&) = default;
+
+} // namespace webrtc
diff --git a/api/transport/media/audio_transport.h b/api/transport/media/audio_transport.h
new file mode 100644
index 0000000..dcbdcd7
--- /dev/null
+++ b/api/transport/media/audio_transport.h
@@ -0,0 +1,120 @@
+/* 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_AUDIO_TRANSPORT_H_
+#define API_TRANSPORT_MEDIA_AUDIO_TRANSPORT_H_
+
+#include <vector>
+
+#include "api/array_view.h"
+
+namespace webrtc {
+
+// 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 {
+ public:
+ enum class FrameType {
+ // Normal audio frame (equivalent to webrtc::kAudioFrameSpeech).
+ kSpeech,
+
+ // DTX frame (equivalent to webrtc::kAudioFrameCN).
+ kDiscontinuousTransmission,
+ // TODO(nisse): Mis-spelled version, update users, then delete.
+ kDiscountinuousTransmission = kDiscontinuousTransmission,
+ };
+
+ MediaTransportEncodedAudioFrame(
+ // Audio sampling rate, for example 48000.
+ int sampling_rate_hz,
+
+ // Starting sample index of the frame, i.e. how many audio samples were
+ // before this frame since the beginning of the call or beginning of time
+ // in one channel (the starting point should not matter for NetEq). In
+ // WebRTC it is used as a timestamp of the frame.
+ // TODO(sukhanov): Starting_sample_index is currently adjusted on the
+ // receiver side in RTP path. Non-RTP implementations should preserve it.
+ // For NetEq initial offset should not matter so we should consider fixing
+ // RTP path.
+ int starting_sample_index,
+
+ // Number of audio samples in audio frame in 1 channel.
+ int samples_per_channel,
+
+ // Sequence number of the frame in the order sent, it is currently
+ // required by NetEq, but we can fix NetEq, because starting_sample_index
+ // should be enough.
+ int sequence_number,
+
+ // If audio frame is a speech or discontinued transmission.
+ FrameType frame_type,
+
+ // 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.
+ int payload_type,
+
+ // Vector with opaque encoded data.
+ std::vector<uint8_t> encoded_data);
+
+ ~MediaTransportEncodedAudioFrame();
+ MediaTransportEncodedAudioFrame(const MediaTransportEncodedAudioFrame&);
+ MediaTransportEncodedAudioFrame& operator=(
+ const MediaTransportEncodedAudioFrame& other);
+ MediaTransportEncodedAudioFrame& operator=(
+ MediaTransportEncodedAudioFrame&& other);
+ MediaTransportEncodedAudioFrame(MediaTransportEncodedAudioFrame&&);
+
+ // Getters.
+ int sampling_rate_hz() const { return sampling_rate_hz_; }
+ int starting_sample_index() const { return starting_sample_index_; }
+ int samples_per_channel() const { return samples_per_channel_; }
+ int sequence_number() const { return sequence_number_; }
+
+ 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_; }
+
+ private:
+ int sampling_rate_hz_;
+ int starting_sample_index_;
+ int samples_per_channel_;
+
+ // TODO(sukhanov): Refactor NetEq so we don't need sequence number.
+ // Having sample_index and samples_per_channel should be enough.
+ int sequence_number_;
+
+ FrameType frame_type_;
+
+ int payload_type_;
+
+ std::vector<uint8_t> encoded_data_;
+};
+
+// Interface for receiving encoded audio frames from MediaTransportInterface
+// implementations.
+class MediaTransportAudioSinkInterface {
+ public:
+ virtual ~MediaTransportAudioSinkInterface() = default;
+
+ // Called when new encoded audio frame is received.
+ virtual void OnData(uint64_t channel_id,
+ MediaTransportEncodedAudioFrame frame) = 0;
+};
+
+} // namespace webrtc
+#endif // API_TRANSPORT_MEDIA_AUDIO_TRANSPORT_H_