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
2014-07-06 17:25:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e5e2729967d157f8c5b4865b48f17b1379d21971
e5e27299
1 parent
574cd15e
refine amf0 and handshake code, add comments to utest.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
118 行增加
和
6 行删除
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/rtmp/srs_protocol_handshake.hpp
trunk/src/utest/srs_utest_amf0.cpp
trunk/src/utest/srs_utest_protocol.hpp
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
e5e2729
...
...
@@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef SRS_AUTO_SSL
using
namespace
srs
;
using
namespace
_srs_internal
;
// for openssl_HMACsha256
#include <openssl/evp.h>
...
...
@@ -43,7 +43,7 @@ using namespace srs;
// for __openssl_generate_key
#include <openssl/dh.h>
namespace
srs
namespace
_srs_internal
{
// 68bytes FMS key which is used to sign the sever packet.
u_int8_t
SrsGenuineFMSKey
[]
=
{
...
...
trunk/src/rtmp/srs_protocol_handshake.hpp
查看文件 @
e5e2729
...
...
@@ -36,7 +36,7 @@ class SrsHandshakeBytes;
#ifdef SRS_AUTO_SSL
namespace
srs
namespace
_srs_internal
{
/**
* the schema type.
...
...
trunk/src/utest/srs_utest_amf0.cpp
查看文件 @
e5e2729
...
...
@@ -29,7 +29,10 @@ using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_kernel_stream.hpp>
// user scenario: coding and decoding with amf0
/**
* main scenario to use amf0.
* user scenario: coding and decoding with amf0
*/
VOID
TEST
(
ProtocolAMF0Test
,
ScenarioMain
)
{
// coded amf0 object
...
...
@@ -171,6 +174,9 @@ VOID TEST(ProtocolAMF0Test, ScenarioMain)
}
}
/**
* to calc the size of amf0 instances.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiSize
)
{
// size of elem
...
...
@@ -427,6 +433,9 @@ VOID TEST(ProtocolAMF0Test, ApiSize)
}
}
/**
* about the AMF0 any.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiAnyElem
)
{
SrsAmf0Any
*
o
=
NULL
;
...
...
@@ -510,6 +519,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyElem)
}
}
/**
* about the stream to serialize/deserialize AMF0 instance.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiAnyIO
)
{
SrsStream
s
;
...
...
@@ -820,7 +832,10 @@ VOID TEST(ProtocolAMF0Test, ApiAnyIO)
}
}
VOID
TEST
(
ProtocolAMF0Test
,
ApiAnyAssert
)
/**
* to get the type identity
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiAnyTypeAssert
)
{
SrsStream
s
;
SrsAmf0Any
*
o
=
NULL
;
...
...
@@ -908,6 +923,9 @@ VOID TEST(ProtocolAMF0Test, ApiAnyAssert)
}
}
/**
* object property get/set
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiObjectProps
)
{
SrsAmf0Object
*
o
=
NULL
;
...
...
@@ -986,6 +1004,9 @@ VOID TEST(ProtocolAMF0Test, ApiObjectProps)
}
}
/**
* ecma array properties.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiEcmaArrayProps
)
{
SrsAmf0EcmaArray
*
o
=
NULL
;
...
...
@@ -1064,6 +1085,9 @@ VOID TEST(ProtocolAMF0Test, ApiEcmaArrayProps)
}
}
/**
* strict array.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ApiStrictArray
)
{
SrsStream
s
;
...
...
@@ -1132,6 +1156,9 @@ VOID TEST(ProtocolAMF0Test, ApiStrictArray)
}
}
/**
* object has object property,
*/
VOID
TEST
(
ProtocolAMF0Test
,
ObjectObjectObject
)
{
SrsAmf0Any
*
obj
=
SrsAmf0Any
::
object
();
...
...
@@ -1156,3 +1183,88 @@ VOID TEST(ProtocolAMF0Test, ObjectObjectObject)
EXPECT_EQ
(
1
,
child2
->
to_object
()
->
count
());
EXPECT_EQ
(
0
,
child3
->
to_object
()
->
count
());
}
/**
* ecma array has ecma array property,
*/
VOID
TEST
(
ProtocolAMF0Test
,
EcmaEcmaEcma
)
{
SrsAmf0Any
*
arr
=
SrsAmf0Any
::
ecma_array
();
SrsAutoFree
(
SrsAmf0Any
,
arr
);
EXPECT_EQ
(
0
,
arr
->
to_ecma_array
()
->
count
());
SrsAmf0Any
*
arr1
=
SrsAmf0Any
::
ecma_array
();
arr
->
to_ecma_array
()
->
set
(
"child1"
,
arr1
);
EXPECT_EQ
(
1
,
arr
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
0
,
arr1
->
to_ecma_array
()
->
count
());
SrsAmf0Any
*
arr2
=
SrsAmf0Any
::
ecma_array
();
arr1
->
to_ecma_array
()
->
set
(
"child2"
,
arr2
);
EXPECT_EQ
(
1
,
arr
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
0
,
arr2
->
to_ecma_array
()
->
count
());
SrsAmf0Any
*
arr3
=
SrsAmf0Any
::
ecma_array
();
arr2
->
to_ecma_array
()
->
set
(
"child3"
,
arr3
);
EXPECT_EQ
(
1
,
arr
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
1
,
arr2
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
0
,
arr3
->
to_ecma_array
()
->
count
());
}
/**
* strict array contains strict array
*/
VOID
TEST
(
ProtocolAMF0Test
,
StrictStrictStrict
)
{
SrsAmf0Any
*
arr
=
SrsAmf0Any
::
strict_array
();
SrsAutoFree
(
SrsAmf0Any
,
arr
);
EXPECT_EQ
(
0
,
arr
->
to_strict_array
()
->
count
());
SrsAmf0Any
*
arr1
=
SrsAmf0Any
::
strict_array
();
arr
->
to_strict_array
()
->
append
(
arr1
);
EXPECT_EQ
(
1
,
arr
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
0
,
arr1
->
to_strict_array
()
->
count
());
SrsAmf0Any
*
arr2
=
SrsAmf0Any
::
strict_array
();
arr1
->
to_strict_array
()
->
append
(
arr2
);
EXPECT_EQ
(
1
,
arr
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
0
,
arr2
->
to_strict_array
()
->
count
());
SrsAmf0Any
*
arr3
=
SrsAmf0Any
::
strict_array
();
arr2
->
to_strict_array
()
->
append
(
arr3
);
EXPECT_EQ
(
1
,
arr
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
1
,
arr2
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
0
,
arr3
->
to_strict_array
()
->
count
());
}
/**
* object has ecma array property,
* where ecma array contains strict array.
*/
VOID
TEST
(
ProtocolAMF0Test
,
ObjectEcmaStrict
)
{
SrsAmf0Any
*
obj
=
SrsAmf0Any
::
object
();
SrsAutoFree
(
SrsAmf0Any
,
obj
);
EXPECT_EQ
(
0
,
obj
->
to_object
()
->
count
());
SrsAmf0Any
*
arr1
=
SrsAmf0Any
::
ecma_array
();
obj
->
to_object
()
->
set
(
"child1"
,
arr1
);
EXPECT_EQ
(
1
,
obj
->
to_object
()
->
count
());
EXPECT_EQ
(
0
,
arr1
->
to_ecma_array
()
->
count
());
SrsAmf0Any
*
arr2
=
SrsAmf0Any
::
strict_array
();
arr1
->
to_ecma_array
()
->
set
(
"child2"
,
arr2
);
EXPECT_EQ
(
1
,
obj
->
to_object
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
0
,
arr2
->
to_strict_array
()
->
count
());
SrsAmf0Any
*
arr3
=
SrsAmf0Any
::
ecma_array
();
arr2
->
to_strict_array
()
->
append
(
arr3
);
EXPECT_EQ
(
1
,
obj
->
to_object
()
->
count
());
EXPECT_EQ
(
1
,
arr1
->
to_ecma_array
()
->
count
());
EXPECT_EQ
(
1
,
arr2
->
to_strict_array
()
->
count
());
EXPECT_EQ
(
0
,
arr3
->
to_ecma_array
()
->
count
());
}
...
...
trunk/src/utest/srs_utest_protocol.hpp
查看文件 @
e5e2729
...
...
@@ -36,7 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_handshake.hpp>
#ifdef SRS_AUTO_SSL
using
namespace
srs
;
using
namespace
_srs_internal
;
#endif
#include <srs_protocol_io.hpp>
...
...
请
注册
或
登录
后发表评论