📄 h323rtp.cxx
字号:
/* * h323rtp.cxx * * H.323 RTP protocol handler * * Open H323 Library * * Copyright (c) 1999-2000 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Open H323 Library. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Contributor(s): ______________________________________. * * $Log: h323rtp.cxx,v $ * Revision 1.7 2000/07/12 13:06:49 robertj * Removed test for sessionID in OLC, just trace a warning instead of abandoning connection. * * Revision 1.6 2000/07/11 19:36:43 robertj * Fixed silenceSuppression field in OLC only to be included on transmitter. * * Revision 1.5 2000/05/23 12:57:37 robertj * Added ability to change IP Type Of Service code from applications. * * Revision 1.4 2000/05/02 04:32:27 robertj * Fixed copyright notice comment. * * Revision 1.3 2000/04/05 03:17:32 robertj * Added more RTP statistics gathering and H.245 round trip delay calculation. * * Revision 1.2 2000/01/20 05:57:46 robertj * Added extra flexibility in receiving incorrectly formed OpenLogicalChannel PDU's * * Revision 1.1 1999/12/23 23:02:36 robertj * File reorganision for separating RTP from H.323 and creation of LID for VPB support. * */#include <ptlib.h>#include "h323rtp.h"#include "h323.h"#include "h225.h"#include "h245.h"#define new PNEW/////////////////////////////////////////////////////////////////////////////H323_RTP_Session::H323_RTP_Session(const H323Connection & conn) : connection(conn){}void H323_RTP_Session::OnTxStatistics(const RTP_Session & session) const{ connection.OnRTPStatistics(session);}void H323_RTP_Session::OnRxStatistics(const RTP_Session & session) const{ connection.OnRTPStatistics(session);}/////////////////////////////////////////////////////////////////////////////H323_RTP_UDP::H323_RTP_UDP(const H323Connection & conn, RTP_UDP & rtp_udp) : H323_RTP_Session(conn), rtp(rtp_udp){ const H323Transport & transport = connection.GetControlChannel(); PIPSocket::Address localAddress; WORD dummy; transport.GetLocalAddress().GetIpAndPort(localAddress, dummy); const H323EndPoint & endpoint = connection.GetEndPoint(); rtp.Open(localAddress, endpoint.GetRtpIpPortBase(), endpoint.GetRtpIpTypeofService());}BOOL H323_RTP_UDP::OnSendingPDU(H245_H2250LogicalChannelParameters & param, BOOL includeMediaChannel) const{ PTRACE(3, "RTP\tOnSendingPDU"); param.m_sessionID = rtp.GetSessionID(); param.IncludeOptionalField(H245_H2250LogicalChannelParameters::e_mediaGuaranteedDelivery); param.m_mediaGuaranteedDelivery = FALSE; if (!includeMediaChannel) { param.IncludeOptionalField(H245_H2250LogicalChannelParameters::e_silenceSuppression); param.m_silenceSuppression = TRUE; } const H323Transport & transport = connection.GetControlChannel(); // unicast must have mediaControlChannel param.IncludeOptionalField(H245_H2250LogicalChannelParameters::e_mediaControlChannel); transport.SetUpTransportPDU(param.m_mediaControlChannel, rtp.GetLocalControlPort()); if (includeMediaChannel) { // set mediaChannel param.IncludeOptionalField(H245_H2250LogicalChannelAckParameters::e_mediaChannel); transport.SetUpTransportPDU(param.m_mediaChannel, rtp.GetLocalDataPort()); } return TRUE;}void H323_RTP_UDP::OnSendingAckPDU(H245_H2250LogicalChannelAckParameters & param) const{ PTRACE(3, "RTP\tOnSendingAckPDU"); const H323Transport & transport = connection.GetControlChannel(); // set mediaControlChannel param.IncludeOptionalField(H245_H2250LogicalChannelAckParameters::e_mediaControlChannel); transport.SetUpTransportPDU(param.m_mediaControlChannel, rtp.GetLocalControlPort()); // set mediaChannel param.IncludeOptionalField(H245_H2250LogicalChannelAckParameters::e_mediaChannel); transport.SetUpTransportPDU(param.m_mediaChannel, rtp.GetLocalDataPort());}static BOOL ExtractTransport(const H245_TransportAddress & pdu, RTP_UDP & rtp, BOOL isDataPort, unsigned & errorCode){ if (pdu.GetTag() != H245_TransportAddress::e_unicastAddress) { PTRACE(1, "RTP_UDP\tOnly unicast supported at this time"); errorCode = H245_OpenLogicalChannelReject_cause::e_multicastChannelNotAllowed; return FALSE; } const H245_UnicastAddress & unicast = pdu; if (unicast.GetTag() != H245_UnicastAddress::e_iPAddress) { PTRACE(1, "RTP_UDP\tLogic error, UDP must be IP unicast"); errorCode = H245_OpenLogicalChannelReject_cause::e_unspecified; return FALSE; } const H245_UnicastAddress_iPAddress & addr = unicast; PIPSocket::Address ipnum(addr.m_network[0], addr.m_network[1], addr.m_network[2], addr.m_network[3]); return rtp.SetRemoteSocketInfo(ipnum, (WORD)(unsigned)addr.m_tsapIdentifier, isDataPort);}BOOL H323_RTP_UDP::OnReceivedPDU(const H245_H2250LogicalChannelParameters & param, unsigned & errorCode){ if (param.m_sessionID != rtp.GetSessionID()) { PTRACE(1, "RTP_UDP\tOpen for invalid session: " << param.m_sessionID); errorCode = H245_OpenLogicalChannelReject_cause::e_invalidSessionID; return FALSE; } BOOL ok = FALSE; if (param.HasOptionalField(H245_H2250LogicalChannelParameters::e_mediaControlChannel)) { if (!ExtractTransport(param.m_mediaControlChannel, rtp, FALSE, errorCode)) return FALSE; ok = TRUE; } if (param.HasOptionalField(H245_H2250LogicalChannelParameters::e_mediaChannel)) { if (!ExtractTransport(param.m_mediaChannel, rtp, TRUE, errorCode)) return FALSE; ok = TRUE; } if (ok) return TRUE; PTRACE(1, "RTP_UDP\tNo mediaChannel or mediaControlChannel specified"); errorCode = H245_OpenLogicalChannelReject_cause::e_unspecified; return FALSE;}BOOL H323_RTP_UDP::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param){ if (!param.HasOptionalField(H245_H2250LogicalChannelAckParameters::e_sessionID)) { PTRACE(1, "RTP_UDP\tNo session specified"); } if (param.m_sessionID != rtp.GetSessionID()) { PTRACE(1, "RTP_UDP\tAck for invalid session: " << param.m_sessionID); } if (!param.HasOptionalField(H245_H2250LogicalChannelAckParameters::e_mediaControlChannel)) { PTRACE(1, "RTP_UDP\tNo mediaControlChannel specified"); return FALSE; } unsigned errorCode; if (!ExtractTransport(param.m_mediaControlChannel, rtp, FALSE, errorCode)) return FALSE; if (!param.HasOptionalField(H245_H2250LogicalChannelAckParameters::e_mediaChannel)) { PTRACE(1, "RTP_UDP\tNo mediaChannel specified"); return FALSE; } if (!ExtractTransport(param.m_mediaChannel, rtp, TRUE, errorCode)) return FALSE; return TRUE;}void H323_RTP_UDP::OnSendRasInfo(H225_RTPSession & info){ info.m_sessionId = rtp.GetSessionID(); info.m_ssrc = rtp.GetSyncSourceOut(); const H323Transport & transport = connection.GetControlChannel(); transport.SetUpTransportPDU(info.m_rtpAddress.m_recvAddress, rtp.GetLocalDataPort()); H323TransportAddress ta1(rtp.GetRemoteAddress(), rtp.GetRemoteDataPort()); ta1.SetPDU(info.m_rtpAddress.m_sendAddress); transport.SetUpTransportPDU(info.m_rtcpAddress.m_recvAddress, rtp.GetLocalControlPort()); H323TransportAddress ta2(rtp.GetRemoteAddress(), rtp.GetRemoteDataPort()); ta2.SetPDU(info.m_rtcpAddress.m_sendAddress);}/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -