mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] release NvCodec DLL only when loaded success
This commit is contained in:
@@ -20,6 +20,7 @@ PeerConnection::~PeerConnection() {
|
|||||||
|
|
||||||
video_codec_inited_ = false;
|
video_codec_inited_ = false;
|
||||||
audio_codec_inited_ = false;
|
audio_codec_inited_ = false;
|
||||||
|
load_nvcodec_dll_success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PeerConnection::Init(PeerConnectionParams params,
|
int PeerConnection::Init(PeerConnectionParams params,
|
||||||
@@ -201,16 +202,6 @@ int PeerConnection::Init(PeerConnectionParams params,
|
|||||||
|
|
||||||
LOG_INFO("[{}] Init finish", user_id);
|
LOG_INFO("[{}] Init finish", user_id);
|
||||||
|
|
||||||
// if (0 != CreateVideoCodec(hardware_acceleration_)) {
|
|
||||||
// LOG_ERROR("Create video codec failed");
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (0 != CreateAudioCodec()) {
|
|
||||||
// LOG_ERROR("Create audio codec failed");
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
inited_ = true;
|
inited_ = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -237,6 +228,7 @@ int PeerConnection::CreateVideoCodec(bool hardware_acceleration) {
|
|||||||
} else {
|
} else {
|
||||||
if (hardware_acceleration_) {
|
if (hardware_acceleration_) {
|
||||||
if (0 == LoadNvCodecDll()) {
|
if (0 == LoadNvCodecDll()) {
|
||||||
|
load_nvcodec_dll_success = true;
|
||||||
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(true, false);
|
video_encoder_ = VideoEncoderFactory::CreateVideoEncoder(true, false);
|
||||||
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(true, false);
|
video_decoder_ = VideoDecoderFactory::CreateVideoDecoder(true, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -614,7 +606,7 @@ int PeerConnection::Destroy() {
|
|||||||
nv12_data_ = nullptr;
|
nv12_data_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hardware_acceleration_) {
|
if (hardware_acceleration_ && load_nvcodec_dll_success) {
|
||||||
ReleaseNvCodecDll();
|
ReleaseNvCodecDll();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ class PeerConnection {
|
|||||||
bool hardware_accelerated_decode_ = false;
|
bool hardware_accelerated_decode_ = false;
|
||||||
bool b_force_i_frame_ = false;
|
bool b_force_i_frame_ = false;
|
||||||
bool video_codec_inited_ = false;
|
bool video_codec_inited_ = false;
|
||||||
|
bool load_nvcodec_dll_success = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<AudioEncoder> audio_encoder_ = nullptr;
|
std::unique_ptr<AudioEncoder> audio_encoder_ = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user