Commit 363fe205 authored by DanmeiChen's avatar DanmeiChen
Browse files

avoid using weak_ptr for realTimeText

parent 6aec4218
......@@ -210,7 +210,7 @@ LinphoneCall *linphone_chat_room_get_call (const LinphoneChatRoom *cr) {
void linphone_chat_room_set_call (LinphoneChatRoom *cr, LinphoneCall *call) {
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return;
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->call = LinphonePrivate::Call::toCpp(call)->getSharedFromThis();
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->callId = linphone_call_log_get_call_id(linphone_call_get_call_log(call));
}
void linphone_chat_room_mark_as_read (LinphoneChatRoom *cr) {
......
......@@ -44,7 +44,7 @@ shared_ptr<CallSession> Call::getActiveSession () const {
shared_ptr<RealTimeTextChatRoom> Call::getChatRoom () {
if (!mChatRoom && (getState() != CallSession::State::End) && (getState() != CallSession::State::Released)) {
mChatRoom = static_pointer_cast<RealTimeTextChatRoom>(getCore()->getOrCreateBasicChatRoom(*getRemoteAddress(), true));
if (mChatRoom) mChatRoom->getPrivate()->setCall(getSharedFromThis());
if (mChatRoom) mChatRoom->getPrivate()->setCallId(linphone_call_log_get_call_id(getLog()));
}
return mChatRoom;
}
......
......@@ -37,9 +37,9 @@ public:
void realtimeTextReceived (uint32_t character, const std::shared_ptr<Call> &call);
void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) override;
void onChatMessageSent (const std::shared_ptr<ChatMessage> &chatMessage) override;
void setCall (const std::shared_ptr<Call> &value) { call = value; }
void setCallId (const std::string &value) { callId = value;}
std::weak_ptr<Call> call;
std::string callId;
std::list<Character> receivedRttCharacters;
std::shared_ptr<ChatMessage> pendingMessage = nullptr;
......
......@@ -130,7 +130,7 @@ uint32_t RealTimeTextChatRoom::getChar () const {
shared_ptr<Call> RealTimeTextChatRoom::getCall () const {
L_D();
return d->call.lock();
return getCore()->getCallByCallId(d->callId);
}
LINPHONE_END_NAMESPACE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment