Skip to content

Commit

Permalink
For #1105, http server support mp4 range.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 26, 2019
1 parent 7584c47 commit b9d720c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ For previous versions, please read:

## V3 changes

* v3.0, 2019-12-26, For [#1105][bug #1105], http server support mp4 range.
* v3.0, 2019-12-26, For [#1105][bug #1105], dvr mp4 supports playing on Chrome/Safari/Firefox. 3.0.86
* <strong>v3.0, 2019-12-26, [3.0 alpha6(3.0.85)][r3.0a6] released. 116056 lines.</strong>
* v3.0, 2019-12-26, For [#1488][bug #1488], pass client ip to http callback. 3.0.85
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_http_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ srs_error_t SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMe

// parse -1 to whole file.
if (end == -1) {
end = (int)fs->filesize();
end = (int)(fs->filesize() - 1);
}

if (end > fs->filesize() || start > end) {
if (end > fs->filesize() || start > end || end < 0) {
return srs_error_new(ERROR_HTTP_REMUX_OFFSET_OVERFLOW, "http mp4 streaming %s overflow. size=%" PRId64 ", offset=%d",
fullpath.c_str(), fs->filesize(), start);
}
Expand Down
9 changes: 9 additions & 0 deletions trunk/src/protocol/srs_http_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,15 @@ srs_error_t SrsHttpFileServer::serve_mp4_file(ISrsHttpResponseWriter* w, ISrsHtt
if (range.empty()) {
range = r->query_get("bytes");
}

// Fetch range from header.
SrsHttpHeader* h = r->header();
if (range.empty() && h) {
range = h->get("Range");
if (range.find("bytes=") == 0) {
range = range.substr(6);
}
}

// rollback to serve whole file.
size_t pos = string::npos;
Expand Down

0 comments on commit b9d720c

Please sign in to comment.