Commit 1bcda92e authored by Julien Wadel's avatar Julien Wadel
Browse files

Fix : on incoming call, do not start the ring tone if the call's state has...

Fix : on incoming call, do not start the ring tone if the call's state has been modified by listeners.
Add onStartRingtone to decide when to start ring
parent 9384c68a
......@@ -544,7 +544,6 @@ void Call::onIncomingCallSessionStarted (const shared_ptr<CallSession> &session)
if (linphone_core_get_calls_nb(getCore()->getCCore()) == 1 && !isInConference()) {
L_GET_PRIVATE_FROM_C_OBJECT(getCore()->getCCore())->setCurrentCall(getSharedFromThis());
}
getCore()->getPrivate()->getToneManager()->startRingtone(session);
}
void Call::onIncomingCallSessionTimeoutCheck (const shared_ptr<CallSession> &session, int elapsed, bool oneSecondElapsed) {
......@@ -661,6 +660,10 @@ void Call::onSnapshotTaken(const shared_ptr<CallSession> &session, const char *f
linphone_call_notify_snapshot_taken(this->toC(), file_path);
}
void Call::onStartRingtone(const shared_ptr<CallSession> &session){
getCore()->getPrivate()->getToneManager()->startRingtone(session);
}
// =============================================================================
Call::Call (
......
......@@ -260,7 +260,7 @@ public:
void onRealTimeTextCharacterReceived (const std::shared_ptr<CallSession> &session, RealtimeTextReceivedCharacter *character) override;
void onTmmbrReceived(const std::shared_ptr<CallSession> &session, int streamIndex, int tmmbr) override;
void onSnapshotTaken(const std::shared_ptr<CallSession> &session, const char *file_path) override;
void onStartRingtone(const std::shared_ptr<CallSession> &session) override;
LinphoneConference *getConference () const;
void setConference (LinphoneConference *ref);
......
......@@ -56,6 +56,7 @@ public:
virtual void onLossOfMediaDetected (const std::shared_ptr<CallSession> &session) {}
virtual void onTmmbrReceived (const std::shared_ptr<CallSession> &session, int streamIndex, int tmmbr) {}
virtual void onSnapshotTaken(const std::shared_ptr<CallSession> &session, const char *file_path) {}
virtual void onStartRingtone(const std::shared_ptr<CallSession> &session){}
virtual void onEncryptionChanged (const std::shared_ptr<CallSession> &session, bool activated, const std::string &authToken) {}
......
......@@ -181,10 +181,13 @@ void CallSessionPrivate::setTransferState (CallSession::State newState) {
void CallSessionPrivate::startIncomingNotification () {
L_Q();
bool_t tryStartRingtone = TRUE;// Try to start a tone if this notification is not a PushIncomingReceived and have listener
if (listener && state != CallSession::State::PushIncomingReceived)
listener->onIncomingCallSessionStarted(q->getSharedFromThis());
listener->onIncomingCallSessionStarted(q->getSharedFromThis());// Can set current call to this sessions
else
tryStartRingtone = FALSE;
setState(CallSession::State::IncomingReceived, "Incoming call received");
setState(CallSession::State::IncomingReceived, "Incoming call received"); // Change state and notify listeners
// From now on, the application is aware of the call and supposed to take background task or already submitted
// notification to the user. We can then drop our background task.
......@@ -192,6 +195,8 @@ void CallSessionPrivate::startIncomingNotification () {
listener->onBackgroundTaskToBeStopped(q->getSharedFromThis());
if (state == CallSession::State::IncomingReceived) {
if(tryStartRingtone)// The state is still in IncomingReceived state. Start ringing if it was needed
listener->onStartRingtone(q->getSharedFromThis());
handleIncomingReceivedStateInIncomingNotification();
}
......@@ -1268,8 +1273,10 @@ void CallSession::startBasicIncomingNotification (bool notifyRinging) {
void CallSession::startPushIncomingNotification () {
L_D();
if (d->listener)
if (d->listener){
d->listener->onIncomingCallSessionStarted(getSharedFromThis());
d->listener->onStartRingtone(getSharedFromThis());
}
d->setState(CallSession::State::PushIncomingReceived, "Push notification received");
}
......
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