This commit is contained in:
mannol 2015-05-12 22:16:00 +02:00
parent 73fbc22961
commit 64037017cc
3 changed files with 23 additions and 6 deletions

View File

@ -205,6 +205,12 @@ int msi_hangup ( MSICall* call )
MSISession* session = call->session; MSISession* session = call->session;
pthread_mutex_lock(session->mutex); pthread_mutex_lock(session->mutex);
if ( call->state == msi_CallInactive ) {
LOGGER_ERROR("Call is in invalid state!");
pthread_mutex_unlock(session->mutex);
return -1;
}
MSIMessage msg; MSIMessage msg;
msg_init(&msg, requ_pop); msg_init(&msg, requ_pop);

View File

@ -113,7 +113,7 @@ int callback_capabilites(void* toxav_inst, MSICall* call);
bool audio_bit_rate_invalid(uint32_t bit_rate); bool audio_bit_rate_invalid(uint32_t bit_rate);
bool video_bit_rate_invalid(uint32_t bit_rate); bool video_bit_rate_invalid(uint32_t bit_rate);
void invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state); bool invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state);
ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error); ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error);
ToxAVCall* call_get(ToxAV* av, uint32_t friend_number); ToxAVCall* call_get(ToxAV* av, uint32_t friend_number);
ToxAVCall* call_remove(ToxAVCall* call); ToxAVCall* call_remove(ToxAVCall* call);
@ -998,6 +998,11 @@ int callback_invite(void* toxav_inst, MSICall* call)
if (toxav->ccb.first) if (toxav->ccb.first)
toxav->ccb.first(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio, toxav->ccb.first(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio,
call->peer_capabilities & msi_CapSVideo, toxav->ccb.second); call->peer_capabilities & msi_CapSVideo, toxav->ccb.second);
else {
/* No handler to capture the call request, send failure */
pthread_mutex_unlock(toxav->mutex);
return -1;
}
pthread_mutex_unlock(toxav->mutex); pthread_mutex_unlock(toxav->mutex);
return 0; return 0;
@ -1018,12 +1023,15 @@ int callback_start(void* toxav_inst, MSICall* call)
if (!call_prepare_transmission(av_call)) { if (!call_prepare_transmission(av_call)) {
callback_error(toxav_inst, call); callback_error(toxav_inst, call);
call_remove(av_call);
pthread_mutex_unlock(toxav->mutex); pthread_mutex_unlock(toxav->mutex);
return -1; return -1;
} }
invoke_call_state(toxav, call->friend_number, call->peer_capabilities); if (!invoke_call_state(toxav, call->friend_number, call->peer_capabilities)) {
callback_error(toxav_inst, call);
pthread_mutex_unlock(toxav->mutex);
return -1;
}
pthread_mutex_unlock(toxav->mutex); pthread_mutex_unlock(toxav->mutex);
return 0; return 0;
@ -1083,10 +1091,13 @@ bool video_bit_rate_invalid(uint32_t bit_rate)
return false; return false;
} }
void invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state) bool invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state)
{ {
if (av->scb.first) if (av->scb.first)
av->scb.first(av, friend_number, state, av->scb.second); av->scb.first(av, friend_number, state, av->scb.second);
else
return false;
return true;
} }
ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error) ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error)

View File

@ -190,7 +190,7 @@ bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, ui
* :: Call state graph * :: Call state graph
* *
******************************************************************************/ ******************************************************************************/
typedef enum TOXAV_CALL_STATE { enum TOXAV_CALL_STATE {
/** /**
* The flag that marks that friend is sending audio. * The flag that marks that friend is sending audio.
*/ */
@ -218,7 +218,7 @@ typedef enum TOXAV_CALL_STATE {
* state will never be triggered in combination with other call states. * state will never be triggered in combination with other call states.
*/ */
TOXAV_CALL_STATE_ERROR = 32768 TOXAV_CALL_STATE_ERROR = 32768
} TOXAV_CALL_STATE; };
/** /**
* The function type for the `call_state` callback. * The function type for the `call_state` callback.
* *