diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-08 19:51:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-08 19:51:35 +0300 |
commit | 0b5fbaf1808367a10424e395fca1231790bc5ae7 (patch) | |
tree | 8a5a43f44362fa95eedcffcb399fa4b4bb430be1 | |
parent | 7ef04dbd77d561031c318f6066783e1b279d541c (diff) |
Jabber: more voip
-rw-r--r-- | plugins/ExternalAPI/m_voice.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 22 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opt.cpp | 13 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 13 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 49 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_voip.cpp | 55 |
7 files changed, 101 insertions, 54 deletions
diff --git a/plugins/ExternalAPI/m_voice.h b/plugins/ExternalAPI/m_voice.h index 046eae5383..b538d6d4a3 100644 --- a/plugins/ExternalAPI/m_voice.h +++ b/plugins/ExternalAPI/m_voice.h @@ -51,7 +51,7 @@ struct VOICE_CALL { int cbSize; // Struct size const char *moduleName; // The name of the module (the same as VOICE_MODULE.name or the protocol szModule) - char *id; // Protocol especific ID for this call + const char *id; // Protocol specific ID for this call int flags; // VOICE_UNICODE to say the string is unicode or 0. VOICE_SECURE to say this is an encrypted call // Either contact or number must be != NULL diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 18dbc9d928..920d390f1a 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -47,7 +47,6 @@ static HGENMENU g_hMenuSendNote; static HGENMENU g_hMenuResourcesRoot;
static HGENMENU g_hMenuResourcesActive;
static HGENMENU g_hMenuResourcesServer;
-static HGENMENU g_hMenuVoiceCall;
struct
{
@@ -122,19 +121,11 @@ static int JabberPrebuildContactMenu(WPARAM hContact, LPARAM lParam) Menu_ShowItem(g_hMenuAddBookmark, false);
Menu_ShowItem(g_hMenuResourcesRoot, false);
Menu_ShowItem(g_hMenuDirectPresence[0], false);
- Menu_ShowItem(g_hMenuVoiceCall, false);
CJabberProto *ppro = CMPlugin::getInstance(hContact);
return(ppro) ? ppro->OnPrebuildContactMenu(hContact, lParam) : 0;
}
-static INT_PTR JabberVOIPCallIinitiate(WPARAM hContact, LPARAM)
-{
- CJabberProto *ppro = CMPlugin::getInstance(hContact);
- ppro->VOIPCallIinitiate(hContact);
- return 0;
-}
-
void g_MenuInit(void)
{
hStatusMenuInit = CreateHookableEvent(ME_JABBER_MENUINIT);
@@ -254,16 +245,6 @@ void g_MenuInit(void) mi.hIcolibItem = g_plugin.getIconHandle(IDI_NODE_SERVER);
g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi);
CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER);
-
- SET_UID(mi, 0x2fe60fc5, 0x6417, 0x4f37, 0xa0, 0xbe, 0xa0, 0x59, 0x94, 0x11, 0x1d, 0xd9);
- mi.root = nullptr;
- mi.flags = 0;
- mi.hIcolibItem = g_plugin.getIconHandle(IDI_NODE_RSS);
- mi.name.a = LPGEN("Voice call");
- mi.pszService = "Jabber/VOIPCallIinitiate";
- mi.position = -1999902010;
- g_hMenuVoiceCall = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, JabberVOIPCallIinitiate);
}
void g_MenuUninit(void)
@@ -315,9 +296,6 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(g_hMenuRefresh, true);
}
- if (m_bEnableVOIP)
- Menu_ShowItem(g_hMenuVoiceCall, true);
-
ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return 0;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 97f27a7db4..dd3308ae2a 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -764,8 +764,19 @@ public: else
m_proto->m_omemo.deinit();
- if (!m_proto->m_bEnableVOIP)
+ // Voip
+ VOICE_MODULE vsr = {};
+ vsr.cbSize = sizeof(VOICE_MODULE);
+ vsr.description = L"XMPP/DTLS-SRTP";
+ vsr.name = m_proto->m_szModuleName;
+ vsr.icon = g_plugin.getIconHandle(IDI_NOTES);
+ vsr.flags = 3;
+ if (m_proto->m_bEnableVOIP)
+ CallService(MS_VOICESERVICE_REGISTER, (WPARAM)&vsr, 0);
+ else {
m_proto->VOIPTerminateSession();
+ CallService(MS_VOICESERVICE_UNREGISTER, (WPARAM)&vsr, 0);
+ }
m_proto->UpdateFeatHash();
m_proto->SendPresence(m_proto->m_iStatus, true);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index db9d903b56..3dd1f5ebc7 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -269,11 +269,24 @@ CJabberProto::~CJabberProto() if (m_hPopupClass)
Popup_UnregisterClass(m_hPopupClass);
+ // Events
DestroyHookableEvent(m_hEventNudge);
DestroyHookableEvent(m_hEventXStatusIconChanged);
DestroyHookableEvent(m_hEventXStatusChanged);
DestroyHookableEvent(m_hVoiceEvent);
+ // Voice
+ VOIPTerminateSession();
+
+ VOICE_MODULE vsr = {};
+ vsr.cbSize = sizeof(VOICE_MODULE);
+ vsr.description = L"XMPP/DTLS-SRTP";
+ vsr.name = m_szModuleName;
+ vsr.icon = g_plugin.getIconHandle(IDI_NOTES);
+ vsr.flags = 3;
+ CallService(MS_VOICESERVICE_UNREGISTER, (WPARAM)&vsr, 0);
+
+ // Lists & strings
ListWipe();
mir_free(m_tszSelectedLang);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 8475e110f6..dc31a60dd2 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -904,6 +904,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface CMStringA m_voipSession, m_voipPeerJid;
CMStringA m_voipICEPwd, m_voipICEUfrag, m_medianame;
bool m_isOutgoing;
+ TiXmlDocument m_offerDoc; const TiXmlElement *m_offerNode;
HANDLE m_hVoiceEvent;
struct _GstElement *m_pipe1 = NULL;
struct _GstElement *m_webrtc1 = NULL;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 689e7b00a6..b8aede5040 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1786,19 +1786,30 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) const TiXmlElement *descr = XmlGetChildByTag(content, "description", "xmlns", JABBER_FEAT_JINGLE_RTP);
if (m_bEnableVOIP && m_voipSession == "" && descr) {
- /* if (VOIPCallAccept(child, from)) {
- m_voipSession = szSid;
- m_voipPeerJid = from;
- return true;
- }*/
+ m_voipSession = szSid;
+ m_voipPeerJid = from;
+ m_offerNode = child->DeepClone(&m_offerDoc)->ToElement();
+
+ //Make call GUI
VOICE_CALL vc = {};
vc.cbSize = sizeof(VOICE_CALL);
vc.moduleName = m_szModuleName;
- vc.id = "jvhvjvjbj"; // Protocol especific ID for this call
- vc.flags = 0;
- vc.hContact = HContactFromJID(from); // Contact associated with the call (can be NULL)
+ vc.id = szSid; // Protocol specific ID for this call
+ vc.hContact = HContactFromJID(from); // Contact associated with the call (can be NULL)
vc.state = VOICE_STATE_RINGING;
NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0);
+
+ // ringing message
+ XmlNodeIq iq("set", SerialNext(), from);
+ TiXmlElement *rjNode = iq << XCHILDNS("jingle", JABBER_FEAT_JINGLE);
+ rjNode << XATTR("action", "session-info");
+ if (szInitiator)
+ rjNode << XATTR("initiator", szInitiator);
+ if (szSid)
+ rjNode << XATTR("sid", szSid);
+ rjNode << XCHILDNS("ringing", "urn:xmpp:jingle:apps:rtp:info:1");
+
+ m_ThreadInfo->send(iq);
return true;
}
@@ -1817,7 +1828,17 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) else if (!mir_strcmp(szAction, "session-accept")) {
if (m_bEnableVOIP && m_voipSession == szSid) {
m_ThreadInfo->send(XmlNodeIq("result", idStr, from));
- OnRTPDescription(child);
+ if(OnRTPDescription(child)) {
+ //Make call GUI
+ VOICE_CALL vc = {};
+ vc.cbSize = sizeof(VOICE_CALL);
+ vc.moduleName = m_szModuleName;
+ vc.id = szSid;
+ vc.flags = 0;
+ vc.hContact = HContactFromJID(from);
+ vc.state = VOICE_STATE_TALKING;
+ NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0);
+ }
return true;
}
}
@@ -1825,6 +1846,16 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) if (m_bEnableVOIP && m_voipSession == szSid) {
// EndCall()
m_ThreadInfo->send(XmlNodeIq("result", idStr, from));
+
+ VOICE_CALL vc = {};
+ vc.cbSize = sizeof(VOICE_CALL);
+ vc.moduleName = m_szModuleName;
+ vc.id = szSid;
+ vc.flags = 0;
+ vc.hContact = HContactFromJID(from);
+ vc.state = VOICE_STATE_ENDED;
+ NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0);
+
VOIPTerminateSession();
m_voipSession.Empty();
m_voipPeerJid.Empty();
diff --git a/protocols/JabberG/src/jabber_voip.cpp b/protocols/JabberG/src/jabber_voip.cpp index c4f89786af..a982f86066 100644 --- a/protocols/JabberG/src/jabber_voip.cpp +++ b/protocols/JabberG/src/jabber_voip.cpp @@ -251,8 +251,8 @@ void send_ice_candidate_message_cb(G_GNUC_UNUSED GstElement */*webrtcbin*/, guin static gboolean check_plugins(void) { - const gchar *needed[] = { "opus", "nice", "webrtc", "dtls", "srtp", "rtpmanager", - /*"vpx", "videotestsrc", "audiotestsrc",*/ NULL }; + const gchar *needed[] = { "opus", "nice", "webrtc", "dtls", "srtp", "rtpmanager" + /*"vpx", "videotestsrc", "audiotestsrc",*/ }; GstRegistry *registry = gst_registry_get(); gst_registry_scan_path(registry, "libs\\gst_plugins"); @@ -506,37 +506,50 @@ bool CJabberProto::VOIPCallAccept(const TiXmlElement *jingleNode, const char *fr return false; OnRTPDescription(jingleNode); - - // ringing message - XmlNodeIq iq("set", SerialNext(), from); - TiXmlElement *rjNode = iq << XCHILDNS("jingle", JABBER_FEAT_JINGLE); - rjNode << XATTR("action", "session-info"); - const char *szInitiator = XmlGetAttr(jingleNode, "initiator"); - if (szInitiator) - rjNode << XATTR("initiator", szInitiator); - const char *szSid = XmlGetAttr(jingleNode, "sid"); - if (szSid) - rjNode << XATTR("sid", szSid); - rjNode << XCHILDNS("ringing", "urn:xmpp:jingle:apps:rtp:info:1"); - - m_ThreadInfo->send(iq); return true; } INT_PTR CJabberProto::JabberVOIP_call(WPARAM hContact, LPARAM) { - MessageBoxA(0,"CALL called", NULL,0); + if (VOIPCallIinitiate(hContact)) { + VOICE_CALL vc = {}; + vc.cbSize = sizeof(VOICE_CALL); + vc.moduleName = m_szModuleName; + vc.id = m_voipSession; // Protocol especific ID for this call + vc.flags = 0; + vc.hContact = hContact; // Contact associated with the call (can be NULL) + vc.state = VOICE_STATE_CALLING; + NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0); + } + return 0; } -INT_PTR CJabberProto::JabberVOIP_answercall(WPARAM hContact, LPARAM) +INT_PTR CJabberProto::JabberVOIP_answercall(WPARAM id, LPARAM) { - MessageBoxA(0,"ANSWER called", NULL,0); + VOICE_CALL vc = {}; + vc.cbSize = sizeof(VOICE_CALL); + vc.moduleName = m_szModuleName; + vc.id = (char *)id; + vc.flags = 0; + vc.hContact = HContactFromJID(m_voipPeerJid); + + vc.state = VOIPCallAccept(m_offerNode, m_voipPeerJid) ? VOICE_STATE_TALKING : VOICE_STATE_ENDED; + NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0); return 0; } -INT_PTR CJabberProto::JabberVOIP_dropcall(WPARAM hContact, LPARAM) +INT_PTR CJabberProto::JabberVOIP_dropcall(WPARAM id, LPARAM) { - MessageBoxA(0,"DROP called", NULL,0); + VOICE_CALL vc = {}; + vc.cbSize = sizeof(VOICE_CALL); + vc.moduleName = m_szModuleName; + vc.id = (char*)id; + vc.flags = 0; + vc.hContact = 0;//HContactFromJID(from); + vc.state = VOICE_STATE_ENDED; + NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0); + + VOIPTerminateSession(); return 0; } |