00001 #ifndef __H_RTP_STREAM__ 00002 #define __H_RTP_STREAM__ 00003 00004 #include <sys/time.h> 00005 #include <string> 00006 #include <pthread.h> 00007 #include "socket.h" 00008 00009 using namespace std; 00010 00011 extern int fd_stream; 00012 00013 class RTP_Stream { 00014 public: 00015 RTP_Stream(void); 00016 virtual ~RTP_Stream() {}; 00017 00018 int ptype(void) { return _ptype; }; 00019 virtual void Start(string ip, int port); 00020 virtual void Stop(void); 00021 protected: 00022 void init_pthread(void *__this); 00023 pthread_t pth; 00024 int pth_id; 00025 static void *pthread_f(void *_this); 00026 void *thread(void); 00027 pthread_mutex_t pthm_flow; 00028 virtual bool process(void) = 0; 00029 00030 int _ptype; 00031 bool _play; 00032 Socket *rtp_socket; 00033 Socket *rtcp_socket; 00034 00035 unsigned short packet_num; 00036 unsigned long SSRC; 00037 00038 struct timeval f_tv; 00039 struct timeval rtcp_tv; // time of last SR 00040 long rtcp_delay; 00041 unsigned long timestamp; 00042 00043 unsigned long rtp_packets; 00044 unsigned long rtp_octets; 00045 unsigned long rtcp_c; 00046 00047 void rtcp(void); 00048 void rtcp_send_sr(void); 00049 void rtcp_send_sdes(void); 00050 00051 string stream_name; 00052 00053 static int _fd; 00054 }; 00055 00056 #endif //__H_RTP_STREAM__