winlin

decode the amf0 command message: connect.

@@ -55,22 +55,28 @@ std::string srs_amf0_read_string(SrsStream* stream) @@ -55,22 +55,28 @@ std::string srs_amf0_read_string(SrsStream* stream)
55 55
56 // marker 56 // marker
57 if (!stream->require(1)) { 57 if (!stream->require(1)) {
  58 + srs_warn("amf0 read string marker failed");
58 return str; 59 return str;
59 } 60 }
60 61
61 char marker = stream->read_char(); 62 char marker = stream->read_char();
62 if (marker != RTMP_AMF0_String) { 63 if (marker != RTMP_AMF0_String) {
  64 + srs_warn("amf0 check string marker failed. marker=%#x, required=%#x", marker, RTMP_AMF0_String);
63 return str; 65 return str;
64 } 66 }
  67 + srs_verbose("amf0 read string marker success");
65 68
66 // len 69 // len
67 if (!stream->require(2)) { 70 if (!stream->require(2)) {
  71 + srs_warn("amf0 read string length failed");
68 return str; 72 return str;
69 } 73 }
70 int16_t len = stream->read_2bytes(); 74 int16_t len = stream->read_2bytes();
  75 + srs_verbose("amf0 read string length success. len=%d", len);
71 76
72 // data 77 // data
73 if (!stream->require(len)) { 78 if (!stream->require(len)) {
  79 + srs_warn("amf0 read string data failed");
74 return str; 80 return str;
75 } 81 }
76 str = stream->read_string(len); 82 str = stream->read_string(len);
@@ -85,6 +91,7 @@ std::string srs_amf0_read_string(SrsStream* stream) @@ -85,6 +91,7 @@ std::string srs_amf0_read_string(SrsStream* stream)
85 return ""; 91 return "";
86 } 92 }
87 } 93 }
  94 + srs_verbose("amf0 read string data success. str=%s", str.c_str());
88 95
89 return str; 96 return str;
90 } 97 }
@@ -66,8 +66,17 @@ public: @@ -66,8 +66,17 @@ public:
66 */ 66 */
67 virtual bool require(int required_size); 67 virtual bool require(int required_size);
68 public: 68 public:
  69 + /**
  70 + * get 1bytes char from stream.
  71 + */
69 virtual char read_char(); 72 virtual char read_char();
  73 + /**
  74 + * get 2bytes int from stream.
  75 + */
70 virtual int16_t read_2bytes(); 76 virtual int16_t read_2bytes();
  77 + /**
  78 + * get string from stream, length specifies by param len.
  79 + */
71 virtual std::string read_string(int len); 80 virtual std::string read_string(int len);
72 }; 81 };
73 82