diff --git a/coreapi/event.c b/coreapi/event.c index c50ca460d..9eae159b8 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -135,6 +135,7 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s linphone_event_release(lev); break; case LinphonePublishOk: + if (lev->oneshot) linphone_event_release(lev); break; case LinphonePublishError: linphone_event_release(lev); @@ -275,6 +276,12 @@ LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddr return lev; } +LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event){ + LinphoneEvent *lev = linphone_core_create_publish(lc, resource, event, -1); + lev->oneshot = TRUE; + return lev; +} + static int _linphone_event_send_publish(LinphoneEvent *lev, const LinphoneContent *body, bool_t notify_err){ SalBodyHandler *body_handler; int err; diff --git a/coreapi/event.h b/coreapi/event.h index 247df2a9d..47db9cc79 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -204,6 +204,19 @@ LINPHONE_PUBLIC LinphoneEvent *linphone_core_publish(LinphoneCore *lc, const Lin **/ LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires); + +/** + * Create a publish context for a one-shot publish. + * After being created, the publish must be sent using linphone_event_send_publish(). + * The LinphoneEvent is automatically terminated when the publish transaction is finished, either with success or failure. + * The application must not call linphone_event_terminate() for such one-shot publish. + * @param lc the #LinphoneCore + * @param resource the resource uri for the event + * @param event the event name + * @return the LinphoneEvent holding the context of the publish. +**/ +LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event); + /** * Send a publish created by linphone_core_create_publish(). * @param lev the #LinphoneEvent diff --git a/coreapi/private.h b/coreapi/private.h index 21f57e974..be1936d2b 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1085,6 +1085,7 @@ struct _LinphoneEvent{ bool_t terminating; bool_t is_out_of_dialog_op; /*used for out of dialog notify*/ bool_t internal; + bool_t oneshot; }; BELLE_SIP_DECLARE_VPTR(LinphoneEvent); diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index 92a402a3c..ecf301ca7 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -264,7 +264,6 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off static int send_report(LinphoneCall* call, reporting_session_report_t * report, const char * report_event) { LinphoneContent *content; - int expires = -1; size_t offset = 0; size_t size = 2048; char * buffer; @@ -357,7 +356,7 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, collector_uri = ms_strdup_printf("sip:%s", linphone_proxy_config_get_domain(call->dest_proxy)); } request_uri = linphone_address_new(collector_uri); - lev=linphone_core_create_publish(call->core, request_uri, "vq-rtcpxr", expires); + lev = linphone_core_create_one_shot_publish(call->core, request_uri, "vq-rtcpxr"); /* Special exception for quality report PUBLISH: if the collector_uri has any transport related parameters * (port, transport, maddr), then it is sent directly. * Otherwise it is routed as any LinphoneEvent publish, following proxy config policy. @@ -370,7 +369,6 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, } if (linphone_event_send_publish(lev, content) != 0){ - linphone_event_unref(lev); lev=NULL; ret=4; } else {