From 81cb216c22448716b96ce2cded2a6fc7306abbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Mon, 11 Sep 2017 14:42:36 +0200 Subject: [PATCH] Add a callback to get TMMBR values --- coreapi/linphonecall.c | 16 ++++++++++++++++ coreapi/private.h | 2 ++ include/linphone/call.h | 14 ++++++++++++++ include/linphone/callbacks.h | 8 ++++++++ 4 files changed, 40 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d89414bba..fbb05f447 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -144,6 +144,14 @@ void linphone_call_cbs_set_ack_processing(LinphoneCallCbs *cbs, LinphoneCallCbsA cbs->ack_processing = cb; } +LinphoneCallCbsTmmbrReceivedCb linphone_call_cbs_get_tmmbr_received(LinphoneCallCbs *cbs) { + return cbs->tmmbr_received_cb; +} + +void linphone_call_cbs_set_tmmbr_received(LinphoneCallCbs *cbs, LinphoneCallCbsTmmbrReceivedCb cb) { + cbs->tmmbr_received_cb = cb; +} + bool_t linphone_call_state_is_early(LinphoneCallState state){ switch (state){ @@ -4860,6 +4868,10 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ /* If this event happens then it should be a video stream */ if (stream_index == call->main_video_stream_index) stats->estimated_download_bandwidth = (float)(evd->info.video_bandwidth_available)*1e-3; + } else if (evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) { + if (rtcp_RTPFB_get_type(evd->packet) == RTCP_RTPFB_TMMBR) { + linphone_call_notify_tmmbr_received(call, stream_index, (int)rtcp_RTPFB_tmmbr_get_max_bitrate(evd->packet)); + } } ortp_event_destroy(ev); } @@ -6235,3 +6247,7 @@ void linphone_call_notify_info_message_received(LinphoneCall *call, const Linpho void linphone_call_notify_ack_processing(LinphoneCall *call, LinphoneHeaders *msg, bool_t is_received) { NOTIFY_IF_EXIST(ack_processing, call, msg, is_received) } + +void linphone_call_notify_tmmbr_received(LinphoneCall *call, int stream_index, int tmmbr) { + NOTIFY_IF_EXIST(tmmbr_received_cb, call, stream_index, tmmbr) +} diff --git a/coreapi/private.h b/coreapi/private.h index 46c0d663f..b0940a30d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -309,6 +309,7 @@ struct _LinphoneCallCbs { LinphoneCallCbsStatsUpdatedCb stats_updated_cb; LinphoneCallCbsTransferStateChangedCb transfer_state_changed_cb; LinphoneCallCbsAckProcessingCb ack_processing; + LinphoneCallCbsTmmbrReceivedCb tmmbr_received_cb; }; LinphoneCallCbs * _linphone_call_cbs_new(void); @@ -420,6 +421,7 @@ void linphone_call_notify_transfer_state_changed(LinphoneCall *call, LinphoneCal void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallStats *stats); void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg); void linphone_call_notify_ack_processing(LinphoneCall *call, LinphoneHeaders *msg, bool_t is_received); +void linphone_call_notify_tmmbr_received(LinphoneCall *call, int stream_index, int tmmbr); LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg); LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op); diff --git a/include/linphone/call.h b/include/linphone/call.h index ffa4b8261..ee7036eca 100644 --- a/include/linphone/call.h +++ b/include/linphone/call.h @@ -684,6 +684,20 @@ LINPHONE_PUBLIC LinphoneCallCbsAckProcessingCb linphone_call_cbs_get_ack_process */ LINPHONE_PUBLIC void linphone_call_cbs_set_ack_processing(LinphoneCallCbs *cbs, LinphoneCallCbsAckProcessingCb cb); +/** + * Get the TMMBR received callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current TMMBR received callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsTmmbrReceivedCb linphone_call_cbs_get_tmmbr_received(LinphoneCallCbs *cbs); + +/** + * Set the TMMBR received callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The TMMBR received callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_tmmbr_received(LinphoneCallCbs *cbs, LinphoneCallCbsTmmbrReceivedCb cb); + /** * @} */ diff --git a/include/linphone/callbacks.h b/include/linphone/callbacks.h index e25180714..83aefe18b 100644 --- a/include/linphone/callbacks.h +++ b/include/linphone/callbacks.h @@ -134,6 +134,14 @@ typedef void (*LinphoneCallCbsTransferStateChangedCb)(LinphoneCall *call, Linpho */ typedef void (*LinphoneCallCbsAckProcessingCb)(LinphoneCall *call, LinphoneHeaders *ack, bool_t is_received); +/** + * Callback for notifying a received TMMBR. + * @param call LinphoneCall for which the TMMBR has changed + * @param stream_index the index of the current stream + * @param tmmbr the value of the received TMMBR + */ +typedef void (*LinphoneCallCbsTmmbrReceivedCb)(LinphoneCall *call, int stream_index, int tmmbr); + /** * @} **/