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 void DestroyPeer(PeerPtr* peer_ptr);
|
||||
DLLAPI void DestroyPeer(PeerPtr** peer_ptr);
|
||||
|
||||
DLLAPI int Init(PeerPtr* peer_ptr, const char* user_id);
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ PeerConnection::~PeerConnection() {
|
||||
video_codec_inited_ = false;
|
||||
audio_codec_inited_ = false;
|
||||
load_nvcodec_dll_success = false;
|
||||
|
||||
user_data_ = nullptr;
|
||||
|
||||
ice_transmission_list_.clear();
|
||||
}
|
||||
|
||||
int PeerConnection::Init(PeerConnectionParams params,
|
||||
@@ -218,9 +222,12 @@ int PeerConnection::CreateVideoCodec(bool hardware_acceleration) {
|
||||
hardware_acceleration_ = hardware_acceleration;
|
||||
|
||||
if (av1_encoding_) {
|
||||
if (hardware_acceleration_) {
|
||||
hardware_acceleration_ = false;
|
||||
LOG_WARN("Only support software codec for AV1");
|
||||
}
|
||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, true);
|
||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, true);
|
||||
LOG_WARN("Only support software codec for AV1");
|
||||
} else {
|
||||
#ifdef __APPLE__
|
||||
if (hardware_acceleration_) {
|
||||
@@ -244,6 +251,9 @@ int PeerConnection::CreateVideoCodec(bool hardware_acceleration) {
|
||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, false);
|
||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, false);
|
||||
}
|
||||
} else {
|
||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(false, false);
|
||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(false, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -604,7 +614,8 @@ int PeerConnection::RequestTransmissionMemberList(
|
||||
|
||||
int PeerConnection::Destroy() {
|
||||
if (ws_transport_) {
|
||||
ws_transport_->Close(0, "destroy");
|
||||
LOG_INFO("Close websocket")
|
||||
ws_transport_->Close();
|
||||
}
|
||||
|
||||
ice_transmission_list_.clear();
|
||||
|
||||
@@ -39,11 +39,12 @@ PeerPtr *CreatePeer(const Params *params) {
|
||||
return peer_ptr;
|
||||
}
|
||||
|
||||
void DestroyPeer(PeerPtr *peer_ptr) {
|
||||
peer_ptr->peer_connection->Destroy();
|
||||
delete peer_ptr;
|
||||
peer_ptr = nullptr;
|
||||
LOG_INFO("Destroy peer");
|
||||
void DestroyPeer(PeerPtr **peer_ptr) {
|
||||
(*peer_ptr)->peer_connection->Destroy();
|
||||
delete (*peer_ptr)->peer_connection;
|
||||
(*peer_ptr)->peer_connection = nullptr;
|
||||
delete *peer_ptr;
|
||||
*peer_ptr = nullptr;
|
||||
}
|
||||
|
||||
int Init(PeerPtr *peer_ptr, const char *user_id) {
|
||||
|
||||
Reference in New Issue
Block a user