Commit ac7bf95e authored by François Grisez's avatar François Grisez
Browse files

Based LinphoneConference and LinphoneConferenceParams on belle_sip_object_t

parent 62c03843
...@@ -912,106 +912,173 @@ const char *linphone_conference_state_to_string(LinphoneConferenceState state) { ...@@ -912,106 +912,173 @@ const char *linphone_conference_state_to_string(LinphoneConferenceState state) {
return Conference::stateToString(state); return Conference::stateToString(state);
} }
struct _LinphoneConferenceParams {
::belle_sip_object_t base;
Conference::Params *params;
};
static void _linphone_conference_params_uninit(LinphoneConferenceParams *params);
static void _linphone_conference_params_clone(LinphoneConferenceParams *params, const LinphoneConferenceParams *orig);
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneConferenceParams);
BELLE_SIP_DECLARE_VPTR(LinphoneConferenceParams);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneConferenceParams, belle_sip_object_t,
_linphone_conference_params_uninit, // uninit
_linphone_conference_params_clone, // clone
NULL, // marshal
FALSE // unown
);
LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core) { LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core) {
return (LinphoneConferenceParams *)new Conference::Params(core); LinphoneConferenceParams *obj = belle_sip_object_new(LinphoneConferenceParams);
obj->params = new Conference::Params(core);
return obj;
}
static void _linphone_conference_params_uninit(LinphoneConferenceParams *params) {
delete params->params;
}
LinphoneConferenceParams *linphone_conference_params_ref(LinphoneConferenceParams *params) {
return (LinphoneConferenceParams *)belle_sip_object_ref(params);
}
void linphone_conference_params_unref(LinphoneConferenceParams *params) {
belle_sip_object_unref(params);
} }
void linphone_conference_params_free(LinphoneConferenceParams *params) { void linphone_conference_params_free(LinphoneConferenceParams *params) {
delete (Conference::Params *)params; linphone_conference_params_unref(params);
}
static void _linphone_conference_params_clone(LinphoneConferenceParams *params, const LinphoneConferenceParams *orig) {
params->params = new Conference::Params(*orig->params);
} }
LinphoneConferenceParams *linphone_conference_params_clone(const LinphoneConferenceParams *params) { LinphoneConferenceParams *linphone_conference_params_clone(const LinphoneConferenceParams *params) {
return (LinphoneConferenceParams *)new Conference::Params(*(Conference::Params *)params); return (LinphoneConferenceParams *)belle_sip_object_clone((const belle_sip_object_t *)params);
} }
void linphone_conference_params_enable_video(LinphoneConferenceParams *params, bool_t enable) { void linphone_conference_params_enable_video(LinphoneConferenceParams *params, bool_t enable) {
((Conference::Params *)params)->enableVideo((enable == TRUE) ? true : false); params->params->enableVideo(enable ? true : false);
} }
bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params) { bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params) {
return ((Conference::Params *)params)->videoRequested(); return params->params->videoRequested() ? TRUE : FALSE;
} }
void linphone_conference_params_set_state_changed_callback(LinphoneConferenceParams *params, LinphoneConferenceStateChangedCb cb, void *user_data) { void linphone_conference_params_set_state_changed_callback(LinphoneConferenceParams *params, LinphoneConferenceStateChangedCb cb, void *user_data) {
((Conference::Params *)params)->setStateChangedCallback(cb, user_data); params->params->setStateChangedCallback(cb, user_data);
} }
struct _LinphoneConference {
belle_sip_object_t base;
Conference *conf;
};
static void _linphone_conference_uninit(LinphoneConference *conf);
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneConference);
BELLE_SIP_DECLARE_VPTR(LinphoneConference);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneConference, belle_sip_object_t,
_linphone_conference_uninit, // uninit
NULL, // clone
NULL, // marshal
FALSE // unown
);
LinphoneConference *linphone_local_conference_new(LinphoneCore *core) { LinphoneConference *linphone_local_conference_new(LinphoneCore *core) {
return (LinphoneConference *) new LocalConference(core); LinphoneConference *conf = belle_sip_object_new(LinphoneConference);
conf->conf = new LocalConference(core);
return conf;
} }
LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) { LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) {
return (LinphoneConference *) new LocalConference(core, (Conference::Params *)params); LinphoneConference *conf = belle_sip_object_new(LinphoneConference);
conf->conf = new LocalConference(core, params->params);
return conf;
} }
LinphoneConference *linphone_remote_conference_new(LinphoneCore *core) { LinphoneConference *linphone_remote_conference_new(LinphoneCore *core) {
return (LinphoneConference *) new RemoteConference(core); LinphoneConference *conf = belle_sip_object_new(LinphoneConference);
conf->conf = new RemoteConference(core);
return conf;
} }
LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) { LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) {
return (LinphoneConference *) new RemoteConference(core, (Conference::Params *)params); LinphoneConference *conf = belle_sip_object_new(LinphoneConference);
conf->conf = new RemoteConference(core, params->params);
return conf;
}
static void _linphone_conference_uninit(LinphoneConference *conf) {
delete conf->conf;
}
LinphoneConference *linphone_conference_ref(LinphoneConference *conf) {
return (LinphoneConference *)belle_sip_object_ref(conf);
} }
void linphone_conference_free(LinphoneConference *obj) { void linphone_conference_unref(LinphoneConference *conf) {
delete (Conference *)obj; belle_sip_object_unref(conf);
} }
LinphoneConferenceState linphone_conference_get_state(const LinphoneConference *obj) { LinphoneConferenceState linphone_conference_get_state(const LinphoneConference *obj) {
return ((Conference *)obj)->getState(); return obj->conf->getState();
} }
int linphone_conference_add_participant(LinphoneConference *obj, LinphoneCall *call) { int linphone_conference_add_participant(LinphoneConference *obj, LinphoneCall *call) {
return ((Conference *)obj)->addParticipant(call); return obj->conf->addParticipant(call);
} }
int linphone_conference_remove_participant(LinphoneConference *obj, const LinphoneAddress *uri) { int linphone_conference_remove_participant(LinphoneConference *obj, const LinphoneAddress *uri) {
return ((Conference *)obj)->removeParticipant(uri); return obj->conf->removeParticipant(uri);
} }
int linphone_conference_remove_participant_with_call(LinphoneConference *obj, LinphoneCall *call) { int linphone_conference_remove_participant_with_call(LinphoneConference *obj, LinphoneCall *call) {
return ((Conference *)obj)->removeParticipant(call); return obj->conf->removeParticipant(call);
} }
int linphone_conference_terminate(LinphoneConference *obj) { int linphone_conference_terminate(LinphoneConference *obj) {
return ((Conference *)obj)->terminate(); return obj->conf->terminate();
} }
int linphone_conference_enter(LinphoneConference *obj) { int linphone_conference_enter(LinphoneConference *obj) {
return ((Conference *)obj)->enter(); return obj->conf->enter();
} }
int linphone_conference_leave(LinphoneConference *obj) { int linphone_conference_leave(LinphoneConference *obj) {
return ((Conference *)obj)->leave(); return obj->conf->leave();
} }
bool_t linphone_conference_is_in(const LinphoneConference *obj) { bool_t linphone_conference_is_in(const LinphoneConference *obj) {
return ((Conference *)obj)->isIn(); return obj->conf->isIn();
} }
AudioStream *linphone_conference_get_audio_stream(const LinphoneConference *obj) { AudioStream *linphone_conference_get_audio_stream(const LinphoneConference *obj) {
return ((Conference *)obj)->getAudioStream(); return obj->conf->getAudioStream();
} }
int linphone_conference_mute_microphone(LinphoneConference *obj, bool_t val) { int linphone_conference_mute_microphone(LinphoneConference *obj, bool_t val) {
return ((Conference *)obj)->muteMicrophone((val == TRUE) ? true : false); return obj->conf->muteMicrophone(val ? true : false);
} }
bool_t linphone_conference_microphone_is_muted(const LinphoneConference *obj) { bool_t linphone_conference_microphone_is_muted(const LinphoneConference *obj) {
return ((Conference *)obj)->microphoneIsMuted(); return obj->conf->microphoneIsMuted() ? TRUE : FALSE;
} }
float linphone_conference_get_input_volume(const LinphoneConference *obj) { float linphone_conference_get_input_volume(const LinphoneConference *obj) {
return ((Conference *)obj)->getInputVolume(); return obj->conf->getInputVolume();
} }
int linphone_conference_get_size(const LinphoneConference *obj) { int linphone_conference_get_size(const LinphoneConference *obj) {
return ((Conference *)obj)->getSize(); return obj->conf->getSize();
} }
bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj) { bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj) {
const list<Conference::Participant *> &participants = ((Conference *)obj)->getParticipants(); const list<Conference::Participant *> &participants = obj->conf->getParticipants();
bctbx_list_t *participants_list = NULL; bctbx_list_t *participants_list = NULL;
for(list<Conference::Participant *>::const_iterator it=participants.begin();it!=participants.end();it++) { for(list<Conference::Participant *>::const_iterator it=participants.begin();it!=participants.end();it++) {
LinphoneAddress *uri = linphone_address_clone((*it)->getUri()); LinphoneAddress *uri = linphone_address_clone((*it)->getUri());
...@@ -1021,29 +1088,29 @@ bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj ...@@ -1021,29 +1088,29 @@ bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj
} }
int linphone_conference_start_recording(LinphoneConference *obj, const char *path) { int linphone_conference_start_recording(LinphoneConference *obj, const char *path) {
return ((Conference *)obj)->startRecording(path); return obj->conf->startRecording(path);
} }
int linphone_conference_stop_recording(LinphoneConference *obj) { int linphone_conference_stop_recording(LinphoneConference *obj) {
return ((Conference *)obj)->stopRecording(); return obj->conf->stopRecording();
} }
void linphone_conference_on_call_stream_starting(LinphoneConference *obj, LinphoneCall *call, bool_t is_paused_by_remote) { void linphone_conference_on_call_stream_starting(LinphoneConference *obj, LinphoneCall *call, bool_t is_paused_by_remote) {
((Conference *)obj)->onCallStreamStarting(call, (is_paused_by_remote == TRUE) ? true : false); obj->conf->onCallStreamStarting(call, is_paused_by_remote ? true : false);
} }
void linphone_conference_on_call_stream_stopping(LinphoneConference *obj, LinphoneCall *call) { void linphone_conference_on_call_stream_stopping(LinphoneConference *obj, LinphoneCall *call) {
((Conference *)obj)->onCallStreamStopping(call); obj->conf->onCallStreamStopping(call);
} }
void linphone_conference_on_call_terminating(LinphoneConference *obj, LinphoneCall *call) { void linphone_conference_on_call_terminating(LinphoneConference *obj, LinphoneCall *call) {
((Conference *)obj)->onCallTerminating(call); obj->conf->onCallTerminating(call);
} }
bool_t linphone_conference_check_class(LinphoneConference *obj, LinphoneConferenceClass _class) { bool_t linphone_conference_check_class(LinphoneConference *obj, LinphoneConferenceClass _class) {
switch(_class) { switch(_class) {
case LinphoneConferenceClassLocal: return typeid(obj) == typeid(LocalConference); case LinphoneConferenceClassLocal: return typeid(obj->conf) == typeid(LocalConference);
case LinphoneConferenceClassRemote: return typeid(obj) == typeid(RemoteConference); case LinphoneConferenceClassRemote: return typeid(obj->conf) == typeid(RemoteConference);
default: return FALSE; default: return FALSE;
} }
} }
...@@ -74,7 +74,7 @@ LinphoneConference *linphone_local_conference_new(LinphoneCore *core); ...@@ -74,7 +74,7 @@ LinphoneConference *linphone_local_conference_new(LinphoneCore *core);
LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params); LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params);
LinphoneConference *linphone_remote_conference_new(LinphoneCore *core); LinphoneConference *linphone_remote_conference_new(LinphoneCore *core);
LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params); LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params);
void linphone_conference_free(LinphoneConference *obj);
/** /**
* Get the state of a conference * Get the state of a conference
*/ */
......
...@@ -6586,7 +6586,7 @@ LinphoneRingtonePlayer *linphone_core_get_ringtoneplayer(LinphoneCore *lc) { ...@@ -6586,7 +6586,7 @@ LinphoneRingtonePlayer *linphone_core_get_ringtoneplayer(LinphoneCore *lc) {
static int _linphone_core_delayed_conference_destriction_cb(void *user_data, unsigned int event) { static int _linphone_core_delayed_conference_destriction_cb(void *user_data, unsigned int event) {
LinphoneConference *conf = (LinphoneConference *)user_data; LinphoneConference *conf = (LinphoneConference *)user_data;
linphone_conference_free(conf); linphone_conference_unref(conf);
return 0; return 0;
} }
...@@ -6658,7 +6658,7 @@ int linphone_core_terminate_conference(LinphoneCore *lc) { ...@@ -6658,7 +6658,7 @@ int linphone_core_terminate_conference(LinphoneCore *lc) {
return -1; return -1;
} }
linphone_conference_terminate(lc->conf_ctx); linphone_conference_terminate(lc->conf_ctx);
linphone_conference_free(lc->conf_ctx); linphone_conference_unref(lc->conf_ctx);
lc->conf_ctx = NULL; lc->conf_ctx = NULL;
return 0; return 0;
} }
......
...@@ -1606,7 +1606,9 @@ BELLE_SIP_TYPE_ID(LinphonePresenceService), ...@@ -1606,7 +1606,9 @@ BELLE_SIP_TYPE_ID(LinphonePresenceService),
BELLE_SIP_TYPE_ID(LinphonePresencePerson), BELLE_SIP_TYPE_ID(LinphonePresencePerson),
BELLE_SIP_TYPE_ID(LinphonePresenceActivity), BELLE_SIP_TYPE_ID(LinphonePresenceActivity),
BELLE_SIP_TYPE_ID(LinphonePresenceNote), BELLE_SIP_TYPE_ID(LinphonePresenceNote),
BELLE_SIP_TYPE_ID(LinphoneTunnel) BELLE_SIP_TYPE_ID(LinphoneTunnel),
BELLE_SIP_TYPE_ID(LinphoneConferenceParams),
BELLE_SIP_TYPE_ID(LinphoneConference)
BELLE_SIP_DECLARE_TYPES_END BELLE_SIP_DECLARE_TYPES_END
......
...@@ -44,11 +44,25 @@ extern "C" { ...@@ -44,11 +44,25 @@ extern "C" {
*/ */
LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core); LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core);
/**
* Take a reference on a #LinphoneConferencParams.
* @param[in] params The #LinphoneConferenceParams to ref.
* @return The freshly refed #LinphoneConferenceParams.
*/
LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_ref(LinphoneConferenceParams *params);
/**
* Release a #LinphoneConferenceParams.
* @param[in] params The #LinphoneConferenceParams to release.
*/
LINPHONE_PUBLIC void linphone_conference_params_unref(LinphoneConferenceParams *params);
/** /**
* Free a #LinphoneConferenceParams * Free a #LinphoneConferenceParams
* @param params #LinphoneConferenceParams to free * @param params #LinphoneConferenceParams to free
* @deprecated Use linphone_conference_params_unref() instead.
*/ */
LINPHONE_PUBLIC void linphone_conference_params_free(LinphoneConferenceParams *params); LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_conference_params_free(LinphoneConferenceParams *params);
/** /**
* Clone a #LinphoneConferenceParams * Clone a #LinphoneConferenceParams
...@@ -71,6 +85,19 @@ LINPHONE_PUBLIC void linphone_conference_params_enable_video(LinphoneConferenceP ...@@ -71,6 +85,19 @@ LINPHONE_PUBLIC void linphone_conference_params_enable_video(LinphoneConferenceP
LINPHONE_PUBLIC bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params); LINPHONE_PUBLIC bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params);
/**
* Take a reference on a #LinphoneConference.
* @param[in] conf The #LinphoneConference to ref.
* @return The freshly refed #LinphoneConference.
*/
LINPHONE_PUBLIC LinphoneConference *linphone_conference_ref(LinphoneConference *conf);
/**
* Release a #LinphoneConference.
* @param[in] conf The #LinphoneConference to release.
*/
LINPHONE_PUBLIC void linphone_conference_unref(LinphoneConference *conf);
/** /**
* Remove a participant from a conference * Remove a participant from a conference
* @param obj A #LinphoneConference * @param obj A #LinphoneConference
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment