mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 12:38:09 +00:00
change LinphoneEvent from/to management to only use op
This commit is contained in:
parent
0e9a92ef5a
commit
078e2d461d
5 changed files with 44 additions and 32 deletions
|
|
@ -1075,7 +1075,7 @@ static void notify(SalOp *op, SalSubscribeStatus st, const char *eventname, cons
|
|||
|
||||
if (lev==NULL) {
|
||||
/*out of subscribe notify */
|
||||
lev=linphone_event_new_with_op(lc,op,LinphoneSubscriptionOutgoing,eventname);
|
||||
lev=linphone_event_new_with_out_of_dialog_op(lc,op,LinphoneSubscriptionOutgoing,eventname);
|
||||
}
|
||||
if (lc->vtable.notify_received){
|
||||
const LinphoneContent *ct=linphone_content_from_sal_body(&content,body);
|
||||
|
|
|
|||
|
|
@ -74,17 +74,17 @@ LinphoneEvent *linphone_event_new(LinphoneCore *lc, LinphoneSubscriptionDir dir,
|
|||
return lev;
|
||||
}
|
||||
|
||||
LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name){
|
||||
static LinphoneEvent *linphone_event_new_with_op_base(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name, bool_t is_out_of_dialog){
|
||||
LinphoneEvent *lev=linphone_event_new_base(lc, dir, name, op);
|
||||
if (dir==LinphoneSubscriptionIncoming){
|
||||
lev->resource_addr=linphone_address_clone((LinphoneAddress*)sal_op_get_to_address(op));
|
||||
lev->from=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(lev->op));
|
||||
}else{
|
||||
lev->resource_addr=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(op));
|
||||
}
|
||||
lev->is_out_of_dialog_op=is_out_of_dialog;
|
||||
return lev;
|
||||
}
|
||||
|
||||
LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name) {
|
||||
return linphone_event_new_with_op_base(lc,op,dir,name,FALSE);
|
||||
}
|
||||
LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name) {
|
||||
return linphone_event_new_with_op_base(lc,op,dir,name,TRUE);
|
||||
}
|
||||
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){
|
||||
LinphoneCore *lc=lev->lc;
|
||||
if (lev->subscription_state!=state){
|
||||
|
|
@ -129,8 +129,6 @@ LinphoneEvent *linphone_core_create_subscribe(LinphoneCore *lc, const LinphoneAd
|
|||
LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionOutgoing, event, expires);
|
||||
linphone_configure_op(lc,lev->op,resource,NULL,TRUE);
|
||||
sal_op_set_manual_refresher_mode(lev->op,!lp_config_get_int(lc->config,"sip","refresh_generic_subscribe",1));
|
||||
lev->resource_addr=linphone_address_clone(resource);
|
||||
lev->from=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(lev->op));
|
||||
return lev;
|
||||
}
|
||||
|
||||
|
|
@ -318,8 +316,6 @@ static void linphone_event_destroy(LinphoneEvent *lev){
|
|||
if (lev->op)
|
||||
sal_op_release(lev->op);
|
||||
ms_free(lev->name);
|
||||
if (lev->resource_addr) linphone_address_destroy(lev->resource_addr);
|
||||
if (lev->from) linphone_address_destroy(lev->from);
|
||||
ms_free(lev);
|
||||
}
|
||||
|
||||
|
|
@ -341,11 +337,19 @@ const char *linphone_event_get_name(const LinphoneEvent *lev){
|
|||
}
|
||||
|
||||
const LinphoneAddress *linphone_event_get_from(const LinphoneEvent *lev){
|
||||
return lev->from;
|
||||
if (lev->is_out_of_dialog_op){
|
||||
return (LinphoneAddress*)sal_op_get_to_address(lev->op);
|
||||
}else{
|
||||
return (LinphoneAddress*)sal_op_get_from_address(lev->op);
|
||||
}
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *lev){
|
||||
return lev->resource_addr;
|
||||
if (lev->is_out_of_dialog_op){
|
||||
return (LinphoneAddress*)sal_op_get_from_address(lev->op);
|
||||
}else{
|
||||
return (LinphoneAddress*)sal_op_get_to_address(lev->op);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneCore *linphone_event_get_core(const LinphoneEvent *lev){
|
||||
|
|
|
|||
|
|
@ -710,10 +710,9 @@ struct _LinphoneEvent{
|
|||
void *userdata;
|
||||
int refcnt;
|
||||
char *name;
|
||||
LinphoneAddress *from;
|
||||
LinphoneAddress *resource_addr;
|
||||
int expires;
|
||||
bool_t terminating;
|
||||
bool_t is_out_of_dialog_op; /*used for out of dialog notify*/
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -819,6 +818,10 @@ SalReason linphone_reason_to_sal(LinphoneReason reason);
|
|||
LinphoneReason linphone_reason_from_sal(SalReason reason);
|
||||
LinphoneEvent *linphone_event_new(LinphoneCore *lc, LinphoneSubscriptionDir dir, const char *name, int expires);
|
||||
LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name);
|
||||
/**
|
||||
* Useful for out of dialog notify
|
||||
* */
|
||||
LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name);
|
||||
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state);
|
||||
void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state);
|
||||
LinphoneSubscriptionState linphone_subscription_state_from_sal(SalSubscribeStatus ss);
|
||||
|
|
|
|||
|
|
@ -1388,31 +1388,32 @@ static void early_media_call_with_ringing(void){
|
|||
CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingRinging,1,1000));
|
||||
|
||||
|
||||
/* send a 183 to initiate the early media */
|
||||
if (linphone_core_inc_invite_pending(pauline->lc)) {
|
||||
/* send a 183 to initiate the early media */
|
||||
|
||||
linphone_core_accept_early_media(pauline->lc, linphone_core_get_current_call(pauline->lc));
|
||||
linphone_core_accept_early_media(pauline->lc, linphone_core_get_current_call(pauline->lc));
|
||||
|
||||
CU_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
|
||||
CU_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000) );
|
||||
CU_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
|
||||
CU_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000) );
|
||||
|
||||
liblinphone_tester_check_rtcp(marie, pauline);
|
||||
liblinphone_tester_check_rtcp(marie, pauline);
|
||||
|
||||
linphone_core_accept_call(pauline->lc, linphone_core_get_current_call(pauline->lc));
|
||||
linphone_core_accept_call(pauline->lc, linphone_core_get_current_call(pauline->lc));
|
||||
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
|
||||
|
||||
CU_ASSERT_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
|
||||
CU_ASSERT_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
|
||||
|
||||
liblinphone_tester_check_rtcp(marie, pauline);
|
||||
liblinphone_tester_check_rtcp(marie, pauline);
|
||||
|
||||
linphone_core_terminate_all_calls(pauline->lc);
|
||||
linphone_core_terminate_all_calls(pauline->lc);
|
||||
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000));
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000));
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000));
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000));
|
||||
|
||||
|
||||
ms_list_free(lcs);
|
||||
|
||||
ms_list_free(lcs);
|
||||
}
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,12 +48,16 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
|
|||
stats* counters = get_stats(lc);
|
||||
LinphoneCoreManager *mgr=get_manager(lc);
|
||||
LinphoneContent content={0};
|
||||
|
||||
const LinphoneAddress* from_addr = linphone_event_get_from(lev);
|
||||
char* from = linphone_address_as_string(from_addr);
|
||||
content.type="application";
|
||||
content.subtype="somexml2";
|
||||
content.data=(void*)notify_content;
|
||||
content.size=strlen(notify_content);
|
||||
|
||||
ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from);
|
||||
ms_free(from);
|
||||
|
||||
switch(state){
|
||||
case LinphoneSubscriptionNone:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue