call.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:7k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.12 $
- * $Date: 1999/03/15 22:49:36 $
- */
- ////////////////////////////////////////////////////////////////
- // 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. //
- ////////////////////////////////////////////////////////////////
- #if !defined(__CALL_H__)
- #define __CALL_H__
- #include "api/h225types.h"
- #include "api/h225csp.h"
- #include "api/h245sig.h"
- #include "api/h245ind.h"
- #include "api/h245cmd.h"
- #include "api/h245rr.h"
- #include "mq.h"
- #include "rtpstuff.h"
- #include "h450msgs.h"
- class Exchange;
- // Define the Identifiers that will be passed down in the constructors
- // of the H.225 and the H.245 protocols.
- #define ID_H225 2000 // H225 ids will start from 2000
- #define ID_H245 4000 // H245 ids will start from 4000
- #define G7231_INDEX 1
- #define G711_INDEX 2
- #define G7231_AUDIO_SAMPLING_RATE 8000
- #define G7231_RTP_PAYLOAD_TYPE 96
- class H323Call : public H225CSProtocol, public H245Protocol,
- public MessageQueue
- {
- public:
- H323Call(Exchange *ex, int h225_id, int h245_id,
- H225CSEndpointType& ep, int terminal_type,char *display,
- int outgoing_call,ProtReturnCode& result);
- ~H323Call();
- // returns the remote endpoints name.
- char* GetRemoteName()
- {
- return remote_name;
- }
- // transfer releated
- inline void SetInvokeID(int invokeID)
- {
- transfer_invoke_id = invokeID;
- }
- inline void SetTransferFlag(int flag)
- {
- transfer_flag = flag;
- }
- inline void SetTransferCallID(char *callID)
- {
- strncpy(transfer_call_id, callID, 5);
- }
- inline void SetParentIndex(int parent_index)
- {
- transfer_parent_index = parent_index;
- }
- // ph is a null terminated string containing the
- // phone number.
- void SetPhoneNumber(char *ph)
- {
- strcpy(phone,ph);
- }
- void SetSrcPhoneNumber(char *ph)
- {
- strcpy(src_phone,ph);
- }
- int IsAudioSessionRunning()
- {
- return audio_session_flag;
- }
- void SetApplicationPrivate(unsigned long priv)
- {
- application_private = priv;
- }
- unsigned long GetApplicationPrivate()
- {
- return application_private;
- }
- void TestIndication(int type);
- void TestConfRequest(int type);
- void TestConfResponse(int type);
- int Q931SendAlerting();
- int Q931SendProceeding();
- int Q931SendConnect();
- int Q931SendSetupAck();
- int Q931SendInformation(char *);
- // Q.931 callback methods implementation.
- void NotifyEvent(int, int, Q931Event* , H225CSUUIE* );
- // H.245 callback methods implementation.
- void NotifyState(int h245_state, ProtReturnCode error);
- void NotifyMSDError(int error);
- void NotifyMSDConfirm(int decision);
- void NotifyRemoteTermCaps(H245SigMuxCap *mux_cap,
- H245SigCapTable *cap_table,
- H245SigCapDescs *cap_descriptors);
- void NotifyTermCapsAck();
- void NotifyTermCapsReject(int, boolean , int , int);
- void NotifyOutLCError(int lc_num, int errorCode);
- void NotifyInLCError(int lc_num, int error_code);
- void NotifyCommand(H245SigCommand &cmd);
- void NotifyIndication(H245SigIndication &ind);
- void NotifyOpenLCReq( int lc_num, unsigned short port_number,
- H245SigDataType& dataType,
- H245SigMuxParams& lc_mux_params);
- void NotifyOpenLCReject(int lc_num, int reason);
- void NotifyOpenLCAck(int lc_num,
- H245SigH225AckParams *h225_lc_ack_params);
- void NotifyCloseOutLCReq(int lc_num);
- void NotifyCloseOutLCAck(int lc_num);
- void NotifyCloseInLC(int lc_num);
- void NotifyCloseInLCAck(int lc_num);
- void NotifyCloseInLCReject(int lc_num);
- void NotifyConfRequest(H245SigConfRequest &);
- void NotifyConfResponse(H245SigConfResponse &);
- #if defined(ENABLE_BENCHMARKS)
- // Instance of time when the call was started.
- unsigned int st_sec;
- unsigned int st_msec;
- unsigned int end_sec;
- unsigned int end_msec;
- // For tracking the call stack size.
- int max_stack_size;
- int cur_stack_size;
- #endif
- private:
- Exchange* exchange;
- // h245 address local if we are listening, remote if we are connecting.
- struct sockaddr_in remote_lc0_addr;
- struct sockaddr_in local_lc0_addr;
- // IP address in net byte order of local endpoint.
- unsigned long if_ip_addr;
- // did both ends do cap exchange, olc exchange, end session, etc...
- int cap_done;
- int olc_done;
- int msd_done;
- // The LC numbers..
- int in_lc_num;
- int out_lc_num;
- // The H245 rtp/rtcp Audio Session and the local rtp/rtcp addresses.
- H245RTPSession *audio_session;
- struct sockaddr_in rtp_addr, rtcp_addr;
- void NotifyMessage(USER_MESSAGE&);
- void QueueIt(unsigned int wparam, unsigned long lparam);
- // Added for version 2.
- H225CSCallID callid;
- char confid[16];
- // Information related to faststart.
- #define FAST_START_STATE_DISABLED 0
- #define FAST_START_STATE_PENDING 1
- #define FAST_START_STATE_ENABLED 2
- #define H245_FAST_START_STATE_SWITCH_OUT_BEGIN 3
- #define H245_FAST_START_STATE_SWITCHED_OUT 4
- int faststart_state;
- #define FS_CHANNEL_OUTGOING 0
- #define FS_CHANNEL_INCOMING 1
- H245SigOpenLogicalChannel fs_channels[2];
- int do_faststart;
- int do_overlapsend;
- int do_tunneling;
- int do_alerting;
- int do_proceeding;
- int is_outgoing_call;
- // Internal helpers..
- void InitCapTable(H245SigCapTable& cap_table);
- void InitCapDescs(H245SigCapDescs& cap_descs);
- void InitMuxCap(H245SigMuxCap& mux_cap);
- boolean CheckCap(H245SigCapTable& cap_table, H245SigCap& cap);
- void PrintCaps(H245SigCapTable &cap_table);
- void DropQ931(int);
- int StartAudio();
- int LocalHangup();
- int SendFacility(H450SSseq *ssSeq);
- int CreateRtpSession();
- int SwitchToRegularH245();
- void SendQ932Facility(int, H450SSseq *ssSeq);
- // internal helpers for faststart
- int InitFastStartProposal(H225CSSetupUUIE *setup_uuie);
- int InitFastStartReply(H225CSSetupUUIE *setup_uuie);
- int InterpretFastStartReply(UUIEItemFastStartList *fs_list);
- char remote_name[256];
- char *display_str;
- char phone[256];
- char src_phone[256];
- int endsession_sent;
- int audio_session_flag;
- int call_dropped;
- unsigned long application_private;
- // transfer related
- int transfer_flag;
- int transfer_invoke_id;
- char transfer_call_id[5];
- int transfer_parent_index; // used in terminal B to associate the two calls
- };
- #endif // __TERM_H__