正在显示
4 个修改的文件
包含
118 行增加
和
6 行删除
@@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
35 | 35 | ||
36 | #ifdef SRS_AUTO_SSL | 36 | #ifdef SRS_AUTO_SSL |
37 | 37 | ||
38 | -using namespace srs; | 38 | +using namespace _srs_internal; |
39 | 39 | ||
40 | // for openssl_HMACsha256 | 40 | // for openssl_HMACsha256 |
41 | #include <openssl/evp.h> | 41 | #include <openssl/evp.h> |
@@ -43,7 +43,7 @@ using namespace srs; | @@ -43,7 +43,7 @@ using namespace srs; | ||
43 | // for __openssl_generate_key | 43 | // for __openssl_generate_key |
44 | #include <openssl/dh.h> | 44 | #include <openssl/dh.h> |
45 | 45 | ||
46 | -namespace srs | 46 | +namespace _srs_internal |
47 | { | 47 | { |
48 | // 68bytes FMS key which is used to sign the sever packet. | 48 | // 68bytes FMS key which is used to sign the sever packet. |
49 | u_int8_t SrsGenuineFMSKey[] = { | 49 | u_int8_t SrsGenuineFMSKey[] = { |
@@ -29,7 +29,10 @@ using namespace std; | @@ -29,7 +29,10 @@ using namespace std; | ||
29 | #include <srs_kernel_error.hpp> | 29 | #include <srs_kernel_error.hpp> |
30 | #include <srs_kernel_stream.hpp> | 30 | #include <srs_kernel_stream.hpp> |
31 | 31 | ||
32 | -// user scenario: coding and decoding with amf0 | 32 | +/** |
33 | +* main scenario to use amf0. | ||
34 | +* user scenario: coding and decoding with amf0 | ||
35 | +*/ | ||
33 | VOID TEST(ProtocolAMF0Test, ScenarioMain) | 36 | VOID TEST(ProtocolAMF0Test, ScenarioMain) |
34 | { | 37 | { |
35 | // coded amf0 object | 38 | // coded amf0 object |
@@ -171,6 +174,9 @@ VOID TEST(ProtocolAMF0Test, ScenarioMain) | @@ -171,6 +174,9 @@ VOID TEST(ProtocolAMF0Test, ScenarioMain) | ||
171 | } | 174 | } |
172 | } | 175 | } |
173 | 176 | ||
177 | +/** | ||
178 | +* to calc the size of amf0 instances. | ||
179 | +*/ | ||
174 | VOID TEST(ProtocolAMF0Test, ApiSize) | 180 | VOID TEST(ProtocolAMF0Test, ApiSize) |
175 | { | 181 | { |
176 | // size of elem | 182 | // size of elem |
@@ -427,6 +433,9 @@ VOID TEST(ProtocolAMF0Test, ApiSize) | @@ -427,6 +433,9 @@ VOID TEST(ProtocolAMF0Test, ApiSize) | ||
427 | } | 433 | } |
428 | } | 434 | } |
429 | 435 | ||
436 | +/** | ||
437 | +* about the AMF0 any. | ||
438 | +*/ | ||
430 | VOID TEST(ProtocolAMF0Test, ApiAnyElem) | 439 | VOID TEST(ProtocolAMF0Test, ApiAnyElem) |
431 | { | 440 | { |
432 | SrsAmf0Any* o = NULL; | 441 | SrsAmf0Any* o = NULL; |
@@ -510,6 +519,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyElem) | @@ -510,6 +519,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyElem) | ||
510 | } | 519 | } |
511 | } | 520 | } |
512 | 521 | ||
522 | +/** | ||
523 | +* about the stream to serialize/deserialize AMF0 instance. | ||
524 | +*/ | ||
513 | VOID TEST(ProtocolAMF0Test, ApiAnyIO) | 525 | VOID TEST(ProtocolAMF0Test, ApiAnyIO) |
514 | { | 526 | { |
515 | SrsStream s; | 527 | SrsStream s; |
@@ -820,7 +832,10 @@ VOID TEST(ProtocolAMF0Test, ApiAnyIO) | @@ -820,7 +832,10 @@ VOID TEST(ProtocolAMF0Test, ApiAnyIO) | ||
820 | } | 832 | } |
821 | } | 833 | } |
822 | 834 | ||
823 | -VOID TEST(ProtocolAMF0Test, ApiAnyAssert) | 835 | +/** |
836 | +* to get the type identity | ||
837 | +*/ | ||
838 | +VOID TEST(ProtocolAMF0Test, ApiAnyTypeAssert) | ||
824 | { | 839 | { |
825 | SrsStream s; | 840 | SrsStream s; |
826 | SrsAmf0Any* o = NULL; | 841 | SrsAmf0Any* o = NULL; |
@@ -908,6 +923,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyAssert) | @@ -908,6 +923,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyAssert) | ||
908 | } | 923 | } |
909 | } | 924 | } |
910 | 925 | ||
926 | +/** | ||
927 | +* object property get/set | ||
928 | +*/ | ||
911 | VOID TEST(ProtocolAMF0Test, ApiObjectProps) | 929 | VOID TEST(ProtocolAMF0Test, ApiObjectProps) |
912 | { | 930 | { |
913 | SrsAmf0Object* o = NULL; | 931 | SrsAmf0Object* o = NULL; |
@@ -986,6 +1004,9 @@ VOID TEST(ProtocolAMF0Test, ApiObjectProps) | @@ -986,6 +1004,9 @@ VOID TEST(ProtocolAMF0Test, ApiObjectProps) | ||
986 | } | 1004 | } |
987 | } | 1005 | } |
988 | 1006 | ||
1007 | +/** | ||
1008 | +* ecma array properties. | ||
1009 | +*/ | ||
989 | VOID TEST(ProtocolAMF0Test, ApiEcmaArrayProps) | 1010 | VOID TEST(ProtocolAMF0Test, ApiEcmaArrayProps) |
990 | { | 1011 | { |
991 | SrsAmf0EcmaArray* o = NULL; | 1012 | SrsAmf0EcmaArray* o = NULL; |
@@ -1064,6 +1085,9 @@ VOID TEST(ProtocolAMF0Test, ApiEcmaArrayProps) | @@ -1064,6 +1085,9 @@ VOID TEST(ProtocolAMF0Test, ApiEcmaArrayProps) | ||
1064 | } | 1085 | } |
1065 | } | 1086 | } |
1066 | 1087 | ||
1088 | +/** | ||
1089 | +* strict array. | ||
1090 | +*/ | ||
1067 | VOID TEST(ProtocolAMF0Test, ApiStrictArray) | 1091 | VOID TEST(ProtocolAMF0Test, ApiStrictArray) |
1068 | { | 1092 | { |
1069 | SrsStream s; | 1093 | SrsStream s; |
@@ -1132,6 +1156,9 @@ VOID TEST(ProtocolAMF0Test, ApiStrictArray) | @@ -1132,6 +1156,9 @@ VOID TEST(ProtocolAMF0Test, ApiStrictArray) | ||
1132 | } | 1156 | } |
1133 | } | 1157 | } |
1134 | 1158 | ||
1159 | +/** | ||
1160 | +* object has object property, | ||
1161 | +*/ | ||
1135 | VOID TEST(ProtocolAMF0Test, ObjectObjectObject) | 1162 | VOID TEST(ProtocolAMF0Test, ObjectObjectObject) |
1136 | { | 1163 | { |
1137 | SrsAmf0Any* obj = SrsAmf0Any::object(); | 1164 | SrsAmf0Any* obj = SrsAmf0Any::object(); |
@@ -1156,3 +1183,88 @@ VOID TEST(ProtocolAMF0Test, ObjectObjectObject) | @@ -1156,3 +1183,88 @@ VOID TEST(ProtocolAMF0Test, ObjectObjectObject) | ||
1156 | EXPECT_EQ(1, child2->to_object()->count()); | 1183 | EXPECT_EQ(1, child2->to_object()->count()); |
1157 | EXPECT_EQ(0, child3->to_object()->count()); | 1184 | EXPECT_EQ(0, child3->to_object()->count()); |
1158 | } | 1185 | } |
1186 | + | ||
1187 | +/** | ||
1188 | +* ecma array has ecma array property, | ||
1189 | +*/ | ||
1190 | +VOID TEST(ProtocolAMF0Test, EcmaEcmaEcma) | ||
1191 | +{ | ||
1192 | + SrsAmf0Any* arr = SrsAmf0Any::ecma_array(); | ||
1193 | + SrsAutoFree(SrsAmf0Any, arr); | ||
1194 | + EXPECT_EQ(0, arr->to_ecma_array()->count()); | ||
1195 | + | ||
1196 | + SrsAmf0Any* arr1 = SrsAmf0Any::ecma_array(); | ||
1197 | + arr->to_ecma_array()->set("child1", arr1); | ||
1198 | + EXPECT_EQ(1, arr->to_ecma_array()->count()); | ||
1199 | + EXPECT_EQ(0, arr1->to_ecma_array()->count()); | ||
1200 | + | ||
1201 | + SrsAmf0Any* arr2 = SrsAmf0Any::ecma_array(); | ||
1202 | + arr1->to_ecma_array()->set("child2", arr2); | ||
1203 | + EXPECT_EQ(1, arr->to_ecma_array()->count()); | ||
1204 | + EXPECT_EQ(1, arr1->to_ecma_array()->count()); | ||
1205 | + EXPECT_EQ(0, arr2->to_ecma_array()->count()); | ||
1206 | + | ||
1207 | + SrsAmf0Any* arr3 = SrsAmf0Any::ecma_array(); | ||
1208 | + arr2->to_ecma_array()->set("child3", arr3); | ||
1209 | + EXPECT_EQ(1, arr->to_ecma_array()->count()); | ||
1210 | + EXPECT_EQ(1, arr1->to_ecma_array()->count()); | ||
1211 | + EXPECT_EQ(1, arr2->to_ecma_array()->count()); | ||
1212 | + EXPECT_EQ(0, arr3->to_ecma_array()->count()); | ||
1213 | +} | ||
1214 | + | ||
1215 | +/** | ||
1216 | +* strict array contains strict array | ||
1217 | +*/ | ||
1218 | +VOID TEST(ProtocolAMF0Test, StrictStrictStrict) | ||
1219 | +{ | ||
1220 | + SrsAmf0Any* arr = SrsAmf0Any::strict_array(); | ||
1221 | + SrsAutoFree(SrsAmf0Any, arr); | ||
1222 | + EXPECT_EQ(0, arr->to_strict_array()->count()); | ||
1223 | + | ||
1224 | + SrsAmf0Any* arr1 = SrsAmf0Any::strict_array(); | ||
1225 | + arr->to_strict_array()->append(arr1); | ||
1226 | + EXPECT_EQ(1, arr->to_strict_array()->count()); | ||
1227 | + EXPECT_EQ(0, arr1->to_strict_array()->count()); | ||
1228 | + | ||
1229 | + SrsAmf0Any* arr2 = SrsAmf0Any::strict_array(); | ||
1230 | + arr1->to_strict_array()->append(arr2); | ||
1231 | + EXPECT_EQ(1, arr->to_strict_array()->count()); | ||
1232 | + EXPECT_EQ(1, arr1->to_strict_array()->count()); | ||
1233 | + EXPECT_EQ(0, arr2->to_strict_array()->count()); | ||
1234 | + | ||
1235 | + SrsAmf0Any* arr3 = SrsAmf0Any::strict_array(); | ||
1236 | + arr2->to_strict_array()->append(arr3); | ||
1237 | + EXPECT_EQ(1, arr->to_strict_array()->count()); | ||
1238 | + EXPECT_EQ(1, arr1->to_strict_array()->count()); | ||
1239 | + EXPECT_EQ(1, arr2->to_strict_array()->count()); | ||
1240 | + EXPECT_EQ(0, arr3->to_strict_array()->count()); | ||
1241 | +} | ||
1242 | + | ||
1243 | +/** | ||
1244 | +* object has ecma array property, | ||
1245 | +* where ecma array contains strict array. | ||
1246 | +*/ | ||
1247 | +VOID TEST(ProtocolAMF0Test, ObjectEcmaStrict) | ||
1248 | +{ | ||
1249 | + SrsAmf0Any* obj = SrsAmf0Any::object(); | ||
1250 | + SrsAutoFree(SrsAmf0Any, obj); | ||
1251 | + EXPECT_EQ(0, obj->to_object()->count()); | ||
1252 | + | ||
1253 | + SrsAmf0Any* arr1 = SrsAmf0Any::ecma_array(); | ||
1254 | + obj->to_object()->set("child1", arr1); | ||
1255 | + EXPECT_EQ(1, obj->to_object()->count()); | ||
1256 | + EXPECT_EQ(0, arr1->to_ecma_array()->count()); | ||
1257 | + | ||
1258 | + SrsAmf0Any* arr2 = SrsAmf0Any::strict_array(); | ||
1259 | + arr1->to_ecma_array()->set("child2", arr2); | ||
1260 | + EXPECT_EQ(1, obj->to_object()->count()); | ||
1261 | + EXPECT_EQ(1, arr1->to_ecma_array()->count()); | ||
1262 | + EXPECT_EQ(0, arr2->to_strict_array()->count()); | ||
1263 | + | ||
1264 | + SrsAmf0Any* arr3 = SrsAmf0Any::ecma_array(); | ||
1265 | + arr2->to_strict_array()->append(arr3); | ||
1266 | + EXPECT_EQ(1, obj->to_object()->count()); | ||
1267 | + EXPECT_EQ(1, arr1->to_ecma_array()->count()); | ||
1268 | + EXPECT_EQ(1, arr2->to_strict_array()->count()); | ||
1269 | + EXPECT_EQ(0, arr3->to_ecma_array()->count()); | ||
1270 | +} |
@@ -36,7 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,7 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
36 | #include <srs_protocol_handshake.hpp> | 36 | #include <srs_protocol_handshake.hpp> |
37 | 37 | ||
38 | #ifdef SRS_AUTO_SSL | 38 | #ifdef SRS_AUTO_SSL |
39 | -using namespace srs; | 39 | +using namespace _srs_internal; |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <srs_protocol_io.hpp> | 42 | #include <srs_protocol_io.hpp> |
-
请 注册 或 登录 后发表评论