|
|
@ -217,6 +217,14 @@ srs_error_t SrsPacket::encode_packet(SrsBuffer* stream)
|
|
|
|
return srs_error_new(ERROR_SYSTEM_PACKET_INVALID, "encode");
|
|
|
|
return srs_error_new(ERROR_SYSTEM_PACKET_INVALID, "encode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ISrsProtocolPerf::ISrsProtocolPerf()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ISrsProtocolPerf::~ISrsProtocolPerf()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SrsProtocol::AckWindowSize::AckWindowSize()
|
|
|
|
SrsProtocol::AckWindowSize::AckWindowSize()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
window = 0;
|
|
|
|
window = 0;
|
|
|
@ -256,6 +264,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
|
|
|
|
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
|
|
|
|
|
|
|
|
perf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SrsProtocol::~SrsProtocol()
|
|
|
|
SrsProtocol::~SrsProtocol()
|
|
|
@ -303,6 +312,11 @@ void SrsProtocol::set_auto_response(bool v)
|
|
|
|
auto_response_when_recv = v;
|
|
|
|
auto_response_when_recv = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SrsProtocol::set_perf(ISrsProtocolPerf* v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
perf = v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
srs_error_t SrsProtocol::manual_response_flush()
|
|
|
|
srs_error_t SrsProtocol::manual_response_flush()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
srs_error_t err = srs_success;
|
|
|
|
srs_error_t err = srs_success;
|
|
|
@ -449,6 +463,11 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
|
|
|
int c0c3_cache_index = 0;
|
|
|
|
int c0c3_cache_index = 0;
|
|
|
|
char* c0c3_cache = out_c0c3_caches + c0c3_cache_index;
|
|
|
|
char* c0c3_cache = out_c0c3_caches + c0c3_cache_index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// How many messages are merged in written.
|
|
|
|
|
|
|
|
int nb_msgs_merged_written = 0;
|
|
|
|
|
|
|
|
// How many bytes of messages are merged in written.
|
|
|
|
|
|
|
|
int bytes_msgs_merged_written = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// try to send use the c0c3 header cache,
|
|
|
|
// try to send use the c0c3 header cache,
|
|
|
|
// if cache is consumed, try another loop.
|
|
|
|
// if cache is consumed, try another loop.
|
|
|
|
for (int i = 0; i < nb_msgs; i++) {
|
|
|
|
for (int i = 0; i < nb_msgs; i++) {
|
|
|
@ -463,6 +482,10 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Increase the perf stat data.
|
|
|
|
|
|
|
|
nb_msgs_merged_written++;
|
|
|
|
|
|
|
|
bytes_msgs_merged_written += msg->size;
|
|
|
|
|
|
|
|
|
|
|
|
// p set to current write position,
|
|
|
|
// p set to current write position,
|
|
|
|
// it's ok when payload is NULL and size is 0.
|
|
|
|
// it's ok when payload is NULL and size is 0.
|
|
|
|
char* p = msg->payload;
|
|
|
|
char* p = msg->payload;
|
|
|
@ -523,6 +546,12 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
|
|
|
return srs_error_wrap(err, "send iovs");
|
|
|
|
return srs_error_wrap(err, "send iovs");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Notify about perf stat.
|
|
|
|
|
|
|
|
if (perf) {
|
|
|
|
|
|
|
|
perf->perf_mw_on_msgs(nb_msgs_merged_written, bytes_msgs_merged_written, iov_index);
|
|
|
|
|
|
|
|
nb_msgs_merged_written = 0; bytes_msgs_merged_written = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// reset caches, while these cache ensure
|
|
|
|
// reset caches, while these cache ensure
|
|
|
|
// atleast we can sendout a chunk.
|
|
|
|
// atleast we can sendout a chunk.
|
|
|
|
iov_index = 0;
|
|
|
|
iov_index = 0;
|
|
|
@ -540,7 +569,18 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return do_iovs_send(out_iovs, iov_index);
|
|
|
|
// Send out iovs at a time.
|
|
|
|
|
|
|
|
if ((err = do_iovs_send(out_iovs, iov_index)) != srs_success) {
|
|
|
|
|
|
|
|
return srs_error_wrap(err, "send iovs");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Notify about perf stat.
|
|
|
|
|
|
|
|
if (perf) {
|
|
|
|
|
|
|
|
perf->perf_mw_on_msgs(nb_msgs_merged_written, bytes_msgs_merged_written, iov_index);
|
|
|
|
|
|
|
|
nb_msgs_merged_written = 0; bytes_msgs_merged_written = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
// try to send use the c0c3 header cache,
|
|
|
|
// try to send use the c0c3 header cache,
|
|
|
|
// if cache is consumed, try another loop.
|
|
|
|
// if cache is consumed, try another loop.
|
|
|
@ -587,6 +627,11 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
|
|
|
if ((er = skt->writev(iovs, 2, NULL)) != srs_success) {
|
|
|
|
if ((er = skt->writev(iovs, 2, NULL)) != srs_success) {
|
|
|
|
return srs_error_wrap(err, "writev");
|
|
|
|
return srs_error_wrap(err, "writev");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Notify about perf stat.
|
|
|
|
|
|
|
|
if (perf) {
|
|
|
|
|
|
|
|
perf->perf_mw_on_packets(1, payload_size, 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2209,6 +2254,11 @@ void SrsRtmpServer::set_auto_response(bool v)
|
|
|
|
protocol->set_auto_response(v);
|
|
|
|
protocol->set_auto_response(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SrsRtmpServer::set_perf(ISrsProtocolPerf* v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
protocol->set_perf(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_PERF_MERGED_READ
|
|
|
|
#ifdef SRS_PERF_MERGED_READ
|
|
|
|
void SrsRtmpServer::set_merge_read(bool v, IMergeReadHandler* handler)
|
|
|
|
void SrsRtmpServer::set_merge_read(bool v, IMergeReadHandler* handler)
|
|
|
|
{
|
|
|
|
{
|
|
|
|