Commit 7588a540 authored by Ghislain MARY's avatar Ghislain MARY

Convert LinphoneCall to Call C++ class.

parent d795a305
......@@ -20,17 +20,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/call_params.h"
#include "private.h"
#include "c-wrapper/c-private-types.h"
#include "c-wrapper/c-tools.h"
#include "conference/params/media-session-params.h"
#include "conference/params/call-session-params-p.h"
#include "conference/params/media-session-params-p.h"
struct _LinphoneCallParams{
belle_sip_object_t base;
void *user_data;
LinphonePrivate::MediaSessionParams *msp;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallParams);
......@@ -82,15 +78,15 @@ SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params) {
}
void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setCustomHeaders(ch);
L_GET_PRIVATE(static_cast<LinphonePrivate::CallSessionParams *>(params->msp.get()))->setCustomHeaders(ch);
}
void linphone_call_params_set_custom_sdp_attributes(LinphoneCallParams *params, const SalCustomSdpAttribute *csa) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setCustomSdpAttributes(csa);
L_GET_PRIVATE(params->msp.get())->setCustomSdpAttributes(csa);
}
void linphone_call_params_set_custom_sdp_media_attributes(LinphoneCallParams *params, LinphoneStreamType type, const SalCustomSdpAttribute *csa) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setCustomSdpMediaAttributes(type, csa);
L_GET_PRIVATE(params->msp.get())->setCustomSdpMediaAttributes(type, csa);
}
......@@ -247,7 +243,7 @@ const OrtpPayloadType *linphone_call_params_get_used_audio_codec(const LinphoneC
}
void linphone_call_params_set_used_audio_codec(LinphoneCallParams *params, OrtpPayloadType *codec) {
params->msp->getPrivate()->setUsedAudioCodec(codec);
L_GET_PRIVATE(params->msp.get())->setUsedAudioCodec(codec);
}
const OrtpPayloadType *linphone_call_params_get_used_video_codec(const LinphoneCallParams *params) {
......@@ -255,7 +251,7 @@ const OrtpPayloadType *linphone_call_params_get_used_video_codec(const LinphoneC
}
void linphone_call_params_set_used_video_codec(LinphoneCallParams *params, OrtpPayloadType *codec) {
params->msp->getPrivate()->setUsedVideoCodec(codec);
L_GET_PRIVATE(params->msp.get())->setUsedVideoCodec(codec);
}
const OrtpPayloadType *linphone_call_params_get_used_text_codec(const LinphoneCallParams *params) {
......@@ -263,7 +259,7 @@ const OrtpPayloadType *linphone_call_params_get_used_text_codec(const LinphoneCa
}
void linphone_call_params_set_used_text_codec(LinphoneCallParams *params, OrtpPayloadType *codec) {
params->msp->getPrivate()->setUsedRealtimeTextCodec(codec);
L_GET_PRIVATE(params->msp.get())->setUsedRealtimeTextCodec(codec);
}
bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *params) {
......@@ -366,11 +362,11 @@ void linphone_call_params_set_avpf_rr_interval(LinphoneCallParams *params, uint1
}
void linphone_call_params_set_sent_fps(LinphoneCallParams *params, float value) {
params->msp->getPrivate()->setSentFps(value);
L_GET_PRIVATE(params->msp.get())->setSentFps(value);
}
void linphone_call_params_set_received_fps(LinphoneCallParams *params, float value) {
params->msp->getPrivate()->setReceivedFps(value);
L_GET_PRIVATE(params->msp.get())->setReceivedFps(value);
}
......@@ -379,111 +375,115 @@ void linphone_call_params_set_received_fps(LinphoneCallParams *params, float val
******************************************************************************/
bool_t linphone_call_params_get_in_conference(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getInConference();
return L_GET_PRIVATE(static_cast<const LinphonePrivate::CallSessionParams *>(params->msp.get()))->getInConference();
}
void linphone_call_params_set_in_conference(LinphoneCallParams *params, bool_t value) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setInConference(value);
L_GET_PRIVATE(static_cast<LinphonePrivate::CallSessionParams *>(params->msp.get()))->setInConference(value);
}
bool_t linphone_call_params_get_internal_call_update(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getInternalCallUpdate();
return L_GET_PRIVATE(static_cast<const LinphonePrivate::CallSessionParams *>(params->msp.get()))->getInternalCallUpdate();
}
void linphone_call_params_set_internal_call_update(LinphoneCallParams *params, bool_t value) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setInternalCallUpdate(value);
L_GET_PRIVATE(static_cast<LinphonePrivate::CallSessionParams *>(params->msp.get()))->setInternalCallUpdate(value);
}
bool_t linphone_call_params_implicit_rtcp_fb_enabled(const LinphoneCallParams *params) {
return params->msp->getPrivate()->implicitRtcpFbEnabled();
return L_GET_PRIVATE(params->msp.get())->implicitRtcpFbEnabled();
}
void linphone_call_params_enable_implicit_rtcp_fb(LinphoneCallParams *params, bool_t value) {
params->msp->getPrivate()->enableImplicitRtcpFb(value);
L_GET_PRIVATE(params->msp.get())->enableImplicitRtcpFb(value);
}
int linphone_call_params_get_down_bandwidth(const LinphoneCallParams *params) {
return params->msp->getPrivate()->getDownBandwidth();
return L_GET_PRIVATE(params->msp.get())->getDownBandwidth();
}
void linphone_call_params_set_down_bandwidth(LinphoneCallParams *params, int value) {
params->msp->getPrivate()->setDownBandwidth(value);
L_GET_PRIVATE(params->msp.get())->setDownBandwidth(value);
}
int linphone_call_params_get_up_bandwidth(const LinphoneCallParams *params) {
return params->msp->getPrivate()->getUpBandwidth();
return L_GET_PRIVATE(params->msp.get())->getUpBandwidth();
}
void linphone_call_params_set_up_bandwidth(LinphoneCallParams *params, int value) {
params->msp->getPrivate()->setUpBandwidth(value);
L_GET_PRIVATE(params->msp.get())->setUpBandwidth(value);
}
int linphone_call_params_get_down_ptime(const LinphoneCallParams *params) {
return params->msp->getPrivate()->getDownPtime();
return L_GET_PRIVATE(params->msp.get())->getDownPtime();
}
void linphone_call_params_set_down_ptime(LinphoneCallParams *params, int value) {
params->msp->getPrivate()->setDownPtime(value);
L_GET_PRIVATE(params->msp.get())->setDownPtime(value);
}
int linphone_call_params_get_up_ptime(const LinphoneCallParams *params) {
return params->msp->getPrivate()->getUpPtime();
return L_GET_PRIVATE(params->msp.get())->getUpPtime();
}
void linphone_call_params_set_up_ptime(LinphoneCallParams *params, int value) {
params->msp->getPrivate()->setUpPtime(value);
L_GET_PRIVATE(params->msp.get())->setUpPtime(value);
}
SalCustomHeader * linphone_call_params_get_custom_headers(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getCustomHeaders();
return L_GET_PRIVATE(static_cast<const LinphonePrivate::CallSessionParams *>(params->msp.get()))->getCustomHeaders();
}
SalCustomSdpAttribute * linphone_call_params_get_custom_sdp_attributes(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getCustomSdpAttributes();
return L_GET_PRIVATE(params->msp.get())->getCustomSdpAttributes();
}
SalCustomSdpAttribute * linphone_call_params_get_custom_sdp_media_attributes(const LinphoneCallParams *params, LinphoneStreamType type) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getCustomSdpMediaAttributes(type);
return L_GET_PRIVATE(params->msp.get())->getCustomSdpMediaAttributes(type);
}
LinphoneCall * linphone_call_params_get_referer(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getReferer();
return L_GET_PRIVATE(static_cast<const LinphonePrivate::CallSessionParams *>(params->msp.get()))->getReferer();
}
void linphone_call_params_set_referer(LinphoneCallParams *params, LinphoneCall *referer) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setReferer(referer);
L_GET_PRIVATE(static_cast<LinphonePrivate::CallSessionParams *>(params->msp.get()))->setReferer(referer);
}
bool_t linphone_call_params_get_update_call_when_ice_completed(const LinphoneCallParams *params) {
return params->msp->getPrivate()->getUpdateCallWhenIceCompleted();
return L_GET_PRIVATE(params->msp.get())->getUpdateCallWhenIceCompleted();
}
void linphone_call_params_set_update_call_when_ice_completed(LinphoneCallParams *params, bool_t value) {
params->msp->getPrivate()->setUpdateCallWhenIceCompleted(value);
L_GET_PRIVATE(params->msp.get())->setUpdateCallWhenIceCompleted(value);
}
void linphone_call_params_set_sent_vsize(LinphoneCallParams *params, MSVideoSize vsize) {
params->msp->getPrivate()->setSentVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr));
L_GET_PRIVATE(params->msp.get())->setSentVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr));
}
void linphone_call_params_set_recv_vsize(LinphoneCallParams *params, MSVideoSize vsize) {
params->msp->getPrivate()->setReceivedVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr));
L_GET_PRIVATE(params->msp.get())->setReceivedVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr));
}
void linphone_call_params_set_sent_video_definition(LinphoneCallParams *params, LinphoneVideoDefinition *vdef) {
params->msp->getPrivate()->setSentVideoDefinition(vdef);
L_GET_PRIVATE(params->msp.get())->setSentVideoDefinition(vdef);
}
void linphone_call_params_set_received_video_definition(LinphoneCallParams *params, LinphoneVideoDefinition *vdef) {
params->msp->getPrivate()->setReceivedVideoDefinition(vdef);
L_GET_PRIVATE(params->msp.get())->setReceivedVideoDefinition(vdef);
}
bool_t linphone_call_params_get_no_user_consent(const LinphoneCallParams *params) {
return static_cast<const LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->getNoUserConsent();
return L_GET_PRIVATE(static_cast<const LinphonePrivate::CallSessionParams *>(params->msp.get()))->getNoUserConsent();
}
void linphone_call_params_set_no_user_consent(LinphoneCallParams *params, bool_t value) {
static_cast<LinphonePrivate::CallSessionParams *>(params->msp)->getPrivate()->setNoUserConsent(value);
L_GET_PRIVATE(static_cast<LinphonePrivate::CallSessionParams *>(params->msp.get()))->setNoUserConsent(value);
}
std::shared_ptr<LinphonePrivate::MediaSessionParams> linphone_call_params_get_cpp_obj(const LinphoneCallParams *params) {
return params->msp;
}
......@@ -514,19 +514,24 @@ void linphone_call_params_unref(LinphoneCallParams *cp) {
******************************************************************************/
static void _linphone_call_params_destroy(LinphoneCallParams *params) {
delete params->msp;
params->msp = nullptr;
}
static void _linphone_call_params_clone(LinphoneCallParams *dst, const LinphoneCallParams *src) {
dst->msp = new LinphonePrivate::MediaSessionParams(*src->msp);
dst->msp = std::make_shared<LinphonePrivate::MediaSessionParams>(*src->msp);
}
LinphoneCallParams * linphone_call_params_new(void) {
LinphoneCallParams * linphone_call_params_new(LinphoneCore *core) {
LinphoneCallParams *params = belle_sip_object_new(LinphoneCallParams);
params->msp = new LinphonePrivate::MediaSessionParams();
params->msp = std::make_shared<LinphonePrivate::MediaSessionParams>();
params->msp->initDefault(core);
return params;
}
LinphoneCallParams * linphone_call_params_new_for_wrapper(void) {
return belle_sip_object_new(LinphoneCallParams);
}
/* DEPRECATED */
void linphone_call_params_destroy(LinphoneCallParams *cp) {
linphone_call_params_unref(cp);
......
This diff is collapsed.
......@@ -192,7 +192,7 @@ static LinphoneChatRoom *_linphone_core_create_chat_room(LinphoneCore *lc, Linph
}
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call){
LinphoneChatRoom *cr = _linphone_core_create_chat_room_base(call->core,
LinphoneChatRoom *cr = _linphone_core_create_chat_room_base(linphone_call_get_core(call),
linphone_address_clone(linphone_call_get_remote_address(call)));
linphone_chat_room_set_call(cr, call);
return cr;
......@@ -614,7 +614,7 @@ LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t
const uint32_t crlf = 0x0D0A;
const uint32_t lf = 0x0A;
if (!call || !call->textstream) {
if (!call || !linphone_call_get_stream(call, LinphoneStreamTypeText)) {
return -1;
}
......@@ -637,7 +637,7 @@ LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t
delete value;
}
text_stream_putchar32(call->textstream, character);
text_stream_putchar32(reinterpret_cast<TextStream *>(linphone_call_get_stream(call, LinphoneStreamTypeText)), character);
return 0;
}
......
......@@ -54,8 +54,9 @@ public:
~Participant() {
linphone_address_unref(m_uri);
#if 0
if(m_call) m_call->conf_ref = NULL;
#endif
}
const LinphoneAddress *getUri() const {
......@@ -257,7 +258,9 @@ Conference::Conference(LinphoneCore *core, LinphoneConference *conf, const Confe
int Conference::addParticipant(LinphoneCall *call) {
Participant *p =new Participant(call);
m_participants.push_back(p);
#if 0
call->conf_ref = m_conference;
#endif
return 0;
}
......@@ -424,7 +427,7 @@ int LocalConference::inviteAddresses(const std::list<const LinphoneAddress*> &ad
linphone_call_params_unref(new_params);
}else{
/*there is already a call to this address, so simply join it to the local conference if not already done*/
if (!linphone_call_params_get_in_conference(call->current_params))
if (!linphone_call_params_get_in_conference(linphone_call_get_current_params(call)))
addParticipant(call);
}
/*if the local participant is not yet created, created it and it to the conference */
......@@ -434,6 +437,7 @@ int LocalConference::inviteAddresses(const std::list<const LinphoneAddress*> &ad
}
int LocalConference::addParticipant(LinphoneCall *call) {
#if 0
if (linphone_call_params_get_in_conference(call->current_params)){
ms_error("Already in conference");
return -1;
......@@ -465,9 +469,13 @@ int LocalConference::addParticipant(LinphoneCall *call) {
return -1;
}
return 0;
#else
return 0;
#endif
}
int LocalConference::removeFromConference(LinphoneCall *call, bool_t active){
#if 0
int err=0;
char *str;
......@@ -501,6 +509,9 @@ int LocalConference::removeFromConference(LinphoneCall *call, bool_t active){
err=_linphone_call_pause(call);
}
return err;
#else
return 0;
#endif
}
int LocalConference::remoteParticipantsCount() {
......@@ -522,7 +533,7 @@ int LocalConference::convertConferenceToCall(){
while (calls) {
LinphoneCall *rc=(LinphoneCall*)calls->data;
calls=calls->next;
if (linphone_call_params_get_in_conference(rc->params)) { // not using current_param
if (linphone_call_params_get_in_conference(linphone_call_get_params(rc))) { // not using current_param
bool_t active_after_removed=isIn();
err=removeFromConference(rc, active_after_removed);
break;
......@@ -566,7 +577,7 @@ int LocalConference::terminate() {
while (calls) {
LinphoneCall *call=(LinphoneCall*)calls->data;
calls=calls->next;
if (linphone_call_params_get_in_conference(call->current_params)) {
if (linphone_call_params_get_in_conference(linphone_call_get_current_params(call))) {
linphone_call_terminate(call);
}
}
......@@ -639,6 +650,7 @@ int LocalConference::stopRecording() {
}
void LocalConference::onCallStreamStarting(LinphoneCall *call, bool isPausedByRemote) {
#if 0
linphone_call_params_enable_video(call->params, FALSE);
call->camera_enabled = FALSE;
ms_message("LocalConference::onCallStreamStarting(): joining AudioStream [%p] of call [%p] into conference.", call->audiostream, call);
......@@ -648,16 +660,20 @@ void LocalConference::onCallStreamStarting(LinphoneCall *call, bool isPausedByRe
call->endpoint=ep;
setState(LinphoneConferenceRunning);
Conference::addParticipant(call);
#endif
}
void LocalConference::onCallStreamStopping(LinphoneCall *call) {
#if 0
ms_audio_conference_remove_member(m_conf,call->endpoint);
ms_audio_endpoint_release_from_stream(call->endpoint);
call->endpoint=NULL;
Conference::removeParticipant(call);
#endif
}
void LocalConference::onCallTerminating(LinphoneCall *call) {
#if 0
int remote_count=remoteParticipantsCount();
ms_message("conference_check_uninit(): size=%i", getSize());
if (remote_count==1 && !m_terminating){
......@@ -672,6 +688,7 @@ void LocalConference::onCallTerminating(LinphoneCall *call) {
}
setState(LinphoneConferenceStopped);
}
#endif
}
......@@ -701,6 +718,7 @@ int RemoteConference::inviteAddresses(const std::list<const LinphoneAddress *> &
}
int RemoteConference::addParticipant(LinphoneCall *call) {
#if 0
LinphoneAddress *addr;
LinphoneCallParams *params;
......@@ -742,6 +760,9 @@ int RemoteConference::addParticipant(LinphoneCall *call) {
ms_error("Could not add call %p to the conference. Bad conference state (%s)", call, stateToString(m_state));
return -1;
}
#else
return -1;
#endif
}
int RemoteConference::removeParticipant(const LinphoneAddress *uri) {
......@@ -762,7 +783,7 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) {
linphone_address_set_method_param(refer_to_addr, "BYE");
refer_to = linphone_address_as_string(refer_to_addr);
linphone_address_unref(refer_to_addr);
res = sal_call_refer(m_focusCall->op, refer_to);
res = sal_call_refer(linphone_call_get_op(m_focusCall), refer_to);
ms_free(refer_to);
if(res == 0) {
......
......@@ -78,8 +78,8 @@ LinphoneInfoMessage *linphone_core_create_info_message(LinphoneCore *lc){
LinphoneStatus linphone_call_send_info_message(LinphoneCall *call, const LinphoneInfoMessage *info) {
SalBodyHandler *body_handler = sal_body_handler_from_content(info->content);
sal_op_set_sent_custom_header(call->op, info->headers);
return sal_send_info(call->op,NULL, NULL, body_handler);
sal_op_set_sent_custom_header(linphone_call_get_op(call), info->headers);
return sal_send_info(linphone_call_get_op(call), NULL, NULL, body_handler);
}
void linphone_info_message_add_header(LinphoneInfoMessage *im, const char *name, const char *value){
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -163,12 +163,7 @@ bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy *policy) {
void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, bool_t enable) {
policy->upnp_enabled = enable;
if (enable) {
#ifdef BUILD_UPNP
policy->stun_enabled = policy->turn_enabled = policy->ice_enabled = FALSE;
ms_warning("Enabling uPnP NAT policy has disabled any other previously enabled policies");
#else
ms_warning("Cannot enable the uPnP NAT policy because the uPnP support is not compiled in");
#endif
ms_warning("uPnP NAT policy is no longer supported");
}
}
......
......@@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "offeranswer.h"
#include "private.h"
#include "utils/payload-type-handler.h"
static bool_t only_telephone_event(const bctbx_list_t *l){
for(;l!=NULL;l=l->next){
PayloadType *p=(PayloadType*)l->data;
......
......@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/payload_type.h"
#include "private.h"
#include "utils/payload-type-handler.h"
struct _LinphonePayloadType {
belle_sip_object_t base;
OrtpPayloadType *pt;
......@@ -134,16 +136,16 @@ const char *linphone_payload_type_get_encoder_description(const LinphonePayloadT
}
static int _linphone_core_get_payload_type_normal_bitrate(const LinphoneCore *lc, const OrtpPayloadType *pt) {
int maxbw = get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
int maxbw = LinphonePrivate::PayloadTypeHandler::getMinBandwidth(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);
return LinphonePrivate::PayloadTypeHandler::getAudioPayloadTypeBandwidth(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);
video_bw=LinphonePrivate::PayloadTypeHandler::getRemainingBandwidthForVideo(maxbw,lc->audio_bw);
}
return video_bw;
}
......@@ -258,7 +260,7 @@ bool_t linphone_payload_type_is_vbr(const LinphonePayloadType *pt) {
}
bool_t _linphone_core_check_payload_type_usability(const LinphoneCore *lc, const OrtpPayloadType *pt) {
int maxbw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
int maxbw=LinphonePrivate::PayloadTypeHandler::getMinBandwidth(linphone_core_get_download_bandwidth(lc),
linphone_core_get_upload_bandwidth(lc));
return linphone_core_is_payload_type_usable_for_bandwidth(lc, pt, maxbw);
}
......@@ -293,3 +295,15 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphonePayloadType, belle_sip_object_t,
NULL, // marshale
TRUE // unown
);
void payload_type_set_enable(OrtpPayloadType *pt, bool_t value) {
if (value)
payload_type_set_flag(pt, PAYLOAD_TYPE_ENABLED);
else
payload_type_unset_flag(pt, PAYLOAD_TYPE_ENABLED);
}
bool_t payload_type_enabled(const OrtpPayloadType *pt) {
return (pt->flags & PAYLOAD_TYPE_ENABLED);
}
......@@ -112,15 +112,16 @@ void _linphone_player_destroy(LinphonePlayer *player) {
static bool_t call_player_check_state(LinphonePlayer *player, bool_t check_player){
LinphoneCall *call=(LinphoneCall*)player->impl;
if (call->state!=LinphoneCallStreamsRunning){
ms_warning("Call [%p]: in-call player not usable in state [%s]",call,linphone_call_state_to_string(call->state));
if (linphone_call_get_state(call)!=LinphoneCallStreamsRunning){
ms_warning("Call [%p]: in-call player not usable in state [%s]",call,linphone_call_state_to_string(linphone_call_get_state(call)));
return FALSE;
}
if (call->audiostream==NULL) {
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
if (astream==NULL) {
ms_error("call_player_check_state(): no audiostream.");
return FALSE;
}
if (check_player && call->audiostream->av_player.player==NULL){
if (check_player && astream->av_player.player==NULL){
ms_error("call_player_check_state(): no player.");
return FALSE;
}
......@@ -138,7 +139,8 @@ static int call_player_open(LinphonePlayer* player, const char *filename){
LinphoneCall *call=(LinphoneCall*)player->impl;
MSFilter *filter;
if (!call_player_check_state(player,FALSE)) return -1;
filter=audio_stream_open_remote_play(call->audiostream,filename);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
filter=audio_stream_open_remote_play(astream,filename);
if (!filter) return -1;
ms_filter_add_notify_callback(filter,&on_eof,player,FALSE);
return 0;
......@@ -147,33 +149,38 @@ static int call_player_open(LinphonePlayer* player, const char *filename){
static int call_player_start(LinphonePlayer *player){
LinphoneCall *call=(LinphoneCall*)player->impl;
if (!call_player_check_state(player,TRUE)) return -1;
return ms_filter_call_method_noarg(call->audiostream->av_player.player,MS_PLAYER_START);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
return ms_filter_call_method_noarg(astream->av_player.player,MS_PLAYER_START);
}
static int call_player_pause(LinphonePlayer *player){
LinphoneCall *call=(LinphoneCall*)player->impl;
if (!call_player_check_state(player,TRUE)) return -1;
return ms_filter_call_method_noarg(call->audiostream->av_player.player,MS_PLAYER_PAUSE);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
return ms_filter_call_method_noarg(astream->av_player.player,MS_PLAYER_PAUSE);
}
static MSPlayerState call_player_get_state(LinphonePlayer *player){
LinphoneCall *call=(LinphoneCall*)player->impl;
MSPlayerState state=MSPlayerClosed;
if (!call_player_check_state(player,TRUE)) return MSPlayerClosed;
ms_filter_call_method(call->audiostream->av_player.player,MS_PLAYER_GET_STATE,&state);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
ms_filter_call_method(astream->av_player.player,MS_PLAYER_GET_STATE,&state);
return state;
}
static int call_player_seek(LinphonePlayer *player, int time_ms){
LinphoneCall *call=(LinphoneCall*)player->impl;
if (!call_player_check_state(player,TRUE)) return -1;
return ms_filter_call_method(call->audiostream->av_player.player,MS_PLAYER_SEEK_MS,&time_ms);
AudioStream *astream = reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
return ms_filter_call_method(astream->av_player.player,MS_PLAYER_SEEK_MS,&time_ms);
}
static void call_player_close(LinphonePlayer *player){
LinphoneCall *call=(LinphoneCall*)player->impl;
if (!call_player_check_state(player,TRUE)) return;