1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00
This commit is contained in:
zhengfl 2015-07-08 17:08:29 +08:00
parent f9257b89e7
commit db9ea4e66e
5 changed files with 23 additions and 44 deletions

View file

@ -423,20 +423,26 @@ int SrsRtmpConn::stream_service_cycle()
}
}
srs_assert(source != NULL);
// check ASAP, to fail it faster if invalid.
if (type != SrsRtmpConnPlay) {
if ((ret = prepare_publish(source, vhost_is_edge)) != ERROR_SUCCESS) {
return ret;
}
}
// update the statistic when source disconveried.
SrsStatistic* stat = SrsStatistic::instance();
if ((ret = stat->on_client(_srs_context->get_id(), req)) != ERROR_SUCCESS) {
srs_error("stat client failed. ret=%d", ret);
return ret;
}
// check ASAP, to fail it faster if invalid.
if (type != SrsRtmpConnPlay) {
// check publish available
if (!source->can_publish(vhost_is_edge)) {
ret = ERROR_SYSTEM_STREAM_BUSY;
srs_warn("stream %s is already publishing. ret=%d",
req->get_stream_url().c_str(), ret);
// to delay request
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
return ret;
}
}
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
srs_trace("source url=%s, ip=%s, cache=%d, is_edge=%d, source_id=%d[%d]",
@ -1253,31 +1259,6 @@ int SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client)
return ret;
}
int SrsRtmpConn::prepare_publish(SrsSource* source, bool vhost_is_edge)
{
int ret = ERROR_SUCCESS;
srs_assert(source);
// check publish available
bool can_publish = false;
if (vhost_is_edge) {
can_publish = source->proxy_can_publish();
} else {
can_publish = source->can_publish();
}
if (!can_publish) {
ret = ERROR_SYSTEM_STREAM_BUSY;
srs_warn("stream %s is already publishing. ret=%d",
req->get_stream_url().c_str(), ret);
// to delay request
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
return ret;
}
return ret;
}
int SrsRtmpConn::http_hooks_on_connect()
{
int ret = ERROR_SUCCESS;