mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Support statistic for HTTP-API, HTTP-Callback and Security (#2483)
* commit message for your changes. Lines starting * Update srs_app_rtc_api.cpp * add SrsRtcConnPlay and SrsRtcConnPublish, in enum SrsRtmpConnType * Update srs_rtmp_stack.cpp * Update srs_app_rtc_conn.cpp * Update srs_app_rtc_api.cpp * update utest * Update srs_utest_app.cpp
This commit is contained in:
parent
20931ddbb1
commit
0efd7b1bbc
9 changed files with 170 additions and 51 deletions
|
@ -94,6 +94,9 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
if ((prop = req->ensure_property_string("clientip")) != NULL) {
|
||||
clientip = prop->to_str();
|
||||
}
|
||||
if (clientip.empty()) {
|
||||
clientip = dynamic_cast<SrsHttpMessage*>(r)->connection()->remote_ip();
|
||||
}
|
||||
|
||||
string api;
|
||||
if ((prop = req->ensure_property_string("api")) != NULL) {
|
||||
|
@ -105,17 +108,19 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
tid = prop->to_str();
|
||||
}
|
||||
|
||||
// TODO: FIXME: Parse vhost.
|
||||
// Parse app and stream from streamurl.
|
||||
string app;
|
||||
string stream_name;
|
||||
if (true) {
|
||||
string tcUrl;
|
||||
srs_parse_rtmp_url(streamurl, tcUrl, stream_name);
|
||||
// The RTC user config object.
|
||||
SrsRtcUserConfig ruc;
|
||||
ruc.req_->ip = clientip;
|
||||
|
||||
int port;
|
||||
string schema, host, vhost, param;
|
||||
srs_discovery_tc_url(tcUrl, schema, host, vhost, app, stream_name, port, param);
|
||||
srs_parse_rtmp_url(streamurl, ruc.req_->tcUrl, ruc.req_->stream);
|
||||
|
||||
srs_discovery_tc_url(ruc.req_->tcUrl, ruc.req_->schema, ruc.req_->host, ruc.req_->vhost,
|
||||
ruc.req_->app, ruc.req_->stream, ruc.req_->port, ruc.req_->param);
|
||||
|
||||
// discovery vhost, resolve the vhost from config
|
||||
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost);
|
||||
if (parsed_vhost) {
|
||||
ruc.req_->vhost = parsed_vhost->arg0();
|
||||
}
|
||||
|
||||
// For client to specifies the candidate(EIP) of server.
|
||||
|
@ -129,12 +134,10 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
string dtls = r->query_get("dtls");
|
||||
|
||||
srs_trace("RTC play %s, api=%s, tid=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s, srtp=%s, dtls=%s",
|
||||
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(),
|
||||
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(), remote_sdp_str.length(),
|
||||
eip.c_str(), codec.c_str(), srtp.c_str(), dtls.c_str()
|
||||
);
|
||||
|
||||
// The RTC user config object.
|
||||
SrsRtcUserConfig ruc;
|
||||
ruc.eip_ = eip;
|
||||
ruc.codec_ = codec;
|
||||
ruc.publish_ = false;
|
||||
|
@ -155,16 +158,6 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
return srs_error_wrap(err, "remote sdp check failed");
|
||||
}
|
||||
|
||||
ruc.req_->app = app;
|
||||
ruc.req_->stream = stream_name;
|
||||
|
||||
// TODO: FIXME: Parse vhost.
|
||||
// discovery vhost, resolve the vhost from config
|
||||
SrsConfDirective* parsed_vhost = _srs_config->get_vhost("");
|
||||
if (parsed_vhost) {
|
||||
ruc.req_->vhost = parsed_vhost->arg0();
|
||||
}
|
||||
|
||||
SrsSdp local_sdp;
|
||||
|
||||
// Config for SDP and session.
|
||||
|
@ -288,6 +281,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
|
||||
// Parse req, the request json object, from body.
|
||||
SrsJsonObject* req = NULL;
|
||||
SrsAutoFree(SrsJsonObject, req);
|
||||
if (true) {
|
||||
string req_json;
|
||||
if ((err = r->body_read_all(req_json)) != srs_success) {
|
||||
|
@ -318,6 +312,9 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
if ((prop = req->ensure_property_string("clientip")) != NULL) {
|
||||
clientip = prop->to_str();
|
||||
}
|
||||
if (clientip.empty()){
|
||||
clientip = dynamic_cast<SrsHttpMessage*>(r)->connection()->remote_ip();
|
||||
}
|
||||
|
||||
string api;
|
||||
if ((prop = req->ensure_property_string("api")) != NULL) {
|
||||
|
@ -329,16 +326,19 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
tid = prop->to_str();
|
||||
}
|
||||
|
||||
// Parse app and stream from streamurl.
|
||||
string app;
|
||||
string stream_name;
|
||||
if (true) {
|
||||
string tcUrl;
|
||||
srs_parse_rtmp_url(streamurl, tcUrl, stream_name);
|
||||
// The RTC user config object.
|
||||
SrsRtcUserConfig ruc;
|
||||
ruc.req_->ip = clientip;
|
||||
|
||||
int port;
|
||||
string schema, host, vhost, param;
|
||||
srs_discovery_tc_url(tcUrl, schema, host, vhost, app, stream_name, port, param);
|
||||
srs_parse_rtmp_url(streamurl, ruc.req_->tcUrl, ruc.req_->stream);
|
||||
|
||||
srs_discovery_tc_url(ruc.req_->tcUrl, ruc.req_->schema, ruc.req_->host, ruc.req_->vhost,
|
||||
ruc.req_->app, ruc.req_->stream, ruc.req_->port, ruc.req_->param);
|
||||
|
||||
// discovery vhost, resolve the vhost from config
|
||||
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost);
|
||||
if (parsed_vhost) {
|
||||
ruc.req_->vhost = parsed_vhost->arg0();
|
||||
}
|
||||
|
||||
// For client to specifies the candidate(EIP) of server.
|
||||
|
@ -349,12 +349,10 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
string codec = r->query_get("codec");
|
||||
|
||||
srs_trace("RTC publish %s, api=%s, tid=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s",
|
||||
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(),
|
||||
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(),
|
||||
remote_sdp_str.length(), eip.c_str(), codec.c_str()
|
||||
);
|
||||
|
||||
// The RTC user config object.
|
||||
SrsRtcUserConfig ruc;
|
||||
ruc.eip_ = eip;
|
||||
ruc.codec_ = codec;
|
||||
ruc.publish_ = true;
|
||||
|
@ -369,16 +367,6 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
return srs_error_wrap(err, "remote sdp check failed");
|
||||
}
|
||||
|
||||
ruc.req_->app = app;
|
||||
ruc.req_->stream = stream_name;
|
||||
|
||||
// TODO: FIXME: Parse vhost.
|
||||
// discovery vhost, resolve the vhost from config
|
||||
SrsConfDirective* parsed_vhost = _srs_config->get_vhost("");
|
||||
if (parsed_vhost) {
|
||||
ruc.req_->vhost = parsed_vhost->arg0();
|
||||
}
|
||||
|
||||
SrsSdp local_sdp;
|
||||
|
||||
// TODO: FIXME: move to create_session.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue