mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
json objects support dumps to string.
This commit is contained in:
parent
b78781707e
commit
3f7e69b617
14 changed files with 729 additions and 761 deletions
|
@ -63,16 +63,16 @@ int SrsHttpHooks::on_connect(string url, SrsRequest* req)
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_connect"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("tcUrl", SrsAmf0Any::str(req->tcUrl.c_str()));
|
||||
obj->set("pageUrl", SrsAmf0Any::str(req->pageUrl.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_connect"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
|
||||
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -99,16 +99,16 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_close"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("send_bytes", SrsAmf0Any::number(send_bytes));
|
||||
obj->set("recv_bytes", SrsAmf0Any::number(recv_bytes));
|
||||
obj->set("action", SrsJsonAny::str("on_close"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("send_bytes", SrsJsonAny::number(send_bytes));
|
||||
obj->set("recv_bytes", SrsJsonAny::number(recv_bytes));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -135,15 +135,15 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req)
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_publish"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_publish"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -170,15 +170,15 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_unpublish"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_unpublish"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -205,16 +205,16 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req)
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_play"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("pageUrl", SrsAmf0Any::str(req->pageUrl.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_play"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -241,15 +241,15 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
|
|||
|
||||
int client_id = _srs_context->get_id();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_stop"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_stop"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -277,17 +277,17 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file)
|
|||
int client_id = cid;
|
||||
std::string cwd = _srs_config->cwd();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_dvr"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("cwd", SrsAmf0Any::str(cwd.c_str()));
|
||||
obj->set("file", SrsAmf0Any::str(file.c_str()));
|
||||
obj->set("action", SrsJsonAny::str("on_dvr"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
obj->set("cwd", SrsJsonAny::str(cwd.c_str()));
|
||||
obj->set("file", SrsJsonAny::str(file.c_str()));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
@ -315,22 +315,22 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri
|
|||
int client_id = cid;
|
||||
std::string cwd = _srs_config->cwd();
|
||||
|
||||
SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
SrsAutoFree(SrsAmf0Object, obj);
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("action", SrsAmf0Any::str("on_hls"));
|
||||
obj->set("client_id", SrsAmf0Any::number(client_id));
|
||||
obj->set("ip", SrsAmf0Any::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsAmf0Any::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsAmf0Any::str(req->app.c_str()));
|
||||
obj->set("stream", SrsAmf0Any::str(req->stream.c_str()));
|
||||
obj->set("duration", SrsAmf0Any::number(duration));
|
||||
obj->set("cwd", SrsAmf0Any::str(cwd.c_str()));
|
||||
obj->set("file", SrsAmf0Any::str(file.c_str()));
|
||||
obj->set("url", SrsAmf0Any::str(url.c_str()));
|
||||
obj->set("m3u8", SrsAmf0Any::str(m3u8.c_str()));
|
||||
obj->set("m3u8_url", SrsAmf0Any::str(m3u8_url.c_str()));
|
||||
obj->set("seq_no", SrsAmf0Any::number(sn));
|
||||
obj->set("action", SrsJsonAny::str("on_hls"));
|
||||
obj->set("client_id", SrsJsonAny::number(client_id));
|
||||
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
|
||||
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
|
||||
obj->set("app", SrsJsonAny::str(req->app.c_str()));
|
||||
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
|
||||
obj->set("duration", SrsJsonAny::number(duration));
|
||||
obj->set("cwd", SrsJsonAny::str(cwd.c_str()));
|
||||
obj->set("file", SrsJsonAny::str(file.c_str()));
|
||||
obj->set("url", SrsJsonAny::str(url.c_str()));
|
||||
obj->set("m3u8", SrsJsonAny::str(m3u8.c_str()));
|
||||
obj->set("m3u8_url", SrsJsonAny::str(m3u8_url.c_str()));
|
||||
obj->set("seq_no", SrsJsonAny::number(sn));
|
||||
|
||||
std::string data = obj->to_json();
|
||||
std::string res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue