rename base message to ISrsMessage

pull/133/head
winlin 11 years ago
parent d8a99dde52
commit 52a454c41b

@ -320,12 +320,12 @@ int SrsProtocol::recv_message(SrsCommonMessage** pmsg)
return ret;
}
int SrsProtocol::send_message(SrsOutputableMessage* msg)
int SrsProtocol::send_message(ISrsMessage* msg)
{
int ret = ERROR_SUCCESS;
// free msg whatever return value.
SrsAutoFree(SrsOutputableMessage, msg, false);
SrsAutoFree(ISrsMessage, msg, false);
if ((ret = msg->encode_packet()) != ERROR_SUCCESS) {
srs_error("encode packet to message payload failed. ret=%d", ret);
@ -479,10 +479,15 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg)
return ret;
}
int SrsProtocol::on_send_message(SrsOutputableMessage* msg)
int SrsProtocol::on_send_message(ISrsMessage* msg)
{
int ret = ERROR_SUCCESS;
if (!msg->can_decode()) {
srs_verbose("ignore the un-decodable message.");
return ret;
}
SrsCommonMessage* common_msg = dynamic_cast<SrsCommonMessage*>(msg);
if (!msg) {
srs_verbose("ignore the shared ptr message.");
@ -927,18 +932,18 @@ SrsChunkStream::~SrsChunkStream()
srs_freep(msg);
}
SrsOutputableMessage::SrsOutputableMessage()
ISrsMessage::ISrsMessage()
{
payload = NULL;
size = 0;
}
SrsOutputableMessage::~SrsOutputableMessage()
ISrsMessage::~ISrsMessage()
{
free_payload();
}
void SrsOutputableMessage::free_payload()
void ISrsMessage::free_payload()
{
srs_freepa(payload);
}
@ -955,6 +960,11 @@ SrsCommonMessage::~SrsCommonMessage()
srs_freep(stream);
}
bool SrsCommonMessage::can_decode()
{
return true;
}
int SrsCommonMessage::decode_packet()
{
int ret = ERROR_SUCCESS;
@ -1145,6 +1155,11 @@ void SrsSharedPtrMessage::free_payload()
}
}
bool SrsSharedPtrMessage::can_decode()
{
return true;
}
int SrsSharedPtrMessage::initialize(SrsMessageHeader* header, char* payload, int size, int perfer_cid)
{
int ret = ERROR_SUCCESS;

@ -47,7 +47,7 @@ class SrsChunkStream;
class SrsAmf0Object;
class SrsAmf0Null;
class SrsAmf0Undefined;
class SrsOutputableMessage;
class ISrsMessage;
// convert class name to string.
#define CLASS_NAME_STRING(className) #className
@ -112,7 +112,7 @@ public:
* then sendout over socket.
* @msg this method will free it whatever return value.
*/
virtual int send_message(SrsOutputableMessage* msg);
virtual int send_message(ISrsMessage* msg);
private:
/**
* when recv message, update the context.
@ -121,7 +121,7 @@ private:
/**
* when message sentout, update the context.
*/
virtual int on_send_message(SrsOutputableMessage* msg);
virtual int on_send_message(ISrsMessage* msg);
/**
* try to recv interlaced message from peer,
* return error if error occur and nerver set the pmsg,
@ -235,7 +235,7 @@ public:
/**
* message to output.
*/
class SrsOutputableMessage
class ISrsMessage
{
// 4.1. Message Header
public:
@ -251,10 +251,16 @@ public:
int32_t size;
int8_t* payload;
public:
SrsOutputableMessage();
virtual ~SrsOutputableMessage();
ISrsMessage();
virtual ~ISrsMessage();
protected:
virtual void free_payload();
public:
/**
* whether message canbe decoded.
* only update the context when message canbe decoded.
*/
virtual bool can_decode() = 0;
/**
* encode functions.
*/
@ -274,10 +280,10 @@ public:
* common RTMP message defines in rtmp.part2.Message-Formats.pdf.
* cannbe parse and decode.
*/
class SrsCommonMessage : public SrsOutputableMessage
class SrsCommonMessage : public ISrsMessage
{
private:
typedef SrsOutputableMessage super;
typedef ISrsMessage super;
// decoded message payload.
private:
SrsStream* stream;
@ -285,6 +291,8 @@ private:
public:
SrsCommonMessage();
virtual ~SrsCommonMessage();
public:
virtual bool can_decode();
/**
* decode functions.
*/
@ -324,10 +332,10 @@ public:
* for audio/video/data message that need less memory copy.
* and only for output.
*/
class SrsSharedPtrMessage : public SrsOutputableMessage
class SrsSharedPtrMessage : public ISrsMessage
{
private:
typedef SrsOutputableMessage super;
typedef ISrsMessage super;
private:
struct SrsSharedPtr
{
@ -345,6 +353,8 @@ public:
virtual ~SrsSharedPtrMessage();
protected:
virtual void free_payload();
public:
virtual bool can_decode();
public:
/**
* set the shared payload.

Loading…
Cancel
Save