mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix DestroyPeer() method object delete
This commit is contained in:
@@ -75,7 +75,7 @@ typedef struct {
|
|||||||
|
|
||||||
DLLAPI PeerPtr* CreatePeer(const Params* params);
|
DLLAPI PeerPtr* CreatePeer(const Params* params);
|
||||||
|
|
||||||
DLLAPI void DestroyPeer(PeerPtr* peer_ptr);
|
DLLAPI void DestroyPeer(PeerPtr** peer_ptr);
|
||||||
|
|
||||||
DLLAPI int Init(PeerPtr* peer_ptr, const char* user_id);
|
DLLAPI int Init(PeerPtr* peer_ptr, const char* user_id);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ PeerConnection::~PeerConnection() {
|
|||||||
video_codec_inited_ = false;
|
video_codec_inited_ = false;
|
||||||
audio_codec_inited_ = false;
|
audio_codec_inited_ = false;
|
||||||
load_nvcodec_dll_success = false;
|
load_nvcodec_dll_success = false;
|
||||||
|
|
||||||
|
user_data_ = nullptr;
|
||||||
|
|
||||||
|
ice_transmission_list_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PeerConnection::Init(PeerConnectionParams params,
|
int PeerConnection::Init(PeerConnectionParams params,
|
||||||
@@ -218,9 +222,12 @@ int PeerConnection::CreateVideoCodec(bool hardware_acceleration) {
|
|||||||
hardware_acceleration_ = hardware_acceleration;
|
hardware_acceleration_ = hardware_acceleration;
|
||||||
|
|
||||||
if (av1_encoding_) {
|
if (av1_encoding_) {
|
||||||
|
if (hardware_acceleration_) {
|
||||||
|
hardware_acceleration_ = false;
|
||||||
|
LOG_WARN("Only support software codec for AV1");
|
||||||
|
}
|
||||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, true);
|
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, true);
|
||||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, true);
|
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, true);
|
||||||
LOG_WARN("Only support software codec for AV1");
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (hardware_acceleration_) {
|
if (hardware_acceleration_) {
|
||||||
@@ -244,6 +251,9 @@ int PeerConnection::CreateVideoCodec(bool hardware_acceleration) {
|
|||||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, false);
|
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, false);
|
||||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, false);
|
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, false);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, false);
|
||||||
|
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -604,7 +614,8 @@ int PeerConnection::RequestTransmissionMemberList(
|
|||||||
|
|
||||||
int PeerConnection::Destroy() {
|
int PeerConnection::Destroy() {
|
||||||
if (ws_transport_) {
|
if (ws_transport_) {
|
||||||
ws_transport_->Close(0, "destroy");
|
LOG_INFO("Close websocket")
|
||||||
|
ws_transport_->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ice_transmission_list_.clear();
|
ice_transmission_list_.clear();
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ PeerPtr *CreatePeer(const Params *params) {
|
|||||||
return peer_ptr;
|
return peer_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyPeer(PeerPtr *peer_ptr) {
|
void DestroyPeer(PeerPtr **peer_ptr) {
|
||||||
peer_ptr->peer_connection->Destroy();
|
(*peer_ptr)->peer_connection->Destroy();
|
||||||
delete peer_ptr;
|
delete (*peer_ptr)->peer_connection;
|
||||||
peer_ptr = nullptr;
|
(*peer_ptr)->peer_connection = nullptr;
|
||||||
LOG_INFO("Destroy peer");
|
delete *peer_ptr;
|
||||||
|
*peer_ptr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Init(PeerPtr *peer_ptr, const char *user_id) {
|
int Init(PeerPtr *peer_ptr, const char *user_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user