mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
finish basic protocol utest, fix the bug of fmt11 length error.
This commit is contained in:
parent
2ddd805297
commit
d86e07b745
4 changed files with 3003 additions and 83 deletions
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "9"
|
#define VERSION_MINOR "9"
|
||||||
#define VERSION_REVISION "154"
|
#define VERSION_REVISION "155"
|
||||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
|
@ -1013,6 +1013,11 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
|
||||||
* 3bytes: payload length, fmt=0,1
|
* 3bytes: payload length, fmt=0,1
|
||||||
* 1bytes: message type, fmt=0,1
|
* 1bytes: message type, fmt=0,1
|
||||||
* 4bytes: stream id, fmt=0
|
* 4bytes: stream id, fmt=0
|
||||||
|
* where:
|
||||||
|
* fmt=0, 0x0X
|
||||||
|
* fmt=1, 0x4X
|
||||||
|
* fmt=2, 0x8X
|
||||||
|
* fmt=3, 0xCX
|
||||||
*/
|
*/
|
||||||
// see also: ngx_rtmp_recv
|
// see also: ngx_rtmp_recv
|
||||||
if (fmt <= RTMP_FMT_TYPE2) {
|
if (fmt <= RTMP_FMT_TYPE2) {
|
||||||
|
@ -1060,21 +1065,25 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt <= RTMP_FMT_TYPE1) {
|
if (fmt <= RTMP_FMT_TYPE1) {
|
||||||
pp = (char*)&chunk->header.payload_length;
|
int32_t payload_length = 0;
|
||||||
|
pp = (char*)&payload_length;
|
||||||
pp[2] = *p++;
|
pp[2] = *p++;
|
||||||
pp[1] = *p++;
|
pp[1] = *p++;
|
||||||
pp[0] = *p++;
|
pp[0] = *p++;
|
||||||
pp[3] = 0;
|
pp[3] = 0;
|
||||||
|
|
||||||
// if msg exists in cache, the size must not changed.
|
// if msg exists in cache, the size must not changed.
|
||||||
if (chunk->msg->size > 0 && chunk->msg->size != chunk->header.payload_length) {
|
// always use the actual msg size, for the cache payload length can changed,
|
||||||
|
// for the fmt type1(stream_id not changed), user can change the payload length.
|
||||||
|
if (chunk->msg->size > 0 && chunk->header.payload_length != payload_length) {
|
||||||
ret = ERROR_RTMP_PACKET_SIZE;
|
ret = ERROR_RTMP_PACKET_SIZE;
|
||||||
srs_error("msg exists in chunk cache, "
|
srs_error("msg exists in chunk cache, "
|
||||||
"size=%d cannot change to %d, ret=%d",
|
"size=%d cannot change to %d, ret=%d",
|
||||||
chunk->msg->size, chunk->header.payload_length, ret);
|
chunk->header.payload_length, payload_length, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunk->header.payload_length = payload_length;
|
||||||
chunk->header.message_type = *p++;
|
chunk->header.message_type = *p++;
|
||||||
|
|
||||||
if (fmt == RTMP_FMT_TYPE0) {
|
if (fmt == RTMP_FMT_TYPE0) {
|
||||||
|
|
|
@ -256,23 +256,27 @@ class SrsMessageHeader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* One byte field to represent the message type. A range of type IDs
|
* 3bytes.
|
||||||
* (1-7) are reserved for protocol control messages.
|
|
||||||
*/
|
|
||||||
int8_t message_type;
|
|
||||||
/**
|
|
||||||
* Three-byte field that represents the size of the payload in bytes.
|
|
||||||
* It is set in big-endian format.
|
|
||||||
*/
|
|
||||||
int32_t payload_length;
|
|
||||||
/**
|
|
||||||
* Three-byte field that contains a timestamp delta of the message.
|
* Three-byte field that contains a timestamp delta of the message.
|
||||||
* The 4 bytes are packed in the big-endian order.
|
* The 4 bytes are packed in the big-endian order.
|
||||||
* @remark, only used for decoding message from chunk stream.
|
* @remark, only used for decoding message from chunk stream.
|
||||||
*/
|
*/
|
||||||
int32_t timestamp_delta;
|
int32_t timestamp_delta;
|
||||||
/**
|
/**
|
||||||
* Three-byte field that identifies the stream of the message. These
|
* 3bytes.
|
||||||
|
* Three-byte field that represents the size of the payload in bytes.
|
||||||
|
* It is set in big-endian format.
|
||||||
|
*/
|
||||||
|
int32_t payload_length;
|
||||||
|
/**
|
||||||
|
* 1byte.
|
||||||
|
* One byte field to represent the message type. A range of type IDs
|
||||||
|
* (1-7) are reserved for protocol control messages.
|
||||||
|
*/
|
||||||
|
int8_t message_type;
|
||||||
|
/**
|
||||||
|
* 4bytes.
|
||||||
|
* Four-byte field that identifies the stream of the message. These
|
||||||
* bytes are set in big-endian format.
|
* bytes are set in big-endian format.
|
||||||
*/
|
*/
|
||||||
int32_t stream_id;
|
int32_t stream_id;
|
||||||
|
@ -379,12 +383,17 @@ public:
|
||||||
// 4.2. Message Payload
|
// 4.2. Message Payload
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The other part which is the payload is the actual data that is
|
* current message parsed size,
|
||||||
* contained in the message. For example, it could be some audio samples
|
* size <= header.payload_length
|
||||||
* or compressed video data. The payload format and interpretation are
|
* for the payload maybe sent in multiple chunks.
|
||||||
* beyond the scope of this document.
|
|
||||||
*/
|
*/
|
||||||
int32_t size;
|
int32_t size;
|
||||||
|
/**
|
||||||
|
* the payload of message, the SrsMessage never know about the detail of payload,
|
||||||
|
* user must use SrsProtocol.decode_message to get concrete packet.
|
||||||
|
* @remark, not all message payload can be decoded to packet. for example,
|
||||||
|
* video/audio packet use raw bytes, no video/audio packet.
|
||||||
|
*/
|
||||||
int8_t* payload;
|
int8_t* payload;
|
||||||
protected:
|
protected:
|
||||||
SrsMessage();
|
SrsMessage();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue