callcb.cpp
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:13k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.8 $
- * $Date: 1998/11/03 18:32:54 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996-98 Lucent Technologies //
- // All Rights Reserved //
- // //
- // THIS IS UNPUBLISHED //
- // PROPRIETARY SOURCE //
- // CODE OF Lucent Technologies //
- // AND elemedia //
- // //
- ////////////////////////////////////////////////////////////////
- //
- ////////////////////////////////////////////////////////////////
- // Example programs are provided soley to demonstrate one //
- // possible use of the stack libraries and are included for //
- // instructional purposes only. You are free to use, modify //
- // and/or redistribute any portion of code in the example //
- // programs. However, such examples are not intended to //
- // represent production quality code. //
- // //
- // THE COPYRIGHT HOLDERS PROVIDE THESE EXAMPLE PROGRAMS //
- // "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED //
- // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED //
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A //
- // PARTICULAR PURPOSE. //
- ////////////////////////////////////////////////////////////////
- #include "api/h225csp.h"
- #include "api/h245sig.h"
- #include "api/h4501suppserv.h"
- #include "exchange.h"
- #include "call.h"
- #include "msg.h"
- #include <assert.h>
- #if (defined(ENABLE_BENCHMARKS))
- #include "perf.h"
- #endif
- void
- H323Call::QueueIt(unsigned int arg1, unsigned long arg2)
- {
- USER_MESSAGE msg;
- msg.message = PROT_CALL_MSG;
- msg.wParam = arg1;
- msg.lParam = arg2;
- QueueMessage(&msg);
- }
- void
- H323Call::NotifyEvent(int old_state, int new_state,
- Q931Event* event, H225CSUUIE* ie)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyEvent - ");
- Q931Evt *msg;
- UUIEItemFastStartList *fslist;
- int incoming_fs_present = 0;
- LOG("old_state = %d, new_state = %d,"
- " event = %p, ie = %pn",
- old_state, new_state, event, ie);
- msg = new Q931Evt;
- msg->old_state = old_state;
- msg->new_state = new_state;
- if (event)
- {
- msg->event_type = event->GetEventType();
- LOG("event type = %dn", msg->event_type);
- if (event->GetEventType() == Q931EVENT_MESSAGE)
- {
- Q931Message *message = (Q931Message *)event;
- if (message)
- {
- int type;
- message->GetType(type);
- LOG("Got Message Type 0x%x, uuie = 0x%lxn", type, ie);
- msg->message = new Q931Message(type);
- *(msg->message) = *message;
- if (ie)
- {
- switch(type)
- {
- case MESSAGE_SETUP:
- msg->ie = new H225CSSetupUUIE(*this);
- *((H225CSSetupUUIE*)msg->ie) =
- *(H225CSSetupUUIE*)ie;
- // Check if faststart is set.
- if (((H225CSSetupUUIE*)ie)->IsFastStartPresent())
- {
- incoming_fs_present = 1;
- fslist = (UUIEItemFastStartList *)
- (H225CSSetupUUIE*)ie;
- }
- break;
- case MESSAGE_ALERTING:
- msg->ie = new H225CSAlertingUUIE(*this);
- *((H225CSAlertingUUIE*)msg->ie) =
- *(H225CSAlertingUUIE*)ie;
- // Check if faststart is set.
- if (((H225CSAlertingUUIE*)ie)->IsFastStartPresent())
- {
- incoming_fs_present = 1;
- fslist = (UUIEItemFastStartList *)
- (H225CSAlertingUUIE*)ie;
- }
- break;
- case MESSAGE_RELEASE_COMPLETE:
- msg->ie = new H225CSReleaseCompleteUUIE(*this);
- *((H225CSReleaseCompleteUUIE*)msg->ie) =
- *(H225CSReleaseCompleteUUIE*)ie;
- break;
- case MESSAGE_CALL_PROCEEDING:
- msg->ie = new H225CSCallProceedingUUIE(*this);
- *((H225CSCallProceedingUUIE*)msg->ie) =
- *(H225CSCallProceedingUUIE*)ie;
- // Check if faststart is set.
- if (((H225CSCallProceedingUUIE*)ie)->IsFastStartPresent())
- {
- incoming_fs_present = 1;
- fslist = (UUIEItemFastStartList *)
- (H225CSCallProceedingUUIE*)ie;
- }
- break;
- case MESSAGE_CONNECT:
- msg->ie = new H225CSConnectUUIE(*this);
- *((H225CSConnectUUIE*)msg->ie) =
- *(H225CSConnectUUIE*)ie;
- // Check if faststart is set.
- if (((H225CSConnectUUIE*)ie)->IsFastStartPresent())
- {
- incoming_fs_present = 1;
- fslist = (UUIEItemFastStartList *)
- (H225CSConnectUUIE*)ie;
- }
- break;
- case MESSAGE_Q932_FACILITY:
- {
- msg->ie = new H225CSFacilityUUIE(*this);
- *((H225CSFacilityUUIE*)msg->ie) =
- *(H225CSFacilityUUIE*)ie;
- }
- break;
- default:
- break;
- }
- }
- else
- {
- msg->ie = NULL;
- }
- }
- }
- else if (event->GetEventType() == Q931EVENT_ERROR)
- {
- msg->err = new Q931Error(0);
- *(msg->err) = *(Q931Error *)event;
- }
- else
- {
- assert(0);
- }
- }
- if (do_faststart && incoming_fs_present)
- {
- if (is_outgoing_call && faststart_state == FAST_START_STATE_PENDING)
- {
- LOG("interpreting a faststart reply messagen");
- if (InterpretFastStartReply((UUIEItemFastStartList *) fslist) == 0)
- {
- faststart_state = FAST_START_STATE_ENABLED;
- audio_session_flag = 1;
- #if defined (ENABLE_BENCHMARKS)
- get_current_time(end_sec,end_msec);
- #endif
- StartAudio();
- }
- else
- {
- LOG("ERROR, interpreting the faststart reply messagen");
- }
- }
- else
- {
- LOG("Creating a faststart reply messagen");
- if (InitFastStartReply((H225CSSetupUUIE *)ie) == 0)
- {
- faststart_state = FAST_START_STATE_PENDING;
- }
- else
- {
- LOG("ERROR, creating a faststart reply messagen");
- }
- }
- LOG("faststart state= %dn", faststart_state);
- }
- QueueIt(CB_Q931_EVENT,(unsigned long)msg);
- }
- // H.245 callbacks.
- void
- H323Call::NotifyMSDError(int error)
- {
- LOG("H323Call::NotifyMSDError");
- LOG("error = %dn", error);
- MSDError *msg;
- msg = new MSDError;
- msg->error = error;
- QueueIt(CB_MSD_ERROR,(unsigned long)msg);
- }
- void
- H323Call::NotifyMSDConfirm(int decision)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyMSDConfirm");
- LOG("decision = %dn", decision);
- MSDConfirm *msg;
- msg = new MSDConfirm;
- msg->decision = decision;
- QueueIt(CB_MSD_CONFIRM,(unsigned long)msg);
- }
- void
- H323Call::NotifyRemoteTermCaps(H245SigMuxCap *mux_cap,
- H245SigCapTable *cap_table,
- H245SigCapDescs *cap_descriptors)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyRemoteTermCaps");
- RemoteTermCaps *msg;
- msg = new RemoteTermCaps;
- if (mux_cap)
- {
- msg->mux_cap = &msg->_h225_mux_cap;
- msg->_h225_mux_cap = *(H245SigH225Cap*)mux_cap;
- }
- if (cap_table)
- {
- msg->cap_table = &(msg->_cap_table);
- *(msg->cap_table) = *cap_table;
- }
- if (cap_descriptors)
- {
- msg->cap_desc = &(msg->_cap_desc);
- *(msg->cap_desc) = *cap_descriptors;
- }
- QueueIt(CB_REMOTE_TERM_CAPS,(unsigned long)msg);
- }
- void
- H323Call::NotifyTermCapsAck()
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- TermCapsAck *msg;
- LOG("H323Call::NotifyTermCapsAck");
- msg = new TermCapsAck;
- QueueIt(CB_TERM_CAPS_ACK,(unsigned int) msg);
- }
- void
- H323Call::NotifyTermCapsReject(int cause, boolean exeeded_type,
- int max_entry, int direction)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyTermCapsReject");
- LOG("cause = %d, direction = %dn", cause, direction);
- TermCapsReject *msg;
- msg = new TermCapsReject;
- msg->cause = cause;
- msg->direction = direction;
- QueueIt(CB_TERM_CAPS_REJECT,(unsigned long)msg);
- }
- void
- H323Call::NotifyOutLCError(int lc_num, int errorCode)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyOutLCError");
- LOG("lc_num = %dn, errorCode = %dn", lc_num, errorCode);
- LCError *msg;
- msg = new LCError;
- msg->lc_num = lc_num;
- msg->error = errorCode;
- QueueIt(CB_OUT_LC_ERROR,(unsigned long)msg);
- }
- void
- H323Call::NotifyInLCError(int lc_num, int error_code)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyInLCError");
- LOG("lc_num = %dn errorCode = %dn", lc_num, error_code);
- LCError *msg;
- msg = new LCError;
- msg->lc_num = lc_num;
- msg->error = error_code;
- QueueIt(CB_IN_LC_ERROR,(unsigned long)msg);
- }
- void
- H323Call::NotifyCommand(H245SigCommand &cmd)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCommandn");
- int type;
- cmd.GetCommandType(type);
- LOG("command type = %dn", type);
- H245CMD *msg;
- msg = new H245CMD;
- H245SigCommand::Factory(msg->cmd, type);
- *(msg->cmd) = cmd;
- QueueIt(CB_NOTIFY_CMD, (unsigned long)msg);
- }
- void
- H323Call::NotifyIndication(H245SigIndication &ind)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyIndicationn");
- int type;
- ind.GetIndicationType(type);
- LOG("indication type = %dn", type);
- H245IND *msg;
- msg = new H245IND;
- H245SigIndication::Factory(msg->ind, type);
- *(msg->ind) = ind;
- QueueIt(CB_NOTIFY_IND, (unsigned long)msg);
- }
- void
- H323Call::NotifyOpenLCReq( int lc_num, unsigned short port_number,
- H245SigDataType& data_type,
- H245SigMuxParams& lc_mux_params)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyOpenLCReq");
- LOG("lc_num = %d, port = %dn", lc_num, port_number);
- OLCReq *msg;
- int type, captype, capsubtype;
- msg = new OLCReq;
- msg->port = port_number;
- msg->lc_num = lc_num;
- data_type.GetType(type,captype,capsubtype);
- switch(type)
- {
- case DT_AUDIO:
- msg->data_type = &msg->aud;
- msg->aud = *(H245SigAudDataType*)&data_type;
- break;
- case DT_VIDEO:
- msg->data_type = &msg->vid;
- msg->vid = *(H245SigVidDataType*)&data_type;
- break;
- }
- msg->h225_params = *(H245SigH225Params*)&lc_mux_params;
- msg->mux_params = &(msg->h225_params);
- QueueIt(CB_OLC_REQUEST,(unsigned long)msg);
- }
- void
- H323Call::NotifyOpenLCReject(int lc_num, int reason)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyOpenLCReject");
- LOG("lc_num = %d, reason = %dn", lc_num, reason);
- OLCReject *msg;
- msg = new OLCReject;
- msg->lc_num = lc_num;
- msg->reason = reason;
- QueueIt(CB_OLC_REJECT,(unsigned long)msg);
- }
- void
- H323Call::NotifyOpenLCAck(int lc_num,
- H245SigH225AckParams *h225_lc_ack_params)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyOpenLCAck");
- LOG("lc_num = %dn", lc_num);
- OLCAck *msg;
- msg = new OLCAck;
- msg->lc_num = lc_num;
- msg->ack_params = &msg->_ack_params;
- msg->_ack_params = *h225_lc_ack_params;
- QueueIt(CB_OLC_ACK,(unsigned long)msg);
- }
- void
- H323Call::NotifyCloseOutLCReq(int lc_num)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCloseOutLCReq");
- LOG("lc_num = %dn", lc_num);
- CloseXXX *msg;
- msg = new CloseXXX;
- msg->lc_num = lc_num;
- QueueIt(CB_CLOSE_OUT_LC_REQUEST,(unsigned long)msg);
- }
- void
- H323Call::NotifyCloseOutLCAck(int lc_num)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCloseOutLCAck");
- LOG("lc_num = %dn", lc_num);
- CloseXXX *msg;
- msg = new CloseXXX;
- msg->lc_num = lc_num;
- QueueIt(CB_CLOSE_OUT_LC_ACK,(unsigned long)msg);
- }
- void
- H323Call::NotifyCloseInLC(int lc_num)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCloseInLC");
- LOG("lc_num = %dn", lc_num);
- CloseXXX *msg;
- msg = new CloseXXX;
- msg->lc_num = lc_num;
- QueueIt(CB_CLOSE_IN_LC,(unsigned long)msg);
- }
- void
- H323Call::NotifyCloseInLCAck(int lc_num)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCloseInLCAck");
- LOG("lc_num = %dn", lc_num);
- CloseXXX *msg;
- msg = new CloseXXX;
- msg->lc_num = lc_num;
- QueueIt(CB_CLOSE_IN_LC_ACK,(unsigned long)msg);
- }
- void
- H323Call::NotifyCloseInLCReject(int lc_num)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyCloseInLCReject");
- LOG("lc_num = %dn", lc_num);
- CloseXXX *msg;
- msg = new CloseXXX;
- msg->lc_num = lc_num;
- QueueIt(CB_CLOSE_IN_LC_REJECT,(unsigned long)msg);
- }
- void
- H323Call::NotifyConfRequest(H245SigConfRequest &req)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyConfRequestn");
- ConfRequest *msg;
- msg = new ConfRequest;
- msg->req = req;
- QueueIt(CB_CONF_REQ,(unsigned long)msg);
- }
- void
- H323Call::NotifyConfResponse(H245SigConfResponse &resp)
- {
- #if (defined(ENABLE_BENCHMARKS))
- UPDATE_STACK_SIZE();
- #endif
- LOG("H323Call::NotifyConfResponsen");
- ConfResponse *msg;
- msg = new ConfResponse;
- msg->resp = resp;
- QueueIt(CB_CONF_RESP,(unsigned long)msg);
- }