mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Add destroy method for peer instance
This commit is contained in:
@@ -73,6 +73,8 @@ typedef struct {
|
||||
|
||||
DLLAPI PeerPtr* CreatePeer(const Params* params);
|
||||
|
||||
DLLAPI void DestroyPeer(PeerPtr* peer_ptr);
|
||||
|
||||
DLLAPI int Init(PeerPtr* peer_ptr, const char* user_id);
|
||||
|
||||
DLLAPI int CreateConnection(PeerPtr* peer_ptr, const char* transmission_id,
|
||||
|
||||
@@ -179,15 +179,15 @@ int PeerConnection::Init(PeerConnectionParams params,
|
||||
|
||||
nv12_data_ = new char[1280 * 720 * 3 / 2];
|
||||
|
||||
if (0 != CreateVideoCodec(hardware_acceleration_)) {
|
||||
LOG_ERROR("Create video codec failed");
|
||||
return -1;
|
||||
}
|
||||
// if (0 != CreateVideoCodec(hardware_acceleration_)) {
|
||||
// LOG_ERROR("Create video codec failed");
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
if (0 != CreateAudioCodec()) {
|
||||
LOG_ERROR("Create audio codec failed");
|
||||
return -1;
|
||||
}
|
||||
// if (0 != CreateAudioCodec()) {
|
||||
// LOG_ERROR("Create audio codec failed");
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
inited_ = true;
|
||||
return 0;
|
||||
@@ -396,6 +396,14 @@ void PeerConnection::ProcessSignal(const std::string &signal) {
|
||||
}
|
||||
LOG_INFO("]");
|
||||
|
||||
if (0 != CreateVideoCodec(hardware_acceleration_)) {
|
||||
LOG_ERROR("Create video codec failed");
|
||||
}
|
||||
|
||||
if (0 != CreateAudioCodec()) {
|
||||
LOG_ERROR("Create audio codec failed");
|
||||
}
|
||||
|
||||
for (auto &remote_user_id : user_id_list_) {
|
||||
// if (remote_user_id == user_id_) {
|
||||
// continue;
|
||||
@@ -455,6 +463,14 @@ void PeerConnection::ProcessSignal(const std::string &signal) {
|
||||
std::string remote_user_id = j["remote_user_id"].get<std::string>();
|
||||
LOG_INFO("[{}] receive offer from [{}]", user_id_, remote_user_id);
|
||||
|
||||
if (0 != CreateVideoCodec(hardware_acceleration_)) {
|
||||
LOG_ERROR("Create video codec failed");
|
||||
}
|
||||
|
||||
if (0 != CreateAudioCodec()) {
|
||||
LOG_ERROR("Create audio codec failed");
|
||||
}
|
||||
|
||||
ice_transmission_list_[remote_user_id] =
|
||||
std::make_unique<IceTransmission>(false, transmission_id, user_id_,
|
||||
remote_user_id, ws_transport_,
|
||||
@@ -529,7 +545,14 @@ int PeerConnection::RequestTransmissionMemberList(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PeerConnection::Destroy() { return 0; }
|
||||
int PeerConnection::Destroy() {
|
||||
ice_transmission_list_.clear();
|
||||
if (nv12_data_) {
|
||||
delete nv12_data_;
|
||||
nv12_data_ = nullptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SignalStatus PeerConnection::GetSignalStatus() {
|
||||
std::lock_guard<std::mutex> l(signal_status_mutex_);
|
||||
|
||||
@@ -39,6 +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;
|
||||
}
|
||||
|
||||
int Init(PeerPtr *peer_ptr, const char *user_id) {
|
||||
if (!peer_ptr) {
|
||||
LOG_ERROR("peer_ptr not created");
|
||||
|
||||
Reference in New Issue
Block a user