1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

finish utest of protocol stack. 0.9.156

This commit is contained in:
winlin 2014-07-11 18:08:34 +08:00
parent 8e27df4cf7
commit 9556790a5e
14 changed files with 730 additions and 45 deletions

View file

@ -764,8 +764,8 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id)
// to message
SrsMessage* msg = new SrsCommonMessage();
msg->payload = (int8_t*)payload;
msg->size = (int32_t)size;
msg->payload = payload;
msg->size = size;
msg->header.payload_length = size;
msg->header.message_type = packet->get_message_type();
@ -1297,7 +1297,7 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, int bh_size, int mh
// create msg payload if not initialized
if (!chunk->msg->payload) {
chunk->msg->payload = new int8_t[chunk->header.payload_length];
chunk->msg->payload = new char[chunk->header.payload_length];
memset(chunk->msg->payload, 0, chunk->header.payload_length);
srs_verbose("create empty payload for RTMP message. size=%d", chunk->header.payload_length);
}
@ -1708,7 +1708,7 @@ int SrsSharedPtrMessage::create(SrsMessageHeader* pheader, char* payload, int si
ptr->size = size;
// message can access it.
SrsMessage::payload = (int8_t*)ptr->payload;
SrsMessage::payload = ptr->payload;
SrsMessage::size = ptr->size;
return ret;
@ -1731,7 +1731,7 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy()
copy->ptr = ptr;
ptr->shared_count++;
copy->payload = (int8_t*)ptr->payload;
copy->payload = ptr->payload;
copy->size = ptr->size;
return copy;
@ -3708,7 +3708,7 @@ int SrsSetChunkSizePacket::encode_packet(SrsStream* stream)
SrsSetPeerBandwidthPacket::SrsSetPeerBandwidthPacket()
{
bandwidth = 0;
type = 2;
type = SrsPeerBandwidthDynamic;
}
SrsSetPeerBandwidthPacket::~SrsSetPeerBandwidthPacket()
@ -3824,7 +3824,7 @@ int SrsUserControlPacket::encode_packet(SrsStream* stream)
// when event type is set buffer length,
// write the extra buffer length.
if (event_type == SrcPCUCSetBufferLength) {
stream->write_2bytes(extra_data);
stream->write_4bytes(extra_data);
srs_verbose("user control message, buffer_length=%d", extra_data);
}

View file

@ -388,14 +388,14 @@ public:
* size <= header.payload_length
* for the payload maybe sent in multiple chunks.
*/
int32_t size;
int 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;
char* payload;
protected:
SrsMessage();
public:
@ -1023,6 +1023,7 @@ protected:
virtual int get_size();
virtual int encode_packet(SrsStream* stream);
};
/**
* response for SrsPlayPacket.
* @remark, user must set the stream_id in header.
@ -1352,6 +1353,16 @@ protected:
virtual int encode_packet(SrsStream* stream);
};
// 5.6. Set Peer Bandwidth (6)
enum SrsPeerBandwidthType
{
// The sender can mark this message hard (0), soft (1), or dynamic (2)
// using the Limit type field.
SrsPeerBandwidthHard = 0,
SrsPeerBandwidthSoft = 1,
SrsPeerBandwidthDynamic = 2,
};
/**
* 5.6. Set Peer Bandwidth (6)
* The client or the server sends this message to update the output
@ -1361,6 +1372,7 @@ class SrsSetPeerBandwidthPacket : public SrsPacket
{
public:
int32_t bandwidth;
// @see: SrsPeerBandwidthType
int8_t type;
public:
SrsSetPeerBandwidthPacket();