1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Squash: Fix bugs

This commit is contained in:
winlin 2021-12-26 17:30:51 +08:00
parent 10d188faab
commit 716e578a19
382 changed files with 170096 additions and 220 deletions

View file

@ -456,8 +456,8 @@ srs_error_t SrsHttpFileServer::serve_file(ISrsHttpResponseWriter* w, ISrsHttpMes
// write body.
int64_t left = length;
if ((err = copy(w, fs, r, (int)left)) != srs_success) {
return srs_error_wrap(err, "copy file=%s size=%d", fullpath.c_str(), (int)left);
if ((err = copy(w, fs, r, left)) != srs_success) {
return srs_error_wrap(err, "copy file=%s size=%" PRId64, fullpath.c_str(), left);
}
if ((err = w->final_request()) != srs_success) {
@ -474,7 +474,7 @@ srs_error_t SrsHttpFileServer::serve_flv_file(ISrsHttpResponseWriter* w, ISrsHtt
return serve_file(w, r, fullpath);
}
int offset = ::atoi(start.c_str());
int64_t offset = ::atoll(start.c_str());
if (offset <= 0) {
return serve_file(w, r, fullpath);
}
@ -507,15 +507,15 @@ srs_error_t SrsHttpFileServer::serve_mp4_file(ISrsHttpResponseWriter* w, ISrsHtt
}
// parse the start in query string
int start = 0;
int64_t start = 0;
if (pos > 0) {
start = ::atoi(range.substr(0, pos).c_str());
start = ::atoll(range.substr(0, pos).c_str());
}
// parse end in query string.
int end = -1;
int64_t end = -1;
if (pos < range.length() - 1) {
end = ::atoi(range.substr(pos + 1).c_str());
end = ::atoll(range.substr(pos + 1).c_str());
}
// invalid param, serve as whole mp4 file.
@ -524,39 +524,39 @@ srs_error_t SrsHttpFileServer::serve_mp4_file(ISrsHttpResponseWriter* w, ISrsHtt
}
return serve_mp4_stream(w, r, fullpath, start, end);
}
srs_error_t SrsHttpFileServer::serve_m3u8_file(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath)
{
return serve_m3u8_ctx(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::serve_flv_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int offset)
srs_error_t SrsHttpFileServer::serve_m3u8_file(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath)
{
return serve_m3u8_ctx(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::serve_flv_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int64_t offset)
{
// @remark For common http file server, we don't support stream request, please use SrsVodStream instead.
// TODO: FIXME: Support range in header https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Range_requests
return serve_file(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int start, int end)
srs_error_t SrsHttpFileServer::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int64_t start, int64_t end)
{
// @remark For common http file server, we don't support stream request, please use SrsVodStream instead.
// TODO: FIXME: Support range in header https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Range_requests
return serve_file(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath)
{
// @remark For common http file server, we don't support stream request, please use SrsVodStream instead.
// TODO: FIXME: Support range in header https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Range_requests
return serve_file(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, ISrsHttpMessage* r, int size)
srs_error_t SrsHttpFileServer::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath)
{
// @remark For common http file server, we don't support stream request, please use SrsVodStream instead.
// TODO: FIXME: Support range in header https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Range_requests
return serve_file(w, r, fullpath);
}
srs_error_t SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, ISrsHttpMessage* r, int64_t size)
{
srs_error_t err = srs_success;
int left = size;
int64_t left = size;
char* buf = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE];
SrsAutoFreeA(char, buf);
@ -564,12 +564,12 @@ srs_error_t SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs
ssize_t nread = -1;
int max_read = srs_min(left, SRS_HTTP_TS_SEND_BUFFER_SIZE);
if ((err = fs->read(buf, max_read, &nread)) != srs_success) {
return srs_error_wrap(err, "read limit=%d, left=%d", max_read, left);
return srs_error_wrap(err, "read limit=%d, left=%" PRId64, max_read, left);
}
left -= nread;
if ((err = w->write(buf, (int)nread)) != srs_success) {
return srs_error_wrap(err, "write limit=%d, bytes=%d, left=%d", max_read, (int)nread, left);
return srs_error_wrap(err, "write limit=%d, bytes=%d, left=%" PRId64, max_read, (int)nread, left);
}
}