init ems server code

This commit is contained in:
2024-09-27 15:39:34 +08:00
parent 9d4009aaca
commit 9930e4e58f
1551 changed files with 110216 additions and 102864 deletions

99
plat/rtp/Makefile Normal file
View File

@@ -0,0 +1,99 @@
##----------------------------------------------------------##
## ##
## Universal Makefile for module template : V1.6.3 ##
## ##
## Created : Wei Liu 07/04/11 ##
## Revision: [Last]Wei Liu 07/07/07 ##
## ##
##----------------------------------------------------------##
##---------------------------------------------------------------------##
##--------------------------------------
##
## Project correlation(Customer define)
##
##--------------------------------------
## MODULE= [Module Name]
## TYPE = app/plat => Module Type
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ]
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release]
## BUILD = lib/exef => Output file format
## CFG = debug/release => Build Configuration
## SRC_PATH = [Source file path]
## INC_PATH = [Include file path]
## APP_PATH = [App Module path]
## PLT_PATH = [Plat Module path]
## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main
## APP_LIB = [Needed app lib for Link] => just for test or wxc2main
## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main
## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \
## 8ecp bicc smpp xapp tcap mtp3 m2ua \
## snmp iptrans debug sccp public
##
## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas
## LIB_ADD e.g. = -liba3a8 -lm
## OBJ_ADD = [Extend third party object files needed]
## TEST_OBJ_PATH = [module object files Path for test ] => just for test
##---------------------------------------------------------------------##
MODULE = rtp
TYPE = plat
DBUG_FLAGS_ADD =
RELS_FLAGS_ADD =
##Default commonly as below
BUILD = lib
CFG = debug
PLT_LIB =
APP_LIB =
LIB_ADD =
SRC_PATH = ./src
INC_PATH = ./src/include
PLT_PATH = ../../plat
APP_PATH = ../../mss
OBJ_ADD =
TEST_OBJ_PATH =
PREPROC_CMD =
POSTPROC_CMD =
##---------------------------------------------------------------------##
##--------------------------------------
##
## Make configuration(Customer define)
##
##--------------------------------------
## CCFLAG_SWITCH = on/off => gcc flag show on/off
## COVER_NEED = yes/no => PTF cover report needed
## COVER_REPORT_PATH = [path ] => PTF cover report path
CCFLAG_SWITCH = off
COVER_NEED = no
COVER_REPORT_PATH = ./output
MAKE_INCLUDE = $(HOME)/ems.git/include
##---------------------------------------------------------------------##
##--------------------------------------
##
## include makefile.rules (Do not change)
##
##--------------------------------------
include $(MAKE_INCLUDE)/Makefile.rules

View File

@@ -0,0 +1,56 @@
#ifndef _RTP__H
#define _RTP__H
#define RTP_MAX_NUM_OF_SAP 4
#define RTP_MAX_NUM_OF_PORT 1024
#define RTP_MAX_NUM_OF_PORT_1 1023
#define RTP_MAX_USER_NAME_LEN 16
#define RTP_MAX_PAYLOAD_SIZE 1024
#define RTP_MODE_INACTIVE 0
#define RTP_MODE_RECVONLY 1
#define RTP_MODE_SENDONLY 2
#define RTP_MODE_SENDRECV 3
typedef struct _RTP_SAP
{
char name[RTP_MAX_USER_NAME_LEN]; // User name
// Having received a RTP packet, the RTP module calls this function to send payloads to the user
// If the user doesn't need to receive RTP packets, can leave the pointer to be NULL
int (*rtp_recv)(WORD usrPort, WORD hdlPort, BYTE pt, WORD sn, BYTE *payload, WORD len);
// Handshake every 10 seconds
int (*rtp_handshake)(WORD usrPort, WORD hdlPort, WORD rtpPort);
}RTP_SAP;
typedef struct _RTP_SESSION
{
DWORD dstIp;
WORD dstPort;
BYTE plType; // Payload type
BYTE interval; // RTP interval in ms
}RTP_SESSION;
typedef struct _RTP_PAYLOAD
{
BYTE padding[12];
BYTE payload[RTP_MAX_PAYLOAD_SIZE];
}RTP_PAYLOAD;
void rtp_init(void);
void rtp_timer(void);
int rtp_bind(RTP_SAP *sap);
int rtp_unbind(RTP_SAP *sap, BYTE sapIndex);
int rtp_set_mode(BYTE sapIndex, WORD usrPort, WORD hdlPort, BYTE mode);
int rtp_sess_update(BYTE sapIndex, WORD usrPort, WORD hdlPort, RTP_SESSION *sess);
int rtp_allocate_port(BYTE sapIndex, WORD usrPort, WORD *rtpPort);
int rtp_release_port(BYTE sapIndex, WORD usrPort, WORD rtpPort, WORD hdlPort);
int rtp_send(BYTE sapIndex, WORD usrPort, WORD hdlPort, WORD sn, RTP_PAYLOAD *payload, WORD len);
#endif

