mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-16 04:27:55 +00:00
For fixes for real time text.
This commit is contained in:
parent
de13310b03
commit
983471e8d0
19 changed files with 156 additions and 127 deletions
|
|
@ -198,7 +198,11 @@ const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl){
|
|||
return cl->refkey;
|
||||
}
|
||||
|
||||
LinphoneAddress *linphone_call_log_get_remote_address(const LinphoneCallLog *cl){
|
||||
const LinphoneAddress *linphone_call_log_get_local_address(const LinphoneCallLog *cl) {
|
||||
return (cl->dir == LinphoneCallIncoming) ? cl->to : cl->from;
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_call_log_get_remote_address(const LinphoneCallLog *cl){
|
||||
return (cl->dir == LinphoneCallIncoming) ? cl->from : cl->to;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "linphone/wrapper_utils.h"
|
||||
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "call/call.h"
|
||||
#include "chat/chat-room/basic-chat-room.h"
|
||||
#include "chat/chat-room/client-group-chat-room.h"
|
||||
#include "chat/chat-room/client-group-to-basic-chat-room.h"
|
||||
|
|
@ -149,12 +150,9 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
|
|||
}
|
||||
|
||||
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call) {
|
||||
if (linphone_core_realtime_text_enabled(lc)) {
|
||||
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
|
||||
static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_OBJECT(cr));
|
||||
L_GET_PRIVATE(rttcr)->realtimeTextReceived(character, call);
|
||||
//L_GET_PRIVATE(static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_OBJECT(cr)))->realtimeTextReceived(character, call);
|
||||
}
|
||||
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
|
||||
return;
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->realtimeTextReceived(character, L_GET_CPP_PTR_FROM_C_OBJECT(call));
|
||||
}
|
||||
|
||||
unsigned int linphone_chat_message_store(LinphoneChatMessage *msg) {
|
||||
|
|
|
|||
|
|
@ -151,11 +151,6 @@ struct _LinphoneAuthInfo
|
|||
char *algorithm;
|
||||
};
|
||||
|
||||
struct _LinphoneChatMessageCharacter {
|
||||
uint32_t value;
|
||||
bool_t has_been_read;
|
||||
};
|
||||
|
||||
struct _LinphoneFriendPresence {
|
||||
char *uri_or_tel;
|
||||
LinphonePresenceModel *presence;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ typedef struct StunCandidate StunCandidate;
|
|||
|
||||
typedef struct _PortConfig PortConfig;
|
||||
|
||||
typedef struct _LinphoneChatMessageCharacter LinphoneChatMessageCharacter;
|
||||
|
||||
typedef struct _LinphoneFriendPresence LinphoneFriendPresence;
|
||||
|
||||
typedef struct _LinphoneFriendPhoneNumberSipUri LinphoneFriendPhoneNumberSipUri;
|
||||
|
|
|
|||
|
|
@ -90,12 +90,19 @@ LINPHONE_PUBLIC float linphone_call_log_get_quality(const LinphoneCallLog *cl);
|
|||
**/
|
||||
LINPHONE_PUBLIC const char * linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
|
||||
|
||||
/**
|
||||
* Get the local address (that is from or to depending on call direction)
|
||||
* @param[in] cl LinphoneCallLog object
|
||||
* @return The local address of the call
|
||||
*/
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_call_log_get_local_address(const LinphoneCallLog *cl);
|
||||
|
||||
/**
|
||||
* Get the remote address (that is from or to depending on call direction).
|
||||
* @param[in] cl LinphoneCallLog object
|
||||
* @return The remote address of the call.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneAddress * linphone_call_log_get_remote_address(const LinphoneCallLog *cl);
|
||||
LINPHONE_PUBLIC const LinphoneAddress * linphone_call_log_get_remote_address(const LinphoneCallLog *cl);
|
||||
|
||||
/**
|
||||
* Get the RTP statistics computed by the remote end and sent back via RTCP.
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "call/call.h"
|
||||
#include "call/local-conference-call.h"
|
||||
#include "call/remote-conference-call.h"
|
||||
#include "chat/chat-room/real-time-text-chat-room.h"
|
||||
#include "conference/params/media-session-params-p.h"
|
||||
#include "core/core-p.h"
|
||||
|
||||
|
|
@ -246,7 +247,7 @@ const char *linphone_call_get_to_header (const LinphoneCall *call, const char *n
|
|||
}
|
||||
|
||||
char *linphone_call_get_remote_address_as_string (const LinphoneCall *call) {
|
||||
return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddressAsString().c_str());
|
||||
return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddress().asString().c_str());
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_call_get_diversion_address (const LinphoneCall *call) {
|
||||
|
|
@ -538,16 +539,10 @@ bool_t linphone_call_echo_limiter_enabled (const LinphoneCall *call) {
|
|||
}
|
||||
|
||||
LinphoneChatRoom *linphone_call_get_chat_room (LinphoneCall *call) {
|
||||
#if 0
|
||||
if (!call->chat_room){
|
||||
if (call->state != LinphoneCallReleased && call->state != LinphoneCallEnd){
|
||||
call->chat_room = _linphone_core_create_chat_room_from_call(call);
|
||||
}
|
||||
}
|
||||
return call->chat_room;
|
||||
#else
|
||||
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> acr = L_GET_PRIVATE_FROM_C_OBJECT(call)->getChatRoom();
|
||||
if (acr)
|
||||
return L_GET_C_BACK_PTR(acr);
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
float linphone_call_get_play_volume (const LinphoneCall *call) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "address/identity-address.h"
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "call/call.h"
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "chat/chat-room/basic-chat-room.h"
|
||||
#include "chat/chat-room/client-group-chat-room-p.h"
|
||||
|
|
@ -156,9 +157,9 @@ void linphone_chat_room_receive_chat_message (LinphoneChatRoom *cr, LinphoneChat
|
|||
}
|
||||
|
||||
uint32_t linphone_chat_room_get_char (const LinphoneChatRoom *cr) {
|
||||
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getChar();
|
||||
return 0;
|
||||
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
|
||||
return 0;
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getChar();
|
||||
}
|
||||
|
||||
void linphone_chat_room_compose (LinphoneChatRoom *cr) {
|
||||
|
|
@ -166,14 +167,15 @@ void linphone_chat_room_compose (LinphoneChatRoom *cr) {
|
|||
}
|
||||
|
||||
LinphoneCall *linphone_chat_room_get_call (const LinphoneChatRoom *cr) {
|
||||
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getCall();
|
||||
return nullptr;
|
||||
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
|
||||
return nullptr;
|
||||
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getCall());
|
||||
}
|
||||
|
||||
void linphone_chat_room_set_call (LinphoneChatRoom *cr, LinphoneCall *call) {
|
||||
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->call = 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 = L_GET_CPP_PTR_FROM_C_OBJECT(call);
|
||||
}
|
||||
|
||||
void linphone_chat_room_mark_as_read (LinphoneChatRoom *cr) {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class CallSession;
|
||||
class RealTimeTextChatRoom;
|
||||
|
||||
class CallPrivate : public ObjectPrivate, public CallSessionListener {
|
||||
public:
|
||||
|
|
@ -50,6 +51,7 @@ public:
|
|||
|
||||
virtual std::shared_ptr<CallSession> getActiveSession () const { return nullptr; }
|
||||
bool getAudioMuted () const;
|
||||
std::shared_ptr<RealTimeTextChatRoom> getChatRoom ();
|
||||
|
||||
LinphoneProxyConfig *getDestProxy () const;
|
||||
IceSession *getIceSession () const;
|
||||
|
|
@ -109,6 +111,7 @@ private:
|
|||
void onStopRingingIfNeeded (const std::shared_ptr<const CallSession> &session) override;
|
||||
bool areSoundResourcesAvailable (const std::shared_ptr<const CallSession> &session) override;
|
||||
bool isPlayingRingbackTone (const std::shared_ptr<const CallSession> &session) override;
|
||||
void onRealTimeTextCharacterReceived (const std::shared_ptr<const CallSession> &session, RealtimeTextReceivedCharacter *character) override;
|
||||
|
||||
mutable LinphonePlayer *player = nullptr;
|
||||
|
||||
|
|
@ -119,6 +122,8 @@ private:
|
|||
|
||||
BackgroundTask bgTask;
|
||||
|
||||
mutable std::shared_ptr<RealTimeTextChatRoom> chatRoom;
|
||||
|
||||
L_DECLARE_PUBLIC(Call);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "call-p.h"
|
||||
#include "chat/chat-room/real-time-text-chat-room-p.h"
|
||||
#include "conference/params/media-session-params-p.h"
|
||||
#include "conference/session/call-session-p.h"
|
||||
#include "conference/session/media-session-p.h"
|
||||
|
|
@ -37,6 +38,17 @@ bool CallPrivate::getAudioMuted () const {
|
|||
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getAudioMuted();
|
||||
}
|
||||
|
||||
shared_ptr<RealTimeTextChatRoom> CallPrivate::getChatRoom () {
|
||||
L_Q();
|
||||
if (!chatRoom && (q->getState() != CallSession::State::End) && (q->getState() != CallSession::State::Released)) {
|
||||
ChatRoomId chatRoomId(q->getRemoteAddress(), q->getLocalAddress());
|
||||
RealTimeTextChatRoom *rttcr = new RealTimeTextChatRoom(q->getCore(), chatRoomId);
|
||||
chatRoom.reset(rttcr);
|
||||
rttcr->getPrivate()->setCall(q->getSharedFromThis());
|
||||
}
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
LinphoneProxyConfig *CallPrivate::getDestProxy () const {
|
||||
return getActiveSession()->getPrivate()->getDestProxy();
|
||||
}
|
||||
|
|
@ -167,7 +179,7 @@ void CallPrivate::startRemoteRing () {
|
|||
|
||||
void CallPrivate::terminateBecauseOfLostMedia () {
|
||||
L_Q();
|
||||
lInfo() << "Call [" << q << "]: Media connectivity with " << q->getRemoteAddressAsString()
|
||||
lInfo() << "Call [" << q << "]: Media connectivity with " << q->getRemoteAddress().asString()
|
||||
<< " is lost, call is going to be terminated";
|
||||
static_pointer_cast<MediaSession>(getActiveSession())->terminateBecauseOfLostMedia();
|
||||
linphone_core_play_named_tone(q->getCore()->getCCore(), LinphoneToneCallLost);
|
||||
|
|
@ -459,6 +471,11 @@ bool CallPrivate::isPlayingRingbackTone (const shared_ptr<const CallSession> &se
|
|||
return playingRingbackTone;
|
||||
}
|
||||
|
||||
void CallPrivate::onRealTimeTextCharacterReceived (const shared_ptr<const CallSession> &session, RealtimeTextReceivedCharacter *data) {
|
||||
L_Q();
|
||||
getChatRoom()->getPrivate()->realtimeTextReceived(data->character, q->getSharedFromThis());
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Call::Call (CallPrivate &p, shared_ptr<Core> core) : Object(p), CoreAccessor(core) {
|
||||
|
|
@ -682,6 +699,11 @@ const LinphoneErrorInfo *Call::getErrorInfo () const {
|
|||
return d->getActiveSession()->getErrorInfo();
|
||||
}
|
||||
|
||||
const Address &Call::getLocalAddress () const {
|
||||
L_D();
|
||||
return d->getActiveSession()->getLocalAddress();
|
||||
}
|
||||
|
||||
LinphoneCallLog *Call::getLog () const {
|
||||
L_D();
|
||||
return d->getActiveSession()->getLog();
|
||||
|
|
@ -756,11 +778,6 @@ const Address &Call::getRemoteAddress () const {
|
|||
return d->getActiveSession()->getRemoteAddress();
|
||||
}
|
||||
|
||||
string Call::getRemoteAddressAsString () const {
|
||||
L_D();
|
||||
return d->getActiveSession()->getRemoteAddressAsString();
|
||||
}
|
||||
|
||||
string Call::getRemoteContact () const {
|
||||
L_D();
|
||||
return d->getActiveSession()->getRemoteContact();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class MediaSessionPrivate;
|
|||
|
||||
class Call : public Object, public CoreAccessor {
|
||||
friend class CallSessionPrivate;
|
||||
friend class ChatMessage;
|
||||
friend class CorePrivate;
|
||||
friend class MediaSessionPrivate;
|
||||
|
||||
|
|
@ -85,6 +86,7 @@ public:
|
|||
const Address &getDiversionAddress () const;
|
||||
int getDuration () const;
|
||||
const LinphoneErrorInfo *getErrorInfo () const;
|
||||
const Address &getLocalAddress () const;
|
||||
LinphoneCallLog *getLog () const;
|
||||
RtpTransport *getMetaRtcpTransport (int streamIndex) const;
|
||||
RtpTransport *getMetaRtpTransport (int streamIndex) const;
|
||||
|
|
@ -98,7 +100,6 @@ public:
|
|||
std::shared_ptr<Call> getReferer () const;
|
||||
std::string getReferTo () const;
|
||||
const Address &getRemoteAddress () const;
|
||||
std::string getRemoteAddressAsString () const;
|
||||
std::string getRemoteContact () const;
|
||||
const MediaSessionParams *getRemoteParams () const;
|
||||
std::string getRemoteUserAgent () const;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "address/address.h"
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "call/call.h"
|
||||
#include "call/call-p.h"
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "chat/chat-room/chat-room-p.h"
|
||||
#include "chat/chat-room/client-group-to-basic-chat-room.h"
|
||||
|
|
@ -981,48 +981,50 @@ void ChatMessage::cancelFileTransfer () {
|
|||
int ChatMessage::putCharacter (uint32_t character) {
|
||||
L_D();
|
||||
|
||||
shared_ptr<Core> core = getCore();
|
||||
if (linphone_core_realtime_text_enabled(core->getCCore())) {
|
||||
static const uint32_t new_line = 0x2028;
|
||||
static const uint32_t crlf = 0x0D0A;
|
||||
static const uint32_t lf = 0x0A;
|
||||
static const uint32_t new_line = 0x2028;
|
||||
static const uint32_t crlf = 0x0D0A;
|
||||
static const uint32_t lf = 0x0A;
|
||||
|
||||
shared_ptr<AbstractChatRoom> chatRoom = getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = getChatRoom();
|
||||
if (!(chatRoom->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
|
||||
return -1;
|
||||
|
||||
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
|
||||
static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(chatRoom);
|
||||
LinphoneCall *call = rttcr->getCall();
|
||||
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
|
||||
static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(chatRoom);
|
||||
if (!rttcr)
|
||||
return -1;
|
||||
|
||||
if (!call || !linphone_call_get_stream(call, LinphoneStreamTypeText))
|
||||
return -1;
|
||||
shared_ptr<Call> call = rttcr->getCall();
|
||||
if (!call || !call->getPrivate()->getMediaStream(LinphoneStreamTypeText))
|
||||
return -1;
|
||||
|
||||
if (character == new_line || character == crlf || character == lf) {
|
||||
if (lp_config_get_int(core->getCCore()->config, "misc", "store_rtt_messages", 1) == 1) {
|
||||
// TODO: History.
|
||||
lDebug() << "New line sent, forge a message with content " << d->rttMessage.c_str();
|
||||
d->setTime(ms_time(0));
|
||||
d->state = State::Displayed;
|
||||
// d->direction = Direction::Outgoing;
|
||||
// setFromAddress(Address(
|
||||
// linphone_address_as_string(linphone_address_new(linphone_core_get_identity(core->getCCore())))
|
||||
// ));
|
||||
// linphone_chat_message_store(L_GET_C_BACK_PTR(this));
|
||||
d->rttMessage = "";
|
||||
}
|
||||
} else {
|
||||
char *value = LinphonePrivate::Utils::utf8ToChar(character);
|
||||
d->rttMessage = d->rttMessage + string(value);
|
||||
lDebug() << "Sent RTT character: " << value << "(" << (unsigned long)character <<
|
||||
"), pending text is " << d->rttMessage.c_str();
|
||||
delete value;
|
||||
if (character == new_line || character == crlf || character == lf) {
|
||||
shared_ptr<Core> core = getCore();
|
||||
if (lp_config_get_int(core->getCCore()->config, "misc", "store_rtt_messages", 1) == 1) {
|
||||
// TODO: History.
|
||||
lDebug() << "New line sent, forge a message with content " << d->rttMessage.c_str();
|
||||
d->setTime(ms_time(0));
|
||||
d->state = State::Displayed;
|
||||
// d->direction = Direction::Outgoing;
|
||||
// setFromAddress(Address(
|
||||
// linphone_address_as_string(linphone_address_new(linphone_core_get_identity(core->getCCore())))
|
||||
// ));
|
||||
// linphone_chat_message_store(L_GET_C_BACK_PTR(this));
|
||||
d->rttMessage = "";
|
||||
}
|
||||
|
||||
text_stream_putchar32(reinterpret_cast<TextStream *>(
|
||||
linphone_call_get_stream(call, LinphoneStreamTypeText)), character
|
||||
);
|
||||
return 0;
|
||||
} else {
|
||||
char *value = LinphonePrivate::Utils::utf8ToChar(character);
|
||||
d->rttMessage = d->rttMessage + string(value);
|
||||
lDebug() << "Sent RTT character: " << value << "(" << (unsigned long)character <<
|
||||
"), pending text is " << d->rttMessage.c_str();
|
||||
delete[] value;
|
||||
}
|
||||
return -1;
|
||||
|
||||
text_stream_putchar32(
|
||||
reinterpret_cast<TextStream *>(call->getPrivate()->getMediaStream(LinphoneStreamTypeText)),
|
||||
character
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -29,13 +29,19 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
class RealTimeTextChatRoomPrivate : public BasicChatRoomPrivate {
|
||||
public:
|
||||
struct Character {
|
||||
uint32_t value;
|
||||
bool hasBeenRead;
|
||||
};
|
||||
|
||||
RealTimeTextChatRoomPrivate () = default;
|
||||
|
||||
void realtimeTextReceived (uint32_t character, LinphoneCall *call);
|
||||
void realtimeTextReceived (uint32_t character, const std::shared_ptr<Call> &call);
|
||||
void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
void setCall (const std::shared_ptr<Call> &value) { call = value; }
|
||||
|
||||
LinphoneCall *call = nullptr;
|
||||
std::list<LinphoneChatMessageCharacter *> receivedRttCharacters;
|
||||
std::weak_ptr<Call> call;
|
||||
std::list<Character> receivedRttCharacters;
|
||||
std::shared_ptr<ChatMessage> pendingMessage = nullptr;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "call/call.h"
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "conference/participant.h"
|
||||
#include "core/core.h"
|
||||
|
|
@ -32,7 +33,7 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, LinphoneCall *call) {
|
||||
void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, const shared_ptr<Call> &call) {
|
||||
L_Q();
|
||||
const uint32_t new_line = 0x2028;
|
||||
const uint32_t crlf = 0x0D0A;
|
||||
|
|
@ -41,14 +42,13 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, Linp
|
|||
shared_ptr<Core> core = q->getCore();
|
||||
LinphoneCore *cCore = core->getCCore();
|
||||
|
||||
if (call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call))) {
|
||||
LinphoneChatMessageCharacter *cmc = bctbx_new0(LinphoneChatMessageCharacter, 1);
|
||||
|
||||
if (call && call->getCurrentParams()->realtimeTextEnabled()) {
|
||||
if (!pendingMessage)
|
||||
pendingMessage = q->createChatMessage("");
|
||||
|
||||
cmc->value = character;
|
||||
cmc->has_been_read = FALSE;
|
||||
Character cmc;
|
||||
cmc.value = character;
|
||||
cmc.hasBeenRead = false;
|
||||
receivedRttCharacters.push_back(cmc);
|
||||
|
||||
remoteIsComposing.push_back(q->getPeerAddress());
|
||||
|
|
@ -74,23 +74,24 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, Linp
|
|||
|
||||
onChatMessageReceived(pendingMessage);
|
||||
pendingMessage = nullptr;
|
||||
for (auto &rttChars : receivedRttCharacters)
|
||||
ms_free(rttChars);
|
||||
receivedRttCharacters.clear();
|
||||
} else {
|
||||
char *value = Utils::utf8ToChar(character);
|
||||
char *text = (char *)pendingMessage->getPrivate()->getText().c_str();
|
||||
pendingMessage->getPrivate()->setText(ms_strcat_printf(text, value));
|
||||
lDebug() << "Received RTT character: " << value << " (" << character << "), pending text is " << pendingMessage->getPrivate()->getText();
|
||||
delete value;
|
||||
string text(pendingMessage->getPrivate()->getText());
|
||||
text += string(value);
|
||||
pendingMessage->getPrivate()->setText(text);
|
||||
lInfo() << "Received RTT character: " << value << " (" << character << "), pending text is " << pendingMessage->getPrivate()->getText();
|
||||
delete[] value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RealTimeTextChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage> &chatMessage) {
|
||||
if (call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call))) {
|
||||
uint32_t new_line = 0x2028;
|
||||
chatMessage->putCharacter(new_line);
|
||||
L_Q();
|
||||
shared_ptr<Call> call = q->getCall();
|
||||
if (call && call->getCurrentParams()->realtimeTextEnabled()) {
|
||||
uint32_t newLine = 0x2028;
|
||||
chatMessage->putCharacter(newLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,26 +100,16 @@ void RealTimeTextChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage>
|
|||
RealTimeTextChatRoom::RealTimeTextChatRoom (const shared_ptr<Core> &core, const ChatRoomId &chatRoomId) :
|
||||
BasicChatRoom(*new RealTimeTextChatRoomPrivate, core, chatRoomId) {}
|
||||
|
||||
RealTimeTextChatRoom::~RealTimeTextChatRoom () {
|
||||
L_D();
|
||||
|
||||
if (!d->receivedRttCharacters.empty())
|
||||
for (auto &rttChars : d->receivedRttCharacters)
|
||||
bctbx_free(rttChars);
|
||||
}
|
||||
|
||||
RealTimeTextChatRoom::CapabilitiesMask RealTimeTextChatRoom::getCapabilities () const {
|
||||
return BasicChatRoom::getCapabilities() | Capabilities::RealTimeText;
|
||||
}
|
||||
|
||||
uint32_t RealTimeTextChatRoom::getChar () const {
|
||||
L_D();
|
||||
if (!d->receivedRttCharacters.empty()) {
|
||||
for (auto &cmc : d->receivedRttCharacters) {
|
||||
if (!cmc->has_been_read) {
|
||||
cmc->has_been_read = TRUE;
|
||||
return cmc->value;
|
||||
}
|
||||
for (const auto &cmc : d->receivedRttCharacters) {
|
||||
if (!cmc.hasBeenRead) {
|
||||
const_cast<RealTimeTextChatRoomPrivate::Character *>(&cmc)->hasBeenRead = true;
|
||||
return cmc.value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -126,9 +117,9 @@ uint32_t RealTimeTextChatRoom::getChar () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LinphoneCall *RealTimeTextChatRoom::getCall () const {
|
||||
shared_ptr<Call> RealTimeTextChatRoom::getCall () const {
|
||||
L_D();
|
||||
return d->call;
|
||||
return d->call.lock();
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -26,18 +26,20 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class Call;
|
||||
class RealTimeTextChatRoomPrivate;
|
||||
|
||||
class LINPHONE_PUBLIC RealTimeTextChatRoom : public BasicChatRoom {
|
||||
friend class CallPrivate;
|
||||
friend class CorePrivate;
|
||||
|
||||
public:
|
||||
~RealTimeTextChatRoom ();
|
||||
~RealTimeTextChatRoom () = default;
|
||||
|
||||
CapabilitiesMask getCapabilities () const override;
|
||||
|
||||
uint32_t getChar () const;
|
||||
LinphoneCall *getCall () const;
|
||||
std::shared_ptr<Call> getCall () const;
|
||||
|
||||
private:
|
||||
RealTimeTextChatRoom (const std::shared_ptr<Core> &core, const ChatRoomId &chatRoomId);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "conference/session/call-session.h"
|
||||
|
||||
#include <mediastreamer2/msrtt4103.h>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
|
@ -75,6 +77,8 @@ public:
|
|||
|
||||
virtual bool areSoundResourcesAvailable (const std::shared_ptr<const CallSession> &session) { return true; }
|
||||
virtual bool isPlayingRingbackTone (const std::shared_ptr<const CallSession> &session) { return false; }
|
||||
|
||||
virtual void onRealTimeTextCharacterReceived (const std::shared_ptr<const CallSession> &session, RealtimeTextReceivedCharacter *data) {}
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1226,6 +1226,12 @@ const LinphoneErrorInfo * CallSession::getErrorInfo () const {
|
|||
return d->ei;
|
||||
}
|
||||
|
||||
const Address& CallSession::getLocalAddress () const {
|
||||
L_D();
|
||||
return *L_GET_CPP_PTR_FROM_C_OBJECT((d->direction == LinphoneCallIncoming)
|
||||
? linphone_call_log_get_to(d->log) : linphone_call_log_get_from(d->log));
|
||||
}
|
||||
|
||||
LinphoneCallLog * CallSession::getLog () const {
|
||||
L_D();
|
||||
return d->log;
|
||||
|
|
@ -1251,10 +1257,6 @@ const Address& CallSession::getRemoteAddress () const {
|
|||
? linphone_call_log_get_from(d->log) : linphone_call_log_get_to(d->log));
|
||||
}
|
||||
|
||||
string CallSession::getRemoteAddressAsString () const {
|
||||
return getRemoteAddress().asString();
|
||||
}
|
||||
|
||||
string CallSession::getRemoteContact () const {
|
||||
L_D();
|
||||
if (d->op) {
|
||||
|
|
|
|||
|
|
@ -78,23 +78,23 @@ public:
|
|||
|
||||
CallSessionParams *getCurrentParams () const;
|
||||
LinphoneCallDir getDirection () const;
|
||||
const Address& getDiversionAddress () const;
|
||||
const Address &getDiversionAddress () const;
|
||||
int getDuration () const;
|
||||
const LinphoneErrorInfo * getErrorInfo () const;
|
||||
LinphoneCallLog * getLog () const;
|
||||
const Address &getLocalAddress () const;
|
||||
LinphoneCallLog *getLog () const;
|
||||
virtual const CallSessionParams *getParams () const;
|
||||
LinphoneReason getReason () const;
|
||||
std::shared_ptr<CallSession> getReferer () const;
|
||||
std::string getReferTo () const;
|
||||
const Address& getRemoteAddress () const;
|
||||
std::string getRemoteAddressAsString () const;
|
||||
const Address &getRemoteAddress () const;
|
||||
std::string getRemoteContact () const;
|
||||
const Address *getRemoteContactAddress () const;
|
||||
const CallSessionParams *getRemoteParams ();
|
||||
std::string getRemoteUserAgent () const;
|
||||
std::shared_ptr<CallSession> getReplacedCallSession () const;
|
||||
CallSession::State getState () const;
|
||||
const Address& getToAddress () const;
|
||||
const Address &getToAddress () const;
|
||||
CallSession::State getTransferState () const;
|
||||
std::shared_ptr<CallSession> getTransferTarget () const;
|
||||
std::string getToHeader (const std::string &name) const;
|
||||
|
|
|
|||
|
|
@ -2830,7 +2830,7 @@ void MediaSessionPrivate::startTextStream () {
|
|||
rtp_session_set_multicast_ttl(textStream->ms.sessions.rtp_session, tstream->ttl);
|
||||
text_stream_start(textStream, textProfile, rtpAddr, tstream->rtp_port, rtcpAddr,
|
||||
(linphone_core_rtcp_enabled(q->getCore()->getCCore()) && !isMulticast) ? (tstream->rtcp_port ? tstream->rtcp_port : tstream->rtp_port + 1) : 0, usedPt);
|
||||
ms_filter_add_notify_callback(textStream->rttsink, realTimeTextCharacterReceived, q, false);
|
||||
ms_filter_add_notify_callback(textStream->rttsink, realTimeTextCharacterReceived, this, false);
|
||||
ms_media_stream_sessions_set_encryption_mandatory(&textStream->ms.sessions, isEncryptionMandatory());
|
||||
}
|
||||
} else
|
||||
|
|
@ -3806,12 +3806,11 @@ void MediaSessionPrivate::videoStreamEventCb (const MSFilter *f, const unsigned
|
|||
#endif
|
||||
|
||||
void MediaSessionPrivate::realTimeTextCharacterReceived (MSFilter *f, unsigned int id, void *arg) {
|
||||
L_Q();
|
||||
if (id == MS_RTT_4103_RECEIVED_CHAR) {
|
||||
#if 0
|
||||
RealtimeTextReceivedCharacter *data = reinterpret_cast<RealtimeTextReceivedCharacter *>(arg);
|
||||
LinphoneChatRoom * chat_room = linphone_call_get_chat_room(call);
|
||||
linphone_core_real_time_text_received(call->core, chat_room, data->character, call);
|
||||
#endif
|
||||
if (listener)
|
||||
listener->onRealTimeTextCharacterReceived(q->getSharedFromThis(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1709,6 +1709,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo
|
|||
}
|
||||
linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message);
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1));
|
||||
linphone_chat_message_unref(rtt_message);
|
||||
|
||||
if (sql_storage) {
|
||||
bctbx_list_t *marie_messages = linphone_chat_room_get_history(marie_chat_room, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue