callLogic.cc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include <string>
  4. #include "core/utilities.h"
  5. #include "voip/telephone.h"
  6. #include "base/strings.hpp"
  7. #include "storage/StoragePreferences.h"
  8. #include "core/sip_config.h"
  9. #include "zkaudio.h"
  10. #include "service/BusinessConfig.h"
  11. #include "net/tcp_client.h"
  12. #include "manager/ConfigManager.h"
  13. //#include "voip/wav_player.h"
  14. #include "voip/media_player.h"
  15. #include "manager/LanguageManager.h"
  16. std::string _callActivityType = "wait";
  17. std::string _toIdStr;
  18. //voip::WAVPlayer wavPlayer; // 播放音频
  19. std::string tid;
  20. static base::MediaPlayer mediaPlayer;
  21. static bool _isSleepTimerRegistered = false;
  22. #define CALLING_TIME 60 // 用于控制呼叫时间,定时器
  23. #define GAIN_CALL_TIME 61
  24. const int goBack = 200;
  25. void callActivityFinish(CallFinishType type){
  26. switch (type){
  27. case CANCEL:
  28. LOGD("cancel");
  29. setSleepTimerRegistered(_isSleepTimerRegistered);
  30. EASYUICONTEXT->goBack();
  31. break;
  32. case REJECT:
  33. LOGD("reject");
  34. // wavPlayer.Stop();
  35. mediaPlayer.Stop();
  36. mTextViewNamePtr->setTextTr("RemoteRefuse");
  37. mActivityPtr->unregisterUserTimer(CALLING_TIME);
  38. mActivityPtr->registerUserTimer(goBack, 5000);
  39. break;
  40. case BUSY:
  41. LOGD("BUSY");
  42. // wavPlayer.Stop();
  43. mediaPlayer.Stop();
  44. mTextViewNamePtr->setTextTr("RemoteBusy");
  45. mActivityPtr->unregisterUserTimer(CALLING_TIME);
  46. mActivityPtr->registerUserTimer(goBack, 5000);
  47. break;
  48. case HANDOFF:
  49. LOGD("handoff");
  50. setSleepTimerRegistered(_isSleepTimerRegistered);
  51. EASYUICONTEXT->goBack();
  52. break;
  53. case END:
  54. LOGD("end");
  55. if (mActivityPtr != NULL) {
  56. mediaPlayer.Stop();
  57. EASYUICONTEXT->goBack();
  58. }
  59. break;
  60. case FAILED:
  61. // wavPlayer.Stop();
  62. mediaPlayer.Stop();
  63. mTextViewNamePtr->setTextTr("CallFailed");
  64. mActivityPtr->registerUserTimer(goBack, 5000);
  65. break;
  66. case NOT_FOUND:
  67. {
  68. mTextViewNamePtr->setTextTr("NotFound");
  69. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  70. if (!storeModel.json.isNull() && storeModel.json > 0 && storeModel.json.isMember("id")) {
  71. sendVoiceCancel(storeModel.from_id);
  72. }
  73. else {
  74. sendVoiceCancel(0);
  75. }
  76. mActivityPtr->registerUserTimer(goBack, 5000);
  77. }
  78. break;
  79. case REQUEST_TIMES:
  80. {
  81. mTextViewNamePtr->setTextTr("RequestTimes");
  82. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  83. if (!storeModel.json.isNull() && storeModel.json > 0 && storeModel.json.isMember("id")) {
  84. sendVoiceCancel(storeModel.from_id);
  85. }
  86. else {
  87. sendVoiceCancel(0);
  88. }
  89. mActivityPtr->registerUserTimer(goBack, 5000);
  90. }
  91. break;
  92. case ACCEPT:
  93. mActivityPtr->unregisterUserTimer(CALLING_TIME);
  94. break;
  95. case GAIN_OK:
  96. mActivityPtr->unregisterUserTimer(GAIN_CALL_TIME);
  97. break;
  98. case GAIN_FAIL:
  99. mediaPlayer.Stop();
  100. mTextViewNamePtr->setTextTr("CallAndwered");
  101. mActivityPtr->registerUserTimer(goBack, 5000);
  102. break;
  103. case A1CLICK:
  104. LOGD("a1 click");
  105. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
  106. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  107. if (!storeModel.json.isNull() && storeModel.json > 0 && storeModel.json.isMember("id")) {
  108. //只回传iId
  109. storeModel.data = storeModel.json["id"].asString();
  110. voip::CallInfo info = GetTelephone()->GetCallInfo();
  111. LOGD("info state = %d",info.state);
  112. if (info.state == voip::STATE_CALL_CALLING
  113. || info.state == voip::STATE_CALL_CALLING
  114. || info.state == voip::STATE_CALL_CONFIRMED){
  115. sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
  116. GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
  117. GetTelephone()->Hangup();
  118. setSleepTimerRegistered(_isSleepTimerRegistered);
  119. EASYUICONTEXT->goBack();
  120. }
  121. else if (_callActivityType == "toCall"){ //state = 5
  122. mediaPlayer.Stop();
  123. mButtonAnswerPtr->setVisible(false);
  124. TcpModel model = CallingStatus::instance()->getTcpModel();
  125. model.data = model.json["id"].asString();
  126. sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
  127. mActivityPtr->unregisterUserTimer(CALLING_TIME);
  128. }
  129. else if (_callActivityType == "fromCall") {
  130. sendVoiceCancel(storeModel.from_id);
  131. }
  132. }
  133. else {
  134. sendVoiceCancel(0);
  135. }
  136. }
  137. setSleepTimerRegistered(_isSleepTimerRegistered);
  138. EASYUICONTEXT->goBack();
  139. break;
  140. case KEY6_CLICK:
  141. LOGD("KEY6 click");
  142. if (StoragePreferences::getString(STORE_SIGNAL_TYPE,"TCP")=="TCP"){
  143. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  144. //只回传iId
  145. storeModel.data = storeModel.json["id"].asString();
  146. voip::CallInfo info = GetTelephone()->GetCallInfo();
  147. LOGD("info state = %d",info.state);
  148. if (info.state == voip::STATE_CALL_CALLING
  149. || info.state == voip::STATE_CALL_CALLING
  150. || info.state == voip::STATE_CALL_CONFIRMED){
  151. sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
  152. GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
  153. GetTelephone()->Hangup();
  154. setSleepTimerRegistered(_isSleepTimerRegistered);
  155. EASYUICONTEXT->goBack();
  156. lightControl("DOORLED", "000F");
  157. }
  158. else if (_callActivityType == "toCall"){ //state = 5
  159. mediaPlayer.Stop();
  160. mButtonAnswerPtr->setVisible(false);
  161. TcpModel model = CallingStatus::instance()->getTcpModel();
  162. model.data = model.json["id"].asString();
  163. sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
  164. mActivityPtr->unregisterUserTimer(CALLING_TIME);
  165. }
  166. }
  167. break;
  168. }
  169. }
  170. void buildSIP(std::string toSipId){
  171. // wavPlayer.Stop();
  172. mediaPlayer.Stop();
  173. int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
  174. std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
  175. //std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
  176. std::string od_number_uri = URI(toSipId, domain, port);
  177. LOGD("xxxxxxxxxxxxxx %s",od_number_uri.c_str());
  178. GetTelephone()->MakeCall(od_number_uri);
  179. }
  180. void acceptSIP(){
  181. GetTelephone()->Answer();
  182. }
  183. //static ZKMediaPlayer sPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO);
  184. namespace {
  185. const int kTimerAutoAnswer = 100;
  186. std::string StateString(voip::State state) {
  187. switch (state) {
  188. case voip::STATE_CALL_CALLING:
  189. case voip::STATE_CALL_EARLY:
  190. return LANGUAGEMANAGER->getValue("Calling");
  191. case voip::STATE_CALL_CONFIRMED:
  192. return LANGUAGEMANAGER->getValue("CallConfirmed");
  193. case voip::STATE_CALL_CONNECTING:
  194. return LANGUAGEMANAGER->getValue("CallConnecting");
  195. case voip::STATE_CALL_INCOMING:
  196. return LANGUAGEMANAGER->getValue("CallInComing");
  197. default:
  198. break;
  199. }
  200. return "";
  201. }
  202. } /* anonymous namespace */
  203. /**
  204. * 注册定时器
  205. * 填充数组用于注册定时器
  206. * 注意:id不能重复
  207. */
  208. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  209. //{0, 6000}, //定时器id=0, 时间间隔6秒
  210. {1, 1000},
  211. {kTimerAutoAnswer, 2000},
  212. };
  213. /**
  214. * 当界面构造时触发
  215. */
  216. static void onUI_init(){
  217. // GetTelephone()->SetInputPcmGainSize(10.0);
  218. // player = new ZKMediaPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO);
  219. // player->play("/mnt/extsd/ui/hl.mp3");
  220. //界面操作
  221. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  222. voip::CallInfo info = GetTelephone()->GetCallInfo();
  223. mTextViewNamePtr->setText(info.remote_uri);
  224. if (info.state == voip::STATE_CALL_CALLING) {
  225. mButtonAnswerPtr->setVisible(false);
  226. }
  227. }
  228. // mSeekBarOutputVolumePtr->setMax(zk_audio_output_volume_native_max());
  229. bool isVolume = StoragePreferences::getBool(STORE_VOLUME, false);
  230. mSeekBarGainPtr->setVisible(isVolume);
  231. mTextViewGainPtr->setVisible(isVolume);
  232. mSeekBarInputPtr->setVisible(isVolume);
  233. mTextViewInputPtr->setVisible(isVolume);
  234. //打开时的声音大小
  235. int serverVol = StoragePreferences::getInt(STORE_DAY_VOL,PartSetting::dayDoorVol);
  236. if (checkIsDay()){
  237. serverVol = StoragePreferences::getInt(STORE_NIGHT_VOL,PartSetting::nightDoorVol);
  238. }
  239. LOGD("serverVol == %d", serverVol);
  240. double percent = (double) serverVol / (double)100;
  241. int vol = (int)(zk_audio_output_volume_native_max()*percent);
  242. LOGD("bed vol is %d. server is %d. max is %d",vol,serverVol, zk_audio_output_volume_native_max());
  243. zk_audio_output_set_volume_native(vol);
  244. mSeekBarOutputVolumePtr->setProgress(vol);
  245. mTextViewOutputVolumePtr->setTouchPass(true);
  246. //
  247. mSeekBarGainPtr->setProgress(StoragePreferences::getInt(STORE_GAIN_SIZE, 2));
  248. mTextViewGainPtr->setTouchPass(true);
  249. mSeekBarInputPtr->setProgress(StoragePreferences::getInt(STORE_VOLUME_NATIVE, 6));
  250. mTextViewInputPtr->setTouchPass(true);
  251. // mTextViewNamePtr->setVisible(false);
  252. // mTextViewStatePtr->setVisible(false);
  253. // mTextViewDurationPtr->setVisible(false);
  254. }
  255. /**
  256. * 当切换到该界面时触发
  257. */
  258. static void onUI_intent(const Intent *intentPtr) {
  259. if(intentPtr != NULL) {
  260. LOGD("打开通话页面,进行通话");
  261. CallingStatus::instance()->setBusy(true);
  262. BRIGHTNESSHELPER->screenOn();
  263. _isSleepTimerRegistered = getSleepTimerRegistered();
  264. setSleepTimerRegistered(false);
  265. mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"), "", 1000,
  266. base::MediaPlayer::PlayMode::Loop);
  267. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  268. return;
  269. }
  270. // 键值解析
  271. _callActivityType = intentPtr->getExtra(callActivityType);
  272. if (_callActivityType == "fromCall") {
  273. int toId = 0;
  274. _toIdStr = intentPtr->getExtra(toIdStr);
  275. if (_toIdStr != "") {
  276. toId = atoi(_toIdStr.c_str());
  277. tid = sendVoiceCall(toId);
  278. }
  279. else {
  280. std::string _callRoleType = intentPtr->getExtra(callRoleType);
  281. if (_callRoleType == "") {
  282. _callRoleType = "NURSE";
  283. }
  284. Json::Value json;
  285. json["roleType"] = _callRoleType;
  286. tid = sendVoiceCall(json);
  287. }
  288. // 呼叫的时候需要把tid放进去
  289. mButtonAnswerPtr->setVisible(false);
  290. std::string _callName = intentPtr->getExtra(callName);
  291. if (_callName != "") {
  292. mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
  293. } else {
  294. mTextViewNamePtr->setTextTr("CallOutTitle");
  295. }
  296. mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
  297. }
  298. else if (_callActivityType == "toCall") {
  299. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  300. TcpModel backTcp = storeModel;
  301. backTcp.data = storeModel.json["id"].asString();
  302. //back voice success
  303. sendVoiceTcp(VoiceAction::SUCCESS, backTcp, storeModel.from_id);
  304. mTextViewNamePtr->setText(storeModel.json["fromFrameName"].asString());
  305. //自动接听处理
  306. if (StoragePreferences::getBool(STORE_AUDO_ANSWER,false)){
  307. sleep(3);
  308. mButtonAnswerPtr->setVisible(false);
  309. mediaPlayer.Stop();
  310. GetTelephone()->Answer();
  311. //发出TCP
  312. sendVoiceTcp(VoiceAction::ACCEPT, storeModel, storeModel.from_id);
  313. }
  314. }
  315. else if (_callActivityType == "gainCall") {
  316. mButtonAnswerPtr->setVisible(false);
  317. std::string _callName = intentPtr->getExtra(callName);
  318. if (_callName != "") {
  319. mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
  320. } else {
  321. mTextViewNamePtr->setTextTr("CallOutTitle");
  322. }
  323. mActivityPtr->registerUserTimer(GAIN_CALL_TIME, 60000);
  324. }
  325. }
  326. }
  327. /*
  328. * 当界面显示时触发
  329. */
  330. static void onUI_show() {
  331. EASYUICONTEXT->hideStatusBar();
  332. EASYUICONTEXT->hideNaviBar();
  333. }
  334. /*
  335. * 当界面隐藏时触发
  336. */
  337. static void onUI_hide() {
  338. }
  339. /*
  340. * 当界面完全退出时触发
  341. */
  342. static void onUI_quit() {
  343. EASYUICONTEXT->showNaviBar();
  344. EASYUICONTEXT->showStatusBar();
  345. CallingStatus::instance()->setBusy(false);
  346. CallingStatus::instance()->clearTcpModel();
  347. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
  348. voip::CallInfo info = GetTelephone()->GetCallInfo();
  349. if (info.state == voip::STATE_CALL_CALLING
  350. || info.state == voip::STATE_CALL_CALLING
  351. || info.state == voip::STATE_CALL_CONFIRMED){
  352. GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
  353. GetTelephone()->Hangup();
  354. }
  355. }
  356. _callActivityType = "wait";
  357. mediaPlayer.Stop();
  358. mActivityPtr->unregisterUserTimer(goBack);
  359. }
  360. /**
  361. * 串口数据回调接口
  362. */
  363. static void onProtocolDataUpdate(const SProtocolData &data) {
  364. }
  365. /**
  366. * 定时器触发函数
  367. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  368. * 参数: id
  369. * 当前所触发定时器的id,与注册时的id相同
  370. * 返回值: true
  371. * 继续运行当前定时器
  372. * false
  373. * 停止运行当前定时器
  374. */
  375. static bool onUI_Timer(int id){
  376. switch (id) {
  377. case 1: {
  378. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  379. voip::CallInfo info = GetTelephone()->GetCallInfo();
  380. if (info.state == voip::STATE_CALL_CONFIRMED){
  381. mButtonAnswerPtr->setVisible(false);
  382. }
  383. mTextViewNamePtr->setText(info.remote_uri);
  384. mTextViewStatePtr->setText(StateString(info.state));
  385. mTextViewDurationPtr->setText(
  386. base::format("%02d:%02d",
  387. info.duration/1000/60,
  388. info.duration/1000%60));
  389. } else {
  390. voip::CallInfo info = GetTelephone()->GetCallInfo();
  391. if (info.state == voip::STATE_CALL_CONFIRMED){
  392. mButtonAnswerPtr->setVisible(false);
  393. }
  394. mTextViewStatePtr->setText(StateString(info.state));
  395. mTextViewDurationPtr->setText(
  396. base::format("%02d:%02d",
  397. info.duration/1000/60,
  398. info.duration/1000%60));
  399. }
  400. }
  401. break;
  402. case kTimerAutoAnswer: {
  403. voip::CallInfo info = GetTelephone()->GetCallInfo();
  404. if (info.state == voip::STATE_CALL_INCOMING
  405. || info.state == voip::STATE_CALL_EARLY) {
  406. bool auto_answer = StoragePreferences::getBool(SIP_AUTO_ANSWER, false);
  407. LOGD("is auto answer: %d", auto_answer);
  408. if (auto_answer) {
  409. GetTelephone()->Answer();
  410. }
  411. }
  412. }
  413. return false;
  414. break;
  415. case goBack:{
  416. setSleepTimerRegistered(_isSleepTimerRegistered);
  417. EASYUICONTEXT->goBack();
  418. break;
  419. }
  420. case CALLING_TIME: {
  421. sendVoiceCancel(StoragePreferences::getInt(STORE_DEVICE_ID,0), 0);
  422. lightControl("DOORLED", "000F");
  423. setSleepTimerRegistered(_isSleepTimerRegistered);
  424. EASYUICONTEXT->goBack();
  425. break;
  426. }
  427. case GAIN_CALL_TIME: {
  428. setSleepTimerRegistered(_isSleepTimerRegistered);
  429. EASYUICONTEXT->goBack();
  430. break;
  431. }
  432. default:
  433. break;
  434. }
  435. return true;
  436. }
  437. /**
  438. * 有新的触摸事件时触发
  439. * 参数:ev
  440. * 新的触摸事件
  441. * 返回值:true
  442. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  443. * false
  444. * 触摸事件将继续传递到控件上
  445. */
  446. static bool oncallActivityTouchEvent(const MotionEvent &ev) {
  447. switch (ev.mActionStatus) {
  448. case MotionEvent::E_ACTION_DOWN://触摸按下
  449. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  450. break;
  451. case MotionEvent::E_ACTION_MOVE://触摸滑动
  452. break;
  453. case MotionEvent::E_ACTION_UP: //触摸抬起
  454. break;
  455. default:
  456. break;
  457. }
  458. return false;
  459. }
  460. static void onVideoViewPlayerMessageListener_VideoView1(ZKVideoView *pVideoView, int msg) {
  461. switch (msg) {
  462. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED:
  463. break;
  464. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED:
  465. break;
  466. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_ERROR:
  467. break;
  468. }
  469. }
  470. static void onProgressChanged_SeekBarOutputVolume(ZKSeekBar *pSeekBar, int progress) {
  471. zk_audio_output_set_volume_native(progress);
  472. mTextViewOutputVolumePtr->setText(base::format("%d", progress));
  473. }
  474. static bool onButtonClick_ButtonHangup(ZKButton *pButton) {
  475. LOGD("handup click");
  476. voip::CallInfo info = GetTelephone()->GetCallInfo();
  477. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
  478. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  479. if (storeModel.json != 0) {
  480. //只回传iId
  481. storeModel.data = storeModel.json["id"].asString();
  482. if (info.state == voip::STATE_CALL_CALLING
  483. || info.state == voip::STATE_CALL_CALLING
  484. || info.state == voip::STATE_CALL_CONFIRMED){
  485. sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
  486. GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
  487. GetTelephone()->Hangup();
  488. } else if (_callActivityType == "fromCall" || _callActivityType == "gainCall") {
  489. string storeModelStr = getTcpModelString(storeModel);
  490. sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
  491. lightControl("DOORLED", "000F");
  492. } else {
  493. storeModel.data = storeModel.json["id"].asString();
  494. sendVoiceTcp(VoiceAction::REJECT, storeModel, storeModel.from_id);
  495. }
  496. } else {
  497. TcpModel tcpModel;
  498. tcpModel.tid = tid;
  499. sendVoiceTcp(VoiceAction::CANCEL, tcpModel, StoragePreferences::getInt(STORE_DEVICE_ID,0));
  500. lightControl("DOORLED", "000F");
  501. }
  502. setSleepTimerRegistered(_isSleepTimerRegistered);
  503. EASYUICONTEXT->goBack();
  504. } else {
  505. GetTelephone()->Hangup();
  506. }
  507. return false;
  508. }
  509. static bool onButtonClick_ButtonAnswer(ZKButton *pButton) {
  510. LOGD(" ButtonClick ButtonAnswer !!!\n");
  511. mButtonAnswerPtr->setVisible(false);
  512. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  513. voip::CallInfo info = GetTelephone()->GetCallInfo();
  514. GetTelephone()->Answer();
  515. } else {
  516. TcpModel model = CallingStatus::instance()->getTcpModel();
  517. //LOGD("storeModel :::: type=%s,action=%s,from=%d,to=%d",model.type.c_str(),model.action.c_str(),model.from_id,model.to_id);
  518. //std::string storeModelStr = getTcpModelString(model);
  519. //LOGD("storeModelStr ===== %s",storeModelStr.c_str());
  520. //只回传iId
  521. model.data = model.json["id"].asString();
  522. sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
  523. }
  524. return false;
  525. }
  526. static bool onButtonClick_ButtonVol(ZKButton *pButton) {
  527. LOGD(" ButtonClick ButtonVol !!!\n");
  528. return false;
  529. }
  530. static void onProgressChanged_SeekBarGain(ZKSeekBar *pSeekBar, int progress) {
  531. //LOGD(" ProgressChanged SeekBarGain %d !!!\n", progress);
  532. mTextViewGainPtr->setText(base::format("%d", progress));
  533. GetTelephone()->SetInputPcmGainSize(progress);
  534. }
  535. static void onProgressChanged_SeekBarInput(ZKSeekBar *pSeekBar, int progress) {
  536. //LOGD(" ProgressChanged SeekBarInput %d !!!\n", progress);
  537. mTextViewInputPtr->setText(base::format("%d", progress));
  538. zk_audio_input_set_volume_native(0, 0);
  539. zk_audio_input_set_volume_native(1, progress);
  540. }
  541. static void onVideoViewPlayerMessageListener_VideoView(ZKVideoView *pVideoView, int msg) {
  542. switch (msg) {
  543. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED:
  544. break;
  545. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED:
  546. break;
  547. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_ERROR:
  548. break;
  549. }
  550. }