View File

@@ -0,0 +1,9 @@
#ifndef _RTP_CONST__H
#define _RTP_CONST__H
#define RTP_BASE_UDP_PORT_CONST 25000
#define RTP_MAX_UDP_MSG_LEN 1500
#define RTP_HANDSHAKE_TIMER 1000 // 10 seconds
#endif

View File

@@ -0,0 +1,26 @@
#ifndef _RTP_DEF__H
#define _RTP_DEF__H
#include "rtp_pub.h"
#include "rtp.h"
#include "rtp_const.h"
#include "rtp_struct.h"
RTP_SAP rtpSap[RTP_MAX_NUM_OF_SAP];
RTP_PORT rtpHdlPort[RTP_MAX_NUM_OF_PORT];
WORD rtpHdlPortSelect;
DWORD rtpPort[RTP_MAX_NUM_OF_PORT/32];
WORD rtpPortSelect;
int rtpHdlPortFd[RTP_MAX_NUM_OF_PORT];
DWORD rtpHostIp;
WORD RTP_BASE_UDP_PORT;
struct sockaddr_in rtpSrcInAddr;
struct sockaddr_in rtpDstInAddr;
BYTE rtpMsgRvBuf[RTP_MAX_UDP_MSG_LEN];
#endif

View File

@@ -0,0 +1,22 @@
#ifndef _RTP_EXT__H
#define _RTP_EXT__H
#include "rtp_pub.h"
#include "rtp.h"
#include "rtp_const.h"
#include "rtp_struct.h"
extern RTP_SAP rtpSap[RTP_MAX_NUM_OF_SAP];
extern RTP_PORT rtpHdlPort[RTP_MAX_NUM_OF_PORT];
extern WORD rtpHdlPortSelect;
extern DWORD rtpPort[RTP_MAX_NUM_OF_PORT/32];
extern WORD rtpPortSelect;
extern DWORD rtpHostIp;
extern struct sockaddr_in rtpSrcInAddr;
extern struct sockaddr_in rtpDstInAddr;
extern BYTE rtpMsgRvBuf[RTP_MAX_UDP_MSG_LEN];
#endif

View File

@@ -0,0 +1,6 @@
#ifndef _RTP_MSG__H
#define _RTP_MSG__H
int rtp_recv_udp_msg();
#endif

View File

@@ -0,0 +1,55 @@
#ifndef _RTP_PUB__H
#define _RTP_PUB__H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <netdb.h>
#include <setjmp.h>
#include <unistd.h>
#include <signal.h>
//by simon at 23/9/22
//#include <stropts.h>
#include <time.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/io.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <sys/select.h>
#ifndef _T_BYTE
#define _T_BYTE
typedef unsigned char BYTE;
#endif
#ifndef _T_WORD
#define _T_WORD
typedef unsigned short WORD;
#endif
#ifndef _T_DWORD
#define _T_DWORD
typedef unsigned int DWORD;
#endif
#endif

View File

