mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 17:29:20 +00:00
Add a destroy function to the Linphone Player Interface
This commit is contained in:
parent
d90dc113b2
commit
fd75b79477
5 changed files with 25 additions and 13 deletions
|
|
@ -595,6 +595,7 @@ MSPlayerState linphone_player_get_state(LinphonePlayer *obj);
|
|||
int linphone_player_get_duration(LinphonePlayer *obj);
|
||||
int linphone_player_get_current_position(LinphonePlayer *obj);
|
||||
void linphone_player_close(LinphonePlayer *obj);
|
||||
void linphone_player_destroy(LinphonePlayer *obj);
|
||||
|
||||
/**
|
||||
* @brief Create an independent media file player.
|
||||
|
|
@ -607,12 +608,6 @@ void linphone_player_close(LinphonePlayer *obj);
|
|||
*/
|
||||
LINPHONE_PUBLIC LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, MSSndCard *snd_card, const char *video_out, void *window_id);
|
||||
|
||||
/**
|
||||
* @brief Destroy a local player
|
||||
* @param obj File player to destroy
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_local_player_destroy(LinphonePlayer *obj);
|
||||
|
||||
/**
|
||||
* @brief Check whether Matroksa format is supported by the player
|
||||
* @return TRUE if it is supported
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ static MSPlayerState _local_player_get_state(LinphonePlayer *obj);
|
|||
static int _local_player_get_duration(LinphonePlayer *obj);
|
||||
static int _local_player_get_current_position(LinphonePlayer *obj);
|
||||
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) {
|
||||
|
|
@ -44,15 +45,11 @@ LinphonePlayer *linphone_core_create_local_player(LinphoneCore *lc, MSSndCard *s
|
|||
obj->get_duration = _local_player_get_duration;
|
||||
obj->get_position = _local_player_get_current_position;
|
||||
obj->close = _local_player_close;
|
||||
obj->destroy = _local_player_destroy;
|
||||
ms_media_player_set_eof_callback((MSMediaPlayer *)obj->impl, _local_player_eof_callback, obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
void linphone_local_player_destroy(LinphonePlayer *obj) {
|
||||
ms_media_player_free((MSMediaPlayer *)obj->impl);
|
||||
ms_free(obj);
|
||||
}
|
||||
|
||||
bool_t linphone_local_player_matroska_supported(void) {
|
||||
return ms_media_player_matroska_supported();
|
||||
}
|
||||
|
|
@ -86,6 +83,11 @@ static int _local_player_get_current_position(LinphonePlayer *obj) {
|
|||
return ms_media_player_get_current_position((MSMediaPlayer *)obj->impl);
|
||||
}
|
||||
|
||||
static void _local_player_destroy(LinphonePlayer *obj) {
|
||||
ms_media_player_free((MSMediaPlayer *)obj->impl);
|
||||
_linphone_player_destroy(obj);
|
||||
}
|
||||
|
||||
static void _local_player_close(LinphonePlayer *obj) {
|
||||
ms_media_player_close((MSMediaPlayer *)obj->impl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,18 @@ void linphone_player_close(LinphonePlayer *obj){
|
|||
return obj->close(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy a player
|
||||
* @param obj The player
|
||||
*/
|
||||
void linphone_player_destroy(LinphonePlayer *obj) {
|
||||
if(obj->destroy) obj->destroy(obj);
|
||||
}
|
||||
|
||||
void _linphone_player_destroy(LinphonePlayer *player) {
|
||||
ms_free(player);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Call player implementation below.
|
||||
|
|
@ -169,7 +181,7 @@ static void call_player_close(LinphonePlayer *player){
|
|||
}
|
||||
|
||||
static void on_call_destroy(void *obj, belle_sip_object_t *call_being_destroyed){
|
||||
ms_free(obj);
|
||||
_linphone_player_destroy(obj);
|
||||
}
|
||||
|
||||
LinphonePlayer *linphone_call_build_player(LinphoneCall *call){
|
||||
|
|
|
|||
|
|
@ -923,11 +923,14 @@ struct _LinphonePlayer{
|
|||
int (*get_duration)(struct _LinphonePlayer *player);
|
||||
int (*get_position)(struct _LinphonePlayer *player);
|
||||
void (*close)(struct _LinphonePlayer* player);
|
||||
void (*destroy)(struct _LinphonePlayer *player);
|
||||
LinphonePlayerEofCallback cb;
|
||||
void *user_data;
|
||||
void *impl;
|
||||
};
|
||||
|
||||
void _linphone_player_destroy(LinphonePlayer *player);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* XML UTILITY FUNCTIONS *
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static void play_file(const char *filename, bool_t unsupported_format) {
|
|||
linphone_player_close(player);
|
||||
|
||||
fail:
|
||||
if(player) linphone_local_player_destroy(player);
|
||||
if(player) linphone_player_destroy(player);
|
||||
if(lc_manager) linphone_core_manager_destroy(lc_manager);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue