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 virtual long process(void) = 0; 00030 00031 int _ptype; 00032 bool _play; 00033 Socket *rtp_socket; 00034 Socket *rtcp_socket; 00035 00036 unsigned short packet_num; 00037 unsigned long SSRC; 00038 00039 struct timeval f_tv; 00040 struct timeval rtcp_tv; // time of last SR 00041 long rtcp_delay; 00042 unsigned long timestamp; 00043 00044 unsigned long rtp_packets; 00045 unsigned long rtp_octets; 00046 unsigned long rtcp_c; 00047 00048 void rtcp(void); 00049 void rtcp_send_sr(void); 00050 void rtcp_send_sdes(void); 00051 00052 string stream_name; 00053 00054 static int _fd; 00055 }; 00056 00057 #endif //__H_RTP_STREAM__