Updates rtcp::CompoundPacket to contain unique pointers to packets.
Currently test code passes pointer to temporary objects, while RtcpSender passes raw pointers to objects that are then seen as owned, and will be manually deleted by a overloaded destructor, which is scary and fragile. This CL moves all usage to std::unique_ptr<RtcpPacket> instead, which may create some heap churn in unit tests but that should be fine. Bug: webrtc:11925 Change-Id: I981bc7ccd6a74115c5a3de64b8427adbf3f16cc7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183920 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32084}
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_COMPOUND_PACKET_H_
|
||||
#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_COMPOUND_PACKET_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet.h"
|
||||
@ -25,7 +26,14 @@ class CompoundPacket : public RtcpPacket {
|
||||
CompoundPacket();
|
||||
~CompoundPacket() override;
|
||||
|
||||
void Append(RtcpPacket* packet);
|
||||
void Append(std::unique_ptr<RtcpPacket> packet);
|
||||
|
||||
// Fallback for call-sites that have not yet migrated to passing a unique_ptr.
|
||||
// TODO(bugs.webrtc.org/11925): Remove when all usage is gone.
|
||||
template <typename T>
|
||||
void Append(T* packet) {
|
||||
Append(std::make_unique<T>(*packet));
|
||||
}
|
||||
|
||||
// Size of this packet in bytes (i.e. total size of nested packets).
|
||||
size_t BlockLength() const override;
|
||||
@ -36,7 +44,7 @@ class CompoundPacket : public RtcpPacket {
|
||||
PacketReadyCallback callback) const override;
|
||||
|
||||
protected:
|
||||
std::vector<RtcpPacket*> appended_packets_;
|
||||
std::vector<std::unique_ptr<RtcpPacket>> appended_packets_;
|
||||
|
||||
private:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(CompoundPacket);
|
||||
|
||||
Reference in New Issue
Block a user