Skip to content

Commit

Permalink
use std::unique
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Dec 19, 2023
1 parent 40c44f2 commit e6ee60d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions inc/PeerConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -214,7 +212,7 @@ class PeerConnectionManager {

webrtc::RTCErrorOr<rtc::scoped_refptr<webrtc::DataChannelInterface>> 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();
}
Expand All @@ -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;
Expand Down Expand Up @@ -272,7 +268,7 @@ class PeerConnectionManager {
}
virtual void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> 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;;
Expand Down Expand Up @@ -310,8 +306,8 @@ class PeerConnectionManager {
PeerConnectionManager* m_peerConnectionManager;
const std::string m_peerid;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> m_pc;
DataChannelObserver* m_localChannel;
DataChannelObserver* m_remoteChannel;
std::unique_ptr<DataChannelObserver> m_localChannel;
std::unique_ptr<DataChannelObserver> m_remoteChannel;
Json::Value m_iceCandidateList;
rtc::scoped_refptr<PeerConnectionStatsCollectorCallback> m_statsCallback;
std::unique_ptr<VideoSink> m_videosink;
Expand Down

0 comments on commit e6ee60d

Please sign in to comment.