winlin

for #730, refine code to decode the acknowledge message

@@ -5017,6 +5017,22 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket() @@ -5017,6 +5017,22 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket()
5017 { 5017 {
5018 } 5018 }
5019 5019
  5020 +int SrsAcknowledgementPacket::decode(SrsBuffer* stream)
  5021 +{
  5022 + int ret = ERROR_SUCCESS;
  5023 +
  5024 + if (!stream->require(4)) {
  5025 + ret = ERROR_RTMP_MESSAGE_DECODE;
  5026 + srs_error("decode acknowledgement failed. ret=%d", ret);
  5027 + return ret;
  5028 + }
  5029 +
  5030 + sequence_number = stream->read_4bytes();
  5031 + srs_info("decode acknowledgement success");
  5032 +
  5033 + return ret;
  5034 +}
  5035 +
5020 int SrsAcknowledgementPacket::get_prefer_cid() 5036 int SrsAcknowledgementPacket::get_prefer_cid()
5021 { 5037 {
5022 return RTMP_CID_ProtocolControl; 5038 return RTMP_CID_ProtocolControl;
@@ -1847,6 +1847,9 @@ public: @@ -1847,6 +1847,9 @@ public:
1847 public: 1847 public:
1848 SrsAcknowledgementPacket(); 1848 SrsAcknowledgementPacket();
1849 virtual ~SrsAcknowledgementPacket(); 1849 virtual ~SrsAcknowledgementPacket();
  1850 +// decode functions for concrete packet to override.
  1851 +public:
  1852 + virtual int decode(SrsBuffer* stream);
1850 // encode functions for concrete packet to override. 1853 // encode functions for concrete packet to override.
1851 public: 1854 public:
1852 virtual int get_prefer_cid(); 1855 virtual int get_prefer_cid();
@@ -31,12 +31,12 @@ using namespace std; @@ -31,12 +31,12 @@ using namespace std;
31 VOID TEST(CoreAutoFreeTest, Free) 31 VOID TEST(CoreAutoFreeTest, Free)
32 { 32 {
33 char* data = new char[32]; 33 char* data = new char[32];
34 - srs_freep(data); 34 + srs_freepa(data);
35 EXPECT_TRUE(data == NULL); 35 EXPECT_TRUE(data == NULL);
36 36
37 if (true) { 37 if (true) {
38 data = new char[32]; 38 data = new char[32];
39 - SrsAutoFree(char, data); 39 + SrsAutoFreeA(char, data);
40 } 40 }
41 EXPECT_TRUE(data == NULL); 41 EXPECT_TRUE(data == NULL);
42 } 42 }