mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
Fix #904, replace NXJSON(LGPL) with json-parser(BSD). 3.0.23
This commit is contained in:
parent
6993ac226f
commit
54411e0768
6 changed files with 1427 additions and 572 deletions
|
@ -189,6 +189,7 @@ Please select your language:
|
|||
|
||||
### V3 changes
|
||||
|
||||
* v3.0, 2017-05-30, Fix [#904][bug #904], replace NXJSON(LGPL) with json-parser(BSD). 3.0.23
|
||||
* v3.0, 2017-04-16, Fix [#547][bug #547], support HLS audio in TS. 3.0.22
|
||||
* v3.0, 2017-03-26, Fix [#820][bug #820], extract service for modules. 3.0.21
|
||||
* v3.0, 2017-03-02, Fix [#786][bug #786], simply don't reuse object. 3.0.20
|
||||
|
@ -1417,6 +1418,7 @@ Winlin
|
|||
[bug #786]: https://github.com/ossrs/srs/issues/786
|
||||
[bug #820]: https://github.com/ossrs/srs/issues/820
|
||||
[bug #547]: https://github.com/ossrs/srs/issues/547
|
||||
[bug #904]: https://github.com/ossrs/srs/issues/904
|
||||
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
||||
|
||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||
|
|
|
@ -117,7 +117,7 @@ class RESTClients(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_connect":
|
||||
|
@ -128,7 +128,7 @@ class RESTClients(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
@ -204,7 +204,7 @@ class RESTStreams(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_publish":
|
||||
|
@ -215,7 +215,7 @@ class RESTStreams(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
@ -284,7 +284,7 @@ class RESTDvrs(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_dvr":
|
||||
|
@ -293,7 +293,7 @@ class RESTDvrs(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
@ -405,7 +405,7 @@ class RESTHls(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_hls":
|
||||
|
@ -414,7 +414,7 @@ class RESTHls(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
@ -481,7 +481,7 @@ class RESTSessions(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_play":
|
||||
|
@ -492,7 +492,7 @@ class RESTSessions(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
@ -803,7 +803,7 @@ class RESTSnapshots(object):
|
|||
except Exception, ex:
|
||||
code = Error.system_parse_json
|
||||
trace("parse the request to json failed, req=%s, ex=%s, code=%s"%(req, ex, code))
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
action = json_req["action"]
|
||||
if action == "on_publish":
|
||||
|
@ -814,7 +814,7 @@ class RESTSnapshots(object):
|
|||
trace("invalid request action: %s"%(json_req["action"]))
|
||||
code = Error.request_invalid_action
|
||||
|
||||
return str(code)
|
||||
return json.dumps({"code": int(code), "data": None})
|
||||
|
||||
def OPTIONS(self, *args, **kwargs):
|
||||
enable_crossdomain()
|
||||
|
|
|
@ -466,7 +466,7 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i
|
|||
}
|
||||
|
||||
// parse string res to json.
|
||||
SrsJsonAny* info = SrsJsonAny::loads((char*)res.c_str());
|
||||
SrsJsonAny* info = SrsJsonAny::loads(res);
|
||||
if (!info) {
|
||||
ret = ERROR_HTTP_DATA_INVALID;
|
||||
srs_error("invalid response %s. ret=%d", res.c_str(), ret);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// current release version
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 22
|
||||
#define VERSION_REVISION 23
|
||||
|
||||
// generated by configure, only macros.
|
||||
#include <srs_auto_headers.hpp>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,32 +29,26 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// whether use nxjson
|
||||
// @see: https://bitbucket.org/yarosla/nxjson
|
||||
#undef SRS_JSON_USE_NXJSON
|
||||
#define SRS_JSON_USE_NXJSON
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// json decode
|
||||
// 1. SrsJsonAny: read any from str:char*
|
||||
// SrsJsonAny* pany = NULL;
|
||||
// if ((ret = srs_json_read_any(str, &pany)) != ERROR_SUCCESS) {
|
||||
// return ret;
|
||||
// SrsJsonAny* any = NULL;
|
||||
// if ((any = SrsJsonAny::loads(str)) == NULL) {
|
||||
// return -1;
|
||||
// }
|
||||
// srs_assert(pany); // if success, always valid object.
|
||||
// 2. SrsJsonAny: convert to specifid type, for instance, string
|
||||
// SrsJsonAny* pany = ...
|
||||
// if (pany->is_string()) {
|
||||
// string v = pany->to_str();
|
||||
// SrsJsonAny* any = ...
|
||||
// if (any->is_string()) {
|
||||
// string v = any->to_str();
|
||||
// }
|
||||
//
|
||||
// for detail usage, see interfaces of each object.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// @see: https://bitbucket.org/yarosla/nxjson
|
||||
// @see: https://github.com/udp/json-parser
|
||||
|
||||
class SrsAmf0Any;
|
||||
|
@ -115,6 +109,7 @@ public:
|
|||
virtual SrsAmf0Any* to_amf0();
|
||||
public:
|
||||
static SrsJsonAny* str(const char* value = NULL);
|
||||
static SrsJsonAny* str(const char* value, int length);
|
||||
static SrsJsonAny* boolean(bool value = false);
|
||||
static SrsJsonAny* integer(int64_t value = 0);
|
||||
static SrsJsonAny* number(double value = 0.0);
|
||||
|
@ -123,10 +118,10 @@ public:
|
|||
static SrsJsonArray* array();
|
||||
public:
|
||||
/**
|
||||
* read json tree from str:char*
|
||||
* read json tree from string.
|
||||
* @return json object. NULL if error.
|
||||
*/
|
||||
static SrsJsonAny* loads(char* str);
|
||||
static SrsJsonAny* loads(const std::string& str);
|
||||
};
|
||||
|
||||
class SrsJsonObject : public SrsJsonAny
|
||||
|
|
Loading…
Reference in a new issue