diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 39c24ab7db1db44538195a4ab405c906bb299b18..bba9342fb7bc453addf857d61b4a8d34ecd1318a 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -287,8 +287,8 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers_stereo, int16* data // Notify (with a beep) an incoming call when there is already a call countTime += time->getSecond(); if (Manager::instance().incomingCallWaiting() > 0) { - countTime = countTime % 2000; // more often... - if (countTime < 100 and countTime > 0) { + countTime = countTime % 500; // more often... + if (countTime == 0) { Manager::instance().notificationIncomingCall(); } } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 94de3ae04cd315f3befb61e8b6018169d93c6a35..4acb2c3791a87054d6d686e033fb478e3030a80a 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -203,7 +203,7 @@ ManagerImpl::pushBackNewCall (CALLID id, enum CallType type) Call* ManagerImpl::getCall (CALLID id) { - _debug("CALL: Getting call %d\n", id); + _debug("%10d: Getting call\n", id); Call* call = NULL; unsigned int size = _callVector.size(); for (unsigned int i = 0; i < size; i++) { @@ -223,7 +223,7 @@ ManagerImpl::getCall (CALLID id) void ManagerImpl::deleteCall (CALLID id) { - _debug("CALL: Deleting call %d\n", id); + _debug("%10d: Deleting call\n", id); CallVector::iterator iter = _callVector.begin(); while(iter!=_callVector.end()) { Call *call = *iter; @@ -243,10 +243,20 @@ ManagerImpl::deleteCall (CALLID id) void ManagerImpl::setCurrentCallId(CALLID id) { - _debug("CALL: Setting current callid %d to %d\n", _currentCallId, id); + _debug("%10d: Setting current callid, old one was: %d\n", id, _currentCallId); _currentCallId = id; } +void +ManagerImpl::removeCallFromCurrent(CALLID id) +{ + if ( _currentCallId == id ) { + _debug("%10d: Setting current callid, old one was: %d\n", 0, _currentCallId); + _currentCallId = 0; + } +} + + /////////////////////////////////////////////////////////////////////////////// // Management of events' IP-phone user /////////////////////////////////////////////////////////////////////////////// @@ -275,6 +285,7 @@ ManagerImpl::outgoingCall (const std::string& to) int ManagerImpl::hangupCall (CALLID id) { + _debug("%10d: Hangup Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == NULL) { @@ -287,6 +298,7 @@ ManagerImpl::hangupCall (CALLID id) deleteCall(id); // current call id or no line selected if (id == _currentCallId || _currentCallId == 0) { + removeCallFromCurrent(id); stopTone(); // stop tone, like a 700 error: number not found Not Found } return result; @@ -301,6 +313,7 @@ ManagerImpl::hangupCall (CALLID id) int ManagerImpl::cancelCall (CALLID id) { + _debug("%10d: Cancel Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == NULL) { @@ -319,6 +332,7 @@ ManagerImpl::cancelCall (CALLID id) int ManagerImpl::answerCall (CALLID id) { + _debug("%10d: Answer Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == NULL) { @@ -343,12 +357,13 @@ ManagerImpl::answerCall (CALLID id) int ManagerImpl::onHoldCall (CALLID id) { + _debug("%10d: On Hold Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == NULL) { return -1; } - setCurrentCallId(0); + removeCallFromCurrent(id); if ( call->getState() == Call::OnHold || call->isNotAnswered()) { return 1; } @@ -362,6 +377,7 @@ ManagerImpl::onHoldCall (CALLID id) int ManagerImpl::offHoldCall (CALLID id) { + _debug("%10d: Off Hold Call\n", id); ost::MutexLock m(_mutex); stopTone(); Call* call = getCall(id); @@ -387,12 +403,13 @@ ManagerImpl::offHoldCall (CALLID id) int ManagerImpl::transferCall (CALLID id, const std::string& to) { + _debug("%10d: Transfer Call to %s\n", id, to.c_str()); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == 0) { return -1; } - setCurrentCallId(0); + removeCallFromCurrent(id); return call->transfer(to); } @@ -424,6 +441,7 @@ ManagerImpl::unmute() { int ManagerImpl::refuseCall (CALLID id) { + _debug("%10d: Refuse Call\n", id); ost::MutexLock m(_mutex); Call *call = getCall(id); if (call == NULL) { @@ -433,9 +451,9 @@ ManagerImpl::refuseCall (CALLID id) if ( call->getState() != Call::Progressing ) { return -1; } - int refuse = call->refuse(); - setCurrentCallId(0); + int refuse = call->refuse(); + removeCallFromCurrent(id); deleteCall(id); stopTone(); return refuse; @@ -697,6 +715,7 @@ ManagerImpl::callIsOnHold(CALLID id) { int ManagerImpl::incomingCall (CALLID id, const std::string& name, const std::string& number) { + _debug("%10d: Incoming call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call == NULL) { @@ -706,9 +725,9 @@ ManagerImpl::incomingCall (CALLID id, const std::string& name, const std::string call->setState(Call::Progressing); if ( _currentCallId == 0 ) { - switchCall(id); call->setFlagNotAnswered(false); ringtone(); + switchCall(id); } else { incWaitingCall(); } @@ -732,6 +751,7 @@ ManagerImpl::incomingCall (CALLID id, const std::string& name, const std::string void ManagerImpl::peerAnsweredCall (CALLID id) { + _debug("%10d: Peer Answered Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call != 0) { @@ -752,6 +772,7 @@ ManagerImpl::peerAnsweredCall (CALLID id) int ManagerImpl::peerRingingCall (CALLID id) { + _debug("%10d: Peer Ringing Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if (call != 0) { @@ -771,6 +792,7 @@ ManagerImpl::peerRingingCall (CALLID id) int ManagerImpl::peerHungupCall (CALLID id) { + _debug("%10d: Peer Hungup Call\n", id); ost::MutexLock m(_mutex); Call* call = getCall(id); if ( call == NULL ) { @@ -784,7 +806,7 @@ ManagerImpl::peerHungupCall (CALLID id) deleteCall(id); call->setState(Call::Hungup); - setCurrentCallId(0); + removeCallFromCurrent(id); return 1; } @@ -955,6 +977,7 @@ ManagerImpl::ringtone() */ void ManagerImpl::callBusy(CALLID id) { + _debug("%10d: Call is busy\n", id); playATone(Tone::TONE_BUSY); ost::MutexLock m(_mutex); Call* call = getCall(id); @@ -968,6 +991,7 @@ ManagerImpl::callBusy(CALLID id) { */ void ManagerImpl::callFailure(CALLID id) { + _debug("%10d: Call failed\n", id); playATone(Tone::TONE_BUSY); _mutex.enterMutex(); Call* call = getCall(id); diff --git a/src/managerimpl.h b/src/managerimpl.h index 294b6323ef04f3242cad60f2674745fd58b470d0..d210d6eee4ec5047da575aa8fcc229141585fb74 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -297,6 +297,7 @@ private: void deleteCall (CALLID id); Call* getCall (CALLID id); void setCurrentCallId(CALLID id); + void removeCallFromCurrent(CALLID id); /* * Play one tone diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 75a8fe4c26fe9873f7b50cc98c1e0b4ad89c5fbd..8b44fef49b75dfc46d6146b686450a7f5988de18 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -349,15 +349,15 @@ SipVoIPLink::answer (CALLID id) // Get port snprintf (tmpbuf, 63, "%d", getSipCall(id)->getLocalAudioPort()); - _debug("Answer call [id = %d, cid = %d, did = %d]\n", id, getSipCall(id)->getCid(), getSipCall(id)->getDid()); + _debug("%10d: Answer call [cid = %d, did = %d]\n", id, getSipCall(id)->getCid(), getSipCall(id)->getDid()); port = getSipCall(id)->getLocalAudioPort(); _debug("Local audio port: %d\n", port); - osip_message_t *answerMessage = NULL; SipCall* ca = getSipCall(id); // Send 180 RINGING + _debug("< Send 180 Ringing\n"); eXosip_lock (); eXosip_call_send_answer (ca->getTid(), RINGING, NULL); eXosip_unlock (); @@ -366,16 +366,17 @@ SipVoIPLink::answer (CALLID id) eXosip_lock(); i = eXosip_call_build_answer (ca->getTid(), OK, &answerMessage); if (i != 0) { - // Send 400 BAD_REQUEST + _debug("< Send 400 Bad Request\n"); eXosip_call_send_answer (ca->getTid(), BAD_REQ, NULL); } else { // use exosip, bug locked i = sdp_complete_200ok (ca->getDid(), answerMessage, port); if (i != 0) { osip_message_free (answerMessage); - // Send 415 UNSUPPORTED_MEDIA_TYPE + _debug("< Send 415 Unsupported Media Type\n"); eXosip_call_send_answer (ca->getTid(), UNSUP_MEDIA_TYPE, NULL); } else { + _debug("< Send 200 OK\n"); eXosip_call_send_answer (ca->getTid(), OK, answerMessage); } }