From ea6dd35f763c1f678dbd44da6330a9994abf34bc Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Wed, 25 Apr 2012 14:58:57 +0200 Subject: [PATCH] Add API to know Call audio/video codec --- coreapi/linphonecall.c | 14 ++++++++++++++ coreapi/linphonecore.h | 6 ++++-- coreapi/misc.c | 8 ++++---- coreapi/private.h | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d41c6cda..69f9266a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -770,6 +770,14 @@ void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled){ cp->has_video=enabled; } +const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp) { + return cp->audio_codec; +} + +const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp) { + return cp->video_codec; +} + /** * Returns whether video is enabled. **/ @@ -1146,6 +1154,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna bool_t use_ec; if (used_pt!=-1){ + call->current_params.audio_codec = rtp_profile_get_payload(call->audio_profile, used_pt); if (playcard==NULL) { ms_warning("No card defined for playback !"); } @@ -1262,6 +1271,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna const char *addr=vstream->addr[0]!='\0' ? vstream->addr : call->resultdesc->addr; call->video_profile=make_profile(call,call->resultdesc,vstream,&used_pt); if (used_pt!=-1){ + call->current_params.video_codec = rtp_profile_get_payload(call->video_profile, used_pt); VideoStreamDir dir=VideoStreamSendRecv; MSWebCam *cam=lc->video_conf.device; bool_t is_inactive=FALSE; @@ -1333,6 +1343,10 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){ LinphoneCore *lc=call->core; + + call->current_params.audio_codec = NULL; + call->current_params.video_codec = NULL; + LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc); char *cname; bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index a5a1e8c0..d3a514a6 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -183,6 +183,8 @@ char * linphone_call_log_to_str(LinphoneCallLog *cl); struct _LinphoneCallParams; typedef struct _LinphoneCallParams LinphoneCallParams; +const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); +const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp); LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); @@ -786,13 +788,13 @@ const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc); int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs); -bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt); +bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt); int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable); PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) ; -int linphone_core_get_payload_type_number(LinphoneCore *lc, PayloadType *pt); +int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt); diff --git a/coreapi/misc.c b/coreapi/misc.c index 41d4efac..881b88eb 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -181,12 +181,12 @@ static void payload_type_set_enable(PayloadType *pt,int value) else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED); } -static bool_t payload_type_enabled(PayloadType *pt) { +static bool_t payload_type_enabled(const PayloadType *pt) { return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0); } -bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt){ - if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){ +bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt){ + if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){ return payload_type_enabled(pt); } ms_error("Getting enablement status of codec not in audio or video list of PayloadType !"); @@ -202,7 +202,7 @@ int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t return -1; } -int linphone_core_get_payload_type_number(LinphoneCore *lc, PayloadType *pt){ +int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt){ return payload_type_get_number(pt); } diff --git a/coreapi/private.h b/coreapi/private.h index ec57eaf9..a790276d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -68,6 +68,8 @@ struct _LinphoneCallParams{ LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */ int audio_bw; /* bandwidth limit for audio stream */ LinphoneMediaEncryption media_encryption; + PayloadType *audio_codec; + PayloadType *video_codec; bool_t has_video; bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t in_conference; /*in conference mode */ -- 2.39.2