callcb.cpp
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:13k
源码类别:

IP电话/视频会议

开发平台:

WINDOWS

  1. /*
  2.  * $Revision: 1.8 $
  3.  * $Date: 1998/11/03 18:32:54 $
  4.  */
  5. ////////////////////////////////////////////////////////////////
  6. //               Copyright (c) 1996-98 Lucent Technologies    //
  7. //                       All Rights Reserved                  //
  8. //                                                            //
  9. //                       THIS IS UNPUBLISHED                  //
  10. //                       PROPRIETARY SOURCE                   //
  11. //                   CODE OF Lucent Technologies              //
  12. // AND elemedia   //
  13. //                                                            //
  14. ////////////////////////////////////////////////////////////////
  15. //
  16. ////////////////////////////////////////////////////////////////
  17. // Example programs are provided soley to demonstrate one     //
  18. // possible use of the stack libraries and are included for   //
  19. // instructional purposes only.  You are free to use, modify  //
  20. // and/or redistribute any portion of code in the example     //
  21. // programs.  However, such examples are not intended to      //
  22. // represent production quality code.                         //
  23. //                                                            //
  24. // THE COPYRIGHT HOLDERS PROVIDE THESE EXAMPLE PROGRAMS       //
  25. // "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED     //
  26. // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     //
  27. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A            //
  28. // PARTICULAR PURPOSE.                                        //
  29. ////////////////////////////////////////////////////////////////
  30. #include "api/h225csp.h"
  31. #include "api/h245sig.h"
  32. #include "api/h4501suppserv.h"
  33. #include "exchange.h"
  34. #include "call.h"
  35. #include "msg.h"
  36. #include <assert.h>
  37. #if (defined(ENABLE_BENCHMARKS))
  38. #include "perf.h"
  39. #endif
  40. void 
  41. H323Call::QueueIt(unsigned int arg1, unsigned long arg2)
  42. {
  43. USER_MESSAGE msg;
  44. msg.message = PROT_CALL_MSG;
  45. msg.wParam = arg1;
  46. msg.lParam = arg2;
  47. QueueMessage(&msg);
  48. }
  49. void 
  50. H323Call::NotifyEvent(int old_state, int new_state, 
  51. Q931Event* event, H225CSUUIE* ie)
  52. {
  53. #if (defined(ENABLE_BENCHMARKS))
  54. UPDATE_STACK_SIZE();
  55. #endif
  56. LOG("H323Call::NotifyEvent - ");
  57. Q931Evt *msg;
  58. UUIEItemFastStartList *fslist;
  59. int incoming_fs_present = 0;
  60. LOG("old_state = %d, new_state = %d,"
  61. " event = %p, ie = %pn",  
  62. old_state, new_state, event, ie);
  63. msg = new Q931Evt;
  64. msg->old_state = old_state;
  65. msg->new_state = new_state;
  66. if (event)
  67. {
  68. msg->event_type = event->GetEventType();
  69. LOG("event type = %dn", msg->event_type);
  70. if (event->GetEventType() == Q931EVENT_MESSAGE)
  71. {
  72. Q931Message *message = (Q931Message *)event;
  73. if (message)
  74. {
  75. int type;
  76. message->GetType(type);
  77. LOG("Got Message Type 0x%x, uuie = 0x%lxn", type, ie);
  78. msg->message = new Q931Message(type);
  79. *(msg->message) = *message;
  80. if (ie)
  81. {
  82. switch(type)
  83. {
  84. case MESSAGE_SETUP:
  85. msg->ie = new H225CSSetupUUIE(*this);
  86. *((H225CSSetupUUIE*)msg->ie) = 
  87. *(H225CSSetupUUIE*)ie;
  88. // Check if faststart is set.
  89. if (((H225CSSetupUUIE*)ie)->IsFastStartPresent())
  90. {
  91. incoming_fs_present = 1;
  92. fslist = (UUIEItemFastStartList *)
  93. (H225CSSetupUUIE*)ie;
  94. }
  95. break;
  96. case MESSAGE_ALERTING:
  97. msg->ie = new H225CSAlertingUUIE(*this);
  98. *((H225CSAlertingUUIE*)msg->ie) = 
  99. *(H225CSAlertingUUIE*)ie;
  100. // Check if faststart is set.
  101. if (((H225CSAlertingUUIE*)ie)->IsFastStartPresent())
  102. {
  103. incoming_fs_present = 1;
  104. fslist = (UUIEItemFastStartList *)
  105. (H225CSAlertingUUIE*)ie;
  106. }
  107. break;
  108. case MESSAGE_RELEASE_COMPLETE:
  109. msg->ie = new H225CSReleaseCompleteUUIE(*this);
  110. *((H225CSReleaseCompleteUUIE*)msg->ie) = 
  111. *(H225CSReleaseCompleteUUIE*)ie;
  112. break;
  113. case MESSAGE_CALL_PROCEEDING:
  114. msg->ie = new H225CSCallProceedingUUIE(*this);
  115. *((H225CSCallProceedingUUIE*)msg->ie) = 
  116. *(H225CSCallProceedingUUIE*)ie;
  117. // Check if faststart is set.
  118. if (((H225CSCallProceedingUUIE*)ie)->IsFastStartPresent())
  119. {
  120. incoming_fs_present = 1;
  121. fslist = (UUIEItemFastStartList *)
  122. (H225CSCallProceedingUUIE*)ie;
  123. }
  124. break;
  125. case MESSAGE_CONNECT:
  126. msg->ie = new H225CSConnectUUIE(*this);
  127. *((H225CSConnectUUIE*)msg->ie) = 
  128. *(H225CSConnectUUIE*)ie;
  129. // Check if faststart is set.
  130. if (((H225CSConnectUUIE*)ie)->IsFastStartPresent())
  131. {
  132. incoming_fs_present = 1;
  133. fslist = (UUIEItemFastStartList *)
  134. (H225CSConnectUUIE*)ie;
  135. }
  136. break;
  137. case MESSAGE_Q932_FACILITY:
  138. {
  139. msg->ie = new H225CSFacilityUUIE(*this);
  140. *((H225CSFacilityUUIE*)msg->ie) =
  141. *(H225CSFacilityUUIE*)ie;
  142. }
  143. break;
  144. default:
  145. break;
  146. }
  147. }
  148. else
  149. {
  150. msg->ie = NULL;
  151. }
  152. }
  153. }
  154. else if (event->GetEventType() == Q931EVENT_ERROR)
  155. {
  156. msg->err = new Q931Error(0);
  157. *(msg->err) = *(Q931Error *)event;
  158. }
  159. else
  160. {
  161. assert(0);
  162. }
  163. }
  164. if (do_faststart && incoming_fs_present)
  165. {
  166. if (is_outgoing_call && faststart_state == FAST_START_STATE_PENDING)
  167. {
  168. LOG("interpreting a faststart reply messagen");
  169. if (InterpretFastStartReply((UUIEItemFastStartList *) fslist) == 0)
  170. {
  171. faststart_state = FAST_START_STATE_ENABLED;
  172. audio_session_flag = 1;
  173. #if defined (ENABLE_BENCHMARKS)
  174. get_current_time(end_sec,end_msec);
  175. #endif
  176. StartAudio();
  177. }
  178. else
  179. {
  180. LOG("ERROR, interpreting the faststart reply messagen");
  181. }
  182. }
  183. else
  184. {
  185. LOG("Creating a faststart reply messagen");
  186. if (InitFastStartReply((H225CSSetupUUIE  *)ie) == 0)
  187. {
  188. faststart_state = FAST_START_STATE_PENDING;
  189. }
  190. else
  191. {
  192. LOG("ERROR, creating a faststart reply messagen");
  193. }
  194. }
  195. LOG("faststart state= %dn", faststart_state);
  196. }
  197. QueueIt(CB_Q931_EVENT,(unsigned long)msg);
  198. }
  199. // H.245 callbacks.
  200. void 
  201. H323Call::NotifyMSDError(int error)
  202.  {
  203. LOG("H323Call::NotifyMSDError");
  204. LOG("error = %dn", error);
  205. MSDError *msg;
  206. msg = new MSDError;
  207. msg->error = error;
  208. QueueIt(CB_MSD_ERROR,(unsigned long)msg);
  209. }
  210. void 
  211. H323Call::NotifyMSDConfirm(int decision)
  212. {
  213. #if (defined(ENABLE_BENCHMARKS))
  214. UPDATE_STACK_SIZE();
  215. #endif
  216. LOG("H323Call::NotifyMSDConfirm");
  217. LOG("decision = %dn", decision);
  218. MSDConfirm *msg;
  219. msg = new MSDConfirm;
  220. msg->decision = decision;
  221. QueueIt(CB_MSD_CONFIRM,(unsigned long)msg);
  222. }
  223. void 
  224. H323Call::NotifyRemoteTermCaps(H245SigMuxCap *mux_cap,
  225. H245SigCapTable *cap_table,
  226. H245SigCapDescs *cap_descriptors)
  227. {
  228. #if (defined(ENABLE_BENCHMARKS))
  229. UPDATE_STACK_SIZE();
  230. #endif
  231. LOG("H323Call::NotifyRemoteTermCaps");
  232. RemoteTermCaps *msg;
  233. msg = new RemoteTermCaps;
  234. if (mux_cap)
  235. {
  236. msg->mux_cap = &msg->_h225_mux_cap;
  237. msg->_h225_mux_cap = *(H245SigH225Cap*)mux_cap;
  238. }
  239. if (cap_table)
  240. {
  241. msg->cap_table = &(msg->_cap_table);
  242. *(msg->cap_table) = *cap_table;
  243. }
  244. if (cap_descriptors)
  245. {
  246. msg->cap_desc = &(msg->_cap_desc);
  247. *(msg->cap_desc) = *cap_descriptors;
  248. }
  249. QueueIt(CB_REMOTE_TERM_CAPS,(unsigned long)msg);
  250. }
  251. void 
  252. H323Call::NotifyTermCapsAck()
  253. {
  254. #if (defined(ENABLE_BENCHMARKS))
  255. UPDATE_STACK_SIZE();
  256. #endif
  257. TermCapsAck *msg;
  258. LOG("H323Call::NotifyTermCapsAck");
  259. msg = new TermCapsAck;
  260. QueueIt(CB_TERM_CAPS_ACK,(unsigned int) msg);
  261. }
  262. void 
  263. H323Call::NotifyTermCapsReject(int cause, boolean exeeded_type,  
  264. int max_entry, int direction)
  265. {
  266. #if (defined(ENABLE_BENCHMARKS))
  267. UPDATE_STACK_SIZE();
  268. #endif
  269. LOG("H323Call::NotifyTermCapsReject");
  270. LOG("cause = %d, direction = %dn", cause, direction);
  271. TermCapsReject *msg;
  272. msg = new TermCapsReject;
  273. msg->cause = cause;
  274. msg->direction = direction;
  275. QueueIt(CB_TERM_CAPS_REJECT,(unsigned long)msg);
  276. }
  277. void 
  278. H323Call::NotifyOutLCError(int lc_num, int errorCode)
  279. {
  280. #if (defined(ENABLE_BENCHMARKS))
  281. UPDATE_STACK_SIZE();
  282. #endif
  283. LOG("H323Call::NotifyOutLCError");
  284. LOG("lc_num = %dn, errorCode = %dn", lc_num, errorCode);
  285. LCError *msg;
  286. msg = new LCError;
  287. msg->lc_num = lc_num;
  288. msg->error = errorCode;
  289. QueueIt(CB_OUT_LC_ERROR,(unsigned long)msg);
  290. }
  291. void 
  292. H323Call::NotifyInLCError(int lc_num, int error_code)
  293. {
  294. #if (defined(ENABLE_BENCHMARKS))
  295. UPDATE_STACK_SIZE();
  296. #endif
  297. LOG("H323Call::NotifyInLCError");
  298. LOG("lc_num = %dn errorCode = %dn", lc_num, error_code);
  299. LCError *msg;
  300. msg = new LCError;
  301. msg->lc_num = lc_num;
  302. msg->error = error_code;
  303. QueueIt(CB_IN_LC_ERROR,(unsigned long)msg);
  304. }
  305. void 
  306. H323Call::NotifyCommand(H245SigCommand &cmd)
  307. {
  308. #if (defined(ENABLE_BENCHMARKS))
  309. UPDATE_STACK_SIZE();
  310. #endif
  311. LOG("H323Call::NotifyCommandn");
  312. int type;
  313. cmd.GetCommandType(type);
  314. LOG("command type = %dn", type);
  315. H245CMD *msg;
  316. msg = new H245CMD;
  317. H245SigCommand::Factory(msg->cmd, type);
  318. *(msg->cmd) = cmd;
  319. QueueIt(CB_NOTIFY_CMD, (unsigned long)msg);
  320. }
  321. void 
  322. H323Call::NotifyIndication(H245SigIndication &ind)
  323. {
  324. #if (defined(ENABLE_BENCHMARKS))
  325. UPDATE_STACK_SIZE();
  326. #endif
  327. LOG("H323Call::NotifyIndicationn");
  328. int type;
  329. ind.GetIndicationType(type);
  330. LOG("indication type = %dn", type);
  331. H245IND *msg;
  332. msg = new H245IND;
  333. H245SigIndication::Factory(msg->ind, type);
  334. *(msg->ind) = ind;
  335. QueueIt(CB_NOTIFY_IND, (unsigned long)msg);
  336. }
  337. void 
  338. H323Call::NotifyOpenLCReq( int lc_num, unsigned short port_number,
  339. H245SigDataType& data_type, 
  340. H245SigMuxParams& lc_mux_params)
  341. {
  342. #if (defined(ENABLE_BENCHMARKS))
  343. UPDATE_STACK_SIZE();
  344. #endif
  345. LOG("H323Call::NotifyOpenLCReq");
  346. LOG("lc_num = %d, port = %dn", lc_num, port_number);
  347. OLCReq *msg;
  348. int type, captype, capsubtype;
  349. msg = new OLCReq;
  350. msg->port = port_number;
  351. msg->lc_num = lc_num;
  352. data_type.GetType(type,captype,capsubtype);
  353. switch(type)
  354. {
  355. case DT_AUDIO:
  356. msg->data_type = &msg->aud;
  357. msg->aud = *(H245SigAudDataType*)&data_type;
  358. break;
  359. case DT_VIDEO:
  360. msg->data_type = &msg->vid;
  361. msg->vid = *(H245SigVidDataType*)&data_type;
  362. break;
  363. }
  364. msg->h225_params = *(H245SigH225Params*)&lc_mux_params;
  365. msg->mux_params = &(msg->h225_params);
  366. QueueIt(CB_OLC_REQUEST,(unsigned long)msg);
  367. }
  368. void 
  369. H323Call::NotifyOpenLCReject(int lc_num, int reason)
  370. {
  371. #if (defined(ENABLE_BENCHMARKS))
  372. UPDATE_STACK_SIZE();
  373. #endif
  374. LOG("H323Call::NotifyOpenLCReject");
  375. LOG("lc_num = %d, reason = %dn", lc_num, reason);
  376. OLCReject *msg;
  377. msg = new OLCReject;
  378. msg->lc_num = lc_num;
  379. msg->reason = reason;
  380. QueueIt(CB_OLC_REJECT,(unsigned long)msg);
  381. }
  382. void 
  383. H323Call::NotifyOpenLCAck(int lc_num,
  384. H245SigH225AckParams *h225_lc_ack_params)
  385. {
  386. #if (defined(ENABLE_BENCHMARKS))
  387. UPDATE_STACK_SIZE();
  388. #endif
  389. LOG("H323Call::NotifyOpenLCAck");
  390. LOG("lc_num = %dn", lc_num);
  391. OLCAck *msg;
  392. msg = new OLCAck;
  393. msg->lc_num = lc_num;
  394. msg->ack_params = &msg->_ack_params;
  395. msg->_ack_params = *h225_lc_ack_params;
  396. QueueIt(CB_OLC_ACK,(unsigned long)msg);
  397. }
  398. void 
  399. H323Call::NotifyCloseOutLCReq(int lc_num)
  400. {
  401. #if (defined(ENABLE_BENCHMARKS))
  402. UPDATE_STACK_SIZE();
  403. #endif
  404. LOG("H323Call::NotifyCloseOutLCReq");
  405. LOG("lc_num = %dn", lc_num);
  406. CloseXXX *msg;
  407. msg = new CloseXXX;
  408. msg->lc_num = lc_num;
  409. QueueIt(CB_CLOSE_OUT_LC_REQUEST,(unsigned long)msg);
  410. }
  411. void 
  412. H323Call::NotifyCloseOutLCAck(int lc_num)
  413. {
  414. #if (defined(ENABLE_BENCHMARKS))
  415. UPDATE_STACK_SIZE();
  416. #endif
  417. LOG("H323Call::NotifyCloseOutLCAck");
  418. LOG("lc_num = %dn", lc_num);
  419. CloseXXX *msg;
  420. msg = new CloseXXX;
  421. msg->lc_num = lc_num;
  422. QueueIt(CB_CLOSE_OUT_LC_ACK,(unsigned long)msg);
  423. }
  424. void 
  425. H323Call::NotifyCloseInLC(int lc_num)
  426. {
  427. #if (defined(ENABLE_BENCHMARKS))
  428. UPDATE_STACK_SIZE();
  429. #endif
  430. LOG("H323Call::NotifyCloseInLC");
  431. LOG("lc_num = %dn", lc_num);
  432. CloseXXX *msg;
  433. msg = new CloseXXX;
  434. msg->lc_num = lc_num;
  435. QueueIt(CB_CLOSE_IN_LC,(unsigned long)msg);
  436. }
  437. void 
  438. H323Call::NotifyCloseInLCAck(int lc_num)
  439. {
  440. #if (defined(ENABLE_BENCHMARKS))
  441. UPDATE_STACK_SIZE();
  442. #endif
  443. LOG("H323Call::NotifyCloseInLCAck");
  444. LOG("lc_num = %dn", lc_num);
  445. CloseXXX *msg;
  446. msg = new CloseXXX;
  447. msg->lc_num = lc_num;
  448. QueueIt(CB_CLOSE_IN_LC_ACK,(unsigned long)msg);
  449. }
  450. void 
  451. H323Call::NotifyCloseInLCReject(int lc_num)
  452. {
  453. #if (defined(ENABLE_BENCHMARKS))
  454. UPDATE_STACK_SIZE();
  455. #endif
  456. LOG("H323Call::NotifyCloseInLCReject");
  457. LOG("lc_num = %dn", lc_num);
  458. CloseXXX *msg;
  459. msg = new CloseXXX;
  460. msg->lc_num = lc_num;
  461. QueueIt(CB_CLOSE_IN_LC_REJECT,(unsigned long)msg);
  462. }
  463. void
  464. H323Call::NotifyConfRequest(H245SigConfRequest &req)
  465. {
  466. #if (defined(ENABLE_BENCHMARKS))
  467. UPDATE_STACK_SIZE();
  468. #endif
  469. LOG("H323Call::NotifyConfRequestn");
  470. ConfRequest *msg;
  471. msg = new ConfRequest;
  472. msg->req = req;
  473. QueueIt(CB_CONF_REQ,(unsigned long)msg);
  474. }
  475. void
  476. H323Call::NotifyConfResponse(H245SigConfResponse &resp)
  477. {
  478. #if (defined(ENABLE_BENCHMARKS))
  479. UPDATE_STACK_SIZE();
  480. #endif
  481. LOG("H323Call::NotifyConfResponsen");
  482. ConfResponse *msg;
  483. msg = new ConfResponse;
  484. msg->resp = resp;
  485. QueueIt(CB_CONF_RESP,(unsigned long)msg);
  486. }