@@ -0,0 +1,33 @@
#ifndef _RTP_STRUCT__H
#define _RTP_STRUCT__H
#include "rtp.h"
#include "rtp_const.h"
typedef struct _RTP_PORT
{
BYTE flag;
BYTE sapIndex;
WORD usrPort;
WORD rtpPort;
int fd;
BYTE mode; // inactive/recv/send/sendrecv
DWORD timer; // handshake timer
BYTE times; // handshake times
DWORD timeStamp; // current time stamp
WORD inc; // timestamp increment
RTP_SESSION sess;
}RTP_PORT;
typedef struct _RTP_PACKET
{
BYTE ver __attribute__((packed)); // version
BYTE pt __attribute__((packed)); // payload type
WORD sn __attribute__((packed)); // sequence number
DWORD timeStamp __attribute__((packed));
DWORD ssrc __attribute__((packed)); // synchronization src
BYTE payload[RTP_MAX_PAYLOAD_SIZE] __attribute__((packed));
}RTP_PACKET;
#endif

358
plat/rtp/src/rtp.c Normal file
View File

@@ -0,0 +1,358 @@
/****************************************************************/
/* RTP Implementation Program */
/* Version 9.0.1 */
/* Designed By Ying Min */
/* Last Update: 2007-3-19 */
/****************************************************************/
#include "./include/rtp_pub.h"
#include "./include/rtp.h"
#include "./include/rtp_const.h"
#include "./include/rtp_def.h"
#include "./include/rtp_struct.h"
#include "./include/rtp_msg.h"
int rtp_get_local_ip(void)
{
struct hostent *host;
char hostName[64];
char hostIp[32];
if (gethostname(hostName, 50) == -1)
{
printf("RTP gethostname fail!\n");
exit(3);
}
if ((host = gethostbyname(hostName)) == NULL)
{
printf("RTP gethostbyname fail!\n");
exit(4);
}
else
{
sprintf(hostIp, "%d.%d.%d.%d",
(BYTE)host->h_addr_list[0][0],
(BYTE)host->h_addr_list[0][1],
(BYTE)host->h_addr_list[0][2],
(BYTE)host->h_addr_list[0][3]);
rtpHostIp = inet_addr(hostIp); // Network byte order host_ip, like 0xE60012AC
printf("RTP host IP: %s (0x%lX)\n", hostIp, rtpHostIp);
}
return 0;
}
void rtp_init(void)
{
WORD i;
printf("RTP Init Start!\n");
rtp_get_local_ip();
memset((BYTE *) rtpSap, 0, sizeof(RTP_SAP) * RTP_MAX_NUM_OF_SAP);
memset((BYTE *) rtpPort, 0, RTP_MAX_NUM_OF_PORT / 8);
memset((BYTE *) rtpHdlPort, 0, sizeof(RTP_PORT) * RTP_MAX_NUM_OF_PORT);
memset((BYTE *) rtpHdlPortFd, -1, sizeof(int) * RTP_MAX_NUM_OF_PORT);
for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++)
rtpHdlPort[i].fd = -1;
rtpHdlPortSelect = 0;
rtpPortSelect = 0;
RTP_BASE_UDP_PORT = RTP_BASE_UDP_PORT_CONST;
/*
{
FILE *fp=NULL;
unsigned short base_port=25000;
char s[80]="";
fp = fopen("./conf/rtp.conf","r");
if(fp != NULL)
{
while(fgets(s,1024,fp) !=(char *)0)
{
if( (int *)strchr(s,'#') !=NULL) continue;
if( !strlen(s) ) continue;
if(strncasecmp(s,"base port=",10)==0)
{
base_port = atoi(&s[10]);
if(base_port>1000 && base_port<32768)
RTP_BASE_UDP_PORT = base_port;
else
break;
}
else
break;
}
fclose(fp);
}
} */
printf("RTP Init Complete!\n");
}
// Called every 10 ms
void rtp_timer(void)
{
rtp_recv_udp_msg();
}
void rtp_sap_init(BYTE sapIndex)
{
memset((BYTE *) &rtpSap[sapIndex], 0, sizeof(RTP_SAP));
}
void rtp_port_init(WORD port)
{
memset((BYTE *) &rtpHdlPort[port], 0, sizeof(RTP_PORT));
rtpHdlPort[port].fd = -1;
rtpHdlPortFd[port] = -1;
}
int rtp_init_udp_socket(struct sockaddr_in saddr, int multicast)
{
int sock;
long sockBuf = 40*1024;
int on = 1, timeout = 20;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
fprintf(stderr, "Socket() failed\n");
return -3;
}
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
&sockBuf, sizeof(sockBuf)) != 0)
{
fprintf(stderr, "RTP set socket buffer failed\n");
return -4;
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&on,sizeof(on)) != 0)
{
fprintf(stderr, "RTP set addr reusable failed\n");
return -5;
}
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
&timeout, sizeof(timeout)) != 0)
{
fprintf(stderr, "RTP set keepalive failed\n");
return -6;
}
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0)
{
fprintf(stderr, "RTP set nonblock failed\n");
return -7;
}
if (bind(sock, (struct sockaddr *) &saddr, sizeof(struct sockaddr)) < 0)
{
fprintf(stderr, "RTP binding failed, port: %d\n", htons(saddr.sin_port));
close(sock);
return -2;
}
return sock;
}
int rtp_init_socket(WORD hdlPort, WORD udpPort)
{
struct sockaddr_in sinAddr;
int fd;
memset(&sinAddr, 0, sizeof(struct sockaddr));
sinAddr.sin_family = AF_INET;
sinAddr.sin_port = htons(udpPort);
sinAddr.sin_addr.s_addr = rtpHostIp; // INADDR_ANY;
memset(&(sinAddr.sin_zero), 0, 8);
fd = rtp_init_udp_socket(sinAddr, 0);
if (fd < 0)
{
printf("RTP UDP Socket(%d) failed\n", udpPort);
return -1;
}
rtpHdlPort[hdlPort].fd = fd;
rtpHdlPortFd[hdlPort] = fd;
return 0;
}
int rtp_get_udp_port(WORD hdlPort)
{
WORD port = rtpPortSelect;
WORD i, index1, index2;
for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++)
{
index1 = port / 32;
index2 = port % 32;
if (((rtpPort[index1] >> index2) & 1) == 1)
{
if (++port >= RTP_MAX_NUM_OF_PORT)
port = 0;
continue;
}
if (rtp_init_socket(hdlPort, port * 2 + RTP_BASE_UDP_PORT) < 0)
return -1;
rtpPort[index1] |= 1 << index2;
rtpPortSelect = (port + 1) & RTP_MAX_NUM_OF_PORT_1;
rtpHdlPort[hdlPort].rtpPort = port;
return port;
}
return -1;
}
int rtp_release_udp_port(WORD hdlPort)
{
WORD port = rtpHdlPort[hdlPort].rtpPort;
int fd = rtpHdlPort[hdlPort].fd;
WORD index1, index2;
if (port >= RTP_MAX_NUM_OF_PORT)
return -1;
index1 = port / 32;
index2 = port % 32;
rtpPort[index1] = rtpPort[index1] & (~(1 << index2));
if (fd >= 0)
close(fd);
return 0;
}
int rtp_get_hdl_port()
{
WORD port = rtpHdlPortSelect;
WORD i;
for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++)
{
if (rtpHdlPort[port].flag != 0)
{
if (++port >= RTP_MAX_NUM_OF_PORT)
port = 0;
continue;
}
return port;
}
return -1;
}
int rtp_allocate_port(BYTE sapIndex, WORD usrPort, WORD *rtpPort)
{
int hdlPort, udpPort;
if (sapIndex >= RTP_MAX_NUM_OF_SAP)
return -1;
if ((hdlPort = rtp_get_hdl_port()) < 0)
return -1;
if ((udpPort = rtp_get_udp_port(hdlPort)) < 0)
return -1;
rtpHdlPort[hdlPort].flag = 1;
rtpHdlPort[hdlPort].sapIndex = sapIndex;
rtpHdlPort[hdlPort].usrPort = usrPort;
rtpHdlPort[hdlPort].timer = RTP_HANDSHAKE_TIMER;
rtpHdlPortSelect = (hdlPort + 1) & RTP_MAX_NUM_OF_PORT_1;
*rtpPort = udpPort * 2 + RTP_BASE_UDP_PORT;
return hdlPort;
}
int rtp_release_port(BYTE sapIndex, WORD usrPort, WORD rtpPort, WORD hdlPort)
{
if (hdlPort >= RTP_MAX_NUM_OF_PORT)
return -1;
if (rtpHdlPort[hdlPort].sapIndex != sapIndex)
return -2;
else if (rtpHdlPort[hdlPort].usrPort != usrPort)
return -3;
else if ((rtpHdlPort[hdlPort].rtpPort * 2 + RTP_BASE_UDP_PORT) != rtpPort)
return -4;
rtp_release_udp_port(hdlPort);
rtp_port_init(hdlPort);
return 0;
}
int rtp_sess_update(BYTE sapIndex, WORD usrPort, WORD hdlPort, RTP_SESSION *sess)
{
if (hdlPort >= RTP_MAX_NUM_OF_PORT)
return -1;
if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) ||
(rtpHdlPort[hdlPort].usrPort != usrPort))
return -1;
memcpy((BYTE *) &rtpHdlPort[hdlPort].sess, (BYTE *) sess, sizeof(RTP_SESSION));
rtpHdlPort[hdlPort].inc = rtpHdlPort[hdlPort].sess.interval * 8;
return 0;
}
int rtp_set_mode(BYTE sapIndex, WORD usrPort, WORD hdlPort, BYTE mode)
{
if ((hdlPort >= RTP_MAX_NUM_OF_PORT) || (mode > RTP_MODE_SENDRECV))
return -1;
if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) ||
(rtpHdlPort[hdlPort].usrPort != usrPort))
return -1;
rtpHdlPort[hdlPort].mode = mode;
return 0;
}
int rtp_bind(RTP_SAP *sap)
{
BYTE i;
if ((sap == NULL) || (sap->rtp_handshake == NULL))
return -1;
for (i = 0; i < RTP_MAX_NUM_OF_SAP; i++)
{
if (rtpSap[i].rtp_handshake != NULL)
continue;
memcpy((BYTE *) &rtpSap[i], sap, sizeof(RTP_SAP));
rtpSap[i].name[RTP_MAX_USER_NAME_LEN - 1] = '\0';
return i;
}
return -1;
}
int rtp_unbind(RTP_SAP *sap, BYTE sapIndex)
{
if ((sap == NULL) || (sapIndex >= RTP_MAX_NUM_OF_SAP))
return -1;
if (strcmp(sap->name, rtpSap[sapIndex].name) != 0)
return -1;
rtp_sap_init(sapIndex);
return 0;
}

