Skip to content

Commit f7bb097

Browse files
committed
#2325 WebRTC: p2p voice calling option sometimes becomes disabled after calling another agent back too soon
1 parent 8fef55b commit f7bb097

File tree

5 files changed

+64
-29
lines changed

5 files changed

+64
-29
lines changed

indra/newview/llfloaterimsession.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ bool LLFloaterIMSession::postBuild()
368368
add_btn->setEnabled(isInviteAllowed());
369369
add_btn->setClickedCallback(boost::bind(&LLFloaterIMSession::onAddButtonClicked, this));
370370

371-
childSetAction("voice_call_btn", boost::bind(&LLFloaterIMSession::onCallButtonClicked, this));
372-
373371
LLVoiceClient::addObserver(this);
374372

375373
//*TODO if session is not initialized yet, add some sort of a warning message like "starting session...blablabla"
@@ -551,23 +549,6 @@ void LLFloaterIMSession::boundVoiceChannel()
551549
}
552550
}
553551

554-
void LLFloaterIMSession::onCallButtonClicked()
555-
{
556-
LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);
557-
if (voice_channel)
558-
{
559-
bool is_call_active = voice_channel->getState() >= LLVoiceChannel::STATE_CALL_STARTED;
560-
if (is_call_active)
561-
{
562-
gIMMgr->endCall(mSessionID);
563-
}
564-
else
565-
{
566-
gIMMgr->startCall(mSessionID);
567-
}
568-
}
569-
}
570-
571552
void LLFloaterIMSession::onChange(EStatusType status, const LLSD& channelInfo, bool proximal)
572553
{
573554
if(status != STATUS_JOINING && status != STATUS_LEFT_CHANNEL)

indra/newview/llfloaterimsession.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ class LLFloaterIMSession
159159
void sendParticipantsAddedNotification(const uuid_vec_t& uuids);
160160
bool canAddSelectedToChat(const uuid_vec_t& uuids);
161161

162-
void onCallButtonClicked();
163-
164162
void onVoiceChannelChanged(const LLUUID &session_id);
165163

166164
void boundVoiceChannel();

indra/newview/llfloaterimsessiontab.cpp

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ bool LLFloaterIMSessionTab::postBuild()
302302
mGearBtn = getChild<LLButton>("gear_btn");
303303
mAddBtn = getChild<LLButton>("add_btn");
304304
mVoiceButton = getChild<LLButton>("voice_call_btn");
305+
mVoiceButton->setClickedCallback([this](LLUICtrl*, const LLSD&) { onCallButtonClicked(); });
305306

306307
mParticipantListPanel = getChild<LLLayoutPanel>("speakers_list_panel");
307308
mRightPartPanel = getChild<LLLayoutPanel>("right_part_holder");
@@ -434,16 +435,34 @@ void LLFloaterIMSessionTab::draw()
434435

435436
void LLFloaterIMSessionTab::enableDisableCallBtn()
436437
{
437-
if (LLVoiceClient::instanceExists() && mVoiceButton)
438+
if (!mVoiceButton)
439+
return;
440+
441+
bool enable = false;
442+
443+
if (mSessionID.notNull() && mSession && mSession->mSessionInitialized && mSession->mCallBackEnabled)
438444
{
439-
mVoiceButton->setEnabled(
440-
mSessionID.notNull()
441-
&& mSession
442-
&& mSession->mSessionInitialized
443-
&& LLVoiceClient::getInstance()->voiceEnabled()
444-
&& LLVoiceClient::getInstance()->isVoiceWorking()
445-
&& mSession->mCallBackEnabled);
445+
if (mVoiceButtonHangUpMode)
446+
{
447+
// We allow to hang up from any state
448+
enable = true;
449+
}
450+
else
451+
{
452+
// We allow to start call from this state only
453+
if (mSession->mVoiceChannel->getState() == LLVoiceChannel::STATE_NO_CHANNEL_INFO &&
454+
LLVoiceClient::instanceExists())
455+
{
456+
LLVoiceClient* client = LLVoiceClient::getInstance();
457+
if (client->voiceEnabled() && client->isVoiceWorking())
458+
{
459+
enable = true;
460+
}
461+
}
462+
}
446463
}
464+
465+
mVoiceButton->setEnabled(enable);
447466
}
448467

449468
// virtual
@@ -466,6 +485,25 @@ void LLFloaterIMSessionTab::onFocusLost()
466485
super::onFocusLost();
467486
}
468487

488+
void LLFloaterIMSessionTab::onCallButtonClicked()
489+
{
490+
if (mVoiceButtonHangUpMode)
491+
{
492+
// We allow to hang up from any state
493+
gIMMgr->endCall(mSessionID);
494+
}
495+
else
496+
{
497+
LLVoiceChannel::EState channel_state = mSession && mSession->mVoiceChannel ?
498+
mSession->mVoiceChannel->getState() : LLVoiceChannel::STATE_NO_CHANNEL_INFO;
499+
// We allow to start call from this state only
500+
if (channel_state == LLVoiceChannel::STATE_NO_CHANNEL_INFO)
501+
{
502+
gIMMgr->startCall(mSessionID);
503+
}
504+
}
505+
}
506+
469507
void LLFloaterIMSessionTab::onInputEditorClicked()
470508
{
471509
LLFloaterIMContainer* im_box = LLFloaterIMContainer::findInstance();
@@ -1040,6 +1078,7 @@ void LLFloaterIMSessionTab::updateCallBtnState(bool callIsActive)
10401078
{
10411079
mVoiceButton->setImageOverlay(callIsActive? getString("call_btn_stop") : getString("call_btn_start"));
10421080
mVoiceButton->setToolTip(callIsActive? getString("end_call_button_tooltip") : getString("start_call_button_tooltip"));
1081+
mVoiceButtonHangUpMode = callIsActive;
10431082

10441083
enableDisableCallBtn();
10451084
}

indra/newview/llfloaterimsessiontab.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ class LLFloaterIMSessionTab
198198
LLButton* mAddBtn;
199199
LLButton* mVoiceButton;
200200

201+
// Since mVoiceButton can work in one of two modes, "Start call" or "Hang up",
202+
// (with different images and tooltips depending on the currently chosen mode)
203+
// we should track the mode we're currently using to react on click accordingly
204+
bool mVoiceButtonHangUpMode { false };
205+
201206
private:
202207
// Handling selection and contextual menu
203208
void doToSelected(const LLSD& userdata);
@@ -216,6 +221,8 @@ class LLFloaterIMSessionTab
216221
*/
217222
void reshapeChatLayoutPanel();
218223

224+
void onCallButtonClicked();
225+
219226
void onInputEditorClicked();
220227

221228
void onEmojiRecentPanelToggleBtnClicked();

indra/newview/llvoicechannel.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ void LLVoiceChannel::setState(EState state)
328328

329329
void LLVoiceChannel::doSetState(const EState& new_state)
330330
{
331+
LL_DEBUGS("Voice") << "session '" << mSessionName << "' state " << mState << ", new_state " << new_state << ": "
332+
<< (new_state == STATE_ERROR ? "ERROR" :
333+
new_state == STATE_HUNG_UP ? "HUNG_UP" :
334+
new_state == STATE_READY ? "READY" :
335+
new_state == STATE_CALL_STARTED ? "CALL_STARTED" :
336+
new_state == STATE_RINGING ? "RINGING" :
337+
new_state == STATE_CONNECTED ? "CONNECTED" :
338+
"NO_INFO")
339+
<< LL_ENDL;
340+
331341
EState old_state = mState;
332342
mState = new_state;
333343

0 commit comments

Comments
 (0)