From e6ee60d91212156a306d70dca05c5d3e4761bf67 Mon Sep 17 00:00:00 2001 From: Michel Promonet Date: Tue, 19 Dec 2023 21:38:30 +0100 Subject: [PATCH] use std::unique --- inc/PeerConnectionManager.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/inc/PeerConnectionManager.h b/inc/PeerConnectionManager.h index 006d1339..bb32bf3c 100755 --- a/inc/PeerConnectionManager.h +++ b/inc/PeerConnectionManager.h @@ -199,8 +199,6 @@ class PeerConnectionManager { PeerConnectionObserver(PeerConnectionManager* peerConnectionManager, const std::string& peerid, const webrtc::PeerConnectionInterface::RTCConfiguration & config) : m_peerConnectionManager(peerConnectionManager) , m_peerid(peerid) - , m_localChannel(NULL) - , m_remoteChannel(NULL) , m_iceCandidateList(Json::arrayValue) , m_deleting(false) , m_creationTime(rtc::TimeMicros()) { @@ -214,7 +212,7 @@ class PeerConnectionManager { webrtc::RTCErrorOr> errorOrChannel = m_pc->CreateDataChannelOrError("ServerDataChannel", NULL); if (errorOrChannel.ok()) { - m_localChannel = new DataChannelObserver(errorOrChannel.MoveValue()); + m_localChannel.reset(new DataChannelObserver(errorOrChannel.MoveValue())); } else { RTC_LOG(LS_ERROR) << __FUNCTION__ << "CreateDataChannel peerid:" << peerid << " error:" << errorOrChannel.error().message(); } @@ -229,8 +227,6 @@ class PeerConnectionManager { virtual ~PeerConnectionObserver() { RTC_LOG(LS_INFO) << __PRETTY_FUNCTION__; - delete m_localChannel; - delete m_remoteChannel; if (m_pc.get()) { // warning: pc->close call OnIceConnectionChange m_deleting = true; @@ -272,7 +268,7 @@ class PeerConnectionManager { } virtual void OnDataChannel(rtc::scoped_refptr channel) { RTC_LOG(LS_ERROR) << __PRETTY_FUNCTION__; - m_remoteChannel = new DataChannelObserver(channel); + m_remoteChannel.reset(new DataChannelObserver(channel)); } virtual void OnRenegotiationNeeded() { RTC_LOG(LS_ERROR) << __PRETTY_FUNCTION__ << " peerid:" << m_peerid;; @@ -310,8 +306,8 @@ class PeerConnectionManager { PeerConnectionManager* m_peerConnectionManager; const std::string m_peerid; rtc::scoped_refptr m_pc; - DataChannelObserver* m_localChannel; - DataChannelObserver* m_remoteChannel; + std::unique_ptr m_localChannel; + std::unique_ptr m_remoteChannel; Json::Value m_iceCandidateList; rtc::scoped_refptr m_statsCallback; std::unique_ptr m_videosink;