148
plat/rtp/src/rtp_msg.c Normal file
View File

@@ -0,0 +1,148 @@
#include "./include/rtp_pub.h"
#include "./include/rtp.h"
#include "./include/rtp_const.h"
#include "./include/rtp_def.h"
#include "./include/rtp_struct.h"
extern void rtp_port_init(WORD port);
extern int rtp_release_udp_port(WORD hdlPort);
int rtp_recv_msg_handling(WORD hdlPort, BYTE *rtpMsgRvBuf, WORD len)
{
RTP_PACKET *packet = (RTP_PACKET *) rtpMsgRvBuf;
RTP_PORT *port = &rtpHdlPort[hdlPort];
RTP_SAP *sap;
BYTE cc, csLen;
WORD sn;
if ((port->mode != RTP_MODE_RECVONLY) &&
(port->mode != RTP_MODE_SENDRECV))
return -1;
if (port->sapIndex >= RTP_MAX_NUM_OF_SAP)
return -1;
sap = &rtpSap[port->sapIndex];
if (sap->rtp_recv == NULL)
return -1;
cc = packet->ver & 0x0F;
csLen = cc * 4;
sn = ntohs(packet->sn);
return (sap->rtp_recv(port->usrPort, hdlPort, packet->pt & 0x7F, packet->sn, rtpMsgRvBuf + 12 + csLen, len - 12 - csLen));
}
int rtp_handshake_proc(WORD hdlPort)
{
RTP_PORT *port = &rtpHdlPort[hdlPort];
RTP_SAP *sap;
if (port->sapIndex >= RTP_MAX_NUM_OF_SAP)
return -1;
sap = &rtpSap[port->sapIndex];
if (sap->rtp_handshake == NULL)
return -1;
if (sap->rtp_handshake(port->usrPort, hdlPort, port->rtpPort * 2 + RTP_BASE_UDP_PORT) == -1)
{
if (++port->times >= 3)
{
rtp_release_udp_port(hdlPort);
rtp_port_init(hdlPort);
return -1;
}
}
port->timer = RTP_HANDSHAKE_TIMER;
return 0;
}
int rtp_recv_udp_msg()
{
int port, i, len, addrLen = sizeof(struct sockaddr);
for (port = 0; port < RTP_MAX_NUM_OF_PORT; port++)
{
if (rtpHdlPort[port].flag == 0)
continue;
if (rtpHdlPort[port].timer > 0)
{
if (--rtpHdlPort[port].timer == 0)
rtp_handshake_proc(port);
}
if (rtpHdlPort[port].fd == -1)
continue;
if (rtpHdlPortFd[port] != rtpHdlPort[port].fd)
{
printf("fd has been changed: fd: %d, HdlPortFd: %d\n", rtpHdlPort[port].fd, rtpHdlPortFd[port]);
continue;
}
for (i = 0; i < 5; i++)
{
len = recvfrom(rtpHdlPort[port].fd, rtpMsgRvBuf, RTP_MAX_UDP_MSG_LEN,
0, (struct sockaddr *)&rtpSrcInAddr, &addrLen);
if (len < 0)
break;
if (len >= RTP_MAX_UDP_MSG_LEN)
continue;
rtp_recv_msg_handling(port, rtpMsgRvBuf, len);
}
}
return 0;
}
int rtp_send_udp_msg(WORD hdlPort, BYTE *msg, WORD len)
{
int ret, fd = rtpHdlPort[hdlPort].fd;
if (len >= RTP_MAX_PAYLOAD_SIZE)
return -1;
if (fd < 0)
return -1;
rtpDstInAddr.sin_addr.s_addr = rtpHdlPort[hdlPort].sess.dstIp;
rtpDstInAddr.sin_port = htons(rtpHdlPort[hdlPort].sess.dstPort);
ret = sendto(fd, msg, len, 0, (struct sockaddr *) &rtpDstInAddr, sizeof(rtpDstInAddr));
return ret;
}
int rtp_send(BYTE sapIndex, WORD usrPort, WORD hdlPort, WORD sn, RTP_PAYLOAD *payload, WORD len)
{
RTP_PACKET *packet = (RTP_PACKET *) payload;
if ((hdlPort >= RTP_MAX_NUM_OF_PORT) ||
(len > RTP_MAX_PAYLOAD_SIZE) ||
(payload == NULL))
return -1;
if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) ||
(rtpHdlPort[hdlPort].usrPort != usrPort))
return -1;
if (rtpHdlPort[hdlPort].mode < RTP_MODE_SENDONLY)
return -1;
packet->ver = 0x80;
packet->pt = rtpHdlPort[hdlPort].sess.plType;
packet->sn = htons(sn);
rtpHdlPort[hdlPort].timeStamp += rtpHdlPort[hdlPort].inc;
packet->timeStamp = htonl(rtpHdlPort[hdlPort].timeStamp);
packet->ssrc = htonl(sapIndex + usrPort + hdlPort);
return rtp_send_udp_msg(hdlPort, (BYTE *) packet, len + 12);
}