From a17e2be2fac2a5cef592d9aa61bae896144e6a6a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 24 Apr 2017 15:52:00 +0200 Subject: [PATCH] The LinphonePlayer is now a belle_sip_object and is now wrappable. --- coreapi/localplayer.c | 17 +++-- coreapi/player.c | 100 +++++++++++++++++++++++--- coreapi/private.h | 42 +++++++---- include/linphone/call.h | 5 ++ include/linphone/callbacks.h | 16 +++++ include/linphone/core.h | 6 +- include/linphone/player.h | 131 ++++++++++++++++++++++++++++++++--- include/linphone/types.h | 16 +++++ tester/call_single_tester.c | 26 +++++-- tester/flexisip_tester.c | 10 ++- tester/player_tester.c | 17 +++-- tools/abstractapi.py | 3 +- 12 files changed, 332 insertions(+), 57 deletions(-) diff --git a/coreapi/localplayer.c b/coreapi/localplayer.c index eb7fc3f21..ca433f1f1 100644 --- a/coreapi/localplayer.c +++ b/coreapi/localplayer.c @@ -32,11 +32,14 @@ static void _local_player_close(LinphonePlayer *obj); static void _local_player_destroy(LinphonePlayer *obj); static void _local_player_eof_callback(void *user_data); -LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, MSSndCard *snd_card, const char *video_out, void *window_id) { - LinphonePlayer *obj = ms_new0(LinphonePlayer, 1); - if(snd_card == NULL) snd_card = lc->sound_conf.ring_sndcard; - if(video_out == NULL) video_out = linphone_core_get_video_display_filter(lc); - obj->impl = ms_media_player_new(lc->factory, snd_card, video_out, window_id); +LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, const char *sound_card_name, const char *video_display_name, void *window_id) { + LinphonePlayer *obj = linphone_player_new(); + MSSndCard *snd_card; + MSSndCardManager *snd_card_manager = ms_factory_get_snd_card_manager(lc->factory); + if (sound_card_name == NULL) linphone_core_get_ringer_device(lc); + snd_card = ms_snd_card_manager_get_card(snd_card_manager, sound_card_name); + if (video_display_name == NULL) video_display_name = linphone_core_get_video_display_filter(lc); + obj->impl = ms_media_player_new(lc->factory, snd_card, video_display_name, window_id); obj->open = _local_player_open; obj->start = _local_player_start; obj->pause = _local_player_pause; @@ -94,5 +97,7 @@ static void _local_player_close(LinphonePlayer *obj) { static void _local_player_eof_callback(void *user_data) { LinphonePlayer *obj = (LinphonePlayer *)user_data; - obj->cb(obj, obj->user_data); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(obj); + LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs); + if (cb) cb(obj); } diff --git a/coreapi/player.c b/coreapi/player.c index 275a71702..4ddbd7e25 100644 --- a/coreapi/player.c +++ b/coreapi/player.c @@ -20,9 +20,43 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "private.h" -LinphoneStatus linphone_player_open(LinphonePlayer *obj, const char *filename, LinphonePlayerEofCallback cb, void *user_data){ - obj->user_data=user_data; - obj->cb=cb; +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphonePlayer); + +BELLE_SIP_INSTANCIATE_VPTR(LinphonePlayer, belle_sip_object_t, + _linphone_player_destroy, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +LinphonePlayer * linphone_player_new(void) { + LinphonePlayer *player = belle_sip_object_new(LinphonePlayer); + player->callbacks = linphone_player_cbs_new(); + return player; +} + +LinphonePlayer * linphone_player_ref(LinphonePlayer *player) { + belle_sip_object_ref(player); + return player; +} + +void linphone_player_unref(LinphonePlayer *player) { + belle_sip_object_unref(player); +} + +void *linphone_player_get_user_data(const LinphonePlayer *player) { + return player->user_data; +} + +void linphone_player_set_user_data(LinphonePlayer *player, void *ud) { + player->user_data = ud; +} + +LinphonePlayerCbs * linphone_player_get_callbacks(const LinphonePlayer *player) { + return player->callbacks; +} + +LinphoneStatus linphone_player_open(LinphonePlayer *obj, const char *filename){ return obj->open(obj,filename); } @@ -38,8 +72,16 @@ LinphoneStatus linphone_player_seek(LinphonePlayer *obj, int time_ms){ return obj->seek(obj,time_ms); } -MSPlayerState linphone_player_get_state(LinphonePlayer *obj){ - return obj->get_state(obj); +LinphonePlayerState linphone_player_get_state(LinphonePlayer *obj){ + switch (obj->get_state(obj)) { + case MSPlayerClosed: + default: + return LinphonePlayerClosed; + case MSPlayerPaused: + return LinphonePlayerPaused; + case MSPlayerPlaying: + return LinphonePlayerPlaying; + } } int linphone_player_get_duration(LinphonePlayer *obj) { @@ -59,7 +101,7 @@ void linphone_player_destroy(LinphonePlayer *obj) { } void _linphone_player_destroy(LinphonePlayer *player) { - ms_free(player); + linphone_player_cbs_unref(player->callbacks); } @@ -87,7 +129,9 @@ static bool_t call_player_check_state(LinphonePlayer *player, bool_t check_playe static void on_eof(void *user_data, MSFilter *f, unsigned int event_id, void *arg){ LinphonePlayer *player=(LinphonePlayer *)user_data; - if (player->cb) player->cb(player,player->user_data); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs); + if (cb) cb(player); } static int call_player_open(LinphonePlayer* player, const char *filename){ @@ -134,11 +178,11 @@ static void call_player_close(LinphonePlayer *player){ } static void on_call_destroy(void *obj, belle_sip_object_t *call_being_destroyed){ - _linphone_player_destroy(obj); + linphone_player_unref(obj); } LinphonePlayer *linphone_call_build_player(LinphoneCall *call){ - LinphonePlayer *obj=ms_new0(LinphonePlayer,1); + LinphonePlayer *obj = linphone_player_new(); obj->open=call_player_open; obj->close=call_player_close; obj->start=call_player_start; @@ -149,3 +193,41 @@ LinphonePlayer *linphone_call_build_player(LinphoneCall *call){ belle_sip_object_weak_ref(call,on_call_destroy,obj); return obj; } + + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphonePlayerCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphonePlayerCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE); + +LinphonePlayerCbs *linphone_player_cbs_new(void) { + return belle_sip_object_new(LinphonePlayerCbs); +} + +LinphonePlayerCbs * linphone_player_cbs_ref(LinphonePlayerCbs *cbs) { + belle_sip_object_ref(cbs); + return cbs; +} + +void linphone_player_cbs_unref(LinphonePlayerCbs *cbs) { + belle_sip_object_unref(cbs); +} + +void *linphone_player_cbs_get_user_data(const LinphonePlayerCbs *cbs) { + return cbs->user_data; +} + +void linphone_player_cbs_set_user_data(LinphonePlayerCbs *cbs, void *ud) { + cbs->user_data = ud; +} + +LinphonePlayerCbsEofReachedCb linphone_player_cbs_get_eof_reached(const LinphonePlayerCbs *cbs) { + return cbs->eof; +} + +void linphone_player_cbs_set_eof_reached(LinphonePlayerCbs *cbs, LinphonePlayerCbsEofReachedCb cb) { + cbs->eof = cb; +} diff --git a/coreapi/private.h b/coreapi/private.h index d6e83f35c..cdc11ef43 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1635,21 +1635,35 @@ LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, co * Player interface * ****************************************************************************/ -struct _LinphonePlayer{ - int (*open)(struct _LinphonePlayer* player, const char *filename); - int (*start)(struct _LinphonePlayer* player); - int (*pause)(struct _LinphonePlayer* player); - int (*seek)(struct _LinphonePlayer* player, int time_ms); - MSPlayerState (*get_state)(struct _LinphonePlayer* player); - int (*get_duration)(struct _LinphonePlayer *player); - int (*get_position)(struct _LinphonePlayer *player); - void (*close)(struct _LinphonePlayer* player); - void (*destroy)(struct _LinphonePlayer *player); - LinphonePlayerEofCallback cb; +struct _LinphonePlayerCbs { + belle_sip_object_t base; void *user_data; - void *impl; + LinphonePlayerCbsEofReachedCb eof; }; +BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphonePlayerCbs); + +LinphonePlayerCbs *linphone_player_cbs_new(void); + +struct _LinphonePlayer{ + belle_sip_object_t base; + void *user_data; + int (*open)(LinphonePlayer* player, const char *filename); + int (*start)(LinphonePlayer* player); + int (*pause)(LinphonePlayer* player); + int (*seek)(LinphonePlayer* player, int time_ms); + MSPlayerState (*get_state)(LinphonePlayer* player); + int (*get_duration)(LinphonePlayer *player); + int (*get_position)(LinphonePlayer *player); + void (*close)(LinphonePlayer* player); + void (*destroy)(LinphonePlayer *player); + void *impl; + LinphonePlayerCbs *callbacks; +}; + +BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphonePlayer); + +LinphonePlayer * linphone_player_new(void); void _linphone_player_destroy(LinphonePlayer *player); @@ -1860,7 +1874,9 @@ BELLE_SIP_TYPE_ID(LinphoneRange), BELLE_SIP_TYPE_ID(LinphoneVideoDefinition), BELLE_SIP_TYPE_ID(LinphoneTransports), BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy), -BELLE_SIP_TYPE_ID(LinphoneCallStats) +BELLE_SIP_TYPE_ID(LinphoneCallStats), +BELLE_SIP_TYPE_ID(LinphonePlayer), +BELLE_SIP_TYPE_ID(LinphonePlayerCbs) BELLE_SIP_DECLARE_TYPES_END diff --git a/include/linphone/call.h b/include/linphone/call.h index bef02c5a1..074bca2c7 100644 --- a/include/linphone/call.h +++ b/include/linphone/call.h @@ -804,6 +804,11 @@ LINPHONE_PUBLIC void linphone_call_start_recording(LinphoneCall *call); **/ LINPHONE_PUBLIC void linphone_call_stop_recording(LinphoneCall *call); +/** + * Get a player associated with the call to play a local file and stream it to the remote peer. + * @param[in] call LinphoneCall object + * @return A LinphonePlayer object + */ LINPHONE_PUBLIC LinphonePlayer * linphone_call_get_player(LinphoneCall *call); /** diff --git a/include/linphone/callbacks.h b/include/linphone/callbacks.h index 07bfffc33..b9dd4b7a1 100644 --- a/include/linphone/callbacks.h +++ b/include/linphone/callbacks.h @@ -638,6 +638,22 @@ typedef int (*LinphoneImEncryptionEngineCbsUploadingFileCb)(LinphoneImEncryption **/ typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *request); +/** + * @} +**/ + +/** + * @addtogroup call_control + * @{ + */ + +/** + * Callback for notifying end of play (file). + * @param[in] player The LinphonePlayer object +**/ +typedef void (*LinphonePlayerCbsEofReachedCb)(LinphonePlayer *obj); + + /** * @} **/ diff --git a/include/linphone/core.h b/include/linphone/core.h index ac5035880..a515333dc 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -96,12 +96,12 @@ LINPHONE_PUBLIC LinphoneAddress * linphone_core_create_address(LinphoneCore *lc, * Create an independent media file player. * This player support WAVE and MATROSKA formats. * @param lc A LinphoneCore object - * @param snd_card Playback sound card. If NULL, the sound card set in LinphoneCore will be used - * @param video_out Video display. If NULL, the video display set in LinphoneCore will be used + * @param sound_card_name Playback sound card. If NULL, the ringer sound card set in LinphoneCore will be used + * @param video_display_name Video display. If NULL, the video display set in LinphoneCore will be used * @param window_id Id of the drawing window. Depend of video out * @return A pointer on the new instance. NULL if faild. */ -LINPHONE_PUBLIC LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, MSSndCard *snd_card, const char *video_out, void *window_id); +LINPHONE_PUBLIC LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, const char *sound_card_name, const char *video_display_name, void *window_id); /** * Creates an empty info message. diff --git a/include/linphone/player.h b/include/linphone/player.h index 332cab738..dac160d96 100644 --- a/include/linphone/player.h +++ b/include/linphone/player.h @@ -31,30 +31,145 @@ extern "C" { /** - * Callback for notifying end of play (file). - * @param obj the LinphonePlayer - * @param user_data the user_data provided when calling linphone_player_open(). - * @ingroup call_control + * @addtogroup call_control + * @{ + */ + +/** + * Acquire a reference to the player. + * @param[in] player LinphonePlayer object. + * @return The same LinphonePlayer object. **/ -typedef void (*LinphonePlayerEofCallback)(LinphonePlayer *obj, void *user_data); +LINPHONE_PUBLIC LinphonePlayer * linphone_player_ref(LinphonePlayer *player); -LINPHONE_PUBLIC LinphoneStatus linphone_player_open(LinphonePlayer *obj, const char *filename, LinphonePlayerEofCallback, void *user_data); +/** + * Release reference to the player. + * @param[in] player LinphonePlayer object. +**/ +LINPHONE_PUBLIC void linphone_player_unref(LinphonePlayer *player); +/** + * Retrieve the user pointer associated with the player. + * @param[in] player LinphonePlayer object. + * @return The user pointer associated with the player. +**/ +LINPHONE_PUBLIC void *linphone_player_get_user_data(const LinphonePlayer *player); + +/** + * Assign a user pointer to the player. + * @param[in] player LinphonePlayer object. + * @param[in] ud The user pointer to associate with the player. +**/ +LINPHONE_PUBLIC void linphone_player_set_user_data(LinphonePlayer *player, void *ud); + +/** + * Get the LinphonePlayerCbs object associated with the LinphonePlayer. + * @param[in] player LinphonePlayer object + * @return The LinphonePlayerCbs object associated with the LinphonePlayer. + */ +LINPHONE_PUBLIC LinphonePlayerCbs * linphone_player_get_callbacks(const LinphonePlayer *player); + +/** + * Open a file for playing. + * @param[in] obj LinphonePlayer object + * @param[in] filename The path to the file to open + */ +LINPHONE_PUBLIC LinphoneStatus linphone_player_open(LinphonePlayer *obj, const char *filename); + +/** + * Start playing a file that has been opened with linphone_player_open(). + * @param[in] obj LinphonePlayer object + * @return 0 on success, a negative value otherwise + */ LINPHONE_PUBLIC LinphoneStatus linphone_player_start(LinphonePlayer *obj); +/** + * Pause the playing of a file. + * @param[in] obj LinphonePlayer object + * @return 0 on success, a negative value otherwise + */ LINPHONE_PUBLIC LinphoneStatus linphone_player_pause(LinphonePlayer *obj); +/** + * Seek in an opened file. + * @param[in] obj LinphonePlayer object + * @param[in] time_ms The time we want to go to in the file (in milliseconds). + * @return 0 on success, a negative value otherwise. + */ LINPHONE_PUBLIC LinphoneStatus linphone_player_seek(LinphonePlayer *obj, int time_ms); -LINPHONE_PUBLIC MSPlayerState linphone_player_get_state(LinphonePlayer *obj); +/** + * Get the current state of a player. + * @param[in] obj LinphonePlayer object + * @return The current state of the player. + */ +LINPHONE_PUBLIC LinphonePlayerState linphone_player_get_state(LinphonePlayer *obj); +/** + * Get the duration of the opened file. + * @param[in] obj LinphonePlayer object + * @return The duration of the opened file + */ LINPHONE_PUBLIC int linphone_player_get_duration(LinphonePlayer *obj); +/** + * Get the current position in the opened file. + * @param[in] obj LinphonePlayer object + * @return The current position in the opened file + */ LINPHONE_PUBLIC int linphone_player_get_current_position(LinphonePlayer *obj); +/** + * Close the opened file. + * @param[in] obj LinphonePlayer object + */ LINPHONE_PUBLIC void linphone_player_close(LinphonePlayer *obj); -LINPHONE_PUBLIC void linphone_player_destroy(LinphonePlayer *obj); + +/** + * Acquire a reference to the LinphonePlayerCbs object. + * @param[in] cbs LinphonePlayerCbs object. + * @return The same LinphonePlayerCbs object. + */ +LINPHONE_PUBLIC LinphonePlayerCbs * linphone_player_cbs_ref(LinphonePlayerCbs *cbs); + +/** + * Release reference to the LinphonePlayerCbs object. + * @param[in] cbs LinphonePlayerCbs object. + */ +LINPHONE_PUBLIC void linphone_player_cbs_unref(LinphonePlayerCbs *cbs); + +/** + * Retrieve the user pointer associated with the LinphonePlayerCbs object. + * @param[in] cbs LinphonePlayerCbs object. + * @return The user pointer associated with the LinphonePlayerCbs object. + */ +LINPHONE_PUBLIC void *linphone_player_cbs_get_user_data(const LinphonePlayerCbs *cbs); + +/** + * Assign a user pointer to the LinphonePlayerCbs object. + * @param[in] cbs LinphonePlayerCbs object. + * @param[in] ud The user pointer to associate with the LinphonePlayerCbs object. + */ +LINPHONE_PUBLIC void linphone_player_cbs_set_user_data(LinphonePlayerCbs *cbs, void *ud); + +/** + * Get the end-of-file reached callback. + * @param[in] cbs LinphonePlayerCbs object. + * @return The current end-of-file reached callback. + */ +LINPHONE_PUBLIC LinphonePlayerCbsEofReachedCb linphone_player_cbs_get_eof_reached(const LinphonePlayerCbs *cbs); + +/** + * Set the end-of-file reached callback. + * @param[in] cbs LinphonePlayerCbs object. + * @param[in] cb The end-of-file reached callback to be used. + */ +LINPHONE_PUBLIC void linphone_player_cbs_set_eof_reached(LinphonePlayerCbs *cbs, LinphonePlayerCbsEofReachedCb cb); + +/** + * @} +**/ #ifdef __cplusplus diff --git a/include/linphone/types.h b/include/linphone/types.h index 2fd84800b..dbfcf8ef9 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -710,6 +710,22 @@ typedef enum _LinphoneOnlineStatus{ **/ typedef struct _LinphonePlayer LinphonePlayer; +/** + * An object to handle the callbacks for the handling a LinphonePlayer objects. + * @ingroup call_control + */ +typedef struct _LinphonePlayerCbs LinphonePlayerCbs; + +/** + * The state of a LinphonePlayer. + * @ingroup call_control + */ +typedef enum LinphonePlayerState { + LinphonePlayerClosed, /**< No file is opened for playing. */ + LinphonePlayerPaused, /**< The player is paused. */ + LinphonePlayerPlaying /**< The player is playing. */ +} LinphonePlayerState; + /** * Presence activity type holding information about a presence activity. * @ingroup buddy_list diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 1e48d2d6d..416a5c74b 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -2482,8 +2482,9 @@ end: linphone_core_manager_destroy(pauline); } -static void on_eof(LinphonePlayer *player, void *user_data){ - LinphoneCoreManager *marie=(LinphoneCoreManager*)user_data; +static void on_eof(LinphonePlayer *player){ + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + LinphoneCoreManager *marie=(LinphoneCoreManager*)linphone_player_cbs_get_user_data(cbs); marie->stat.number_of_player_eof++; } @@ -2491,6 +2492,7 @@ static void call_with_file_player(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphonePlayer *player; + LinphonePlayerCbs *cbs; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); char *recordpath = bc_tester_file("record-call_with_file_player.wav"); bool_t call_ok; @@ -2517,9 +2519,12 @@ static void call_with_file_player(void) { BC_ASSERT_TRUE((call_ok=call(marie,pauline))); if (!call_ok) goto end; player=linphone_call_get_player(linphone_core_get_current_call(marie->lc)); + cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, on_eof); + linphone_player_cbs_set_user_data(cbs, marie); BC_ASSERT_PTR_NOT_NULL(player); if (player){ - BC_ASSERT_EQUAL(linphone_player_open(player,hellopath,on_eof,marie),0, int, "%d"); + BC_ASSERT_EQUAL(linphone_player_open(player,hellopath),0, int, "%d"); BC_ASSERT_EQUAL(linphone_player_start(player),0, int, "%d"); } /* This assert should be modified to be at least as long as the WAV file */ @@ -2585,7 +2590,10 @@ static void call_with_mkv_file_player(void) { player=linphone_call_get_player(linphone_core_get_current_call(marie->lc)); BC_ASSERT_PTR_NOT_NULL(player); if (player){ - int res = linphone_player_open(player,hellomkv,on_eof,marie); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, on_eof); + linphone_player_cbs_set_user_data(cbs, marie); + int res = linphone_player_open(player,hellomkv); //if(!ms_filter_codec_supported("opus")) { if(!ms_factory_codec_supported(marie->lc->factory, "opus") && !ms_factory_codec_supported(pauline->lc->factory, "opus")){ BC_ASSERT_EQUAL(res, -1, int, "%d"); @@ -4256,7 +4264,10 @@ static void call_with_rtp_io_mode(void) { player = linphone_call_get_player(linphone_core_get_current_call(marie->lc)); BC_ASSERT_PTR_NOT_NULL(player); if (player) { - BC_ASSERT_EQUAL(linphone_player_open(player, hellopath, on_eof, marie) , 0, int, "%d"); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, on_eof); + linphone_player_cbs_set_user_data(cbs, marie); + BC_ASSERT_EQUAL(linphone_player_open(player, hellopath) , 0, int, "%d"); BC_ASSERT_EQUAL(linphone_player_start(player) , 0, int, "%d"); } @@ -4548,7 +4559,10 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { BC_ASSERT_PTR_NOT_NULL(player); if (player) { // This will ask pauline to play the file - BC_ASSERT_EQUAL(linphone_player_open(player, hellopath, on_eof, pauline),0, int, "%d"); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, on_eof); + linphone_player_cbs_set_user_data(cbs, pauline); + BC_ASSERT_EQUAL(linphone_player_open(player, hellopath),0, int, "%d"); BC_ASSERT_EQUAL(linphone_player_start(player), 0, int, "%d"); } /* This assert should be modified to be at least as long as the WAV file */ diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 53783fbe7..57a401d29 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1295,8 +1295,9 @@ void tls_client_auth_bad_certificate(void) { } } -static void on_eof(LinphonePlayer *player, void *user_data){ - LinphoneCoreManager *marie=(LinphoneCoreManager*)user_data; +static void on_eof(LinphonePlayer *player){ + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + LinphoneCoreManager *marie=(LinphoneCoreManager*)linphone_player_cbs_get_user_data(cbs); marie->stat.number_of_player_eof++; } @@ -1332,7 +1333,10 @@ void transcoder_tester(void) { player=linphone_call_get_player(linphone_core_get_current_call(marie->lc)); BC_ASSERT_PTR_NOT_NULL(player); if (player){ - BC_ASSERT_EQUAL(linphone_player_open(player,hellopath,on_eof,marie),0, int, "%d"); + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, on_eof); + linphone_player_cbs_set_user_data(cbs, marie); + BC_ASSERT_EQUAL(linphone_player_open(player,hellopath),0, int, "%d"); BC_ASSERT_EQUAL(linphone_player_start(player),0, int, "%d"); } /* This assert should be modified to be at least as long as the WAV file */ diff --git a/tester/player_tester.c b/tester/player_tester.c index 5f68c7ba2..533ceec09 100644 --- a/tester/player_tester.c +++ b/tester/player_tester.c @@ -27,14 +27,16 @@ static bool_t wait_for_eof(bool_t *eof, int *time,int time_refresh, int timeout) return *time < timeout; } -static void eof_callback(LinphonePlayer *player, void *user_data) { - bool_t *eof = (bool_t *)user_data; +static void eof_callback(LinphonePlayer *player) { + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + bool_t *eof = (bool_t *)linphone_player_cbs_get_user_data(cbs); *eof = TRUE; } static void play_file(const char *filename, bool_t supported_format, const char *audio_mime, const char *video_mime) { LinphoneCoreManager *lc_manager = linphone_core_manager_new("marie_rc"); LinphonePlayer *player; + LinphonePlayerCbs *cbs; int res, timer = 0; bool_t eof = FALSE; @@ -42,13 +44,14 @@ static void play_file(const char *filename, bool_t supported_format, const char bool_t video_codec_supported = (video_mime && ms_factory_get_decoder(linphone_core_get_ms_factory((void *)lc_manager->lc), video_mime)); int expected_res = (supported_format && (audio_codec_supported || video_codec_supported)) ? 0 : -1; - player = linphone_core_create_local_player(lc_manager->lc, - ms_snd_card_manager_get_default_card(ms_factory_get_snd_card_manager(linphone_core_get_ms_factory((void *)lc_manager->lc))), - video_stream_get_default_video_renderer(), 0); + player = linphone_core_create_local_player(lc_manager->lc, linphone_core_get_ringer_device(lc_manager->lc), video_stream_get_default_video_renderer(), 0); BC_ASSERT_PTR_NOT_NULL(player); if(player == NULL) goto fail; - res = linphone_player_open(player, filename, eof_callback, &eof); + cbs = linphone_player_get_callbacks(player); + linphone_player_cbs_set_eof_reached(cbs, eof_callback); + linphone_player_cbs_set_user_data(cbs, &eof); + res = linphone_player_open(player, filename); BC_ASSERT_EQUAL(res, expected_res, int, "%d"); if(res == -1) goto fail; @@ -62,7 +65,7 @@ static void play_file(const char *filename, bool_t supported_format, const char linphone_player_close(player); fail: - if(player) linphone_player_destroy(player); + if(player) linphone_player_unref(player); if(lc_manager) linphone_core_manager_destroy(lc_manager); } diff --git a/tools/abstractapi.py b/tools/abstractapi.py index f12be7080..eabf276ec 100644 --- a/tools/abstractapi.py +++ b/tools/abstractapi.py @@ -456,8 +456,7 @@ class CParser(object): 'linphone_factory_create_core_with_config', # manualy wrapped 'linphone_vcard_get_belcard'] # manualy wrapped - self.classBl = ['LpConfig', - 'LinphonePlayer'] # temporarly blacklisted + self.classBl = ['LpConfig'] # temporarly blacklisted # list of classes that must be concidered as refcountable even if # they are no ref()/unref() methods