From 31ab25d815e2fa4237d9be074c388bc292cdcbcc Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 13 Aug 2014 16:10:48 +0200 Subject: [PATCH] Handle PayloadType objects in the Python wrapper. --- coreapi/linphonecall.c | 8 ++--- coreapi/linphonecore.c | 21 +++++++++-- coreapi/linphonecore.h | 68 ++++++++++++++++++++++++++++------- coreapi/misc.c | 10 +++--- tools/genapixml.py | 5 +++ tools/python/apixml2python.py | 8 ----- 6 files changed, 88 insertions(+), 32 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 459c8c92f..9d8b6060c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1342,17 +1342,17 @@ void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled){ } /** - * Returns the audio codec used in the call, described as a PayloadType structure. + * Returns the audio codec used in the call, described as a LinphonePayloadType structure. **/ -const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp) { +const LinphonePayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp) { return cp->audio_codec; } /** - * Returns the video codec used in the call, described as a PayloadType structure. + * Returns the video codec used in the call, described as a LinphonePayloadType structure. **/ -const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp) { +const LinphonePayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp) { return cp->video_codec; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 93f30606e..dbed18003 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -6260,8 +6260,8 @@ static PayloadType* find_payload_type_from_list(const char* type, int rate, int } -PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) { - PayloadType* result = find_payload_type_from_list(type, rate, channels, linphone_core_get_audio_codecs(lc)); +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)); if (result) { return result; } else { @@ -6714,3 +6714,20 @@ bool_t linphone_core_sdp_200_ack_enabled(const LinphoneCore *lc) { void linphone_core_set_file_transfer_server(LinphoneCore *core, const char * server_url) { core->file_transfer_server=ms_strdup(server_url); } + + +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; +} + +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; +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index b08c75395..7147f30e7 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -247,6 +247,48 @@ LinphoneDictionary* lp_config_section_to_dict( const LpConfig* lpconfig, const c void lp_config_load_dict_to_section( LpConfig* lpconfig, const char* section, const LinphoneDictionary* dict); +/** + * @addtogroup media_parameters + * @{ +**/ + +/** + * Object representing an RTP payload type. + */ +typedef PayloadType LinphonePayloadType; + +/** + * Get the type of payload. + * @param[in] pt LinphonePayloadType object + * @return The type of payload. + */ +LINPHONE_PUBLIC int linphone_payload_type_get_type(const LinphonePayloadType *pt); + +/** + * Get the normal bitrate in bits/s. + * @param[in] pt LinphonePayloadType object + * @return The normal bitrate in bits/s. + */ +LINPHONE_PUBLIC int linphone_payload_type_get_normal_bitrate(const LinphonePayloadType *pt); + +/** + * Get the mime type. + * @param[in] pt LinphonePayloadType object + * @return The mime type. + */ +LINPHONE_PUBLIC char * linphone_payload_type_get_mime_type(const LinphonePayloadType *pt); + +/** + * Get the number of channels. + * @param[in] pt LinphonePayloadType object + * @return The number of channels. + */ +LINPHONE_PUBLIC int linphone_payload_type_get_channels(const LinphonePayloadType *pt); + +/** + * @} +**/ + #ifdef IN_LINPHONE #include "linphonefriend.h" #include "event.h" @@ -383,8 +425,8 @@ struct _LinphoneCallParams; **/ typedef struct _LinphoneCallParams LinphoneCallParams; -LINPHONE_PUBLIC const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); -LINPHONE_PUBLIC const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp); +LINPHONE_PUBLIC const LinphonePayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); +LINPHONE_PUBLIC const LinphonePayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp); LINPHONE_PUBLIC LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); LINPHONE_PUBLIC void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); LINPHONE_PUBLIC bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); @@ -1887,48 +1929,48 @@ LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *cod /** * Tells whether the specified payload type is enabled. * @param[in] lc #LinphoneCore object. - * @param[in] pt The #PayloadType we want to know is enabled or not. + * @param[in] pt The #LinphonePayloadType we want to know is enabled or not. * @returns TRUE if the payload type is enabled, FALSE if disabled. * @ingroup media_parameters */ -LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt); +LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *pt); /** * Tells whether the specified payload type represents a variable bitrate codec. * @param[in] lc #LinphoneCore object. - * @param[in] pt The #PayloadType we want to know + * @param[in] pt The #LinphonePayloadType we want to know * @returns TRUE if the payload type represents a VBR codec, FALSE if disabled. * @ingroup media_parameters */ -LINPHONE_PUBLIC bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const PayloadType *pt); +LINPHONE_PUBLIC bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayloadType *pt); /** * Set an explicit bitrate (IP bitrate, not codec bitrate) for a given codec, in kbit/s. * @param[in] lc the #LinphoneCore object - * @param[in] pt the #PayloadType to modify. + * @param[in] pt the #LinphonePayloadType to modify. * @param[in] bitrate the IP bitrate in kbit/s. * @ingroup media_parameters **/ -LINPHONE_PUBLIC void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, PayloadType *pt, int bitrate); +LINPHONE_PUBLIC void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, LinphonePayloadType *pt, int bitrate); /** * Get the bitrate explicitely set with linphone_core_set_payload_type_bitrate(). * @param[in] lc the #LinphoneCore object - * @param[in] pt the #PayloadType to modify. + * @param[in] pt the #LinphonePayloadType to modify. * @return bitrate the IP bitrate in kbit/s, or -1 if an error occured. * @ingroup media_parameters **/ -LINPHONE_PUBLIC int linphone_core_get_payload_type_bitrate(LinphoneCore *lc, const PayloadType *pt); +LINPHONE_PUBLIC int linphone_core_get_payload_type_bitrate(LinphoneCore *lc, const LinphonePayloadType *pt); /** * Enable or disable the use of the specified payload type. * @param[in] lc #LinphoneCore object. - * @param[in] pt The #PayloadType to enable or disable. It can be retrieved using #linphone_core_find_payload_type + * @param[in] pt The #LinphonePayloadType to enable or disable. It can be retrieved using #linphone_core_find_payload_type * @param[in] enable TRUE to enable the payload type, FALSE to disable it. * @return 0 if successful, any other value otherwise. * @ingroup media_parameters */ -LINPHONE_PUBLIC int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable); +LINPHONE_PUBLIC int linphone_core_enable_payload_type(LinphoneCore *lc, LinphonePayloadType *pt, bool_t enable); /** * Wildcard value used by #linphone_core_find_payload_type to ignore rate in search algorithm @@ -1950,7 +1992,7 @@ LINPHONE_PUBLIC int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadT * @param channels number of channels, can be #LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS * @return Returns NULL if not found. */ -LINPHONE_PUBLIC PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) ; +LINPHONE_PUBLIC LinphonePayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) ; LINPHONE_PUBLIC int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); diff --git a/coreapi/misc.c b/coreapi/misc.c index 38b0efa5d..d4bf48cd5 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -69,7 +69,7 @@ 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, const PayloadType *pt){ +bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *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); } @@ -77,12 +77,12 @@ bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *p return FALSE; } -bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const PayloadType *pt){ +bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, 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, PayloadType *pt, bool_t enabled){ +int linphone_core_enable_payload_type(LinphoneCore *lc, LinphonePayloadType *pt, bool_t enabled){ if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){ payload_type_set_enable(pt,enabled); _linphone_core_codec_config_write(lc); @@ -108,7 +108,7 @@ const char *linphone_core_get_payload_type_description(LinphoneCore *lc, Payload return NULL; } -void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, PayloadType *pt, int bitrate){ +void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, LinphonePayloadType *pt, int bitrate){ if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){ if (pt->type==PAYLOAD_VIDEO || pt->flags & PAYLOAD_TYPE_IS_VBR){ pt->normal_bitrate=bitrate*1000; @@ -181,7 +181,7 @@ 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 PayloadType *pt){ +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){ diff --git a/tools/genapixml.py b/tools/genapixml.py index 388870e2c..2c9286792 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -335,6 +335,11 @@ class Project: if st.associatedTypedef == td: self.add(CClass(st)) break + elif ('Linphone' + td.definition) == td.name: + st = CStruct(td.name) + st.associatedTypedef = td + self.add(st) + self.add(CClass(st)) # Sort classes by length of name (longest first), so that methods are put in the right class self.classes.sort(key = lambda c: len(c.name), reverse = True) for e in self.__events: diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 34770b328..5b6876a34 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -42,8 +42,6 @@ blacklisted_functions = [ 'linphone_call_log_get_remote_stats', # missing rtp_stats_t 'linphone_call_log_get_start_date', # missing time_t 'linphone_call_params_get_privacy', # missing LinphonePrivacyMask - 'linphone_call_params_get_used_audio_codec', # missing PayloadType - 'linphone_call_params_get_used_video_codec', # missing PayloadType 'linphone_call_params_set_privacy', # missing LinphonePrivacyMask 'linphone_chat_message_get_file_transfer_information', # missing LinphoneContent 'linphone_chat_message_get_time', # missing time_t @@ -52,8 +50,6 @@ blacklisted_functions = [ 'linphone_chat_room_create_file_transfer_message', # missing LinphoneContent 'linphone_chat_room_create_message_2', # missing time_t 'linphone_core_can_we_add_call', # private function - 'linphone_core_enable_payload_type', # missing PayloadType - 'linphone_core_find_payload_type', # missing PayloadType 'linphone_core_get_audio_codecs', # missing PayloadType and MSList 'linphone_core_get_audio_port_range', # to be handwritten because of result via arguments 'linphone_core_get_auth_info_list', # missing MSList @@ -61,7 +57,6 @@ blacklisted_functions = [ 'linphone_core_get_calls', # missing MSList 'linphone_core_get_chat_rooms', # missing MSList 'linphone_core_get_default_proxy', # to be handwritten because of double pointer indirection - 'linphone_core_get_payload_type_bitrate', # missing PayloadType 'linphone_core_get_friend_list', # missing MSList 'linphone_core_get_proxy_config_list', # missing MSList 'linphone_core_get_sip_transports', # missing LCSipTransports @@ -71,14 +66,11 @@ blacklisted_functions = [ 'linphone_core_get_video_devices', # returns a list of strings 'linphone_core_get_video_policy', # missing LinphoneVideoPolicy 'linphone_core_get_video_port_range', # to be handwritten because of result via arguments - 'linphone_core_payload_type_enabled', # missing PayloadType - 'linphone_core_payload_type_is_vbr', # missing PayloadType 'linphone_core_publish', # missing LinphoneContent 'linphone_core_serialize_logs', # There is no use to wrap this function 'linphone_core_set_log_file', # There is no use to wrap this function 'linphone_core_set_log_handler', # Hand-written but put directly in the linphone module 'linphone_core_set_log_level', # There is no use to wrap this function - 'linphone_core_set_payload_type_bitrate', # missing PayloadType 'linphone_core_set_video_policy', # missing LinphoneVideoPolicy 'linphone_core_set_audio_codecs', # missing PayloadType and MSList 'linphone_core_set_sip_transports', # missing LCSipTransports -- 2.21.0