Skip to content

Commit

Permalink
fix #404, register handler then start http thread. 2.0.167.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed May 24, 2015
1 parent a45cf38 commit 069ee0a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ Remark:

### SRS 2.0 history

* v2.0, 2015-05-24, fix [#404](https://github.com/simple-rtmp-server/srs/issues/404) register handler then start http thread. 2.0.167.
* v2.0, 2015-05-23, refine the thread, protocol, kbps code. 2.0.166
* v2.0, 2015-05-23, fix [#391](https://github.com/simple-rtmp-server/srs/issues/391) copy request for async call.
* v2.0, 2015-05-22, fix [#397](https://github.com/simple-rtmp-server/srs/issues/397) the USER_HZ maybe not 100. 2.0.165
Expand Down
15 changes: 9 additions & 6 deletions trunk/src/app/srs_app_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,17 +1854,20 @@ int SrsHttpServer::http_mount(SrsSource* s, SrsRequest* r)

sflvs[sid] = entry;

// start http stream cache thread
if ((ret = entry->cache->start()) != ERROR_SUCCESS) {
srs_error("http: start stream cache failed. ret=%d", ret);
return ret;
}

// mount the http flv stream.
// we must register the handler, then start the thread,
// for the thread will cause thread switch context.
// @see https://github.com/simple-rtmp-server/srs/issues/404
if ((ret = mux.handle(mount, entry->stream)) != ERROR_SUCCESS) {
srs_error("http: mount flv stream for vhost=%s failed. ret=%d", sid.c_str(), ret);
return ret;
}

// start http stream cache thread
if ((ret = entry->cache->start()) != ERROR_SUCCESS) {
srs_error("http: start stream cache failed. ret=%d", ret);
return ret;
}
srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str());
} else {
entry = sflvs[sid];
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 166
#define VERSION_REVISION 167

// server info.
#define RTMP_SIG_SRS_KEY "SRS"
Expand Down
20 changes: 15 additions & 5 deletions trunk/src/kernel/srs_kernel_flv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ int SrsFlvEncoder::write_metadata(char type, char* data, int size)
tag_stream->write_3bytes(size);

if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) {
srs_error("write flv data tag failed. ret=%d", ret);
if (!srs_is_client_gracefully_close(ret)) {
srs_error("write flv data tag failed. ret=%d", ret);
}
return ret;
}

Expand Down Expand Up @@ -168,7 +170,9 @@ int SrsFlvEncoder::write_audio(int64_t timestamp, char* data, int size)
tag_stream->write_1bytes((timestamp >> 24) & 0xFF);

if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) {
srs_error("write flv audio tag failed. ret=%d", ret);
if (!srs_is_client_gracefully_close(ret)) {
srs_error("write flv audio tag failed. ret=%d", ret);
}
return ret;
}

Expand Down Expand Up @@ -221,13 +225,17 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s

// write tag header.
if ((ret = _fs->write(header, header_size, NULL)) != ERROR_SUCCESS) {
srs_error("write flv tag header failed. ret=%d", ret);
if (!srs_is_client_gracefully_close(ret)) {
srs_error("write flv tag header failed. ret=%d", ret);
}
return ret;
}

// write tag data.
if ((ret = _fs->write(tag, tag_size, NULL)) != ERROR_SUCCESS) {
srs_error("write flv tag failed. ret=%d", ret);
if (!srs_is_client_gracefully_close(ret)) {
srs_error("write flv tag failed. ret=%d", ret);
}
return ret;
}

Expand All @@ -238,7 +246,9 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s
}
tag_stream->write_4bytes(tag_size + header_size);
if ((ret = _fs->write(pre_size, sizeof(pre_size), NULL)) != ERROR_SUCCESS) {
srs_error("write flv previous tag size failed. ret=%d", ret);
if (!srs_is_client_gracefully_close(ret)) {
srs_error("write flv previous tag size failed. ret=%d", ret);
}
return ret;
}

Expand Down

0 comments on commit 069ee0a

Please sign in to comment.