diff --git a/include/media_stream.hh b/include/media_stream.hh index 2fb96c9..d710b71 100644 --- a/include/media_stream.hh +++ b/include/media_stream.hh @@ -60,7 +60,7 @@ namespace uvgrtp { * TODO document all error codes! * * Other error return codes are defined in {conn,writer,reader,srtp}.hh */ - rtp_error_t init(uvgrtp::zrtp *zrtp); + rtp_error_t init(std::shared_ptr zrtp); /// \endcond /** @@ -311,7 +311,7 @@ namespace uvgrtp { rtp_error_t free_resources(rtp_error_t ret); rtp_error_t init_srtp_with_zrtp(int flags, int type, uvgrtp::base_srtp* srtp, - uvgrtp::zrtp *zrtp); + std::shared_ptr zrtp); uint32_t key_; diff --git a/include/session.hh b/include/session.hh index 7245942..9313943 100644 --- a/include/session.hh +++ b/include/session.hh @@ -73,7 +73,7 @@ namespace uvgrtp { private: /* Each RTP multimedia session shall have one ZRTP session from which all session are derived */ - uvgrtp::zrtp *zrtp_; + std::shared_ptr zrtp_; /* Each RTP multimedia session is always IP-specific */ std::string addr_; diff --git a/src/media_stream.cc b/src/media_stream.cc index 713b019..71072cd 100644 --- a/src/media_stream.cc +++ b/src/media_stream.cc @@ -264,7 +264,7 @@ rtp_error_t uvgrtp::media_stream::init() return pkt_dispatcher_->start(socket_, ctx_config_.flags); } -rtp_error_t uvgrtp::media_stream::init(uvgrtp::zrtp *zrtp) +rtp_error_t uvgrtp::media_stream::init(std::shared_ptr zrtp) { rtp_error_t ret; @@ -618,7 +618,7 @@ uvgrtp::rtcp *uvgrtp::media_stream::get_rtcp() } rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int flags, int type, uvgrtp::base_srtp* srtp, - uvgrtp::zrtp *zrtp) + std::shared_ptr zrtp) { size_t key_size = srtp->get_key_size(flags); diff --git a/src/session.cc b/src/session.cc index f2e4020..956fb17 100644 --- a/src/session.cc +++ b/src/session.cc @@ -8,7 +8,7 @@ uvgrtp::session::session(std::string addr): #ifdef __RTP_CRYPTO__ - zrtp_(nullptr), + zrtp_(new uvgrtp::zrtp()), #endif addr_(addr), laddr_("") @@ -27,10 +27,6 @@ uvgrtp::session::~session() (void)destroy_stream(i.second); } streams_.clear(); - -#ifdef __RTP_CRYPTO__ - delete zrtp_; -#endif } uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp_format_t fmt, int flags) @@ -68,7 +64,7 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp } if (!zrtp_) { - zrtp_ = new uvgrtp::zrtp(); + zrtp_ = std::shared_ptr (new uvgrtp::zrtp()); } if (stream->init(zrtp_) != RTP_OK) {