mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
decode the amf0 command message: connect.
This commit is contained in:
parent
63bf9e112d
commit
a638ebd1c6
2 changed files with 16 additions and 0 deletions
|
@ -55,22 +55,28 @@ std::string srs_amf0_read_string(SrsStream* stream)
|
||||||
|
|
||||||
// marker
|
// marker
|
||||||
if (!stream->require(1)) {
|
if (!stream->require(1)) {
|
||||||
|
srs_warn("amf0 read string marker failed");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char marker = stream->read_char();
|
char marker = stream->read_char();
|
||||||
if (marker != RTMP_AMF0_String) {
|
if (marker != RTMP_AMF0_String) {
|
||||||
|
srs_warn("amf0 check string marker failed. marker=%#x, required=%#x", marker, RTMP_AMF0_String);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
srs_verbose("amf0 read string marker success");
|
||||||
|
|
||||||
// len
|
// len
|
||||||
if (!stream->require(2)) {
|
if (!stream->require(2)) {
|
||||||
|
srs_warn("amf0 read string length failed");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
int16_t len = stream->read_2bytes();
|
int16_t len = stream->read_2bytes();
|
||||||
|
srs_verbose("amf0 read string length success. len=%d", len);
|
||||||
|
|
||||||
// data
|
// data
|
||||||
if (!stream->require(len)) {
|
if (!stream->require(len)) {
|
||||||
|
srs_warn("amf0 read string data failed");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
str = stream->read_string(len);
|
str = stream->read_string(len);
|
||||||
|
@ -85,6 +91,7 @@ std::string srs_amf0_read_string(SrsStream* stream)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
srs_verbose("amf0 read string data success. str=%s", str.c_str());
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,17 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool require(int required_size);
|
virtual bool require(int required_size);
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* get 1bytes char from stream.
|
||||||
|
*/
|
||||||
virtual char read_char();
|
virtual char read_char();
|
||||||
|
/**
|
||||||
|
* get 2bytes int from stream.
|
||||||
|
*/
|
||||||
virtual int16_t read_2bytes();
|
virtual int16_t read_2bytes();
|
||||||
|
/**
|
||||||
|
* get string from stream, length specifies by param len.
|
||||||
|
*/
|
||||||
virtual std::string read_string(int len);
|
virtual std::string read_string(int len);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue