Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-09-19 13:37:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3042115385f2aff7715bb53d18949eaf4d5b3416
30421153
1 parent
b59d9ba6
refine json to_str to dumps.
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
40 行增加
和
40 行删除
trunk/src/app/srs_app_heartbeat.cpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/protocol/srs_protocol_json.cpp
trunk/src/protocol/srs_protocol_json.hpp
trunk/src/app/srs_app_heartbeat.cpp
查看文件 @
3042115
...
...
@@ -84,7 +84,7 @@ void SrsHttpHeartbeat::heartbeat()
return
;
}
std
::
string
req
=
obj
->
to_json
();
std
::
string
req
=
obj
->
dumps
();
ISrsHttpMessage
*
msg
=
NULL
;
if
((
ret
=
http
.
post
(
uri
.
get_path
(),
req
,
&
msg
))
!=
ERROR_SUCCESS
)
{
srs_info
(
"http post hartbeart uri failed. url=%s, request=%s, ret=%d"
,
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
3042115
...
...
@@ -83,7 +83,7 @@ int srs_api_response_jsonp_code(ISrsHttpResponseWriter* w, string callback, int
obj
->
set
(
"code"
,
SrsJsonAny
::
integer
(
code
));
return
srs_api_response_jsonp
(
w
,
callback
,
obj
->
to_json
());
return
srs_api_response_jsonp
(
w
,
callback
,
obj
->
dumps
());
}
int
srs_api_response_json
(
ISrsHttpResponseWriter
*
w
,
string
data
)
...
...
@@ -103,7 +103,7 @@ int srs_api_response_json_code(ISrsHttpResponseWriter* w, int code)
obj
->
set
(
"code"
,
SrsJsonAny
::
integer
(
code
));
return
srs_api_response_json
(
w
,
obj
->
to_json
());
return
srs_api_response_json
(
w
,
obj
->
dumps
());
}
int
srs_api_response
(
ISrsHttpResponseWriter
*
w
,
ISrsHttpMessage
*
r
,
std
::
string
json
)
...
...
@@ -153,7 +153,7 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
urls
->
set
(
"api"
,
SrsJsonAny
::
str
(
"the api root"
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiApi
::
SrsGoApiApi
()
...
...
@@ -179,7 +179,7 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
urls
->
set
(
"v1"
,
SrsJsonAny
::
str
(
"the api version 1.0"
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiV1
::
SrsGoApiV1
()
...
...
@@ -225,7 +225,7 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
tests
->
set
(
"redirects"
,
SrsJsonAny
::
str
(
"always redirect to /api/v1/test/errors"
));
tests
->
set
(
"[vhost]"
,
SrsJsonAny
::
str
(
"http vhost for http://error.srs.com:1985/api/v1/tests/errors"
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiVersion
::
SrsGoApiVersion
()
...
...
@@ -254,7 +254,7 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
data
->
set
(
"revision"
,
SrsJsonAny
::
number
(
VERSION_REVISION
));
data
->
set
(
"version"
,
SrsJsonAny
::
str
(
RTMP_SIG_SRS_VERSION
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiSummaries
::
SrsGoApiSummaries
()
...
...
@@ -272,7 +272,7 @@ int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_api_dump_summaries
(
obj
);
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiRusages
::
SrsGoApiRusages
()
...
...
@@ -317,7 +317,7 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
data
->
set
(
"ru_nvcsw"
,
SrsJsonAny
::
number
(
ru
->
r
.
ru_nvcsw
));
data
->
set
(
"ru_nivcsw"
,
SrsJsonAny
::
number
(
ru
->
r
.
ru_nivcsw
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiSelfProcStats
::
SrsGoApiSelfProcStats
()
...
...
@@ -394,7 +394,7 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
data
->
set
(
"guest_time"
,
SrsJsonAny
::
number
(
u
->
guest_time
));
data
->
set
(
"cguest_time"
,
SrsJsonAny
::
number
(
u
->
cguest_time
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiSystemProcStats
::
SrsGoApiSystemProcStats
()
...
...
@@ -433,7 +433,7 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
data
->
set
(
"steal"
,
SrsJsonAny
::
number
(
s
->
steal
));
data
->
set
(
"guest"
,
SrsJsonAny
::
number
(
s
->
guest
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiMemInfos
::
SrsGoApiMemInfos
()
...
...
@@ -473,7 +473,7 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
data
->
set
(
"SwapTotal"
,
SrsJsonAny
::
number
(
m
->
SwapTotal
));
data
->
set
(
"SwapFree"
,
SrsJsonAny
::
number
(
m
->
SwapFree
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiAuthors
::
SrsGoApiAuthors
()
...
...
@@ -504,7 +504,7 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
data
->
set
(
"contributors_link"
,
SrsJsonAny
::
str
(
RTMP_SIG_SRS_CONTRIBUTORS_URL
));
data
->
set
(
"contributors"
,
SrsJsonAny
::
str
(
SRS_AUTO_CONSTRIBUTORS
));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiFeatures
::
SrsGoApiFeatures
()
...
...
@@ -622,7 +622,7 @@ int SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
features
->
set
(
"mr"
,
SrsJsonAny
::
boolean
(
false
));
#endif
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiRequests
::
SrsGoApiRequests
()
...
...
@@ -672,7 +672,7 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
server
->
set
(
"link"
,
SrsJsonAny
::
str
(
RTMP_SIG_SRS_URL
));
server
->
set
(
"time"
,
SrsJsonAny
::
number
(
srs_get_system_time_ms
()));
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiVhosts
::
SrsGoApiVhosts
()
...
...
@@ -726,7 +726,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_go_http_error
(
w
,
SRS_CONSTS_HTTP_MethodNotAllowed
);
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiStreams
::
SrsGoApiStreams
()
...
...
@@ -780,7 +780,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_go_http_error
(
w
,
SRS_CONSTS_HTTP_MethodNotAllowed
);
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiClients
::
SrsGoApiClients
()
...
...
@@ -843,7 +843,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_go_http_error
(
w
,
SRS_CONSTS_HTTP_MethodNotAllowed
);
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
SrsGoApiRaw
::
SrsGoApiRaw
(
SrsServer
*
svr
)
...
...
@@ -882,7 +882,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_api_response_code
(
w
,
r
,
ret
);
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
// whether enabled the HTTP RAW API.
...
...
@@ -978,7 +978,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
}
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
// for rpc=update, to update the configs of server.
...
...
@@ -1275,7 +1275,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_warn
(
"raw api update not applied %s=%s%s."
,
scope
.
c_str
(),
value
.
c_str
(),
extra
.
c_str
());
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
return
srs_api_response
(
w
,
r
,
obj
->
dumps
());
}
return
ret
;
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
3042115
...
...
@@ -74,7 +74,7 @@ int SrsHttpHooks::on_connect(string url, SrsRequest* req)
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -110,7 +110,7 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int
obj
->
set
(
"send_bytes"
,
SrsJsonAny
::
number
(
send_bytes
));
obj
->
set
(
"recv_bytes"
,
SrsJsonAny
::
number
(
recv_bytes
));
std
::
string
data
=
obj
->
to_json
();
std
::
string
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -145,7 +145,7 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req)
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -180,7 +180,7 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -216,7 +216,7 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req)
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -251,7 +251,7 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -289,7 +289,7 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file)
obj
->
set
(
"cwd"
,
SrsJsonAny
::
str
(
cwd
.
c_str
()));
obj
->
set
(
"file"
,
SrsJsonAny
::
str
(
file
.
c_str
()));
std
::
string
data
=
obj
->
to_json
();
std
::
string
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
@@ -332,7 +332,7 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri
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
data
=
obj
->
dumps
();
std
::
string
res
;
int
status_code
;
...
...
trunk/src/protocol/srs_protocol_json.cpp
查看文件 @
3042115
...
...
@@ -318,7 +318,7 @@ SrsJsonArray* SrsJsonAny::to_array()
return
p
;
}
string
SrsJsonAny
::
to_json
()
string
SrsJsonAny
::
dumps
()
{
switch
(
marker
)
{
case
SRS_JSON_String
:
{
...
...
@@ -344,11 +344,11 @@ string SrsJsonAny::to_json()
}
case
SRS_JSON_Object
:
{
SrsJsonObject
*
obj
=
to_object
();
return
obj
->
to_json
();
return
obj
->
dumps
();
}
case
SRS_JSON_Array
:
{
SrsJsonArray
*
arr
=
to_array
();
return
arr
->
to_json
();
return
arr
->
dumps
();
}
default
:
{
break
;
...
...
@@ -527,7 +527,7 @@ SrsJsonAny* SrsJsonObject::value_at(int index)
return
elem
.
second
;
}
string
SrsJsonObject
::
to_json
()
string
SrsJsonObject
::
dumps
()
{
stringstream
ss
;
...
...
@@ -537,7 +537,7 @@ string SrsJsonObject::to_json()
std
::
string
name
=
this
->
key_at
(
i
);
SrsJsonAny
*
any
=
this
->
value_at
(
i
);
ss
<<
SRS_JFIELD_NAME
(
name
)
<<
any
->
to_json
();
ss
<<
SRS_JFIELD_NAME
(
name
)
<<
any
->
dumps
();
if
(
i
<
(
int
)
properties
.
size
()
-
1
)
{
ss
<<
SRS_JFIELD_CONT
;
}
...
...
@@ -714,7 +714,7 @@ void SrsJsonArray::append(SrsJsonAny* value)
add
(
value
);
}
string
SrsJsonArray
::
to_json
()
string
SrsJsonArray
::
dumps
()
{
stringstream
ss
;
...
...
@@ -723,7 +723,7 @@ string SrsJsonArray::to_json()
for
(
int
i
=
0
;
i
<
(
int
)
properties
.
size
();
i
++
)
{
SrsJsonAny
*
any
=
properties
[
i
];
ss
<<
any
->
to_json
();
ss
<<
any
->
dumps
();
if
(
i
<
(
int
)
properties
.
size
()
-
1
)
{
ss
<<
SRS_JFIELD_CONT
;
...
...
trunk/src/protocol/srs_protocol_json.hpp
查看文件 @
3042115
...
...
@@ -114,7 +114,7 @@ public:
*/
virtual
SrsJsonArray
*
to_array
();
public
:
virtual
std
::
string
to_json
();
virtual
std
::
string
dumps
();
virtual
SrsAmf0Any
*
to_amf0
();
public
:
static
SrsJsonAny
*
str
(
const
char
*
value
=
NULL
);
...
...
@@ -150,7 +150,7 @@ public:
// @remark: max index is count().
virtual
SrsJsonAny
*
value_at
(
int
index
);
public
:
virtual
std
::
string
to_json
();
virtual
std
::
string
dumps
();
virtual
SrsAmf0Any
*
to_amf0
();
public
:
virtual
void
set
(
std
::
string
key
,
SrsJsonAny
*
value
);
...
...
@@ -181,13 +181,13 @@ public:
// alias to add.
virtual
void
append
(
SrsJsonAny
*
value
);
public
:
virtual
std
::
string
to_json
();
virtual
std
::
string
dumps
();
virtual
SrsAmf0Any
*
to_amf0
();
};
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// json encode, please use
AMF0.to_json
() to encode json object.
// json encode, please use
JSON.dumps
() to encode json object.
#endif
...
...
请
注册
或
登录
后发表评论