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}
This commit is contained in:
parent
f35c6667d6
commit
1807d57ab8
@ -201,6 +201,7 @@ rtc_source_set("audio_options_api") {
|
||||
rtc_source_set("transport_api") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"call/transport.cc",
|
||||
"call/transport.h",
|
||||
]
|
||||
}
|
||||
|
||||
19
api/call/transport.cc
Normal file
19
api/call/transport.cc
Normal file
@ -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
|
||||
@ -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 {
|
||||
|
||||
@ -77,6 +77,7 @@ rtc_source_set("rtp_rtcp_format") {
|
||||
"source/rtp_header_extensions.cc",
|
||||
"source/rtp_packet.cc",
|
||||
"source/rtp_packet_received.cc",
|
||||
"source/rtp_packet_to_send.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
|
||||
27
modules/rtp_rtcp/source/rtp_packet_to_send.cc
Normal file
27
modules/rtp_rtcp/source/rtp_packet_to_send.cc
Normal file
@ -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
|
||||
@ -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 @@ namespace webrtc {
|
||||
// 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 @@ class RtpPacketToSend : public RtpPacket {
|
||||
|
||||
private:
|
||||
int64_t capture_time_ms_ = 0;
|
||||
std::vector<uint8_t> application_data_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -782,6 +782,8 @@ bool RTPSender::PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet,
|
||||
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 @@ bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet,
|
||||
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 @@ std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user