common: Use shared ptr for zrtp module

This commit is contained in:
Joni Räsänen 2022-02-04 08:35:56 +02:00
parent dea14a3e98
commit d97079ffbb
4 changed files with 7 additions and 11 deletions

View File

@ -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<uvgrtp::zrtp> 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<uvgrtp::zrtp> zrtp);
uint32_t key_;

View File

@ -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<uvgrtp::zrtp> zrtp_;
/* Each RTP multimedia session is always IP-specific */
std::string addr_;

View File

@ -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<uvgrtp::zrtp> 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<uvgrtp::zrtp> zrtp)
{
size_t key_size = srtp->get_key_size(flags);

View File

@ -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<uvgrtp::zrtp> (new uvgrtp::zrtp());
}
if (stream->init(zrtp_) != RTP_OK) {