mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix illegal access to IceTransport's member function in lambda
This commit is contained in:
@@ -594,7 +594,7 @@ void PeerConnection::ProcessIceWorkMsg(const IceWorkMsg &msg) {
|
||||
LOG_INFO("]");
|
||||
|
||||
for (auto &remote_user_id : user_id_list) {
|
||||
ice_transport_list_[remote_user_id] = std::make_unique<IceTransport>(
|
||||
ice_transport_list_[remote_user_id] = std::make_shared<IceTransport>(
|
||||
true, transmission_id, user_id_, remote_user_id, ws_transport_,
|
||||
on_ice_status_change_, user_data_);
|
||||
|
||||
@@ -641,7 +641,7 @@ void PeerConnection::ProcessIceWorkMsg(const IceWorkMsg &msg) {
|
||||
if (ice_transport_list_.end() ==
|
||||
ice_transport_list_.find(remote_user_id)) {
|
||||
// Enable TURN for answer peer by default
|
||||
ice_transport_list_[remote_user_id] = std::make_unique<IceTransport>(
|
||||
ice_transport_list_[remote_user_id] = std::make_shared<IceTransport>(
|
||||
false, transmission_id, user_id_, remote_user_id, ws_transport_,
|
||||
on_ice_status_change_, user_data_);
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ class PeerConnection {
|
||||
std::string sdp_without_cands_ = "";
|
||||
|
||||
private:
|
||||
std::map<std::string, std::unique_ptr<IceTransport>> ice_transport_list_;
|
||||
std::map<std::string, std::shared_ptr<IceTransport>> ice_transport_list_;
|
||||
std::map<std::string, bool> is_ice_transport_ready_;
|
||||
|
||||
std::function<void(std::string, const std::string &)> on_ice_status_change_ =
|
||||
|
||||
@@ -130,18 +130,29 @@ void IceTransport::InitializeChannels(
|
||||
audio_channel_send_->Initialize(rtp::PAYLOAD_TYPE::OPUS);
|
||||
data_channel_send_->Initialize(rtp::PAYLOAD_TYPE::DATA);
|
||||
|
||||
std::weak_ptr<IceTransport> weak_self = shared_from_this();
|
||||
video_channel_receive_ = std::make_unique<VideoChannelReceive>(
|
||||
ice_agent_, ice_io_statistics_,
|
||||
[this](VideoFrame &video_frame) { OnReceiveCompleteFrame(video_frame); });
|
||||
[this, weak_self](VideoFrame &video_frame) {
|
||||
if (auto self = weak_self.lock()) {
|
||||
OnReceiveCompleteFrame(video_frame);
|
||||
}
|
||||
});
|
||||
|
||||
audio_channel_receive_ = std::make_unique<AudioChannelReceive>(
|
||||
ice_agent_, ice_io_statistics_, [this](const char *data, size_t size) {
|
||||
OnReceiveCompleteAudio(data, size);
|
||||
ice_agent_, ice_io_statistics_,
|
||||
[this, weak_self](const char *data, size_t size) {
|
||||
if (auto self = weak_self.lock()) {
|
||||
OnReceiveCompleteAudio(data, size);
|
||||
}
|
||||
});
|
||||
|
||||
data_channel_receive_ = std::make_unique<DataChannelReceive>(
|
||||
ice_agent_, ice_io_statistics_, [this](const char *data, size_t size) {
|
||||
OnReceiveCompleteData(data, size);
|
||||
ice_agent_, ice_io_statistics_,
|
||||
[this, weak_self](const char *data, size_t size) {
|
||||
if (auto self = weak_self.lock()) {
|
||||
OnReceiveCompleteData(data, size);
|
||||
}
|
||||
});
|
||||
|
||||
video_channel_receive_->Initialize(video_codec_payload_type_);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "video_encoder_factory.h"
|
||||
#include "ws_client.h"
|
||||
|
||||
class IceTransport {
|
||||
class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
public:
|
||||
typedef enum { VIDEO = 96, AUDIO = 97, DATA = 127 } DATA_TYPE;
|
||||
typedef enum { H264 = 96, AV1 = 99 } VIDEO_TYPE;
|
||||
|
||||
Reference in New Issue
Block a user