mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Remove bandwidth check because falsh is disabled. v5.0.52
This commit is contained in:
parent
1630918b0f
commit
937605b18c
16 changed files with 5 additions and 1490 deletions
|
@ -77,37 +77,6 @@ using namespace std;
|
|||
// the same as the timestamp of Type 0 chunk.
|
||||
#define RTMP_FMT_TYPE3 3
|
||||
|
||||
/****************************************************************************
|
||||
*****************************************************************************
|
||||
****************************************************************************/
|
||||
/**
|
||||
* band width check method name, which will be invoked by client.
|
||||
* band width check mothods use SrsBandwidthPacket as its internal packet type,
|
||||
* so ensure you set command name when you use it.
|
||||
*/
|
||||
// server play control
|
||||
#define SRS_BW_CHECK_START_PLAY "onSrsBandCheckStartPlayBytes"
|
||||
#define SRS_BW_CHECK_STARTING_PLAY "onSrsBandCheckStartingPlayBytes"
|
||||
#define SRS_BW_CHECK_STOP_PLAY "onSrsBandCheckStopPlayBytes"
|
||||
#define SRS_BW_CHECK_STOPPED_PLAY "onSrsBandCheckStoppedPlayBytes"
|
||||
|
||||
// server publish control
|
||||
#define SRS_BW_CHECK_START_PUBLISH "onSrsBandCheckStartPublishBytes"
|
||||
#define SRS_BW_CHECK_STARTING_PUBLISH "onSrsBandCheckStartingPublishBytes"
|
||||
#define SRS_BW_CHECK_STOP_PUBLISH "onSrsBandCheckStopPublishBytes"
|
||||
// @remark, flash never send out this packet, for its queue is full.
|
||||
#define SRS_BW_CHECK_STOPPED_PUBLISH "onSrsBandCheckStoppedPublishBytes"
|
||||
|
||||
// EOF control.
|
||||
// the report packet when check finished.
|
||||
#define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished"
|
||||
// @remark, flash never send out this packet, for its queue is full.
|
||||
#define SRS_BW_CHECK_FINAL "finalClientPacket"
|
||||
|
||||
// data packets
|
||||
#define SRS_BW_CHECK_PLAYING "onSrsBandCheckPlaying"
|
||||
#define SRS_BW_CHECK_PUBLISHING "onSrsBandCheckPublishing"
|
||||
|
||||
/****************************************************************************
|
||||
*****************************************************************************
|
||||
****************************************************************************/
|
||||
|
@ -714,42 +683,6 @@ srs_error_t SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsBuffer*
|
|||
} else if (command == SRS_CONSTS_RTMP_ON_METADATA) {
|
||||
*ppacket = packet = new SrsOnMetaDataPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_FINISHED) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_PLAYING) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_PUBLISHING) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STARTING_PLAY) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STARTING_PUBLISH) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_START_PLAY) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_START_PUBLISH) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STOPPED_PLAY) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STOP_PLAY) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STOP_PUBLISH) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_STOPPED_PUBLISH) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == SRS_BW_CHECK_FINAL) {
|
||||
*ppacket = packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == RTMP_AMF0_COMMAND_CLOSE_STREAM) {
|
||||
*ppacket = packet = new SrsCloseStreamPacket();
|
||||
return packet->decode(stream);
|
||||
|
@ -4166,215 +4099,6 @@ srs_error_t SrsOnStatusCallPacket::encode_packet(SrsBuffer* stream)
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsBandwidthPacket::SrsBandwidthPacket()
|
||||
{
|
||||
command_name = RTMP_AMF0_COMMAND_ON_STATUS;
|
||||
transaction_id = 0;
|
||||
args = SrsAmf0Any::null();
|
||||
data = SrsAmf0Any::object();
|
||||
}
|
||||
|
||||
SrsBandwidthPacket::~SrsBandwidthPacket()
|
||||
{
|
||||
srs_freep(args);
|
||||
srs_freep(data);
|
||||
}
|
||||
|
||||
srs_error_t SrsBandwidthPacket::decode(SrsBuffer *stream)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if ((err = srs_amf0_read_string(stream, command_name)) != srs_success) {
|
||||
return srs_error_wrap(err, "command_name");
|
||||
}
|
||||
|
||||
if ((err = srs_amf0_read_number(stream, transaction_id)) != srs_success) {
|
||||
return srs_error_wrap(err, "transaction_id");
|
||||
}
|
||||
|
||||
if ((err = srs_amf0_read_null(stream)) != srs_success) {
|
||||
return srs_error_wrap(err, "command_object");
|
||||
}
|
||||
|
||||
// @remark, for bandwidth test, ignore the data field.
|
||||
// only decode the stop-play, start-publish and finish packet.
|
||||
if (is_stop_play() || is_start_publish() || is_finish()) {
|
||||
if ((err = data->read(stream)) != srs_success) {
|
||||
return srs_error_wrap(err, "command_object");
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsBandwidthPacket::get_prefer_cid()
|
||||
{
|
||||
return RTMP_CID_OverStream;
|
||||
}
|
||||
|
||||
int SrsBandwidthPacket::get_message_type()
|
||||
{
|
||||
return RTMP_MSG_AMF0CommandMessage;
|
||||
}
|
||||
|
||||
int SrsBandwidthPacket::get_size()
|
||||
{
|
||||
return SrsAmf0Size::str(command_name) + SrsAmf0Size::number()
|
||||
+ SrsAmf0Size::null() + SrsAmf0Size::object(data);
|
||||
}
|
||||
|
||||
srs_error_t SrsBandwidthPacket::encode_packet(SrsBuffer* stream)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if ((err = srs_amf0_write_string(stream, command_name)) != srs_success) {
|
||||
return srs_error_wrap(err, "command_name");
|
||||
}
|
||||
|
||||
if ((err = srs_amf0_write_number(stream, transaction_id)) != srs_success) {
|
||||
return srs_error_wrap(err, "transaction_id");
|
||||
}
|
||||
|
||||
if ((err = srs_amf0_write_null(stream)) != srs_success) {
|
||||
return srs_error_wrap(err, "args");
|
||||
}
|
||||
|
||||
if ((err = data->write(stream)) != srs_success) {
|
||||
return srs_error_wrap(err, "data");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_start_play()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_START_PLAY;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_starting_play()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STARTING_PLAY;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_stop_play()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STOP_PLAY;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_stopped_play()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STOPPED_PLAY;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_start_publish()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_START_PUBLISH;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_starting_publish()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STARTING_PUBLISH;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_stop_publish()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STOP_PUBLISH;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_stopped_publish()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_STOPPED_PUBLISH;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_finish()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_FINISHED;
|
||||
}
|
||||
|
||||
bool SrsBandwidthPacket::is_final()
|
||||
{
|
||||
return command_name == SRS_BW_CHECK_FINAL;
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_start_play()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_START_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_starting_play()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STARTING_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_playing()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_PLAYING);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stop_play()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOP_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stopped_play()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOPPED_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_start_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_START_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_starting_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STARTING_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_publishing()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_PUBLISHING);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stop_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOP_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stopped_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOPPED_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_finish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_FINISHED);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_final()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_FINAL);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::set_command(string command)
|
||||
{
|
||||
command_name = command;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
SrsOnStatusDataPacket::SrsOnStatusDataPacket()
|
||||
{
|
||||
command_name = RTMP_AMF0_COMMAND_ON_STATUS;
|
||||
|
|
|
@ -1241,65 +1241,6 @@ protected:
|
|||
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
||||
};
|
||||
|
||||
// The special packet for the bandwidth test.
|
||||
// actually, it's a SrsOnStatusCallPacket, but
|
||||
// 1. encode with data field, to send data to client.
|
||||
// 2. decode ignore the data field, donot care.
|
||||
class SrsBandwidthPacket : public SrsPacket
|
||||
{
|
||||
public:
|
||||
// Name of command.
|
||||
std::string command_name;
|
||||
// Transaction ID set to 0.
|
||||
double transaction_id;
|
||||
// Command information does not exist. Set to null type.
|
||||
// @remark, never be NULL, an AMF0 null instance.
|
||||
SrsAmf0Any* args; // null
|
||||
// Name-value pairs that describe the response from the server.
|
||||
// 'code','level', 'description' are names of few among such information.
|
||||
// @remark, never be NULL, an AMF0 object instance.
|
||||
SrsAmf0Object* data;
|
||||
public:
|
||||
SrsBandwidthPacket();
|
||||
virtual ~SrsBandwidthPacket();
|
||||
// Decode functions for concrete packet to override.
|
||||
public:
|
||||
virtual srs_error_t decode(SrsBuffer* stream);
|
||||
// Encode functions for concrete packet to override.
|
||||
public:
|
||||
virtual int get_prefer_cid();
|
||||
virtual int get_message_type();
|
||||
protected:
|
||||
virtual int get_size();
|
||||
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
||||
// help function for bandwidth packet.
|
||||
public:
|
||||
virtual bool is_start_play();
|
||||
virtual bool is_starting_play();
|
||||
virtual bool is_stop_play();
|
||||
virtual bool is_stopped_play();
|
||||
virtual bool is_start_publish();
|
||||
virtual bool is_starting_publish();
|
||||
virtual bool is_stop_publish();
|
||||
virtual bool is_stopped_publish();
|
||||
virtual bool is_finish();
|
||||
virtual bool is_final();
|
||||
static SrsBandwidthPacket* create_start_play();
|
||||
static SrsBandwidthPacket* create_starting_play();
|
||||
static SrsBandwidthPacket* create_playing();
|
||||
static SrsBandwidthPacket* create_stop_play();
|
||||
static SrsBandwidthPacket* create_stopped_play();
|
||||
static SrsBandwidthPacket* create_start_publish();
|
||||
static SrsBandwidthPacket* create_starting_publish();
|
||||
static SrsBandwidthPacket* create_publishing();
|
||||
static SrsBandwidthPacket* create_stop_publish();
|
||||
static SrsBandwidthPacket* create_stopped_publish();
|
||||
static SrsBandwidthPacket* create_finish();
|
||||
static SrsBandwidthPacket* create_final();
|
||||
private:
|
||||
virtual SrsBandwidthPacket* set_command(std::string command);
|
||||
};
|
||||
|
||||
// onStatus data, AMF0 Data
|
||||
// @remark, user must set the stream_id by SrsCommonMessage.set_packet().
|
||||
class SrsOnStatusDataPacket : public SrsPacket
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue