cap.cpp
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:8k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.5 $
- * $Date: 1998/06/08 16:57:48 $
- */
- ////////////////////////////////////////////////////////////////
- // 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 "call.h"
- #include "exchange.h"
- #include <assert.h>
- void
- H323Call::InitCapTable(H245SigCapTable& cap_table)
- {
- H245SigG7231Cap g7231cap;
- H245SigG711Ulaw64kCap g711ulawcap;
- g7231cap.SetMaxFrames(3);
- g7231cap.SetSilenceSupp(FALSE);
- cap_table.RegisterAsRW(g7231cap,G7231_INDEX);
- #if NEED_G711
- g711ulawcap.SetFramesPerPkt(90);
- cap_table.RegisterAsRW(g711ulawcap,G711_INDEX);
- #endif
- }
- void
- H323Call::InitCapDescs(H245SigCapDescs& cap_descs)
- {
- H245SigAltSet alt;
- H245SigCapDesc cap_desc;
- #if NEED_G711
- alt.AddCapId(G711_INDEX);
- #endif
- alt.AddCapId(G7231_INDEX);
- cap_desc.AddSet(alt);
- cap_descs.AddDesc(cap_desc);
- }
- void
- H323Call::InitMuxCap(H245SigMuxCap& mux_cap)
- {
- int type;
- H245SigH225Cap *h225_cap;
- H245SigMultipointCap multi_pt_cap;
- H245SigMedDistCap mdist_cap;
- mux_cap.GetType(type);
- if (type != MT_H225)
- {
- return;
- }
- h225_cap = (H245SigH225Cap*)&mux_cap;
- h225_cap->SetAudioDelayJitter(0x3C);
- mdist_cap.SetAudio(TRUE,FALSE);
- mdist_cap.SetControl(TRUE,FALSE);
- multi_pt_cap.AddMedDistCap(mdist_cap);
- h225_cap->SetRxMultipointCap(multi_pt_cap);
- h225_cap->SetTxMultipointCap(multi_pt_cap);
- h225_cap->SetRxTxMultipointCap(multi_pt_cap);
- }
- // Function to check if a given cap is present in the
- // cap table.
- /*ARGSUSED*/
- boolean
- H323Call::CheckCap(H245SigCapTable& cap_table, H245SigCap& cap)
- {
- // NOT IMPLEMENTED...
- return TRUE;
- }
- // Utility function to print the capability table.. demonstrates
- // how to extract information from the capability table...
- void
- H323Call::PrintCaps(H245SigCapTable &cap_table)
- {
- ProtReturnCode result;
- int num,
- count,
- type,
- prot,
- *caps;
- H245SigCap *c;
- LOG("Capability table is as followsn");
- result = cap_table.GetNumNonStd(num);
- if (num)
- {
- count = num;
- caps = new int[num];
- result = cap_table.GetNonStd(caps, count);
- LOG(" Non Standard Capabilities:n");
- for(num = 0; num < count; num++)
- {
- result = cap_table.GetCapType(type, prot, caps[num]);
- LOG(" Id: %d, type = %d, prot = %dn",
- caps[num], type, prot);
- }
- delete []caps;
- }
- result = cap_table.GetNumRx(num);
- if (num)
- {
- count = num;
- caps = new int[num];
- result = cap_table.GetRx(caps, count);
- LOG(" Recv Capabilitiesn");
- for(num = 0; num < count; num++)
- {
- result = cap_table.GetCapType(type, prot, caps[num]);
- LOG(" Id = %d, type = %d, prot = %dn",
- caps[num], type, prot);
- // Demonstrate how to get extract a capability.
- // print nonstandard audio capabilities.
- if (type == CAP_AUDIO && prot == AUD_NONSTD)
- {
- H245SigNonStdAudCap *nsaud_cap;
- H245SigNonStdParam data;
- result = H245SigCap::Factory(c, type, prot);
- result = cap_table.GetCap(*c, caps[num]);
- nsaud_cap = (H245SigNonStdAudCap *)c;
- nsaud_cap->GetData(data);
- LOG(" NonStandard Audio capability contentsn");
- LOG(" IDType = %dn", data.GetIDType());
- if (data.GetIDType() == H245NS_IDT_H221NS)
- {
- unsigned short t35_cc;
- unsigned short t35_ext;
- unsigned short m_code;
- data.GetH221NonStd(t35_cc, t35_ext, m_code);
- LOG(" country = 0x%lx, ext = 0x%lx, manufaturer = 0x%lxn",
- t35_cc, t35_ext, m_code);
- unsigned char *buf;
- unsigned int len1;
- ProtReturnCode ret = data.GetNonStdData(buf, len1);
- int len = (int)len1;
- if (PROT_IS_SUCCESS(ret))
- {
- LOG(" dumping %d bytes of nonstandard datan",
- len);
- if (len > 0)
- {
- LOG(" ");
- }
- for (int i = 0; i < len; i++) {
- LOG("0x%x ", buf[i]);
- if ((i % 8) == 0)
- {
- LOG("n ");
- }
- }
- LOG("n");
- }
- else
- {
- LOG("Failed to extract non standard data, error = 0x%lxn", ret);
- }
- }
- else if (data.GetIDType() == H245NS_IDT_OBJECT)
- {
- unsigned short *data_p;
- unsigned short len;
- data.GetObjectIdentifier(data_p, len);
- assert(data_p != NULL && len > 0);
- LOG(" dumping %d bytes of nonstandard object datan",
- len);
- if (len > 0)
- {
- LOG(" ");
- }
- for (int i = 0; i < len; i++) {
- LOG("0x%x ", data_p[i]);
- if ((i % 8) == 0)
- {
- LOG("n ");
- }
- }
- LOG("n");
- }
- delete c;
- }
- }
- delete []caps;
- }
- result = cap_table.GetNumTx(num);
- if (num)
- {
- count = num;
- caps = new int[num];
- result = cap_table.GetTx(caps, count);
- LOG(" Xmit Capabilitiesn");
- for(num = 0; num < count; num++)
- {
- result = cap_table.GetCapType(type, prot, caps[num]);
- LOG(" Id = %d, type = %d, prot = %dn",
- caps[num], type, prot);
- }
- delete []caps;
- }
- result = cap_table.GetNumRW(num);
- if (num)
- {
- count = num;
- caps = new int[num];
- result = cap_table.GetRW(caps, count);
- LOG(" Xmit Capabilitiesn");
- for(num = 0; num < count; num++)
- {
- result = cap_table.GetCapType(type, prot, caps[num]);
- LOG(" Id = %d, type = %d, prot = %dn",
- caps[num], type, prot);
- // Demonstrate how to get extract a capability.
- // print nonstandard audio capabilities.
- if (type == CAP_AUDIO && prot == AUD_NONSTD)
- {
- H245SigNonStdAudCap *nsaud_cap;
- H245SigNonStdParam data;
- result = H245SigCap::Factory(c, type, prot);
- result = cap_table.GetCap(*c, caps[num]);
- nsaud_cap = (H245SigNonStdAudCap *)c;
- nsaud_cap->GetData(data);
- LOG(" NonStandard Audio capability contentsn");
- LOG(" IDType = %dn", data.GetIDType());
- if (data.GetIDType() == H245NS_IDT_H221NS)
- {
- unsigned short t35_cc;
- unsigned short t35_ext;
- unsigned short m_code;
- data.GetH221NonStd(t35_cc, t35_ext, m_code);
- LOG(" country = 0x%lx, ext = 0x%lx, manufaturer = 0x%lxn",
- t35_cc, t35_ext, m_code);
- }
- else if (data.GetIDType() == H245NS_IDT_OBJECT)
- {
- unsigned short *data_p;
- unsigned short len;
- data.GetObjectIdentifier(data_p, len);
- assert(data_p != NULL && len > 0);
- LOG(" dumping %d bytes of nonstandard datan",
- len);
- if (len > 0)
- {
- LOG(" ");
- }
- for (int i = 0; i < len; i++) {
- LOG("0x%x ", data_p[i]);
- if ((i % 8) == 0)
- {
- LOG("n ");
- }
- }
- LOG("n");
- }
- delete c;
- }
- }
- delete []caps;
- }
- }