Add application_data field(s) to RtpPacketToSend and PacketOptions.
Pass pointer to application_data from RtpPacketToSend arriving via RtpSender::SendToNetwork through to Transport::SendRtp, in PacketOptions.
Bug: webrtc:8906
Change-Id: Ie75013ed472710f4efcfbcc160e46a6119a1f41d
Reviewed-on: https://webrtc-review.googlesource.com/55600
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Dino Radaković <dinor@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22174}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 280b7e7..a238357 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -201,6 +201,7 @@
rtc_source_set("transport_api") {
visibility = [ "*" ]
sources = [
+ "call/transport.cc",
"call/transport.h",
]
}
diff --git a/api/call/transport.cc b/api/call/transport.cc
new file mode 100644
index 0000000..515f27c
--- /dev/null
+++ b/api/call/transport.cc
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2018 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.
+ */
+
+#include "api/call/transport.h"
+
+namespace webrtc {
+
+PacketOptions::PacketOptions() = default;
+
+PacketOptions::~PacketOptions() = default;
+
+} // namespace webrtc
diff --git a/api/call/transport.h b/api/call/transport.h
index 1cdb0d3..df101fc 100644
--- a/api/call/transport.h
+++ b/api/call/transport.h
@@ -13,15 +13,22 @@
#include <stddef.h>
#include <stdint.h>
+#include <vector>
namespace webrtc {
// TODO(holmer): Look into unifying this with the PacketOptions in
// asyncpacketsocket.h.
struct PacketOptions {
+ PacketOptions();
+ ~PacketOptions();
+
// A 16 bits positive id. Negative ids are invalid and should be interpreted
// as packet_id not being set.
int packet_id = -1;
+ // Additional data bound to the RTP packet for use in application code,
+ // outside of WebRTC.
+ std::vector<uint8_t> application_data;
};
class Transport {
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index e53001b..be3fd03 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -77,6 +77,7 @@
"source/rtp_header_extensions.cc",
"source/rtp_packet.cc",
"source/rtp_packet_received.cc",
+ "source/rtp_packet_to_send.cc",
]
deps = [
diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.cc b/modules/rtp_rtcp/source/rtp_packet_to_send.cc
new file mode 100644
index 0000000..9a9a57d
--- /dev/null
+++ b/modules/rtp_rtcp/source/rtp_packet_to_send.cc
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018 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.
+ */
+
+#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
+
+namespace webrtc {
+
+RtpPacketToSend::RtpPacketToSend(const ExtensionManager* extensions)
+ : RtpPacket(extensions) {}
+RtpPacketToSend::RtpPacketToSend(const RtpPacketToSend& packet) = default;
+RtpPacketToSend::RtpPacketToSend(const ExtensionManager* extensions,
+ size_t capacity)
+ : RtpPacket(extensions, capacity) {}
+
+RtpPacketToSend& RtpPacketToSend::operator=(const RtpPacketToSend& packet) =
+ default;
+
+RtpPacketToSend::~RtpPacketToSend() = default;
+
+} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h
index c287f0c..59992a1 100644
--- a/modules/rtp_rtcp/source/rtp_packet_to_send.h
+++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h
@@ -10,6 +10,9 @@
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_TO_SEND_H_
#define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_TO_SEND_H_
+#include <vector>
+
+#include "api/array_view.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
@@ -17,19 +20,29 @@
// Class to hold rtp packet with metadata for sender side.
class RtpPacketToSend : public RtpPacket {
public:
- explicit RtpPacketToSend(const ExtensionManager* extensions)
- : RtpPacket(extensions) {}
- RtpPacketToSend(const RtpPacketToSend& packet) = default;
- RtpPacketToSend(const ExtensionManager* extensions, size_t capacity)
- : RtpPacket(extensions, capacity) {}
+ explicit RtpPacketToSend(const ExtensionManager* extensions);
+ RtpPacketToSend(const RtpPacketToSend& packet);
+ RtpPacketToSend(const ExtensionManager* extensions, size_t capacity);
- RtpPacketToSend& operator=(const RtpPacketToSend& packet) = default;
+ RtpPacketToSend& operator=(const RtpPacketToSend& packet);
+
+ ~RtpPacketToSend();
// Time in local time base as close as it can to frame capture time.
int64_t capture_time_ms() const { return capture_time_ms_; }
void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; }
+ // Additional data bound to the RTP packet for use in application code,
+ // outside of WebRTC.
+ rtc::ArrayView<const uint8_t> application_data() const {
+ return application_data_;
+ }
+
+ void set_application_data(rtc::ArrayView<const uint8_t> data) {
+ application_data_.assign(data.begin(), data.end());
+ }
+
void set_packetization_finish_time_ms(int64_t time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time),
@@ -56,6 +69,7 @@
private:
int64_t capture_time_ms_ = 0;
+ std::vector<uint8_t> application_data_;
};
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index c37c5ac..f8ef130 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -782,6 +782,8 @@
AddPacketToTransportFeedback(options.packet_id, *packet_to_send,
pacing_info);
}
+ options.application_data.assign(packet_to_send->application_data().begin(),
+ packet_to_send->application_data().end());
if (!is_retransmit && !send_over_rtx) {
UpdateDelayStatistics(packet->capture_time_ms(), now_ms);
@@ -914,6 +916,8 @@
AddPacketToTransportFeedback(options.packet_id, *packet.get(),
PacedPacketInfo());
}
+ options.application_data.assign(packet->application_data().begin(),
+ packet->application_data().end());
UpdateDelayStatistics(packet->capture_time_ms(), now_ms);
UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(),
@@ -1211,6 +1215,9 @@
auto payload = packet.payload();
memcpy(rtx_payload + kRtxHeaderSize, payload.data(), payload.size());
+ // Add original application data.
+ rtx_packet->set_application_data(packet.application_data());
+
return rtx_packet;
}