rtpstuff.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:4k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.4 $
- * $Date: 1998/05/19 18:16:24 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996,97 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. //
- ////////////////////////////////////////////////////////////////
- #ifndef __RTPSTUFF_H__
- #define __RTPSTUFF_H__
- #include "rtp/rtp.h"
- #include <stdio.h>
- #if (defined(WIN32))
- #include <windows.h>
- #include <winsock.h>
- #else
- #if defined(VXWORKS)
- #include "vxWorks.h"
- #include "taskLib.h"
- #include "semLib.h"
- #include "selectLib.h"
- #include "fcntl.h"
- #include "sockLib.h"
- #include "inetLib.h"
- #else
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netdb.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #if (defined(__hpux))
- #include <pthread.h>
- #else
- #include <thread.h>
- #endif
- #endif // defined(VXWORKS)
- typedef int SOCKET;
- #endif // defined(WIN32)
- // Defines the RTP session for a pair of H245 Logical channels.
- class H245RTPSession : public RTPSession
- {
- public:
- H245RTPSession(char *session, int payload_type, int sampling_rate,
- int &status);
- ~H245RTPSession();
- // Caveat : ip is in net byte order and the ports are in
- // net byte order too.
- int SetLocalPorts(unsigned int ip, unsigned short &rtp_port,
- unsigned short &rtcp_port);
- void GetLocalPorts(unsigned int& ip, unsigned short &rtp_port,
- unsigned short &rtcp_port);
- int SetRemotePorts(unsigned int ip, unsigned short rtp_port,
- unsigned short rtcp_port);
- void SetLocalPayloadType(int pt)
- {
- local_pt = pt;
- }
- void SetRemotePayloadType(int pt)
- {
- remote_pt = pt;
- }
- int StartSession();
- void StopSession();
- protected:
- #if (defined(WIN32))
- static unsigned __stdcall _begin_rtp_session(void *);
- #elif (defined(VXWORKS))
- static int _begin_rtp_session(void *);
- #else
- static void* _begin_rtp_session(void *);
- #endif
- void recv_rtcp_packet(SOCKET rtcp_sock,
- RTCPPacket *packet);
- void send_rtcp_packet(SOCKET rtcp_sock, RTCPPacket *packet);
- void do_rtp();
- int init_rtp_session();
- int my_bind(SOCKET s, unsigned int ip, unsigned short *port);
- int my_connect(SOCKET s, unsigned int ip, unsigned short port);
- void socket_error(SOCKET s, char *message);
- int current_tc;
- // CAVEAT: All port numbers below are in net byte order.
- SOCKET stop_rtpsession_socket;
- #if(!defined(WIN32))
- int stop_rtpsession_pipefds[2];
- #endif
- SOCKET lrtp_socket;
- SOCKET lrtcp_socket;
- unsigned short lrtp_port;
- unsigned short lrtcp_port;
- SOCKET rrtp_socket;
- SOCKET rrtcp_socket;
- unsigned short rrtp_port;
- unsigned short rrtcp_port;
- unsigned int remote_address;
- unsigned int local_address;
- int local_pt;
- int remote_pt;
- #if (defined(WIN32))
- unsigned long thread_id;
- HANDLE thread_handle;
- #elif (defined(VXWORKS))
- int thread_id;
- #elif (defined(__hpux))
- pthread_t thread_id;
- #else
- thread_t thread_id;
- #endif
- RTPPacket *framer;
- RTPPacket *deframer;
- RTCPPacket *rtcp_packet;
- FILE *audio_fh;
- };
- #endif