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

implements the proxy for edge publish mode

This commit is contained in:
winlin 2014-04-27 11:11:15 +08:00
parent ec96072472
commit 79c9c6dcb7
7 changed files with 187 additions and 65 deletions

View file

@ -652,11 +652,17 @@ int SrsProtocol::on_send_message(ISrsMessage* msg)
}
SrsCommonMessage* common_msg = dynamic_cast<SrsCommonMessage*>(msg);
if (!msg) {
if (!common_msg) {
srs_verbose("ignore the shared ptr message.");
return ret;
}
// for proxy, the common msg is not decoded, ignore.
if (!common_msg->has_packet()) {
srs_verbose("ignore the proxy common message.");
return ret;
}
srs_assert(common_msg != NULL);
switch (common_msg->header.message_type) {
@ -1459,6 +1465,11 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol)
return ret;
}
bool SrsCommonMessage::has_packet()
{
return packet != NULL;
}
SrsPacket* SrsCommonMessage::get_packet()
{
if (!packet) {
@ -1501,6 +1512,14 @@ int SrsCommonMessage::encode_packet()
{
int ret = ERROR_SUCCESS;
// sometimes, for example, the edge proxy,
// the payload is not decoded, so directly sent out.
if (payload != NULL) {
header.payload_length = size;
return ret;
}
// encode packet to payload and size.
if (packet == NULL) {
srs_warn("packet is empty, send out empty message.");
return ret;

View file

@ -352,6 +352,10 @@ public:
// TODO: use protocol to decode it.
virtual int decode_packet(SrsProtocol* protocol);
/**
* whether msg has decoded packet.
*/
virtual bool has_packet();
/**
* get the decoded packet which decoded by decode_packet().
* @remark, user never free the pkt, the message will auto free it.
*/