Add option to attach custom object to an rtp packet
As an alternative to attaching custom array of bytes. Bug: b/178094662 Change-Id: I92dcbf04998d8206091125febc520ebfcc4bcebf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203264 Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33069}
This commit is contained in:
parent
ded6636cf4
commit
5312a8f532
@ -575,6 +575,10 @@ rtc_library("transport_api") {
|
||||
"call/transport.cc",
|
||||
"call/transport.h",
|
||||
]
|
||||
deps = [
|
||||
":refcountedbase",
|
||||
":scoped_refptr",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("bitrate_allocation") {
|
||||
|
||||
@ -16,6 +16,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "api/ref_counted_base.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(holmer): Look into unifying this with the PacketOptions in
|
||||
@ -28,9 +31,11 @@ struct PacketOptions {
|
||||
// A 16 bits positive id. Negative ids are invalid and should be interpreted
|
||||
// as packet_id not being set.
|
||||
int packet_id = -1;
|
||||
// Deprecated: use `additional_data` instead of `application_data`.
|
||||
std::vector<uint8_t> application_data;
|
||||
// Additional data bound to the RTP packet for use in application code,
|
||||
// outside of WebRTC.
|
||||
std::vector<uint8_t> application_data;
|
||||
rtc::scoped_refptr<rtc::RefCountedBase> additional_data;
|
||||
// Whether this is a retransmission of an earlier packet.
|
||||
bool is_retransmit = false;
|
||||
bool included_in_feedback = false;
|
||||
|
||||
@ -103,8 +103,10 @@ rtc_library("rtp_rtcp_format") {
|
||||
"..:module_api_public",
|
||||
"../../api:array_view",
|
||||
"../../api:function_view",
|
||||
"../../api:refcountedbase",
|
||||
"../../api:rtp_headers",
|
||||
"../../api:rtp_parameters",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../api/transport:network_control",
|
||||
"../../api/transport/rtp:dependency_descriptor",
|
||||
|
||||
@ -178,6 +178,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
|
||||
|
||||
options.application_data.assign(packet->application_data().begin(),
|
||||
packet->application_data().end());
|
||||
options.additional_data = packet->additional_data();
|
||||
|
||||
if (packet->packet_type() != RtpPacketMediaType::kPadding &&
|
||||
packet->packet_type() != RtpPacketMediaType::kRetransmission) {
|
||||
|
||||
@ -12,14 +12,20 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "api/ref_counted_base.h"
|
||||
#include "api/rtp_headers.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet.h"
|
||||
#include "rtc_base/deprecation.h"
|
||||
|
||||
namespace webrtc {
|
||||
// Class to hold rtp packet with metadata for receiver side.
|
||||
// The metadata is not parsed from the rtp packet, but may be derived from the
|
||||
// data that is parsed from the rtp packet.
|
||||
class RtpPacketReceived : public RtpPacket {
|
||||
public:
|
||||
RtpPacketReceived();
|
||||
@ -50,19 +56,29 @@ class RtpPacketReceived : public RtpPacket {
|
||||
payload_type_frequency_ = value;
|
||||
}
|
||||
|
||||
// Additional data bound to the RTP packet for use in application code,
|
||||
// outside of WebRTC.
|
||||
// An application can attach arbitrary data to an RTP packet using
|
||||
// `application_data` or `additional_data`.
|
||||
// The additional data does not affect WebRTC processing.
|
||||
RTC_DEPRECATED
|
||||
rtc::ArrayView<const uint8_t> application_data() const {
|
||||
return application_data_;
|
||||
}
|
||||
RTC_DEPRECATED
|
||||
void set_application_data(rtc::ArrayView<const uint8_t> data) {
|
||||
application_data_.assign(data.begin(), data.end());
|
||||
}
|
||||
rtc::scoped_refptr<rtc::RefCountedBase> additional_data() const {
|
||||
return additional_data_;
|
||||
}
|
||||
void set_additional_data(rtc::scoped_refptr<rtc::RefCountedBase> data) {
|
||||
additional_data_ = std::move(data);
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t arrival_time_ms_ = 0;
|
||||
int payload_type_frequency_ = 0;
|
||||
bool recovered_ = false;
|
||||
rtc::scoped_refptr<rtc::RefCountedBase> additional_data_;
|
||||
std::vector<uint8_t> application_data_;
|
||||
};
|
||||
|
||||
|
||||
@ -13,10 +13,13 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/ref_counted_base.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/video/video_timing.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||
@ -24,6 +27,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
// Class to hold rtp packet with metadata for sender side.
|
||||
// The metadata is not send over the wire, but packet sender may use it to
|
||||
// create rtp header extensions or other data that is sent over the wire.
|
||||
class RtpPacketToSend : public RtpPacket {
|
||||
public:
|
||||
// RtpPacketToSend::Type is deprecated. Use RtpPacketMediaType directly.
|
||||
@ -64,8 +69,9 @@ class RtpPacketToSend : public RtpPacket {
|
||||
}
|
||||
bool allow_retransmission() { return allow_retransmission_; }
|
||||
|
||||
// Additional data bound to the RTP packet for use in application code,
|
||||
// outside of WebRTC.
|
||||
// An application can attach arbitrary data to an RTP packet using
|
||||
// `application_data` or `additional_data`.
|
||||
// The additional data does not affect WebRTC processing.
|
||||
rtc::ArrayView<const uint8_t> application_data() const {
|
||||
return application_data_;
|
||||
}
|
||||
@ -73,6 +79,12 @@ class RtpPacketToSend : public RtpPacket {
|
||||
void set_application_data(rtc::ArrayView<const uint8_t> data) {
|
||||
application_data_.assign(data.begin(), data.end());
|
||||
}
|
||||
rtc::scoped_refptr<rtc::RefCountedBase> additional_data() const {
|
||||
return additional_data_;
|
||||
}
|
||||
void set_additional_data(rtc::scoped_refptr<rtc::RefCountedBase> data) {
|
||||
additional_data_ = std::move(data);
|
||||
}
|
||||
|
||||
void set_packetization_finish_time_ms(int64_t time) {
|
||||
SetExtension<VideoTimingExtension>(
|
||||
@ -122,7 +134,10 @@ class RtpPacketToSend : public RtpPacket {
|
||||
absl::optional<RtpPacketMediaType> packet_type_;
|
||||
bool allow_retransmission_ = false;
|
||||
absl::optional<uint16_t> retransmitted_sequence_number_;
|
||||
// TODO(danilchap): Remove applicaion_data_ when application switched to use
|
||||
// additional_data instead.
|
||||
std::vector<uint8_t> application_data_;
|
||||
rtc::scoped_refptr<rtc::RefCountedBase> additional_data_;
|
||||
bool is_first_packet_of_frame_ = false;
|
||||
bool is_key_frame_ = false;
|
||||
bool fec_protect_packet_ = false;
|
||||
|
||||
@ -811,6 +811,7 @@ std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
|
||||
|
||||
// Add original application data.
|
||||
rtx_packet->set_application_data(packet.application_data());
|
||||
rtx_packet->set_additional_data(packet.additional_data());
|
||||
|
||||
// Copy capture time so e.g. TransmissionOffset is correctly set.
|
||||
rtx_packet->set_capture_time_ms(packet.capture_time_ms());
|
||||
|
||||
@ -252,6 +252,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
|
||||
|
||||
options.application_data.assign(packet->application_data().begin(),
|
||||
packet->application_data().end());
|
||||
options.additional_data = packet->additional_data();
|
||||
|
||||
if (packet->packet_type() != RtpPacketMediaType::kPadding &&
|
||||
packet->packet_type() != RtpPacketMediaType::kRetransmission) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user