Commit 351bb970 authored by François Grisez's avatar François Grisez

Reworking of Liblinphone's API around payload types

parent 5e02b53e
......@@ -102,6 +102,7 @@ set(LINPHONE_SOURCE_FILES_C
misc.c
nat_policy.c
offeranswer.c
payload_type.c
player.c
presence.c
proxy.c
......
......@@ -213,15 +213,27 @@ const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp){
return cp->session_name;
}
const LinphonePayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp) {
LinphonePayloadType *linphone_call_params_get_used_audio_payload_type(const LinphoneCallParams *cp) {
return cp->audio_codec ? linphone_payload_type_new(NULL, cp->audio_codec) : NULL;
}
LinphonePayloadType *linphone_call_params_get_used_video_payload_type(const LinphoneCallParams *cp) {
return cp->video_codec ? linphone_payload_type_new(NULL, cp->video_codec) : NULL;
}
LinphonePayloadType *linphone_call_params_get_used_text_payload_type(const LinphoneCallParams *cp) {
return cp->text_codec ? linphone_payload_type_new(NULL, cp->text_codec) : NULL;
}
const OrtpPayloadType *linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp) {
return cp->audio_codec;
}
const LinphonePayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp) {
const OrtpPayloadType *linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp) {
return cp->video_codec;
}
const LinphonePayloadType* linphone_call_params_get_used_text_codec(const LinphoneCallParams *cp) {
const OrtpPayloadType *linphone_call_params_get_used_text_codec(const LinphoneCallParams *cp) {
return cp->text_codec;
}
......
......@@ -27,14 +27,14 @@ if (ENABLE_DOC OR CXX_WRAPPER)
set(top_srcdir "${CMAKE_CURRENT_LIST_DIR}/../../")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
set(DOC_INPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
${LINPHONE_HEADER_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/doxygen.dox
${LINPHONE_HEADER_FILES}
)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html"
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html" "${CMAKE_CURRENT_BINARY_DIR}/doc/xml/index.xml"
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${DOC_INPUT_FILES}
)
add_custom_target(linphone-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html")
add_custom_target(linphone-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html" "${CMAKE_CURRENT_BINARY_DIR}/doc/xml/index.xml")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html" "${CMAKE_CURRENT_BINARY_DIR}/doc/xml"
DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/linphone-${LINPHONE_VERSION}")
else()
......
......@@ -513,7 +513,7 @@ static bctbx_list_t *make_codec_list(LinphoneCore *lc, CodecConstraints * hints,
pt->mime_type,pt->clock_rate,hints->bandwidth_limit);
continue;
}
if (!linphone_core_check_payload_type_usability(lc,pt)){
if (!_linphone_core_check_payload_type_usability(lc, pt)) {
continue;
}
pt=payload_type_clone(pt);
......
......@@ -2220,6 +2220,53 @@ void linphone_core_unref(LinphoneCore *lc) {
belle_sip_object_unref(BELLE_SIP_OBJECT(lc));
}
static bctbx_list_t *ortp_payloads_to_linphone_payloads(const bctbx_list_t *ortp_payloads, LinphoneCore *lc) {
bctbx_list_t *linphone_payloads = NULL;
for (; ortp_payloads!=NULL; ortp_payloads=bctbx_list_next(ortp_payloads)) {
LinphonePayloadType *pt = linphone_payload_type_new(lc, (OrtpPayloadType *)ortp_payloads->data);
linphone_payloads = bctbx_list_append(linphone_payloads, pt);
}
return linphone_payloads;
}
static void sort_ortp_pt_list(bctbx_list_t **ortp_pt_list, const bctbx_list_t *linphone_pt_list) {
bctbx_list_t *new_list = NULL;
const bctbx_list_t *it;
for (it=bctbx_list_first_elem(linphone_pt_list); it; it=bctbx_list_next(it)) {
OrtpPayloadType *ortp_pt = linphone_payload_type_get_ortp_pt((LinphonePayloadType *)it->data);
bctbx_list_t *elem = bctbx_list_find(*ortp_pt_list, ortp_pt);
if (elem) {
*ortp_pt_list = bctbx_list_unlink(*ortp_pt_list, elem);
new_list = bctbx_list_append_link(new_list, elem);
}
}
*ortp_pt_list = bctbx_list_prepend_link(*ortp_pt_list, new_list);
}
bctbx_list_t *linphone_core_get_audio_payload_types(LinphoneCore *lc) {
return ortp_payloads_to_linphone_payloads(lc->codecs_conf.audio_codecs, lc);
}
void linphone_core_set_audio_payload_types(LinphoneCore *lc, const bctbx_list_t *payload_types) {
sort_ortp_pt_list(&lc->codecs_conf.audio_codecs, payload_types);
}
bctbx_list_t *linphone_core_get_video_payload_types(LinphoneCore *lc) {
return ortp_payloads_to_linphone_payloads(lc->codecs_conf.video_codecs, lc);
}
void linphone_core_set_video_payload_types(LinphoneCore *lc, const bctbx_list_t *payload_types) {
sort_ortp_pt_list(&lc->codecs_conf.video_codecs, payload_types);
}
bctbx_list_t *linphone_core_get_text_payload_types(LinphoneCore *lc) {
return ortp_payloads_to_linphone_payloads(lc->codecs_conf.text_codecs, lc);
}
void linphone_core_set_text_payload_types(LinphoneCore *lc, const bctbx_list_t *payload_types) {
sort_ortp_pt_list(&lc->codecs_conf.text_codecs, payload_types);
}
const bctbx_list_t *linphone_core_get_audio_codecs(const LinphoneCore *lc) {
return lc->codecs_conf.audio_codecs;
}
......@@ -4193,7 +4240,7 @@ void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val){
lp_config_set_int(lc->config,"sound","echocancellation",val);
}
bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc){
bool_t linphone_core_echo_cancellation_enabled(const LinphoneCore *lc){
return lc->sound_conf.ec;
}
......@@ -5616,7 +5663,7 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){
lp_config_set_string(lc->config,key,"mime",pt->mime_type);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
lp_config_set_int(lc->config,key,"channels",pt->channels);
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
lp_config_set_int(lc->config,key,"enabled",payload_type_enabled(pt));
index++;
}
sprintf(key,"audio_codec_%i",index);
......@@ -5628,7 +5675,7 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){
sprintf(key,"video_codec_%i",index);
lp_config_set_string(lc->config,key,"mime",pt->mime_type);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
lp_config_set_int(lc->config,key,"enabled",payload_type_enabled(pt));
lp_config_set_string(lc->config,key,"recv_fmtp",pt->recv_fmtp);
index++;
}
......@@ -6003,8 +6050,8 @@ bool_t linphone_core_get_ring_during_incoming_early_media(const LinphoneCore *lc
return (bool_t)lp_config_get_int(lc->config, "sound", "ring_during_incoming_early_media", 0);
}
LinphonePayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) {
LinphonePayloadType* result = find_payload_type_from_list(type, rate, channels, linphone_core_get_audio_codecs(lc));
static OrtpPayloadType* _linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) {
OrtpPayloadType* result = find_payload_type_from_list(type, rate, channels, linphone_core_get_audio_codecs(lc));
if (result) {
return result;
} else {
......@@ -6022,6 +6069,15 @@ LinphonePayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const cha
return NULL;
}
OrtpPayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) {
return _linphone_core_find_payload_type(lc, type, rate, channels);
}
LinphonePayloadType *linphone_core_get_payload_type(LinphoneCore *lc, const char *type, int rate, int channels) {
OrtpPayloadType *pt = _linphone_core_find_payload_type(lc, type, rate, channels);
return pt ? linphone_payload_type_new(lc, pt) : NULL;
}
const char* linphone_configuring_state_to_string(LinphoneConfiguringState cs){
switch(cs){
case LinphoneConfiguringSuccessful:
......@@ -6444,22 +6500,6 @@ void linphone_core_set_avpf_rr_interval(LinphoneCore *lc, int interval){
lp_config_set_int(lc->config,"rtp","avpf_rr_interval",interval);
}
int linphone_payload_type_get_type(const LinphonePayloadType *pt) {
return pt->type;
}
int linphone_payload_type_get_normal_bitrate(const LinphonePayloadType *pt) {
return pt->normal_bitrate;
}
const char * linphone_payload_type_get_mime_type(const LinphonePayloadType *pt) {
return pt->mime_type;
}
int linphone_payload_type_get_channels(const LinphonePayloadType *pt) {
return pt->channels;
}
int linphone_core_set_audio_multicast_addr(LinphoneCore *lc, const char* ip) {
char* new_value;
if (ip && !ms_is_multicast(ip)) {
......
......@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mediastreamer2/mediastream.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SIGHANDLER_T
#include <signal.h>
#endif /*HAVE_SIGHANDLER_T*/
......@@ -62,78 +63,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
static void clear_ice_check_list(LinphoneCall *call, IceCheckList *removed);
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *pt){
if (bctbx_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || bctbx_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || bctbx_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){
return payload_type_enabled(pt);
}
ms_error("Getting enablement status of codec not in audio or video list of PayloadType !");
return FALSE;
}
bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayloadType *pt) {
return linphone_payload_type_is_vbr(pt);
}
bool_t linphone_payload_type_is_vbr(const LinphonePayloadType *pt) {
if (pt->type == PAYLOAD_VIDEO) return TRUE;
return !!(pt->flags & PAYLOAD_TYPE_IS_VBR);
}
int linphone_core_enable_payload_type(LinphoneCore *lc, LinphonePayloadType *pt, bool_t enabled){
if (bctbx_list_find(lc->codecs_conf.audio_codecs,pt) || bctbx_list_find(lc->codecs_conf.video_codecs,pt) || bctbx_list_find(lc->codecs_conf.text_codecs,pt)){
payload_type_set_enable(pt,enabled);
_linphone_core_codec_config_write(lc);
linphone_core_update_allocated_audio_bandwidth(lc);
return 0;
}
ms_error("Enabling codec not in audio or video list of PayloadType !");
return -1;
}
int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt) {
return linphone_payload_type_get_number(pt);
}
int linphone_payload_type_get_number(const LinphonePayloadType *pt) {
return payload_type_get_number(pt);
}
void linphone_core_set_payload_type_number(LinphoneCore *lc, PayloadType *pt, int number) {
linphone_payload_type_set_number(pt, number);
}
void linphone_payload_type_set_number(LinphonePayloadType *pt, int number) {
payload_type_set_number(pt, number);
}
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt){
//if (ms_filter_codec_supported(pt->mime_type)){
if (ms_factory_codec_supported(lc->factory, pt->mime_type)){
MSFilterDesc *desc=ms_factory_get_encoder(lc->factory, pt->mime_type);
#ifdef ENABLE_NLS
return dgettext("mediastreamer",desc->text);
#else
return desc->text;
#endif
}
return NULL;
}
void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, LinphonePayloadType *pt, int bitrate){
if (bctbx_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || bctbx_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || bctbx_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){
if (pt->type==PAYLOAD_VIDEO || pt->flags & PAYLOAD_TYPE_IS_VBR){
pt->normal_bitrate=bitrate*1000;
pt->flags|=PAYLOAD_TYPE_BITRATE_OVERRIDE;
linphone_core_update_allocated_audio_bandwidth(lc);
}else{
ms_error("Cannot set an explicit bitrate for codec %s/%i, because it is not VBR.",pt->mime_type,pt->clock_rate);
return;
}
} else {
ms_error("linphone_core_set_payload_type_bitrate() payload type not in audio or video list !");
}
}
/*
*((codec-birate*ptime/8) + RTP header + UDP header + IP header)*8/ptime;
......@@ -184,8 +113,8 @@ static int lookup_vbr_typical_bitrate(int maxbw, int clock_rate){
return 32;
}
static int get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *pt, int maxbw){
if (linphone_payload_type_is_vbr(pt)){
int get_audio_payload_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int maxbw) {
if (payload_type_is_vbr(pt)) {
if (pt->flags & PAYLOAD_TYPE_BITRATE_OVERRIDE){
ms_debug("PayloadType %s/%i has bitrate override",pt->mime_type,pt->clock_rate);
return pt->normal_bitrate/1000;
......@@ -194,23 +123,6 @@ static int get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *pt,
}else return (int)ceil(get_audio_payload_bandwidth_from_codec_bitrate(pt)/1000.0);/*rounding codec bandwidth should be avoid, specially for AMR*/
}
int linphone_core_get_payload_type_bitrate(LinphoneCore *lc, const LinphonePayloadType *pt){
int maxbw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
linphone_core_get_upload_bandwidth(lc));
if (pt->type==PAYLOAD_AUDIO_CONTINUOUS || pt->type==PAYLOAD_AUDIO_PACKETIZED){
return get_audio_payload_bandwidth(lc,pt,maxbw);
}else if (pt->type==PAYLOAD_VIDEO){
int video_bw;
if (maxbw<=0) {
video_bw=1500; /*default bitrate for video stream when no bandwidth limit is set, around 1.5 Mbit/s*/
}else{
video_bw=get_remaining_bandwidth_for_video(maxbw,lc->audio_bw);
}
return video_bw;
}
return 0;
}
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt, int maxbw){
call->audio_bw=get_audio_payload_bandwidth(call->core,pt,maxbw);
ms_message("Audio bandwidth for this call is %i",call->audio_bw);
......@@ -238,7 +150,7 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
}
}
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit){
bool_t linphone_core_is_payload_type_usable_for_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit){
double codec_band;
const int video_enablement_limit = 99;
bool_t ret=FALSE;
......@@ -263,24 +175,6 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, cons
return ret;
}
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, const PayloadType *pt){
int maxbw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
linphone_core_get_upload_bandwidth(lc));
bool_t ret=linphone_core_is_payload_type_usable_for_bandwidth(lc, pt, maxbw);
if ((pt->type==PAYLOAD_AUDIO_CONTINUOUS || pt->type==PAYLOAD_AUDIO_PACKETIZED)
&& lc->sound_conf.capt_sndcard
&& !(ms_snd_card_get_capabilities(lc->sound_conf.capt_sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER)
&& linphone_core_echo_cancellation_enabled(lc)
&& (pt->clock_rate!=16000 && pt->clock_rate!=8000)
&& strcasecmp(pt->mime_type,"opus")!=0
&& ms_factory_lookup_filter_by_name(lc->factory, "MSWebRTCAEC")!=NULL){
ms_warning("Payload type %s/%i cannot be used because software echo cancellation is required but is unable to operate at this rate.",
pt->mime_type,pt->clock_rate);
ret=FALSE;
}
return ret;
}
bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret){
#if !defined(_WIN32_WCE) && !defined(LINPHONE_WINDOWS_UNIVERSAL)
FILE *f=popen(command,"r");
......
This diff is collapsed.
......@@ -1176,7 +1176,7 @@ void linphone_call_increment_local_media_description(LinphoneCall *call);
void linphone_call_fill_media_multicast_addr(LinphoneCall *call);
void linphone_call_update_streams(LinphoneCall *call, SalMediaDescription *new_md, LinphoneCallState target_state);
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit);
bool_t linphone_core_is_payload_type_usable_for_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit);
#define linphone_core_ready(lc) ((lc)->state==LinphoneGlobalOn || (lc)->state==LinphoneGlobalShutdown)
void _linphone_core_configure_resolver(void);
......@@ -1667,17 +1667,22 @@ char * linphone_timestamp_to_rfc3339_string(time_t timestamp);
void linphone_error_info_from_sal_op(LinphoneErrorInfo *ei, const SalOp *op);
static MS2_INLINE void payload_type_set_enable(PayloadType *pt,int value)
static MS2_INLINE void payload_type_set_enable(OrtpPayloadType *pt,int value)
{
if ((value)!=0) payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); \
else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED);
}
static MS2_INLINE bool_t payload_type_enabled(const PayloadType *pt) {
static MS2_INLINE bool_t payload_type_enabled(const OrtpPayloadType *pt) {
return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0);
}
bool_t is_payload_type_number_available(const MSList *l, int number, const PayloadType *ignore);
bool_t is_payload_type_number_available(const MSList *l, int number, const OrtpPayloadType *ignore);
int get_audio_payload_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int maxbw);
LinphonePayloadType *linphone_payload_type_new(LinphoneCore *lc, OrtpPayloadType *ortp_pt);
bool_t _linphone_core_check_payload_type_usability(const LinphoneCore *lc, const OrtpPayloadType *pt);
OrtpPayloadType *linphone_payload_type_get_ortp_pt(const LinphonePayloadType *pt);
const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc);
MsZrtpCryptoTypesCount linphone_core_get_zrtp_key_agreement_suites(LinphoneCore *lc, MSZrtpKeyAgreement keyAgreements[MS_MAX_ZRTP_CRYPTO_TYPES]);
......@@ -1759,7 +1764,8 @@ BELLE_SIP_TYPE_ID(LinphonePresenceNote),
BELLE_SIP_TYPE_ID(LinphoneErrorInfo),
BELLE_SIP_TYPE_ID(LinphoneConferenceParams),
BELLE_SIP_TYPE_ID(LinphoneConference),
BELLE_SIP_TYPE_ID(LinphoneInfoMessage)
BELLE_SIP_TYPE_ID(LinphoneInfoMessage),
BELLE_SIP_TYPE_ID(LinphonePayloadType)
BELLE_SIP_DECLARE_TYPES_END
......
......@@ -539,15 +539,15 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
/*yet we use the same payload config for local and remote, since this is the largest use case*/
if (stats_type == LINPHONE_CALL_STATS_AUDIO && call->audiostream != NULL) {
stream = &call->audiostream->ms;
local_payload = linphone_call_params_get_used_audio_codec(current_params);
local_payload = current_params->audio_codec;
remote_payload = local_payload;
} else if (stats_type == LINPHONE_CALL_STATS_VIDEO && call->videostream != NULL) {
stream = &call->videostream->ms;
local_payload = linphone_call_params_get_used_video_codec(current_params);
local_payload = current_params->video_codec;
remote_payload = local_payload;
} else if (stats_type == LINPHONE_CALL_STATS_TEXT && call->textstream != NULL) {
stream = &call->textstream->ms;
local_payload = linphone_call_params_get_used_text_codec(current_params);
local_payload = current_params->text_codec;
remote_payload = local_payload;
}
......
......@@ -71,7 +71,7 @@ static PayloadType *findPayload(LinphoneCore *lc, int payload_type, int *index){
for (const bctbx_list_t *node = linphone_core_get_audio_codecs(lc); node != NULL; node = bctbx_list_next(node)) {
PayloadType *payload = reinterpret_cast<PayloadType*>(node->data);
if (index) (*index)++;
if (payload_type == linphone_payload_type_get_number(payload)) {
if (payload_type == payload_type_get_number(payload)) {
return payload;
}
}
......@@ -127,7 +127,7 @@ void AudioCodecSetCommand::exec(Daemon *app, const string& args) {
if (conflict) {
app->sendResponse(Response("New payload type number is already used.", Response::Error));
} else {
linphone_payload_type_set_number(payload, idx);
payload_type_set_number(payload, idx);
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, parser.getPosition()));
}
return;
......
......@@ -33,7 +33,7 @@ static PayloadType *getPayloadType(LinphoneCore *lc, const MSList *codecs, int n
const MSList *elem;
for (elem = codecs; elem != NULL; elem = elem->next) {
PayloadType *pt = (PayloadType*)elem->data;
if (linphone_payload_type_get_number(pt) == number)
if (payload_type_get_number(pt) == number)
return pt;
}
return NULL;
......
......@@ -219,7 +219,7 @@ PayloadTypeResponse::PayloadTypeResponse(LinphoneCore *core, const PayloadType *
if (payloadType != NULL) {
if (index >= 0)
ostr << prefix << "Index: " << index << "\n";
ostr << prefix << "Payload-type-number: " << linphone_payload_type_get_number(payloadType) << "\n";
ostr << prefix << "Payload-type-number: " << payload_type_get_number(payloadType) << "\n";
ostr << prefix << "Clock-rate: " << payloadType->clock_rate << "\n";
ostr << prefix << "Bitrate: " << payloadType->normal_bitrate << "\n";
ostr << prefix << "Mime: " << payloadType->mime_type << "\n";
......@@ -252,7 +252,7 @@ PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type
}else if (number!=-1){
const bctbx_list_t *elem;
for(elem=linphone_core_get_audio_codecs(core);elem!=NULL;elem=elem->next){
if (number==linphone_payload_type_get_number((PayloadType*)elem->data)){
if (number==payload_type_get_number((PayloadType*)elem->data)){
mPayloadType=(PayloadType*)elem->data;
break;
}
......
......@@ -647,7 +647,7 @@ static void linphone_gtk_init_codec_list(GtkTreeView *listview){
}
const char *get_codec_color(LinphoneCore *lc, PayloadType *pt){
const char *get_codec_color(LinphoneCore *lc, OrtpPayloadType *pt){
const gchar *color;
if (linphone_core_check_payload_type_usability(lc,pt)) color="blue";
else color="red";
......@@ -673,7 +673,7 @@ static void linphone_gtk_show_codecs(GtkTreeView *listview, const bctbx_list_t *
const gchar *color;
const char *params="";
struct _PayloadType *pt=(struct _PayloadType *)elem->data;
OrtpPayloadType *pt=(OrtpPayloadType *)elem->data;
color=get_codec_color(linphone_gtk_get_core(),pt);
if (linphone_core_payload_type_enabled(linphone_gtk_get_core(),pt)) status=_("Enabled");
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/types.h"
#include "linphone/payload_type.h"
#ifdef __cplusplus
......@@ -175,25 +176,55 @@ LINPHONE_PUBLIC MSVideoSize linphone_call_params_get_sent_video_size(const Linph
LINPHONE_PUBLIC const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp);
/**
* Get the audio codec used in the call, described as a LinphonePayloadType object.
* @param[in] cp LinphoneCallParams object
* @return The LinphonePayloadType object corresponding to the audio codec being used in the call.
* Get the audio payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no audio payload type has been seleced
* by the call. If a payload type is returned, it must be released with linphone_payload_type_unref() after use.
**/
LINPHONE_PUBLIC const LinphonePayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp);
LINPHONE_PUBLIC LinphonePayloadType *linphone_call_params_get_used_audio_payload_type(const LinphoneCallParams *cp);
/**
* Get the video codec used in the call, described as a LinphonePayloadType structure.
* @param[in] cp LinphoneCallParams object
* @return The LinphonePayloadType object corresponding to the video codec being used in the call.
* Get the video payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no video payload type has been seleced
* by the call. If a payload type is returned, it must be released with linphone_payload_type_unref() after use.
**/
LINPHONE_PUBLIC const LinphonePayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp);
LINPHONE_PUBLIC LinphonePayloadType *linphone_call_params_get_used_video_payload_type(const LinphoneCallParams *cp);
/**
* Get the text codec used in the call, described as a LinphonePayloadType structure.
* @param[in] cp LinphoneCallParams object
* @return The LinphonePayloadType object corresponding to the text codec being used in the call.
* Get the text payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no text payload type has been seleced
* by the call. If a payload type is returned, it must be released with linphone_payload_type_unref() after use.
**/
LINPHONE_PUBLIC LinphonePayloadType *linphone_call_params_get_used_text_payload_type(const LinphoneCallParams *cp);
/**
* Get the audio payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no audio payload type has been seleced by the call.
* @deprecated Use linphone_call_params_get_used_audio_payload_type() instead.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const OrtpPayloadType *linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp);
/**
* Get the video payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no video payload type has been seleced by the call.
* @deprecated Use linphone_call_params_get_used_video_payload_type() instead.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const OrtpPayloadType *linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp);
/**
* Get the text payload type that has been selected by a call.
* @param[in] cp The call.
* @return The selected payload type. NULL is returned if no text payload type has been seleced by the call.
* @deprecated Use linphone_call_params_get_used_text_payload_type() instead.
* @donotwrap
**/
LINPHONE_PUBLIC const LinphonePayloadType* linphone_call_params_get_used_text_codec(const LinphoneCallParams *cp);
LINPHONE_PUBLIC LINPHONE_DEPRECATED const OrtpPayloadType *linphone_call_params_get_used_text_codec(const LinphoneCallParams *cp);
/**
* Tell whether the call has been configured in low bandwidth mode or not.
......
This diff is collapsed.
......@@ -20,77 +20,163 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef LINPHONE_PAYLOAD_TYPE_H_
#define LINPHONE_PAYLOAD_TYPE_H_
#include "linphone/types.h"
/**
* @addtogroup media_parameters
* @{
**/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Take a reference on a #LinphonePayloadType.
*/
LINPHONE_PUBLIC LinphonePayloadType *linphone_payload_type_ref(LinphonePayloadType *pt);
/**
* @addtogroup media_parameters
* @{
**/
* Release a reference on a #LinphonePayloadType.
*/
LINPHONE_PUBLIC void linphone_payload_type_unref(LinphonePayloadType *pt);
/**
* Get the type of payload.
* @param[in] pt LinphonePayloadType object
* @return The type of payload.
* Get the type of a payload type.
* @param[in] pt The payload type.
* @return The type of the payload e.g. PAYLOAD_AUDIO_CONTINUOUS or PAYLOAD_VIDEO.
*/
LINPHONE_PUBLIC int linphone_payload_type_get_type(const LinphonePayloadType *pt);
/**
* Enable/disable a payload type.
* @param[in] pt The payload type to enable/disable.
* @param[in] enabled Set TRUE for enabling and FALSE for disabling.
* @return 0 for success, -1 for failure.
*/
LINPHONE_PUBLIC int linphone_payload_type_enable(LinphonePayloadType *pt, bool_t enabled);
/**
* Check whether a palyoad type is enabled.
* @return TRUE if enabled, FALSE if disabled.
*/
LINPHONE_PUBLIC bool_t linphone_payload_type_enabled(const LinphonePayloadType *pt);
/**
* Return a string describing a payload type. The format of the string is
* &lt;mime_type&gt;/&lt;clock_rate&gt;/&lt;channels&gt;.
* @param[in] pt The payload type.
* @return The description of the payload type. Must be release after use.
*/
LINPHONE_PUBLIC char *linphone_payload_type_get_description(const LinphonePayloadType *pt);
/**
* Get a description of the encoder used to provide a payload type.
* @param[in] pt The payload type.
* @return The description of the encoder. Can be NULL if the payload type is not supported by Mediastreamer2.
*/
LINPHONE_PUBLIC const char *linphone_payload_type_get_encoder_description(const LinphonePayloadType *pt);
/**
* Get the normal bitrate in bits/s.
* @param[in] pt LinphonePayloadType object
* @return The normal bitrate in bits/s.
* @param[in] pt The payload type.
* @return The normal bitrate in bits/s or -1 if an error has occured.
*/
LINPHONE_PUBLIC int linphone_payload_type_get_normal_bitrate(const LinphonePayloadType *pt);
/**
* Change the normal bitrate of a payload type..
* @param[in] pt The payload type to change.
* @param[in] bitrate The new bitrate in bits/s.
*/
LINPHONE_PUBLIC void linphone_payload_type_set_normal_bitrate(LinphonePayloadType *pt, int bitrate);
/**
* Get the mime type.
* @param[in] pt LinphonePayloadType object
* @param[in] pt The payload type.
* @return The mime type.
*/
LINPHONE_PUBLIC const char * linphone_payload_type_get_mime_type(const LinphonePayloadType *pt);
/**
* Get the number of channels.
* @param[in] pt LinphonePayloadType object
* @param[in] pt The payload type.
* @return The number of channels.
*/
LINPHONE_PUBLIC int linphone_payload_type_get_channels(const LinphonePayloadType *pt);
/**
* Returns the payload type number assigned for this codec.
* @param[in] pt LinphonePayloadType object
* @return The number of the payload type
* @param[in] pt The payload type.
* @return The number of the payload type.
**/
LINPHONE_PUBLIC int linphone_payload_type_get_number(const LinphonePayloadType *pt);
/**
* Force a number for a payload type. The LinphoneCore does payload type number assignment automatically. THis function is to be used mainly for tests, in order
* to override the automatic assignment mechanism.
* @param[in] pt LinphonePayloadType object
* @param[in] number The number to assign to the payload type
* Force a number for a payload type. The LinphoneCore does payload type number assignment automatically.
* This function is mainly to be used for tests, in order to override the automatic assignment mechanism.
* @param[in] pt The payload type.
* @param[in] number The number to assign to the payload type.
**/
LINPHONE_PUBLIC void linphone_payload_type_set_number(LinphonePayloadType *pt, int number);
/**
* Get the format parameters for incoming streams.
* @param[in] pt The payload type.
* @return The format parameters as string.
*/
LINPHONE_PUBLIC const char *linphone_payload_type_get_recv_fmtp(const LinphonePayloadType *pt);
/**
* Set the format parameters for incoming streams.
* @param[in] pt The payload type.
* @param[in] recv_fmtp The new format parameters as string. The string will be copied.
*/
LINPHONE_PUBLIC void linphone_payload_type_set_recv_fmtp(LinphonePayloadType *pt, const char *recv_fmtp);
/**
* Get the format parameters for outgoing streams.
* @param[in] pt The payload type.
* @return The format parameters as string.
*/
LINPHONE_PUBLIC const char *linphone_payload_type_get_send_fmtp(const LinphonePayloadType *pt);
/**
* Set the format parameters for outgoing streams.
* @param[in] pt The payload type.
* @param[in] send_fmtp The new format parameters as string. The string will be copied.
*/
LINPHONE_PUBLIC void linphone_payload_type_set_send_fmtp(LinphonePayloadType *pt, const char *send_fmtp);
/**
* Get the clock rate of a payload type.
* @param[in] pt The payload type.
* @return[in] The clock rate in Hz.
*/