mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	for #155, fix all warnings for mac.
This commit is contained in:
		
							parent
							
								
									51967afb52
								
							
						
					
					
						commit
						a15ce1147f
					
				
					 12 changed files with 148 additions and 148 deletions
				
			
		| 
						 | 
				
			
			@ -534,6 +534,85 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy()
 | 
			
		|||
    return copy;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsPacket::SrsPacket()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsPacket::~SrsPacket()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::encode(int& psize, char*& ppayload)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    int size = get_size();
 | 
			
		||||
    char* payload = NULL;
 | 
			
		||||
    
 | 
			
		||||
    SrsStream stream;
 | 
			
		||||
    
 | 
			
		||||
    if (size > 0) {
 | 
			
		||||
        payload = new char[size];
 | 
			
		||||
        
 | 
			
		||||
        if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) {
 | 
			
		||||
            srs_error("initialize the stream failed. ret=%d", ret);
 | 
			
		||||
            srs_freep(payload);
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if ((ret = encode_packet(&stream)) != ERROR_SUCCESS) {
 | 
			
		||||
        srs_error("encode the packet failed. ret=%d", ret);
 | 
			
		||||
        srs_freep(payload);
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    psize = size;
 | 
			
		||||
    ppayload = payload;
 | 
			
		||||
    srs_verbose("encode the packet success. size=%d", size);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::decode(SrsStream* stream)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    srs_assert(stream != NULL);
 | 
			
		||||
    
 | 
			
		||||
    ret = ERROR_SYSTEM_PACKET_INVALID;
 | 
			
		||||
    srs_error("current packet is not support to decode. ret=%d", ret);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_prefer_cid()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_message_type()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_size()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::encode_packet(SrsStream* stream)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    srs_assert(stream != NULL);
 | 
			
		||||
    
 | 
			
		||||
    ret = ERROR_SYSTEM_PACKET_INVALID;
 | 
			
		||||
    srs_error("current packet is not support to encode. ret=%d", ret);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsProtocol::AckWindowSize::AckWindowSize()
 | 
			
		||||
{
 | 
			
		||||
    ack_window_size = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -2020,85 +2099,6 @@ SrsChunkStream::~SrsChunkStream()
 | 
			
		|||
    srs_freep(msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsPacket::SrsPacket()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsPacket::~SrsPacket()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::encode(int& psize, char*& ppayload)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    int size = get_size();
 | 
			
		||||
    char* payload = NULL;
 | 
			
		||||
    
 | 
			
		||||
    SrsStream stream;
 | 
			
		||||
    
 | 
			
		||||
    if (size > 0) {
 | 
			
		||||
        payload = new char[size];
 | 
			
		||||
        
 | 
			
		||||
        if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) {
 | 
			
		||||
            srs_error("initialize the stream failed. ret=%d", ret);
 | 
			
		||||
            srs_freep(payload);
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if ((ret = encode_packet(&stream)) != ERROR_SUCCESS) {
 | 
			
		||||
        srs_error("encode the packet failed. ret=%d", ret);
 | 
			
		||||
        srs_freep(payload);
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    psize = size;
 | 
			
		||||
    ppayload = payload;
 | 
			
		||||
    srs_verbose("encode the packet success. size=%d", size);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::decode(SrsStream* stream)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    srs_assert(stream != NULL);
 | 
			
		||||
 | 
			
		||||
    ret = ERROR_SYSTEM_PACKET_INVALID;
 | 
			
		||||
    srs_error("current packet is not support to decode. ret=%d", ret);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_prefer_cid()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_message_type()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::get_size()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsPacket::encode_packet(SrsStream* stream)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    srs_assert(stream != NULL);
 | 
			
		||||
 | 
			
		||||
    ret = ERROR_SYSTEM_PACKET_INVALID;
 | 
			
		||||
    srs_error("current packet is not support to encode. ret=%d", ret);
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SrsConnectAppPacket::SrsConnectAppPacket()
 | 
			
		||||
{
 | 
			
		||||
    command_name = RTMP_AMF0_COMMAND_CONNECT;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -317,6 +317,60 @@ public:
 | 
			
		|||
    virtual SrsSharedPtrMessage* copy();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * the decoded message payload.
 | 
			
		||||
 * @remark we seperate the packet from message,
 | 
			
		||||
 *        for the packet focus on logic and domain data,
 | 
			
		||||
 *        the message bind to the protocol and focus on protocol, such as header.
 | 
			
		||||
 *         we can merge the message and packet, using OOAD hierachy, packet extends from message,
 | 
			
		||||
 *         it's better for me to use components -- the message use the packet as payload.
 | 
			
		||||
 */
 | 
			
		||||
class SrsPacket
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    SrsPacket();
 | 
			
		||||
    virtual ~SrsPacket();
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * the subpacket can override this encode,
 | 
			
		||||
     * for example, video and audio will directly set the payload withou memory copy,
 | 
			
		||||
     * other packet which need to serialize/encode to bytes by override the
 | 
			
		||||
     * get_size and encode_packet.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int encode(int& size, char*& payload);
 | 
			
		||||
    // decode functions for concrete packet to override.
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * subpacket must override to decode packet from stream.
 | 
			
		||||
     * @remark never invoke the super.decode, it always failed.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int decode(SrsStream* stream);
 | 
			
		||||
    // encode functions for concrete packet to override.
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * the cid(chunk id) specifies the chunk to send data over.
 | 
			
		||||
     * generally, each message perfer some cid, for example,
 | 
			
		||||
     * all protocol control messages perfer RTMP_CID_ProtocolControl,
 | 
			
		||||
     * SrsSetWindowAckSizePacket is protocol control message.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int get_prefer_cid();
 | 
			
		||||
    /**
 | 
			
		||||
     * subpacket must override to provide the right message type.
 | 
			
		||||
     * the message type set the RTMP message type in header.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int get_message_type();
 | 
			
		||||
protected:
 | 
			
		||||
    /**
 | 
			
		||||
     * subpacket can override to calc the packet size.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int get_size();
 | 
			
		||||
    /**
 | 
			
		||||
     * subpacket can override to encode the payload to stream.
 | 
			
		||||
     * @remark never invoke the super.encode_packet, it always failed.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int encode_packet(SrsStream* stream);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* the protocol provides the rtmp-message-protocol services,
 | 
			
		||||
* to recv RTMP message from RTMP chunk stream,
 | 
			
		||||
| 
						 | 
				
			
			@ -662,60 +716,6 @@ public:
 | 
			
		|||
    virtual ~SrsChunkStream();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* the decoded message payload.
 | 
			
		||||
* @remark we seperate the packet from message,
 | 
			
		||||
*        for the packet focus on logic and domain data,
 | 
			
		||||
*        the message bind to the protocol and focus on protocol, such as header.
 | 
			
		||||
*         we can merge the message and packet, using OOAD hierachy, packet extends from message,
 | 
			
		||||
*         it's better for me to use components -- the message use the packet as payload.
 | 
			
		||||
*/
 | 
			
		||||
class SrsPacket
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    SrsPacket();
 | 
			
		||||
    virtual ~SrsPacket();
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
    * the subpacket can override this encode,
 | 
			
		||||
    * for example, video and audio will directly set the payload withou memory copy,
 | 
			
		||||
    * other packet which need to serialize/encode to bytes by override the 
 | 
			
		||||
    * get_size and encode_packet.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int encode(int& size, char*& payload);
 | 
			
		||||
// decode functions for concrete packet to override.
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
    * subpacket must override to decode packet from stream.
 | 
			
		||||
    * @remark never invoke the super.decode, it always failed.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int decode(SrsStream* stream);
 | 
			
		||||
// encode functions for concrete packet to override.
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
    * the cid(chunk id) specifies the chunk to send data over.
 | 
			
		||||
    * generally, each message perfer some cid, for example, 
 | 
			
		||||
    * all protocol control messages perfer RTMP_CID_ProtocolControl,
 | 
			
		||||
    * SrsSetWindowAckSizePacket is protocol control message.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int get_prefer_cid();
 | 
			
		||||
    /**
 | 
			
		||||
    * subpacket must override to provide the right message type.
 | 
			
		||||
    * the message type set the RTMP message type in header.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int get_message_type();
 | 
			
		||||
protected:
 | 
			
		||||
    /**
 | 
			
		||||
    * subpacket can override to calc the packet size.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int get_size();
 | 
			
		||||
    /**
 | 
			
		||||
    * subpacket can override to encode the payload to stream.
 | 
			
		||||
    * @remark never invoke the super.encode_packet, it always failed.
 | 
			
		||||
    */
 | 
			
		||||
    virtual int encode_packet(SrsStream* stream);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* 4.1.1. connect
 | 
			
		||||
* The client sends the connect command to the server to request
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue