正在显示
1 个修改的文件
包含
63 行增加
和
1 行删除
@@ -29,7 +29,48 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -29,7 +29,48 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
29 | */ | 29 | */ |
30 | #include <srs_core.hpp> | 30 | #include <srs_core.hpp> |
31 | 31 | ||
32 | -// json encode macros | 32 | +//////////////////////////////////////////////////////////////////////// |
33 | +//////////////////////////////////////////////////////////////////////// | ||
34 | +//////////////////////////////////////////////////////////////////////// | ||
35 | +/* json encode | ||
36 | + cout<< JOBJECT_START | ||
37 | + << JFIELD_STR("name", "srs") << JFIELD_CONT | ||
38 | + << JFIELD_ORG("version", 100) << JFIELD_CONT | ||
39 | + << JFIELD_NAME("features") << JOBJECT_START | ||
40 | + << JFIELD_STR("rtmp", "released") << JFIELD_CONT | ||
41 | + << JFIELD_STR("hls", "released") << JFIELD_CONT | ||
42 | + << JFIELD_STR("dash", "plan") | ||
43 | + << JOBJECT_END << JFIELD_CONT | ||
44 | + << JFIELD_STR("author", "srs team") | ||
45 | + << JOBJECT_END | ||
46 | +it's: | ||
47 | + cont<< "{" | ||
48 | + << "name:" << "srs" << "," | ||
49 | + << "version:" << 100 << "," | ||
50 | + << "features:" << "{" | ||
51 | + << "rtmp:" << "released" << "," | ||
52 | + << "hls:" << "released" << "," | ||
53 | + << "dash:" << "plan" | ||
54 | + << "}" << "," | ||
55 | + << "author:" << "srs team" | ||
56 | + << "}" | ||
57 | +that is: | ||
58 | + """ | ||
59 | + { | ||
60 | + "name": "srs", | ||
61 | + "version": 100, | ||
62 | + "features": { | ||
63 | + "rtmp": "released", | ||
64 | + "hls": "released", | ||
65 | + "dash": "plan" | ||
66 | + }, | ||
67 | + "author": "srs team" | ||
68 | + } | ||
69 | + """ | ||
70 | +*/ | ||
71 | +//////////////////////////////////////////////////////////////////////// | ||
72 | +//////////////////////////////////////////////////////////////////////// | ||
73 | +//////////////////////////////////////////////////////////////////////// | ||
33 | #define JOBJECT_START "{" | 74 | #define JOBJECT_START "{" |
34 | #define JFIELD_NAME(k) "\"" << k << "\":" | 75 | #define JFIELD_NAME(k) "\"" << k << "\":" |
35 | #define JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\"" | 76 | #define JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\"" |
@@ -40,4 +81,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -40,4 +81,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
40 | #define JARRAY_START "[" | 81 | #define JARRAY_START "[" |
41 | #define JARRAY_END "]" | 82 | #define JARRAY_END "]" |
42 | 83 | ||
84 | +//////////////////////////////////////////////////////////////////////// | ||
85 | +//////////////////////////////////////////////////////////////////////// | ||
86 | +//////////////////////////////////////////////////////////////////////// | ||
87 | +// json decode | ||
88 | +// 1. SrsJsonAny: read any from stream | ||
89 | +// SrsJsonAny* pany = NULL; | ||
90 | +// if ((ret = srs_json_read_any(stream, &pany)) != ERROR_SUCCESS) { | ||
91 | +// return ret; | ||
92 | +// } | ||
93 | +// srs_assert(pany); // if success, always valid object. | ||
94 | +// 2. SrsJsonAny: convert to specifid type, for instance, string | ||
95 | +// SrsJsonAny* pany = ... | ||
96 | +// if (pany->is_string()) { | ||
97 | +// string v = pany->to_str(); | ||
98 | +// } | ||
99 | +// | ||
100 | +// for detail usage, see interfaces of each object. | ||
101 | +//////////////////////////////////////////////////////////////////////// | ||
102 | +//////////////////////////////////////////////////////////////////////// | ||
103 | +//////////////////////////////////////////////////////////////////////// | ||
104 | + | ||
43 | #endif | 105 | #endif |
-
请 注册 或 登录 后发表评论