Skip to content

Commit

Permalink
for #730, refine code to decode the acknowledge message
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 6, 2017
1 parent 759c84a commit dc1f227
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions trunk/src/protocol/srs_rtmp_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5017,6 +5017,22 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket()
{
}

int SrsAcknowledgementPacket::decode(SrsBuffer* stream)
{
int ret = ERROR_SUCCESS;

if (!stream->require(4)) {
ret = ERROR_RTMP_MESSAGE_DECODE;
srs_error("decode acknowledgement failed. ret=%d", ret);
return ret;
}

sequence_number = stream->read_4bytes();
srs_info("decode acknowledgement success");

return ret;
}

int SrsAcknowledgementPacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
Expand Down
3 changes: 3 additions & 0 deletions trunk/src/protocol/srs_rtmp_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,9 @@ class SrsAcknowledgementPacket : public SrsPacket
public:
SrsAcknowledgementPacket();
virtual ~SrsAcknowledgementPacket();
// decode functions for concrete packet to override.
public:
virtual int decode(SrsBuffer* stream);
// encode functions for concrete packet to override.
public:
virtual int get_prefer_cid();
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/utest/srs_utest_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ using namespace std;
VOID TEST(CoreAutoFreeTest, Free)
{
char* data = new char[32];
srs_freep(data);
srs_freepa(data);
EXPECT_TRUE(data == NULL);

if (true) {
data = new char[32];
SrsAutoFree(char, data);
SrsAutoFreeA(char, data);
}
EXPECT_TRUE(data == NULL);
}
Expand Down

0 comments on commit dc1f227

Please sign in to comment.