|
@@ -14,8 +14,7 @@
|
|
|
#include "voip/media_player.h"
|
|
|
#include "manager/LanguageManager.h"
|
|
|
|
|
|
-
|
|
|
-std::string _isOutgoing;
|
|
|
+std::string _callActivityType = "wait";
|
|
|
std::string _toIdStr;
|
|
|
|
|
|
//voip::WAVPlayer wavPlayer; // 播放音频
|
|
@@ -27,6 +26,7 @@ static base::MediaPlayer mediaPlayer;
|
|
|
static bool _isSleepTimerRegistered = false;
|
|
|
|
|
|
#define CALLING_TIME 60 // 用于控制呼叫时间,定时器
|
|
|
+#define GAIN_CALL_TIME 61
|
|
|
|
|
|
|
|
|
|
|
@@ -60,6 +60,13 @@ void callActivityFinish(CallFinishType type){
|
|
|
setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
EASYUICONTEXT->goBack();
|
|
|
break;
|
|
|
+ case END:
|
|
|
+ LOGD("end");
|
|
|
+ if (mActivityPtr != NULL) {
|
|
|
+ mediaPlayer.Stop();
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
+ }
|
|
|
+ break;
|
|
|
case FAILED:
|
|
|
// wavPlayer.Stop();
|
|
|
mediaPlayer.Stop();
|
|
@@ -101,41 +108,54 @@ void callActivityFinish(CallFinishType type){
|
|
|
case ACCEPT:
|
|
|
mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
|
break;
|
|
|
+ case GAIN_OK:
|
|
|
+ mActivityPtr->unregisterUserTimer(GAIN_CALL_TIME);
|
|
|
+ break;
|
|
|
+ case GAIN_FAIL:
|
|
|
+ mediaPlayer.Stop();
|
|
|
+ mTextViewNamePtr->setTextTr("CallAndwered");
|
|
|
+ mActivityPtr->registerUserTimer(goBack, 5000);
|
|
|
+ break;
|
|
|
case A1CLICK:
|
|
|
LOGD("a1 click");
|
|
|
|
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
|
- //只回传iId
|
|
|
- storeModel.data = storeModel.json["id"].asString();
|
|
|
-
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
- LOGD("info state = %d",info.state);
|
|
|
- if (info.state == voip::STATE_CALL_CALLING
|
|
|
- || info.state == voip::STATE_CALL_CALLING
|
|
|
- || info.state == voip::STATE_CALL_CONFIRMED){
|
|
|
- sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
|
- GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
|
- GetTelephone()->Hangup();
|
|
|
-
|
|
|
- setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
- } else if (_isOutgoing == "false"){ //state = 5
|
|
|
- mediaPlayer.Stop();
|
|
|
- mButtonAnswerPtr->setVisible(false);
|
|
|
- TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
|
- model.data = model.json["id"].asString();
|
|
|
- sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
|
|
|
-
|
|
|
- mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
|
-
|
|
|
- } else if (_isOutgoing == "true") {
|
|
|
- sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
|
|
|
-
|
|
|
- setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
+ if (!storeModel.json.isNull() && storeModel.json > 0 && storeModel.json.isMember("id")) {
|
|
|
+ //只回传iId
|
|
|
+ storeModel.data = storeModel.json["id"].asString();
|
|
|
+
|
|
|
+ voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
+ LOGD("info state = %d",info.state);
|
|
|
+ if (info.state == voip::STATE_CALL_CALLING
|
|
|
+ || info.state == voip::STATE_CALL_CALLING
|
|
|
+ || info.state == voip::STATE_CALL_CONFIRMED){
|
|
|
+ sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
|
+ GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
|
+ GetTelephone()->Hangup();
|
|
|
+
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
+ }
|
|
|
+ else if (_callActivityType == "toCall"){ //state = 5
|
|
|
+ mediaPlayer.Stop();
|
|
|
+ mButtonAnswerPtr->setVisible(false);
|
|
|
+ TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
|
+ model.data = model.json["id"].asString();
|
|
|
+ sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
|
|
|
+
|
|
|
+ mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
|
+ }
|
|
|
+ else if (_callActivityType == "fromCall") {
|
|
|
+ sendVoiceCancel(storeModel.from_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sendVoiceCancel(0);
|
|
|
}
|
|
|
}
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
|
|
|
break;
|
|
|
case KEY6_CLICK:
|
|
@@ -158,11 +178,9 @@ void callActivityFinish(CallFinishType type){
|
|
|
setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
EASYUICONTEXT->goBack();
|
|
|
|
|
|
-// std::string heartStr = "DOORLED,000F";
|
|
|
-// const char* sendMsg = heartStr.c_str();
|
|
|
-// sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
|
|
|
lightControl("DOORLED", "000F");
|
|
|
- } else if (_isOutgoing == "false"){ //state = 5
|
|
|
+ }
|
|
|
+ else if (_callActivityType == "toCall"){ //state = 5
|
|
|
mediaPlayer.Stop();
|
|
|
mButtonAnswerPtr->setVisible(false);
|
|
|
TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
@@ -235,8 +253,6 @@ static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
|
|
|
*/
|
|
|
static void onUI_init(){
|
|
|
|
|
|
- CallingStatus::instance()->setBusy(true);
|
|
|
-
|
|
|
// GetTelephone()->SetInputPcmGainSize(10.0);
|
|
|
|
|
|
// player = new ZKMediaPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO);
|
|
@@ -290,23 +306,22 @@ static void onUI_init(){
|
|
|
static void onUI_intent(const Intent *intentPtr) {
|
|
|
if(intentPtr != NULL) {
|
|
|
LOGD("打开通话页面,进行通话");
|
|
|
+ CallingStatus::instance()->setBusy(true);
|
|
|
+
|
|
|
BRIGHTNESSHELPER->screenOn();
|
|
|
_isSleepTimerRegistered = getSleepTimerRegistered();
|
|
|
setSleepTimerRegistered(false);
|
|
|
|
|
|
-// wavPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"));
|
|
|
-// mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"));
|
|
|
mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"), "", 1000,
|
|
|
base::MediaPlayer::PlayMode::Loop);
|
|
|
- // 键值解析
|
|
|
- _isOutgoing = intentPtr->getExtra(isOutgoing);
|
|
|
- std::string _audioOnly = intentPtr->getExtra(audioOnly);
|
|
|
-
|
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (_isOutgoing == "true"){
|
|
|
+ // 键值解析
|
|
|
+ _callActivityType = intentPtr->getExtra(callActivityType);
|
|
|
+
|
|
|
+ if (_callActivityType == "fromCall") {
|
|
|
int toId = 0;
|
|
|
_toIdStr = intentPtr->getExtra(toIdStr);
|
|
|
if (_toIdStr != "") {
|
|
@@ -335,7 +350,8 @@ static void onUI_intent(const Intent *intentPtr) {
|
|
|
}
|
|
|
|
|
|
mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else if (_callActivityType == "toCall") {
|
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
|
TcpModel backTcp = storeModel;
|
|
|
backTcp.data = storeModel.json["id"].asString();
|
|
@@ -355,6 +371,18 @@ static void onUI_intent(const Intent *intentPtr) {
|
|
|
sendVoiceTcp(VoiceAction::ACCEPT, storeModel, storeModel.from_id);
|
|
|
}
|
|
|
}
|
|
|
+ else if (_callActivityType == "gainCall") {
|
|
|
+ mButtonAnswerPtr->setVisible(false);
|
|
|
+
|
|
|
+ std::string _callName = intentPtr->getExtra(callName);
|
|
|
+ if (_callName != "") {
|
|
|
+ mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
|
|
|
+ } else {
|
|
|
+ mTextViewNamePtr->setTextTr("CallOutTitle");
|
|
|
+ }
|
|
|
+
|
|
|
+ mActivityPtr->registerUserTimer(GAIN_CALL_TIME, 60000);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -377,12 +405,13 @@ static void onUI_hide() {
|
|
|
* 当界面完全退出时触发
|
|
|
*/
|
|
|
static void onUI_quit() {
|
|
|
- if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
|
- EASYUICONTEXT->showNaviBar();
|
|
|
- EASYUICONTEXT->showStatusBar();
|
|
|
+ EASYUICONTEXT->showNaviBar();
|
|
|
+ EASYUICONTEXT->showStatusBar();
|
|
|
|
|
|
- CallingStatus::instance()->setBusy(false);
|
|
|
- CallingStatus::instance()->clearTcpModel();
|
|
|
+ CallingStatus::instance()->setBusy(false);
|
|
|
+ CallingStatus::instance()->clearTcpModel();
|
|
|
+
|
|
|
+ if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
|
|
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
if (info.state == voip::STATE_CALL_CALLING
|
|
@@ -393,7 +422,7 @@ static void onUI_quit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ _callActivityType = "wait";
|
|
|
mediaPlayer.Stop();
|
|
|
mActivityPtr->unregisterUserTimer(goBack);
|
|
|
}
|
|
@@ -463,9 +492,6 @@ static bool onUI_Timer(int id){
|
|
|
case CALLING_TIME: {
|
|
|
sendVoiceCancel(StoragePreferences::getInt(STORE_DEVICE_ID,0), 0);
|
|
|
|
|
|
-// std::string heartStr = "DOORLED,000F";
|
|
|
-// const char* sendMsg = heartStr.c_str();
|
|
|
-// sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
|
|
|
lightControl("DOORLED", "000F");
|
|
|
|
|
|
setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
@@ -473,6 +499,11 @@ static bool onUI_Timer(int id){
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
+ case GAIN_CALL_TIME: {
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -531,13 +562,10 @@ static bool onButtonClick_ButtonHangup(ZKButton *pButton) {
|
|
|
sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
|
GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
|
GetTelephone()->Hangup();
|
|
|
- } else if (_isOutgoing == "true") {
|
|
|
+ } else if (_callActivityType == "fromCall" || _callActivityType == "gainCall") {
|
|
|
string storeModelStr = getTcpModelString(storeModel);
|
|
|
sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
|
|
|
|
|
|
-// std::string heartStr = "DOORLED,000F";
|
|
|
-// const char* sendMsg = heartStr.c_str();
|
|
|
-// sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
|
|
|
lightControl("DOORLED", "000F");
|
|
|
} else {
|
|
|
storeModel.data = storeModel.json["id"].asString();
|
|
@@ -548,10 +576,6 @@ static bool onButtonClick_ButtonHangup(ZKButton *pButton) {
|
|
|
tcpModel.tid = tid;
|
|
|
sendVoiceTcp(VoiceAction::CANCEL, tcpModel, StoragePreferences::getInt(STORE_DEVICE_ID,0));
|
|
|
|
|
|
- // 还原成无灯光的状态
|
|
|
-// std::string heartStr = "DOORLED,000F";
|
|
|
-// const char* sendMsg = heartStr.c_str();
|
|
|
-// sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
|
|
|
lightControl("DOORLED", "000F");
|
|
|
}
|
|
|
|