winlin

decode the amf0 command message: connect.

... ... @@ -55,22 +55,28 @@ std::string srs_amf0_read_string(SrsStream* stream)
// marker
if (!stream->require(1)) {
srs_warn("amf0 read string marker failed");
return str;
}
char marker = stream->read_char();
if (marker != RTMP_AMF0_String) {
srs_warn("amf0 check string marker failed. marker=%#x, required=%#x", marker, RTMP_AMF0_String);
return str;
}
srs_verbose("amf0 read string marker success");
// len
if (!stream->require(2)) {
srs_warn("amf0 read string length failed");
return str;
}
int16_t len = stream->read_2bytes();
srs_verbose("amf0 read string length success. len=%d", len);
// data
if (!stream->require(len)) {
srs_warn("amf0 read string data failed");
return str;
}
str = stream->read_string(len);
... ... @@ -85,6 +91,7 @@ std::string srs_amf0_read_string(SrsStream* stream)
return "";
}
}
srs_verbose("amf0 read string data success. str=%s", str.c_str());
return str;
}
... ...
... ... @@ -66,8 +66,17 @@ public:
*/
virtual bool require(int required_size);
public:
/**
* get 1bytes char from stream.
*/
virtual char read_char();
/**
* get 2bytes int from stream.
*/
virtual int16_t read_2bytes();
/**
* get string from stream, length specifies by param len.
*/
virtual std::string read_string(int len);
};
... ...