mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
Cover protocol stack RTMP. 3.0.63
This commit is contained in:
parent
4e8acf80cb
commit
c8bb7e71c9
1 changed files with 47 additions and 0 deletions
|
@ -445,3 +445,50 @@ VOID TEST(ProtoStackTest, OnDecodeMessages)
|
|||
}
|
||||
}
|
||||
|
||||
SrsCommonMessage* _mock_create_message(char* bytes, int size, int stream_id)
|
||||
{
|
||||
SrsCommonMessage* msg = new SrsCommonMessage();
|
||||
msg->header.initialize_amf0_script(size, stream_id);
|
||||
msg->create_payload(size);
|
||||
memcpy(msg->payload, bytes, size);
|
||||
msg->size = size;
|
||||
return msg;
|
||||
}
|
||||
|
||||
VOID TEST(ProtoStackTest, OnDecodeMessages2)
|
||||
{
|
||||
srs_error_t err;
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's', 0x00, 0,0,0,0,0,0,0,0, 0x03,0,0,9};
|
||||
SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1);
|
||||
SrsAutoFree(SrsCommonMessage, msg);
|
||||
msg->header.message_type = RTMP_MSG_AMF3CommandMessage;
|
||||
|
||||
SrsPacket* pkt;
|
||||
SrsAutoFree(SrsPacket, pkt);
|
||||
HELPER_EXPECT_SUCCESS(p.decode_message(msg, &pkt));
|
||||
|
||||
SrsCallPacket* call = (SrsCallPacket*)pkt;
|
||||
EXPECT_STREQ("s", call->command_name.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's'};
|
||||
SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1);
|
||||
SrsAutoFree(SrsCommonMessage, msg);
|
||||
msg->header.message_type = RTMP_MSG_AMF3CommandMessage;
|
||||
|
||||
SrsPacket* pkt;
|
||||
SrsAutoFree(SrsPacket, pkt);
|
||||
|
||||
HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue