move the ts buffer to http message

pull/133/head
winlin 11 years ago
parent a73bf8d4aa
commit 36d8fdfc1a

@ -515,6 +515,7 @@ SrsHttpMessage::SrsHttpMessage()
_uri = new SrsHttpUri(); _uri = new SrsHttpUri();
_match = NULL; _match = NULL;
_requires_crossdomain = false; _requires_crossdomain = false;
_http_ts_send_buffer = new char[HTTP_TS_SEND_BUFFER_SIZE];
} }
SrsHttpMessage::~SrsHttpMessage() SrsHttpMessage::~SrsHttpMessage()
@ -522,6 +523,12 @@ SrsHttpMessage::~SrsHttpMessage()
srs_freep(_body); srs_freep(_body);
srs_freep(_uri); srs_freep(_uri);
srs_freep(_match); srs_freep(_match);
srs_freepa(_http_ts_send_buffer);
}
char* SrsHttpMessage::http_ts_send_buffer()
{
return _http_ts_send_buffer;
} }
void SrsHttpMessage::reset() void SrsHttpMessage::reset()

@ -145,6 +145,9 @@ class SrsHttpHandler;
#define HTTP_GatewayTimeout_str "Gateway Timeout" #define HTTP_GatewayTimeout_str "Gateway Timeout"
#define HTTP_HTTPVersionNotSupported_str "HTTP Version Not Supported" #define HTTP_HTTPVersionNotSupported_str "HTTP Version Not Supported"
// @see SrsHttpMessage._http_ts_send_buffer
#define HTTP_TS_SEND_BUFFER_SIZE 4096
// linux path seprator // linux path seprator
#define __PATH_SEP '/' #define __PATH_SEP '/'
// query string seprator // query string seprator
@ -310,10 +313,15 @@ private:
* whether the message requires crossdomain. * whether the message requires crossdomain.
*/ */
bool _requires_crossdomain; bool _requires_crossdomain;
/**
* use a buffer to read and send ts file.
*/
char* _http_ts_send_buffer;
public: public:
SrsHttpMessage(); SrsHttpMessage();
virtual ~SrsHttpMessage(); virtual ~SrsHttpMessage();
public: public:
virtual char* http_ts_send_buffer();
virtual void reset(); virtual void reset();
virtual int parse_uri(); virtual int parse_uri();
public: public:

@ -195,14 +195,12 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
// write body. // write body.
int64_t left = length; int64_t left = length;
const static int HTTP_PKT_SIZE = 4096; char* buf = req->http_ts_send_buffer();
char* buf = new char[HTTP_PKT_SIZE];
SrsAutoFree(char, buf, true);
while (left > 0) { while (left > 0) {
ssize_t nread = -1; ssize_t nread = -1;
// TODO: FIXME: use st_read. // TODO: FIXME: use st_read.
if ((nread = ::read(fd, buf, HTTP_PKT_SIZE)) < 0) { if ((nread = ::read(fd, buf, HTTP_TS_SEND_BUFFER_SIZE)) < 0) {
::close(fd); ::close(fd);
ret = ERROR_HTTP_READ_FILE; ret = ERROR_HTTP_READ_FILE;
srs_warn("read file %s failed, ret=%d", fullpath.c_str(), ret); srs_warn("read file %s failed, ret=%d", fullpath.c_str(), ret);

Loading…
Cancel
Save