h323_fs.cpp
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:9k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.3 $
- * $Date: 1998/10/23 15:52:32 $
- */
- ////////////////////////////////////////////////////////////////
- // 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 "exchange.h"
- #include "call.h"
- #include <assert.h>
- // Caveats: expects call->rtcp_addr/call->rtp_addr to be valid.
- int
- H323Call::InitFastStartProposal(H225CSSetupUUIE *setup_uuie)
- {
- ProtReturnCode ret;
- H245SigOpenLogicalChannel *olc_p;
- H245SigForwardLCParams *fwd_lcp_p;
- H245SigReverseLCParams *rev_lcp_p;
- H245SigH225Params *h225_mux_p;
- H245SigMuxNone *none_mux_p;
- assert(do_faststart != 0);
- // Lets do only G.723 for now.
- H245SigAudDataType g723type;
- H245SigNullDataType nulltype;
- H245SigG7231Cap g7231cap;
- g7231cap.SetMaxFrames(3);
- g7231cap.SetSilenceSupp(FALSE);
- g723type.Set(g7231cap);
- // Prepare the outgoing Logical channel proposal first.
- h225_mux_p = new H245SigH225Params;
- h225_mux_p->SetSessionID(PRI_SSID_AUDIO);
- h225_mux_p->SetDynamicRTPPayloadType(G7231_RTP_PAYLOAD_TYPE);
- h225_mux_p->SetSilenceSupp(FALSE);
- h225_mux_p->SetMediaCtrlChan((struct sockaddr *)&rtcp_addr);
- fwd_lcp_p = new H245SigForwardLCParams;
- fwd_lcp_p->SetDataType(g723type);
- fwd_lcp_p->SetPortNumber(0x1234);
- fwd_lcp_p->SetMuxParams(*h225_mux_p);
- olc_p = new H245SigOpenLogicalChannel;
- olc_p->SetForwardLCNumber(1);
- olc_p->SetForwardLCParams(*fwd_lcp_p);
- ret = setup_uuie->AddOLC(*olc_p);
- delete olc_p;
- delete fwd_lcp_p;
- delete h225_mux_p;
- if (!(PROT_IS_SUCCESS(ret)))
- {
- return -1;
- }
- // Prepare the incoming Logical channel proposal now.
- none_mux_p = new H245SigMuxNone;
- fwd_lcp_p = new H245SigForwardLCParams;
- fwd_lcp_p->SetDataType(nulltype);
- fwd_lcp_p->SetMuxParams(*none_mux_p);
- h225_mux_p = new H245SigH225Params;
- h225_mux_p->SetSessionID(PRI_SSID_AUDIO);
- h225_mux_p->SetDynamicRTPPayloadType(G7231_RTP_PAYLOAD_TYPE);
- h225_mux_p->SetSilenceSupp(FALSE);
- h225_mux_p->SetMediaChan((struct sockaddr *)&rtp_addr);
- h225_mux_p->SetMediaCtrlChan((struct sockaddr *)&rtcp_addr);
- rev_lcp_p = new H245SigReverseLCParams;
- rev_lcp_p->SetDataType(g723type);
- rev_lcp_p->SetMuxParams(*h225_mux_p);
- olc_p = new H245SigOpenLogicalChannel;
- olc_p->SetForwardLCNumber(2);
- olc_p->SetForwardLCParams(*fwd_lcp_p);
- olc_p->SetReverseLCParams(*rev_lcp_p);
- ret = setup_uuie->AddOLC(*olc_p);
- delete olc_p;
- delete fwd_lcp_p;
- delete rev_lcp_p;
- delete h225_mux_p;
- delete none_mux_p;
- if (!(PROT_IS_SUCCESS(ret)))
- {
- return -1;
- }
- return 0;
- }
- // Caveats: expects call->rtcp_addr/call->rtp_addr to be valid.
- int
- H323Call::InitFastStartReply(H225CSSetupUUIE *setup_uuie)
- {
- // We wil do only G.723.
- ProtReturnCode ret;
- int num_replys = 0;
- int num_selected = 0;
- int i;
- setup_uuie->GetNumOLC(num_replys);
- if (num_replys <= 0)
- {
- return -1;
- }
- H245SigOpenLogicalChannel *olclist =
- new H245SigOpenLogicalChannel[num_replys];
- ret = setup_uuie->GetOLC(olclist, num_replys);
- if (!PROT_IS_SUCCESS(ret))
- {
- delete [] olclist;
- return ret;
- }
- for(i = 0; i < num_replys && num_selected < 2; i++)
- {
- int type;
- H245SigForwardLCParams fwd_lcp;
- H245SigReverseLCParams rev_lcp;
- H245SigAudDataType data_type;
- ret = olclist[i].GetForwardLCParams(fwd_lcp);
- if (!(PROT_IS_SUCCESS(ret)))
- {
- delete [] olclist;
- return -1;
- }
- fwd_lcp.GetTypeOfDataType(type);
- if (type == DT_AUDIO)
- {
- int dtype, cap_type, cap_sub_type;
- fwd_lcp.GetDataType(data_type);
- data_type.GetType(dtype,cap_type,cap_sub_type);
- if (dtype == DT_AUDIO && cap_type == CAP_AUDIO &&
- cap_sub_type == AUD_G7231)
- {
- // Remote end is trying to open g7231 audio channel.
- // accept this. Copy the olc structure and fix the
- // h2250Logicalchannelparameters with our rtp/rtcp addresses.
- H245SigOpenLogicalChannel *olc_p;
- H245SigH225Params h225_mux;
- int dynamic_rtp_pt = 0;
- fs_channels[FS_CHANNEL_INCOMING] = olclist[i];
- olc_p = &fs_channels[FS_CHANNEL_INCOMING];
- // save the incoming lc number and dynamic rtp payload type.
- olc_p->GetForwardLCNumber(in_lc_num);
- fwd_lcp.GetMuxParams(h225_mux);
- h225_mux.GetDynamicRTPPayloadType(dynamic_rtp_pt);
- audio_session->SetRemotePayloadType(dynamic_rtp_pt);
- h225_mux.SetSessionID(PRI_SSID_AUDIO);
- h225_mux.SetSilenceSupp(FALSE);
- h225_mux.SetDynamicRTPPayloadType(G7231_RTP_PAYLOAD_TYPE);
- h225_mux.SetMediaChan((struct sockaddr *)&rtp_addr);
- h225_mux.SetMediaCtrlChan((struct sockaddr *)&rtcp_addr);
- fwd_lcp.SetMuxParams(h225_mux);
- olc_p->SetForwardLCParams(fwd_lcp);
- num_selected++;
- }
- }
- else if (type == DT_NULL)
- {
- ret = olclist[i].GetReverseLCParams(rev_lcp);
- rev_lcp.GetTypeOfDataType(type);
- if (type == DT_AUDIO)
- {
- int dtype, cap_type, cap_sub_type;
- rev_lcp.GetDataType(data_type);
- data_type.GetType(dtype,cap_type,cap_sub_type);
- if (dtype == DT_AUDIO && cap_type == CAP_AUDIO &&
- cap_sub_type == AUD_G7231)
- {
- H245SigOpenLogicalChannel *olc_p;
- H245SigH225Params h225_mux;
- struct sockaddr_in rrtp_addr;
- struct sockaddr_in rrtcp_addr;
- fs_channels[FS_CHANNEL_OUTGOING] = olclist[i];
- olc_p = &fs_channels[FS_CHANNEL_OUTGOING];
- out_lc_num = 1;
- olc_p->SetForwardLCNumber(out_lc_num);
- rev_lcp.GetMuxParams(h225_mux);
- // Save the remote ends rtp/rctp addresses.
- h225_mux.GetMediaChan((sockaddr*)&rrtp_addr);
- h225_mux.GetMediaCtrlChan((sockaddr*)&rrtcp_addr);
- assert(audio_session != NULL);
- audio_session->SetRemotePorts(rrtp_addr.sin_addr.s_addr,
- rrtp_addr.sin_port,rrtcp_addr.sin_port);
- // Fill our rtcp address.
- h225_mux.SetMediaCtrlChan((struct sockaddr *)&rtcp_addr);
- rev_lcp.SetMuxParams(h225_mux);
- olc_p->SetReverseLCParams(rev_lcp);
- num_selected++;
- }
- }
- }
- }
- if (num_selected != 2)
- {
- delete [] olclist;
- return -1;
- }
- delete [] olclist;
- return 0;
- }
- int
- H323Call::InterpretFastStartReply(UUIEItemFastStartList *fs_list)
- {
- ProtReturnCode ret;
- int num_replys = 0;
- int i;
- assert(do_faststart != 0);
- assert(faststart_state == FAST_START_STATE_PENDING);
- fs_list->GetNumOLC(num_replys);
- if (num_replys <= 0)
- {
- return -1;
- }
- H245SigOpenLogicalChannel *olclist =
- new H245SigOpenLogicalChannel[num_replys];
- ret = fs_list->GetOLC(olclist, num_replys);
- if (!PROT_IS_SUCCESS(ret))
- {
- delete [] olclist;
- return ret;
- }
- // Remember we advertized only two lc's in the outgoing
- // side. So, we will not check to see if the remote side
- // chose G.723 or not, since that is our default.
- for(i = 0; i < num_replys ; i++)
- {
- H245SigForwardLCParams fwd_lcp;
- H245SigReverseLCParams rev_lcp;
- H245SigAudDataType data_type;
- ret = olclist[i].GetReverseLCParams(rev_lcp);
- if (!PROT_IS_SUCCESS(ret))
- {
- H245SigOpenLogicalChannel *olc_p;
- H245SigH225Params h225_mux;
- struct sockaddr_in rrtp_addr;
- struct sockaddr_in rrtcp_addr;
- // Reverse LC params not present...
- // This is the case where the lc is opened to the remote side.
- ret = olclist[i].GetForwardLCParams(fwd_lcp);
- if (!(PROT_IS_SUCCESS(ret)))
- {
- delete [] olclist;
- return -1;
- }
- fs_channels[FS_CHANNEL_OUTGOING] = olclist[i];
- olc_p = &fs_channels[FS_CHANNEL_OUTGOING];
- // Update the RTP/RTCP address of the remote side.
- // If more audio capabilities than just one was advertised
- // this would be a place to check for the datatype etc..
- ret = fwd_lcp.GetMuxParams(h225_mux);
- // Save the remote ends rtp/rctp addresses.
- h225_mux.GetMediaChan((sockaddr*)&rrtp_addr);
- h225_mux.GetMediaCtrlChan((sockaddr*)&rrtcp_addr);
- assert(audio_session != NULL);
- audio_session->SetRemotePorts(rrtp_addr.sin_addr.s_addr,
- rrtp_addr.sin_port,rrtcp_addr.sin_port);
- }
- else
- {
- H245SigOpenLogicalChannel *olc_p;
- fs_channels[FS_CHANNEL_INCOMING] = olclist[i];
- olc_p = &fs_channels[FS_CHANNEL_OUTGOING];
- olc_p->GetForwardLCNumber(in_lc_num);
- }
- }
- delete [] olclist;
- return 0;
- }