00001 #ifndef _RTSP_H_
00002 #define _RTSP_H_
00003
00004
00005 #include "session.h"
00006 #include "socket.h"
00007
00008 #include <map>
00009 #include <list>
00010 #include <string>
00011 #include <iostream>
00012
00013 using namespace std;
00014
00015 class _Request {
00016 public:
00017 _Request(const string &req);
00018 inline const string &get_method(void) {
00019 return method;
00020 }
00021 inline const string &get_uri(void) {
00022 return uri;
00023 }
00024 inline const map<string, string> &get_fields(void) {
00025 return fields;
00026 }
00027 protected:
00028 string method;
00029 string uri;
00030 map<string, string> fields;
00031 };
00032
00033 class _Responce {
00034 public:
00035 enum status {STATUS_EMPTY, STATUS_BUSY, STATUS_OK};
00036 _Responce():_status(STATUS_EMPTY) {};
00037 inline void set_status(status st) {
00038 _status = st;
00039 }
00040 void add_field(const string &name, const string &value);
00041 void add_include(const string &include);
00042 string serialize(void);
00043 protected:
00044 status _status;
00045 map<string, string> fields;
00046 string include;
00047 };
00048
00049 class RTSP_Server {
00050 public:
00051 enum event {
00052 EMPTY,
00053 DESCRIBE,
00054 PLAY,
00055 PAUSE,
00056 TEARDOWN
00057 };
00058
00059
00060 RTSP_Server(void (*h)(void *, RTSP_Server *, RTSP_Server::event), void *handler_data, Session *_session = NULL);
00061 ~RTSP_Server();
00062
00063
00064 void main(void);
00065 protected:
00066 bool process(Socket *s);
00067 string make_sdp(string uri);
00068 string make_transport(string req);
00069 Session *session;
00070
00071 void (*handler_f)(void *, RTSP_Server *, RTSP_Server::event);
00072 void *handler_data;
00073 void handler(RTSP_Server::event event) {
00074 handler_f(handler_data, this, event);
00075 }
00076 void *_busy;
00077
00078 string part_of_request;
00079
00080
00081 };
00082
00083 #endif // _RTSP_H_