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-09 14:14:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
54fda96f379037c729fc942c2fc6e3d6d8482860
54fda96f
1 parent
2c3cb73a
add utest for bug #98
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
93 行增加
和
0 行删除
trunk/src/utest/srs_utest_protocol.cpp
trunk/src/utest/srs_utest_protocol.cpp
查看文件 @
54fda96
...
...
@@ -564,3 +564,96 @@ VOID TEST(ProtocolStackTest, ProtocolBytes)
EXPECT_TRUE
(
0
<
proto
.
get_send_bytes
());
}
VOID
TEST
(
ProtocolStackTest
,
ProtocolRecvMessage
)
{
MockBufferIO
bio
;
SrsProtocol
proto
(
&
bio
);
// packet is SrsConnectAppPacket
char
data
[]
=
{
// 12bytes header, 1byts chunk header, 11bytes msg heder
(
char
)
0x03
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x01
,
(
char
)
0xa1
,
(
char
)
0x14
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
// msg payload start
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x07
,
(
char
)
0x63
,
(
char
)
0x6f
,
(
char
)
0x6e
,
(
char
)
0x6e
,
(
char
)
0x65
,
(
char
)
0x63
,
(
char
)
0x74
,
(
char
)
0x00
,
(
char
)
0x3f
,
(
char
)
0xf0
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x03
,
(
char
)
0x00
,
(
char
)
0x03
,
(
char
)
0x61
,
(
char
)
0x70
,
(
char
)
0x70
,
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x04
,
(
char
)
0x6c
,
(
char
)
0x69
,
(
char
)
0x76
,
(
char
)
0x65
,
(
char
)
0x00
,
(
char
)
0x08
,
(
char
)
0x66
,
(
char
)
0x6c
,
(
char
)
0x61
,
(
char
)
0x73
,
(
char
)
0x68
,
(
char
)
0x56
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x0d
,
(
char
)
0x57
,
(
char
)
0x49
,
(
char
)
0x4e
,
(
char
)
0x20
,
(
char
)
0x31
,
(
char
)
0x32
,
(
char
)
0x2c
,
(
char
)
0x30
,
(
char
)
0x2c
,
(
char
)
0x30
,
(
char
)
0x2c
,
(
char
)
0x34
,
(
char
)
0x31
,
(
char
)
0x00
,
(
char
)
0x06
,
(
char
)
0x73
,
(
char
)
0x77
,
(
char
)
0x66
,
(
char
)
0x55
,
(
char
)
0x72
,
(
char
)
0x6c
,
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x51
,
(
char
)
0x68
,
(
char
)
0x74
,
(
char
)
0x74
,
(
char
)
0x70
,
(
char
)
0x3a
,
(
char
)
0x2f
,
(
char
)
0x2f
,
(
char
)
0x77
,
(
char
)
0x77
,
(
char
)
0x77
,
(
char
)
0x2e
,
(
char
)
0x6f
,
(
char
)
0x73
,
(
char
)
0x73
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x2e
,
(
char
)
0x6e
,
(
char
)
0x65
,
(
char
)
0x74
,
(
char
)
0x3a
,
(
char
)
0x38
,
(
char
)
0x30
,
(
char
)
0x38
,
(
char
)
0x35
,
(
char
)
0x2f
,
(
char
)
0x70
,
(
char
)
0x6c
,
(
char
)
0x61
,
(
char
)
0x79
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x2f
,
(
char
)
0x73
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x5f
,
(
char
)
0x70
,
(
char
)
0x6c
,
(
char
)
0x61
,
(
char
)
0x79
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x2f
,
(
char
)
0x72
,
(
char
)
0x65
,
(
char
)
0x6c
,
(
char
)
0x65
,
(
char
)
0x61
,
(
char
)
0x73
,
(
char
)
0x65
,
(
char
)
0x2f
,
(
char
)
0x73
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x5f
,
(
char
)
0x70
,
(
char
)
0x6c
,
(
char
)
0xC3
,
/*next chunk.*/
(
char
)
0x61
,
(
char
)
0x79
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x2e
,
(
char
)
0x73
,
(
char
)
0x77
,
(
char
)
0x66
,
(
char
)
0x3f
,
(
char
)
0x5f
,
(
char
)
0x76
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x69
,
(
char
)
0x6f
,
(
char
)
0x6e
,
(
char
)
0x3d
,
(
char
)
0x31
,
(
char
)
0x2e
,
(
char
)
0x32
,
(
char
)
0x33
,
(
char
)
0x00
,
(
char
)
0x05
,
(
char
)
0x74
,
(
char
)
0x63
,
(
char
)
0x55
,
(
char
)
0x72
,
(
char
)
0x6c
,
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x14
,
(
char
)
0x72
,
(
char
)
0x74
,
(
char
)
0x6d
,
(
char
)
0x70
,
(
char
)
0x3a
,
(
char
)
0x2f
,
(
char
)
0x2f
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x76
,
(
char
)
0x3a
,
(
char
)
0x31
,
(
char
)
0x39
,
(
char
)
0x33
,
(
char
)
0x35
,
(
char
)
0x2f
,
(
char
)
0x6c
,
(
char
)
0x69
,
(
char
)
0x76
,
(
char
)
0x65
,
(
char
)
0x00
,
(
char
)
0x04
,
(
char
)
0x66
,
(
char
)
0x70
,
(
char
)
0x61
,
(
char
)
0x64
,
(
char
)
0x01
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x0c
,
(
char
)
0x63
,
(
char
)
0x61
,
(
char
)
0x70
,
(
char
)
0x61
,
(
char
)
0x62
,
(
char
)
0x69
,
(
char
)
0x6c
,
(
char
)
0x69
,
(
char
)
0x74
,
(
char
)
0x69
,
(
char
)
0x65
,
(
char
)
0x73
,
(
char
)
0x00
,
(
char
)
0x40
,
(
char
)
0x6d
,
(
char
)
0xe0
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x0b
,
(
char
)
0x61
,
(
char
)
0x75
,
(
char
)
0x64
,
(
char
)
0x69
,
(
char
)
0x6f
,
(
char
)
0x43
,
(
char
)
0x6f
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x63
,
(
char
)
0x73
,
(
char
)
0x00
,
(
char
)
0x40
,
(
char
)
0xab
,
(
char
)
0xee
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x0b
,
(
char
)
0x76
,
(
char
)
0x69
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x6f
,
(
char
)
0x43
,
(
char
)
0x6f
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x63
,
(
char
)
0x73
,
(
char
)
0x00
,
(
char
)
0x40
,
(
char
)
0x6f
,
(
char
)
0x80
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0xC3
,
/*next chunk.*/
(
char
)
0x0d
,
(
char
)
0x76
,
(
char
)
0x69
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x6f
,
(
char
)
0x46
,
(
char
)
0x75
,
(
char
)
0x6e
,
(
char
)
0x63
,
(
char
)
0x74
,
(
char
)
0x69
,
(
char
)
0x6f
,
(
char
)
0x6e
,
(
char
)
0x00
,
(
char
)
0x3f
,
(
char
)
0xf0
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x07
,
(
char
)
0x70
,
(
char
)
0x61
,
(
char
)
0x67
,
(
char
)
0x65
,
(
char
)
0x55
,
(
char
)
0x72
,
(
char
)
0x6c
,
(
char
)
0x02
,
(
char
)
0x00
,
(
char
)
0x62
,
(
char
)
0x68
,
(
char
)
0x74
,
(
char
)
0x74
,
(
char
)
0x70
,
(
char
)
0x3a
,
(
char
)
0x2f
,
(
char
)
0x2f
,
(
char
)
0x77
,
(
char
)
0x77
,
(
char
)
0x77
,
(
char
)
0x2e
,
(
char
)
0x6f
,
(
char
)
0x73
,
(
char
)
0x73
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x2e
,
(
char
)
0x6e
,
(
char
)
0x65
,
(
char
)
0x74
,
(
char
)
0x3a
,
(
char
)
0x38
,
(
char
)
0x30
,
(
char
)
0x38
,
(
char
)
0x35
,
(
char
)
0x2f
,
(
char
)
0x70
,
(
char
)
0x6c
,
(
char
)
0x61
,
(
char
)
0x79
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x2f
,
(
char
)
0x73
,
(
char
)
0x72
,
(
char
)
0x73
,
(
char
)
0x5f
,
(
char
)
0x70
,
(
char
)
0x6c
,
(
char
)
0x61
,
(
char
)
0x79
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x2e
,
(
char
)
0x68
,
(
char
)
0x74
,
(
char
)
0x6d
,
(
char
)
0x6c
,
(
char
)
0x3f
,
(
char
)
0x76
,
(
char
)
0x68
,
(
char
)
0x6f
,
(
char
)
0x73
,
(
char
)
0x74
,
(
char
)
0x3d
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x76
,
(
char
)
0x26
,
(
char
)
0x73
,
(
char
)
0x74
,
(
char
)
0x72
,
(
char
)
0x65
,
(
char
)
0x61
,
(
char
)
0x6d
,
(
char
)
0x3d
,
(
char
)
0x6c
,
(
char
)
0x69
,
(
char
)
0x76
,
(
char
)
0x65
,
(
char
)
0x73
,
(
char
)
0x74
,
(
char
)
0x72
,
(
char
)
0x65
,
(
char
)
0x61
,
(
char
)
0x6d
,
(
char
)
0x26
,
(
char
)
0x73
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x76
,
(
char
)
0x65
,
(
char
)
0x72
,
(
char
)
0x3d
,
(
char
)
0x64
,
(
char
)
0x65
,
(
char
)
0x76
,
(
char
)
0x26
,
(
char
)
0x70
,
(
char
)
0x6f
,
(
char
)
0x72
,
(
char
)
0x74
,
(
char
)
0xC3
,
/*next chunk.*/
(
char
)
0x3d
,
(
char
)
0x31
,
(
char
)
0x39
,
(
char
)
0x33
,
(
char
)
0x35
,
(
char
)
0x00
,
(
char
)
0x0e
,
(
char
)
0x6f
,
(
char
)
0x62
,
(
char
)
0x6a
,
(
char
)
0x65
,
(
char
)
0x63
,
(
char
)
0x74
,
(
char
)
0x45
,
(
char
)
0x6e
,
(
char
)
0x63
,
(
char
)
0x6f
,
(
char
)
0x64
,
(
char
)
0x69
,
(
char
)
0x6e
,
(
char
)
0x67
,
(
char
)
0x00
,
(
char
)
0x40
,
(
char
)
0x08
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x09
};
bio
.
in_buffer
.
append
(
data
,
sizeof
(
data
));
SrsMessage
*
msg
=
NULL
;
ASSERT_TRUE
(
ERROR_SUCCESS
==
proto
.
recv_message
(
&
msg
));
SrsAutoFree
(
SrsMessage
,
msg
);
SrsPacket
*
pkt
=
NULL
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
proto
.
decode_message
(
msg
,
&
pkt
));
SrsAutoFree
(
SrsPacket
,
pkt
);
SrsConnectAppPacket
*
spkt
=
dynamic_cast
<
SrsConnectAppPacket
*>
(
pkt
);
ASSERT_TRUE
(
NULL
!=
spkt
);
}
// for librtmp, if ping, it will send a fresh stream with fmt=1,
// 0x42 where: fmt=1, cid=2, protocol contorl user-control message
// 0x00 0x00 0x00 where: timestamp=0
// 0x00 0x00 0x06 where: payload_length=6
// 0x04 where: message_type=4(protocol control user-control message)
// 0x00 0x06 where: event Ping(0x06)
// 0x00 0x00 0x0d 0x0f where: event data 4bytes ping timestamp.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/98
VOID
TEST
(
ProtocolStackTest
,
ProtocolRecvMessageBug98
)
{
MockBufferIO
bio
;
SrsProtocol
proto
(
&
bio
);
// packet is SrsConnectAppPacket
char
data
[]
=
{
(
char
)
0x42
,
// 1bytes chunk header
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x00
,
// timestamp=0
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x06
,
// payload_length=6
(
char
)
0x04
,
// message_type=4(protocol control user-control message)
(
char
)
0x00
,
(
char
)
0x06
,
// event Ping(0x06)
(
char
)
0x00
,
(
char
)
0x00
,
(
char
)
0x0d
,
(
char
)
0x0f
// event data 4bytes ping timestamp.
};
bio
.
in_buffer
.
append
(
data
,
sizeof
(
data
));
SrsMessage
*
msg
=
NULL
;
ASSERT_TRUE
(
ERROR_SUCCESS
==
proto
.
recv_message
(
&
msg
));
SrsAutoFree
(
SrsMessage
,
msg
);
SrsPacket
*
pkt
=
NULL
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
proto
.
decode_message
(
msg
,
&
pkt
));
SrsAutoFree
(
SrsPacket
,
pkt
);
SrsUserControlPacket
*
spkt
=
dynamic_cast
<
SrsUserControlPacket
*>
(
pkt
);
ASSERT_TRUE
(
NULL
!=
spkt
);
EXPECT_EQ
(
SrcPCUCPingRequest
,
spkt
->
event_type
);
EXPECT_EQ
(
0x0d0f
,
spkt
->
event_data
);
}
...
...
请
注册
或
登录
后发表评论