From e741162d9e6051ea74dcaefb789235ce5b490f86 Mon Sep 17 00:00:00 2001 From: sauwming Date: Fri, 20 Dec 2024 16:41:51 +0800 Subject: [PATCH] Fixed Buddy to use correct account during subscription --- pjsip/include/pjsua-lib/pjsua_internal.h | 1 + pjsip/src/pjsua-lib/pjsua_pres.c | 4 +++- pjsip/src/pjsua2/presence.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index ca38660b8b..4750eb7ffc 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -368,6 +368,7 @@ typedef struct pjsua_buddy { pj_pool_t *pool; /**< Pool for this buddy. */ unsigned index; /**< Buddy index. */ + pjsua_acc_id acc_id; /**< Account index. */ void *user_data; /**< Application data. */ pj_str_t uri; /**< Buddy URI. */ pj_str_t contact; /**< Contact learned from subscrp. */ diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index 2ed8d359fd..a3403db03e 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -467,6 +467,7 @@ static void reset_buddy(pjsua_buddy_id id) pj_bzero(&pjsua_var.buddy[id], sizeof(pjsua_var.buddy[id])); pjsua_var.buddy[id].pool = pool; pjsua_var.buddy[id].index = id; + pjsua_var.buddy[id].acc_id = PJSUA_INVALID_ID; } @@ -2013,7 +2014,8 @@ static void subscribe_buddy(pjsua_buddy_id buddy_id, dlg_event_callback.on_rx_notify = &pjsua_evsub_on_rx_dlg_event_notify; buddy = &pjsua_var.buddy[buddy_id]; - acc_id = pjsua_acc_find_for_outgoing(&buddy->uri); + acc_id = (buddy->acc_id != PJSUA_INVALID_ID)? buddy->acc_id: + pjsua_acc_find_for_outgoing(&buddy->uri); acc = &pjsua_var.acc[acc_id]; diff --git a/pjsip/src/pjsua2/presence.cpp b/pjsip/src/pjsua2/presence.cpp index 364c19a3e7..9bb07e8659 100644 --- a/pjsip/src/pjsua2/presence.cpp +++ b/pjsip/src/pjsua2/presence.cpp @@ -22,6 +22,8 @@ using namespace pj; using namespace std; +#include + #define THIS_FILE "presence.cpp" @@ -141,6 +143,7 @@ void Buddy::create(Account &account, const BuddyConfig &cfg) PJSUA2_CHECK_EXPR( pjsua_buddy_add(&pj_cfg, &id) ); account.addBuddy(this); + pjsua_var.buddy[id].acc_id = account.getId(); } int Buddy::getId() const