mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Merge branch '4.0release' into merge/develop
This commit is contained in:
commit
72a48f6115
44 changed files with 141 additions and 1277 deletions
|
@ -154,7 +154,7 @@ The ports used by SRS:
|
||||||
- [x] [Experimental] Support pushing FLV over HTTP POST, please read wiki([CN][v4_CN_Streamer2], [EN][v4_EN_Streamer2]).
|
- [x] [Experimental] Support pushing FLV over HTTP POST, please read wiki([CN][v4_CN_Streamer2], [EN][v4_EN_Streamer2]).
|
||||||
- [x] [Experimental] Support HTTP RAW API, please read [#459][bug #459], [#470][bug #470], [#319][bug #319].
|
- [x] [Experimental] Support HTTP RAW API, please read [#459][bug #459], [#470][bug #470], [#319][bug #319].
|
||||||
- [x] [Experimental] Support SRT server, read [#1147][bug #1147].
|
- [x] [Experimental] Support SRT server, read [#1147][bug #1147].
|
||||||
- [x] [Deprecated] Support pushing RTSP, please read [bug #133][bug #133].
|
- [x] [Deprecated] Support pushing RTSP, please read [bug #2304][bug #2304].
|
||||||
- [x] [Deprecated] Support RTMP client library: srs-librtmp([CN][v4_CN_SrsLibrtmp], [EN][v4_EN_SrsLibrtmp])
|
- [x] [Deprecated] Support RTMP client library: srs-librtmp([CN][v4_CN_SrsLibrtmp], [EN][v4_EN_SrsLibrtmp])
|
||||||
- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v4_CN_DeliveryHDS], [EN][v4_EN_DeliveryHDS]) and [#1535][bug #1535].
|
- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v4_CN_DeliveryHDS], [EN][v4_EN_DeliveryHDS]) and [#1535][bug #1535].
|
||||||
- [x] [Deprecated] Support bandwidth testing([CN][v4_CN_BandwidthTestTool], [EN][v4_EN_BandwidthTestTool]), please read [#1535][bug #1535].
|
- [x] [Deprecated] Support bandwidth testing([CN][v4_CN_BandwidthTestTool], [EN][v4_EN_BandwidthTestTool]), please read [#1535][bug #1535].
|
||||||
|
@ -182,6 +182,8 @@ The ports used by SRS:
|
||||||
|
|
||||||
## V4 changes
|
## V4 changes
|
||||||
|
|
||||||
|
* v4.0, 2021-05-14, RTC: Remove [Object Cache Pool](https://github.com/ossrs/srs/commit/14bfc98122bba369572417c19ebb2a61b373fc45#commitcomment-47655008), no effect. 4.0.110
|
||||||
|
* v4.0, 2021-05-14, Change virtual public to public. 4.0.109
|
||||||
* v4.0, 2021-05-14, Refine id and vid for statistic. 4.0.108
|
* v4.0, 2021-05-14, Refine id and vid for statistic. 4.0.108
|
||||||
* v4.0, 2021-05-09, Refine tid for sdk and demos. 4.0.106
|
* v4.0, 2021-05-09, Refine tid for sdk and demos. 4.0.106
|
||||||
* v4.0, 2021-05-08, Refine shared fast timer. 4.0.105
|
* v4.0, 2021-05-08, Refine shared fast timer. 4.0.105
|
||||||
|
@ -649,7 +651,7 @@ The ports used by SRS:
|
||||||
* v2.0, 2015-02-24, for [#304][bug #304], fix hls bug, write pts/dts error. 2.0.124
|
* v2.0, 2015-02-24, for [#304][bug #304], fix hls bug, write pts/dts error. 2.0.124
|
||||||
* v2.0, 2015-02-19, refine dvr, append file when dvr file exists. 2.0.122.
|
* v2.0, 2015-02-19, refine dvr, append file when dvr file exists. 2.0.122.
|
||||||
* v2.0, 2015-02-19, refine pithy print to more easyer to use. 2.0.121.
|
* v2.0, 2015-02-19, refine pithy print to more easyer to use. 2.0.121.
|
||||||
* v2.0, 2015-02-18, fix [#133][bug #133], support push rtsp to srs. 2.0.120.
|
* v2.0, 2015-02-18, fix [#2304][bug #2304], support push rtsp to srs. 2.0.120.
|
||||||
* v2.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 2.0.119.
|
* v2.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 2.0.119.
|
||||||
* v2.0, 2015-02-15, for [#304][bug #304], support config default acodec/vcodec. 2.0.118.
|
* v2.0, 2015-02-15, for [#304][bug #304], support config default acodec/vcodec. 2.0.118.
|
||||||
* v2.0, 2015-02-15, for [#304][bug #304], rewrite hls/ts code, support h.264+mp3 for hls. 2.0.117.
|
* v2.0, 2015-02-15, for [#304][bug #304], rewrite hls/ts code, support h.264+mp3 for hls. 2.0.117.
|
||||||
|
@ -1921,6 +1923,7 @@ Winlin
|
||||||
[bug #2093]: https://github.com/ossrs/srs/issues/2093
|
[bug #2093]: https://github.com/ossrs/srs/issues/2093
|
||||||
[bug #2188]: https://github.com/ossrs/srs/issues/2188
|
[bug #2188]: https://github.com/ossrs/srs/issues/2188
|
||||||
[bug #1193]: https://github.com/ossrs/srs/issues/1193
|
[bug #1193]: https://github.com/ossrs/srs/issues/1193
|
||||||
|
[bug #2304]: https://github.com/ossrs/srs/issues/2304#issuecomment-826009290
|
||||||
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
|
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
|
||||||
|
|
||||||
[bug #1631]: https://github.com/ossrs/srs/issues/1631
|
[bug #1631]: https://github.com/ossrs/srs/issues/1631
|
||||||
|
|
|
@ -524,30 +524,6 @@ rtc_server {
|
||||||
# TODO: FIXME: We should enable it when refined.
|
# TODO: FIXME: We should enable it when refined.
|
||||||
# default: off
|
# default: off
|
||||||
perf_stat off;
|
perf_stat off;
|
||||||
# For RTP packet and its payload cache.
|
|
||||||
rtp_cache {
|
|
||||||
# Whether enable the RTP packet cache.
|
|
||||||
# default: on
|
|
||||||
enabled on;
|
|
||||||
# The cache size for rtp packet in MB, each object is about 300B..
|
|
||||||
# default: 64
|
|
||||||
pkt_size 64.0;
|
|
||||||
# The cache size for rtp payload in MB, each object is about 40B.
|
|
||||||
# default: 16
|
|
||||||
payload_size 16.0;
|
|
||||||
}
|
|
||||||
# For RTP shared message and the large buffer cache.
|
|
||||||
rtp_msg_cache {
|
|
||||||
#Whether enable the RTP message(a large buffer) cache.
|
|
||||||
# default: on
|
|
||||||
enabled on;
|
|
||||||
# The cache size for message object in MB, each object is about 40B.
|
|
||||||
# default: 16
|
|
||||||
msg_size 16.0;
|
|
||||||
# The cache size for message large buffer in MB, each object is about 1500B.
|
|
||||||
# default: 512
|
|
||||||
buffer_size 512.0;
|
|
||||||
}
|
|
||||||
# The black-hole to copy packet to, for debugging.
|
# The black-hole to copy packet to, for debugging.
|
||||||
# For example, when debugging Chrome publish stream, the received packets are encrypted cipher,
|
# For example, when debugging Chrome publish stream, the received packets are encrypted cipher,
|
||||||
# we can set the publisher black-hole, SRS will copy the plaintext packets to black-hole, and
|
# we can set the publisher black-hole, SRS will copy the plaintext packets to black-hole, and
|
||||||
|
|
|
@ -47,8 +47,7 @@ class SrsSimpleRtmpClient;
|
||||||
#include <srs_kernel_file.hpp>
|
#include <srs_kernel_file.hpp>
|
||||||
|
|
||||||
// The stream caster for flv stream over HTTP POST.
|
// The stream caster for flv stream over HTTP POST.
|
||||||
class SrsAppCasterFlv : virtual public ISrsTcpHandler
|
class SrsAppCasterFlv : public ISrsTcpHandler, public ISrsResourceManager, public ISrsHttpHandler
|
||||||
, virtual public ISrsResourceManager, virtual public ISrsHttpHandler
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string output;
|
std::string output;
|
||||||
|
@ -72,8 +71,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The dynamic http connection, never drop the body.
|
// The dynamic http connection, never drop the body.
|
||||||
class SrsDynamicHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpConnOwner
|
class SrsDynamicHttpConn : public ISrsStartableConneciton, public ISrsHttpConnOwner, public ISrsReloadHandler
|
||||||
, virtual public ISrsReloadHandler
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The manager object to manage the connection.
|
// The manager object to manage the connection.
|
||||||
|
|
|
@ -3679,7 +3679,7 @@ srs_error_t SrsConfig::check_normal_config()
|
||||||
string n = conf->at(i)->name;
|
string n = conf->at(i)->name;
|
||||||
if (n != "enabled" && n != "listen" && n != "dir" && n != "candidate" && n != "ecdsa"
|
if (n != "enabled" && n != "listen" && n != "dir" && n != "candidate" && n != "ecdsa"
|
||||||
&& n != "encrypt" && n != "reuseport" && n != "merge_nalus" && n != "perf_stat" && n != "black_hole"
|
&& n != "encrypt" && n != "reuseport" && n != "merge_nalus" && n != "perf_stat" && n != "black_hole"
|
||||||
&& n != "ip_family" && n != "rtp_cache" && n != "rtp_msg_cache") {
|
&& n != "ip_family") {
|
||||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal rtc_server.%s", n.c_str());
|
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal rtc_server.%s", n.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5050,138 +5050,6 @@ bool SrsConfig::get_rtc_server_perf_stat()
|
||||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_rtc_server_rtp_cache()
|
|
||||||
{
|
|
||||||
SrsConfDirective* conf = root->get("rtc_server");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("rtp_cache");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_rtc_server_rtp_cache_enabled()
|
|
||||||
{
|
|
||||||
static bool DEFAULT = true;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("enabled");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsConfig::get_rtc_server_rtp_cache_pkt_size()
|
|
||||||
{
|
|
||||||
int DEFAULT = 64 * 1024 * 1024;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("pkt_size");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1024 * (uint64_t)(1024 * ::atof(conf->arg0().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsConfig::get_rtc_server_rtp_cache_payload_size()
|
|
||||||
{
|
|
||||||
int DEFAULT = 16 * 1024 * 1024;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("payload_size");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1024 * (uint64_t)(1024 * ::atof(conf->arg0().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_rtc_server_rtp_msg_cache()
|
|
||||||
{
|
|
||||||
SrsConfDirective* conf = root->get("rtc_server");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("rtp_msg_cache");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_rtc_server_rtp_msg_cache_enabled()
|
|
||||||
{
|
|
||||||
static bool DEFAULT = true;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_msg_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("enabled");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsConfig::get_rtc_server_rtp_msg_cache_msg_size()
|
|
||||||
{
|
|
||||||
int DEFAULT = 16 * 1024 * 1024;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_msg_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("msg_size");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1024 * (uint64_t)(1024 * ::atof(conf->arg0().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsConfig::get_rtc_server_rtp_msg_cache_buffer_size()
|
|
||||||
{
|
|
||||||
int DEFAULT = 512 * 1024 * 1024;
|
|
||||||
|
|
||||||
SrsConfDirective* conf = get_rtc_server_rtp_msg_cache();
|
|
||||||
if (!conf) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("buffer_size");
|
|
||||||
if (!conf || conf->arg0().empty()) {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1024 * (uint64_t)(1024 * ::atof(conf->arg0().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_rtc_server_black_hole()
|
bool SrsConfig::get_rtc_server_black_hole()
|
||||||
{
|
{
|
||||||
static bool DEFAULT = false;
|
static bool DEFAULT = false;
|
||||||
|
|
|
@ -543,18 +543,6 @@ public:
|
||||||
virtual int get_rtc_server_reuseport();
|
virtual int get_rtc_server_reuseport();
|
||||||
virtual bool get_rtc_server_merge_nalus();
|
virtual bool get_rtc_server_merge_nalus();
|
||||||
virtual bool get_rtc_server_perf_stat();
|
virtual bool get_rtc_server_perf_stat();
|
||||||
private:
|
|
||||||
SrsConfDirective* get_rtc_server_rtp_cache();
|
|
||||||
public:
|
|
||||||
virtual bool get_rtc_server_rtp_cache_enabled();
|
|
||||||
virtual uint64_t get_rtc_server_rtp_cache_pkt_size();
|
|
||||||
virtual uint64_t get_rtc_server_rtp_cache_payload_size();
|
|
||||||
private:
|
|
||||||
virtual SrsConfDirective* get_rtc_server_rtp_msg_cache();
|
|
||||||
public:
|
|
||||||
virtual bool get_rtc_server_rtp_msg_cache_enabled();
|
|
||||||
virtual uint64_t get_rtc_server_rtp_msg_cache_msg_size();
|
|
||||||
virtual uint64_t get_rtc_server_rtp_msg_cache_buffer_size();
|
|
||||||
public:
|
public:
|
||||||
virtual bool get_rtc_server_black_hole();
|
virtual bool get_rtc_server_black_hole();
|
||||||
virtual std::string get_rtc_server_black_hole_addr();
|
virtual std::string get_rtc_server_black_hole_addr();
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The resource manager remove resource and delete it asynchronously.
|
// The resource manager remove resource and delete it asynchronously.
|
||||||
class SrsResourceManager : virtual public ISrsCoroutineHandler, virtual public ISrsResourceManager
|
class SrsResourceManager : public ISrsCoroutineHandler, public ISrsResourceManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string label_;
|
std::string label_;
|
||||||
|
@ -153,8 +153,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interface for connection that is startable.
|
// Interface for connection that is startable.
|
||||||
class ISrsStartableConneciton : virtual public ISrsConnection
|
class ISrsStartableConneciton : public ISrsConnection
|
||||||
, virtual public ISrsStartable, virtual public ISrsKbpsDelta
|
, public ISrsStartable, public ISrsKbpsDelta
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsStartableConneciton();
|
ISrsStartableConneciton();
|
||||||
|
@ -164,7 +164,7 @@ public:
|
||||||
// The basic connection of SRS, for TCP based protocols,
|
// The basic connection of SRS, for TCP based protocols,
|
||||||
// all connections accept from listener must extends from this base class,
|
// all connections accept from listener must extends from this base class,
|
||||||
// server will add the connection to manager, and delete it when remove.
|
// server will add the connection to manager, and delete it when remove.
|
||||||
class SrsTcpConnection : virtual public ISrsProtocolReadWriter
|
class SrsTcpConnection : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The underlayer st fd handler.
|
// The underlayer st fd handler.
|
||||||
|
@ -196,7 +196,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The SSL connection over TCP transport, in server mode.
|
// The SSL connection over TCP transport, in server mode.
|
||||||
class SrsSslConnection : virtual public ISrsProtocolReadWriter
|
class SrsSslConnection : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The under-layer plaintext transport.
|
// The under-layer plaintext transport.
|
||||||
|
|
|
@ -1303,95 +1303,6 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
||||||
return srs_api_response(w, r, obj->dumps());
|
return srs_api_response(w, r, obj->dumps());
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsGoApiPerf::SrsGoApiPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsGoApiPerf::~SrsGoApiPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|
||||||
{
|
|
||||||
srs_error_t err = srs_success;
|
|
||||||
|
|
||||||
SrsJsonObject* obj = SrsJsonAny::object();
|
|
||||||
SrsAutoFree(SrsJsonObject, obj);
|
|
||||||
|
|
||||||
obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS));
|
|
||||||
SrsJsonObject* data = SrsJsonAny::object();
|
|
||||||
obj->set("data", data);
|
|
||||||
|
|
||||||
SrsStatistic* stat = SrsStatistic::instance();
|
|
||||||
|
|
||||||
string target = r->query_get("target");
|
|
||||||
string reset = r->query_get("reset");
|
|
||||||
srs_trace("query target=%s, reset=%s, rtc_stat_enabled=%d", target.c_str(), reset.c_str(),
|
|
||||||
_srs_config->get_rtc_server_perf_stat());
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("query", p);
|
|
||||||
|
|
||||||
p->set("target", SrsJsonAny::str(target.c_str()));
|
|
||||||
p->set("reset", SrsJsonAny::str(reset.c_str()));
|
|
||||||
p->set("help", SrsJsonAny::str("?target=avframes|rtc|rtp|writev_iovs|bytes"));
|
|
||||||
p->set("help2", SrsJsonAny::str("?reset=all"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!reset.empty()) {
|
|
||||||
stat->reset_perf();
|
|
||||||
return srs_api_response(w, r, obj->dumps());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "avframes") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("avframes", p);
|
|
||||||
if ((err = stat->dumps_perf_msgs(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "rtc") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("rtc", p);
|
|
||||||
if ((err = stat->dumps_perf_rtc_packets(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "rtp") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("rtp", p);
|
|
||||||
if ((err = stat->dumps_perf_rtp_packets(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "writev_iovs") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("writev_iovs", p);
|
|
||||||
if ((err = stat->dumps_perf_writev_iovs(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "bytes") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("bytes", p);
|
|
||||||
if ((err = stat->dumps_perf_bytes(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return srs_api_response(w, r, obj->dumps());
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsGoApiError::SrsGoApiError()
|
SrsGoApiError::SrsGoApiError()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGoApiRaw : virtual public ISrsHttpHandler, virtual public ISrsReloadHandler
|
class SrsGoApiRaw : public ISrsHttpHandler, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsServer* server;
|
SrsServer* server;
|
||||||
|
@ -213,15 +213,6 @@ public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGoApiPerf : public ISrsHttpHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SrsGoApiPerf();
|
|
||||||
virtual ~SrsGoApiPerf();
|
|
||||||
public:
|
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SrsGoApiError : public ISrsHttpHandler
|
class SrsGoApiError : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -256,8 +247,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle the HTTP API request.
|
// Handle the HTTP API request.
|
||||||
class SrsHttpApi : virtual public ISrsStartableConneciton, virtual public ISrsHttpConnOwner
|
class SrsHttpApi : public ISrsStartableConneciton, public ISrsHttpConnOwner
|
||||||
, virtual public ISrsReloadHandler
|
, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The manager object to manage the connection.
|
// The manager object to manage the connection.
|
||||||
|
|
|
@ -75,8 +75,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The http connection which request the static or stream content.
|
// The http connection which request the static or stream content.
|
||||||
class SrsHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsCoroutineHandler
|
class SrsHttpConn : public ISrsStartableConneciton, public ISrsCoroutineHandler
|
||||||
, virtual public ISrsExpire
|
, public ISrsExpire
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
SrsHttpParser* parser;
|
SrsHttpParser* parser;
|
||||||
|
@ -143,8 +143,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Drop body of request, only process the response.
|
// Drop body of request, only process the response.
|
||||||
class SrsResponseOnlyHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpConnOwner
|
class SrsResponseOnlyHttpConn : public ISrsStartableConneciton, public ISrsHttpConnOwner
|
||||||
, virtual public ISrsReloadHandler
|
, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The manager object to manage the connection.
|
// The manager object to manage the connection.
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
|
|
||||||
// The http static server instance,
|
// The http static server instance,
|
||||||
// serve http static file and flv/mp4 vod stream.
|
// serve http static file and flv/mp4 vod stream.
|
||||||
class SrsHttpStaticServer : virtual public ISrsReloadHandler
|
class SrsHttpStaticServer : public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsServer* server;
|
SrsServer* server;
|
||||||
|
|
|
@ -231,8 +231,8 @@ public:
|
||||||
|
|
||||||
// The HTTP Live Streaming Server, to serve FLV/TS/MP3/AAC stream.
|
// The HTTP Live Streaming Server, to serve FLV/TS/MP3/AAC stream.
|
||||||
// TODO: Support multiple stream.
|
// TODO: Support multiple stream.
|
||||||
class SrsHttpStreamServer : virtual public ISrsReloadHandler
|
class SrsHttpStreamServer : public ISrsReloadHandler
|
||||||
, virtual public ISrsHttpMatchHijacker
|
, public ISrsHttpMatchHijacker
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsServer* server;
|
SrsServer* server;
|
||||||
|
|
|
@ -374,29 +374,20 @@ srs_error_t SrsHybridServer::on_timer(srs_utime_t interval)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string objs_desc;
|
string objs_desc;
|
||||||
_srs_pps_objs_rtps->update(); _srs_pps_objs_rraw->update(); _srs_pps_objs_rfua->update(); _srs_pps_objs_rbuf->update(); _srs_pps_objs_msgs->update(); _srs_pps_objs_rothers->update(); _srs_pps_objs_drop->update();
|
_srs_pps_objs_rtps->update(); _srs_pps_objs_rraw->update(); _srs_pps_objs_rfua->update(); _srs_pps_objs_rbuf->update(); _srs_pps_objs_msgs->update(); _srs_pps_objs_rothers->update();
|
||||||
if (_srs_pps_objs_rtps->r10s() || _srs_pps_objs_rraw->r10s() || _srs_pps_objs_rfua->r10s() || _srs_pps_objs_rbuf->r10s() || _srs_pps_objs_msgs->r10s() || _srs_pps_objs_rothers->r10s() || _srs_pps_objs_drop->r10s()) {
|
if (_srs_pps_objs_rtps->r10s() || _srs_pps_objs_rraw->r10s() || _srs_pps_objs_rfua->r10s() || _srs_pps_objs_rbuf->r10s() || _srs_pps_objs_msgs->r10s() || _srs_pps_objs_rothers->r10s()) {
|
||||||
snprintf(buf, sizeof(buf), ", objs=(pkt:%d,raw:%d,fua:%d,msg:%d,oth:%d,buf:%d,drop:%d)",
|
snprintf(buf, sizeof(buf), ", objs=(pkt:%d,raw:%d,fua:%d,msg:%d,oth:%d,buf:%d)",
|
||||||
_srs_pps_objs_rtps->r10s(), _srs_pps_objs_rraw->r10s(), _srs_pps_objs_rfua->r10s(),
|
_srs_pps_objs_rtps->r10s(), _srs_pps_objs_rraw->r10s(), _srs_pps_objs_rfua->r10s(),
|
||||||
_srs_pps_objs_msgs->r10s(), _srs_pps_objs_rothers->r10s(), _srs_pps_objs_rbuf->r10s(), _srs_pps_objs_drop->r10s());
|
_srs_pps_objs_msgs->r10s(), _srs_pps_objs_rothers->r10s(), _srs_pps_objs_rbuf->r10s());
|
||||||
objs_desc = buf;
|
objs_desc = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
string cache_desc;
|
srs_trace("Hybrid cpu=%.2f%%,%dMB%s%s%s%s%s%s%s%s%s%s%s",
|
||||||
if (_srs_rtp_cache->size() || _srs_rtp_raw_cache->size() || _srs_rtp_fua_cache->size() || _srs_rtp_msg_cache_buffers->size() || _srs_rtp_msg_cache_objs->size()) {
|
|
||||||
snprintf(buf, sizeof(buf), ", cache=(pkt:%d-%dw,raw:%d-%dw,fua:%d-%dw,msg:%d-%dw,buf:%d-%dw)",
|
|
||||||
_srs_rtp_cache->size(), _srs_rtp_cache->capacity()/10000, _srs_rtp_raw_cache->size(), _srs_rtp_raw_cache->capacity()/10000,
|
|
||||||
_srs_rtp_fua_cache->size(), _srs_rtp_fua_cache->capacity()/10000, _srs_rtp_msg_cache_objs->size(), _srs_rtp_msg_cache_objs->capacity()/10000,
|
|
||||||
_srs_rtp_msg_cache_buffers->size(), _srs_rtp_msg_cache_buffers->capacity()/10000);
|
|
||||||
cache_desc = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_trace("Hybrid cpu=%.2f%%,%dMB%s%s%s%s%s%s%s%s%s%s%s%s",
|
|
||||||
u->percent * 100, memory,
|
u->percent * 100, memory,
|
||||||
cid_desc.c_str(), timer_desc.c_str(),
|
cid_desc.c_str(), timer_desc.c_str(),
|
||||||
recvfrom_desc.c_str(), io_desc.c_str(), msg_desc.c_str(),
|
recvfrom_desc.c_str(), io_desc.c_str(), msg_desc.c_str(),
|
||||||
epoll_desc.c_str(), sched_desc.c_str(), clock_desc.c_str(),
|
epoll_desc.c_str(), sched_desc.c_str(), clock_desc.c_str(),
|
||||||
thread_desc.c_str(), free_desc.c_str(), objs_desc.c_str(), cache_desc.c_str()
|
thread_desc.c_str(), free_desc.c_str(), objs_desc.c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The mpegts over udp stream caster.
|
// The mpegts over udp stream caster.
|
||||||
class SrsMpegtsOverUdp : virtual public ISrsTsHandler, virtual public ISrsUdpHandler
|
class SrsMpegtsOverUdp : public ISrsTsHandler, public ISrsUdpHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTsContext* context;
|
SrsTsContext* context;
|
||||||
|
|
|
@ -190,9 +190,6 @@ SrsQueueRecvThread::~SrsQueueRecvThread()
|
||||||
srs_error_t SrsQueueRecvThread::start()
|
srs_error_t SrsQueueRecvThread::start()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
SrsStatistic* stat = SrsStatistic::instance();
|
|
||||||
rtmp->set_perf(stat);
|
|
||||||
|
|
||||||
if ((err = trd.start()) != srs_success) {
|
if ((err = trd.start()) != srs_success) {
|
||||||
return srs_error_wrap(err, "queue recv thread");
|
return srs_error_wrap(err, "queue recv thread");
|
||||||
|
|
|
@ -138,9 +138,9 @@ public:
|
||||||
|
|
||||||
// The publish recv thread got message and callback the source method to process message.
|
// The publish recv thread got message and callback the source method to process message.
|
||||||
// @see: https://github.com/ossrs/srs/issues/237
|
// @see: https://github.com/ossrs/srs/issues/237
|
||||||
class SrsPublishRecvThread : virtual public ISrsMessagePumper, virtual public ISrsReloadHandler
|
class SrsPublishRecvThread : public ISrsMessagePumper, public ISrsReloadHandler
|
||||||
#ifdef SRS_PERF_MERGED_READ
|
#ifdef SRS_PERF_MERGED_READ
|
||||||
, virtual public IMergeReadHandler
|
, public IMergeReadHandler
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -460,9 +460,6 @@ srs_error_t SrsRtcPlayStream::initialize(SrsRequest* req, std::map<uint32_t, Srs
|
||||||
track->set_nack_no_copy(nack_no_copy_);
|
track->set_nack_no_copy(nack_no_copy_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update stat for session.
|
|
||||||
session_->stat_->nn_subscribers++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,9 +612,9 @@ srs_error_t SrsRtcPlayStream::cycle()
|
||||||
srs_freep(err);
|
srs_freep(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the packet to cache.
|
// Free the packet.
|
||||||
// @remark Note that the pkt might be set to NULL.
|
// @remark Note that the pkt might be set to NULL.
|
||||||
_srs_rtp_cache->recycle(pkt);
|
srs_freep(pkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,8 +742,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_rr(SrsRtcpRR* rtcp)
|
||||||
|
|
||||||
// TODO: FIXME: Implements it.
|
// TODO: FIXME: Implements it.
|
||||||
|
|
||||||
session_->stat_->nn_sr++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,8 +751,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_xr(SrsRtcpXr* rtcp)
|
||||||
|
|
||||||
// TODO: FIXME: Implements it.
|
// TODO: FIXME: Implements it.
|
||||||
|
|
||||||
session_->stat_->nn_xr++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,8 +800,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_nack(SrsRtcpNack* rtcp)
|
||||||
return srs_error_wrap(err, "track response nack. id:%s, ssrc=%u", target->get_track_id().c_str(), ssrc);
|
return srs_error_wrap(err, "track response nack. id:%s, ssrc=%u", target->get_track_id().c_str(), ssrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_nack++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,8 +814,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_ps_feedback(SrsRtcpPsfbCommon* rtcp)
|
||||||
if (ssrc) {
|
if (ssrc) {
|
||||||
pli_worker_->request_keyframe(ssrc, cid_);
|
pli_worker_->request_keyframe(ssrc, cid_);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_pli++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kSLI: {
|
case kSLI: {
|
||||||
|
@ -1074,9 +1063,6 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti
|
||||||
track->set_nack_no_copy(nack_no_copy_);
|
track->set_nack_no_copy(nack_no_copy_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update stat for session.
|
|
||||||
session_->stat_->nn_publishers++;
|
|
||||||
|
|
||||||
// Setup the publish stream in source to enable PLI as such.
|
// Setup the publish stream in source to enable PLI as such.
|
||||||
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
||||||
return srs_error_wrap(err, "create source");
|
return srs_error_wrap(err, "create source");
|
||||||
|
@ -1193,8 +1179,6 @@ srs_error_t SrsRtcPublishStream::send_rtcp_rr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_rr++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,8 +1200,6 @@ srs_error_t SrsRtcPublishStream::send_rtcp_xr_rrtr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_xr++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,8 +1209,6 @@ srs_error_t SrsRtcPublishStream::on_twcc(uint16_t sn) {
|
||||||
srs_utime_t now = srs_get_system_time();
|
srs_utime_t now = srs_get_system_time();
|
||||||
err = rtcp_twcc_.recv_packet(sn, now);
|
err = rtcp_twcc_.recv_packet(sn, now);
|
||||||
|
|
||||||
session_->stat_->nn_in_twcc++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1236,8 +1216,6 @@ srs_error_t SrsRtcPublishStream::on_rtp(char* data, int nb_data)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
session_->stat_->nn_in_rtp++;
|
|
||||||
|
|
||||||
// For NACK simulator, drop packet.
|
// For NACK simulator, drop packet.
|
||||||
if (nn_simulate_nack_drop) {
|
if (nn_simulate_nack_drop) {
|
||||||
SrsBuffer b(data, nb_data); SrsRtpHeader h; h.ignore_padding(true);
|
SrsBuffer b(data, nb_data); SrsRtpHeader h; h.ignore_padding(true);
|
||||||
|
@ -1309,10 +1287,7 @@ srs_error_t SrsRtcPublishStream::on_rtp_plaintext(char* plaintext, int nb_plaint
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate packet form cache.
|
// Allocate packet form cache.
|
||||||
SrsRtpPacket2* pkt = _srs_rtp_cache->allocate();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
|
|
||||||
// It's better to reset it before decode it.
|
|
||||||
pkt->reset();
|
|
||||||
|
|
||||||
// Copy the packet body.
|
// Copy the packet body.
|
||||||
char* p = pkt->wrap(plaintext, nb_plaintext);
|
char* p = pkt->wrap(plaintext, nb_plaintext);
|
||||||
|
@ -1323,9 +1298,9 @@ srs_error_t SrsRtcPublishStream::on_rtp_plaintext(char* plaintext, int nb_plaint
|
||||||
// @remark Note that the pkt might be set to NULL.
|
// @remark Note that the pkt might be set to NULL.
|
||||||
err = do_on_rtp_plaintext(pkt, &buf);
|
err = do_on_rtp_plaintext(pkt, &buf);
|
||||||
|
|
||||||
// Release the packet to cache.
|
// Free the packet.
|
||||||
// @remark Note that the pkt might be set to NULL.
|
// @remark Note that the pkt might be set to NULL.
|
||||||
_srs_rtp_cache->recycle(pkt);
|
srs_freep(pkt);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1586,8 +1561,6 @@ srs_error_t SrsRtcPublishStream::do_request_keyframe(uint32_t ssrc, SrsContextId
|
||||||
srs_freep(err);
|
srs_freep(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_pli++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,51 +1628,6 @@ void SrsRtcPublishStream::update_send_report_time(uint32_t ssrc, const SrsNtp& n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcConnectionStatistic::SrsRtcConnectionStatistic()
|
|
||||||
{
|
|
||||||
dead = born = srs_get_system_time();
|
|
||||||
nn_publishers = nn_subscribers = 0;
|
|
||||||
nn_rr = nn_xr = 0;
|
|
||||||
nn_sr = nn_nack = nn_pli = 0;
|
|
||||||
nn_in_twcc = nn_in_rtp = nn_in_audios = nn_in_videos = 0;
|
|
||||||
nn_out_twcc = nn_out_rtp = nn_out_audios = nn_out_videos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsRtcConnectionStatistic::~SrsRtcConnectionStatistic()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
string SrsRtcConnectionStatistic::summary()
|
|
||||||
{
|
|
||||||
dead = srs_get_system_time();
|
|
||||||
|
|
||||||
stringstream ss;
|
|
||||||
|
|
||||||
ss << "alive=" << srsu2msi(dead - born) << "ms";
|
|
||||||
|
|
||||||
if (nn_publishers) ss << ", npub=" << nn_publishers;
|
|
||||||
if (nn_subscribers) ss << ", nsub=" << nn_subscribers;
|
|
||||||
|
|
||||||
if (nn_rr) ss << ", nrr=" << nn_rr;
|
|
||||||
if (nn_xr) ss << ", nxr=" << nn_xr;
|
|
||||||
|
|
||||||
if (nn_sr) ss << ", nsr=" << nn_sr;
|
|
||||||
if (nn_nack) ss << ", nnack=" << nn_nack;
|
|
||||||
if (nn_pli) ss << ", npli=" << nn_pli;
|
|
||||||
|
|
||||||
if (nn_in_twcc) ss << ", in_ntwcc=" << nn_in_twcc;
|
|
||||||
if (nn_in_rtp) ss << ", in_nrtp=" << nn_in_rtp;
|
|
||||||
if (nn_in_audios) ss << ", in_naudio=" << nn_in_audios;
|
|
||||||
if (nn_in_videos) ss << ", in_nvideo=" << nn_in_videos;
|
|
||||||
|
|
||||||
if (nn_out_twcc) ss << ", out_ntwcc=" << nn_out_twcc;
|
|
||||||
if (nn_out_rtp) ss << ", out_nrtp=" << nn_out_rtp;
|
|
||||||
if (nn_out_audios) ss << ", out_naudio=" << nn_out_audios;
|
|
||||||
if (nn_out_videos) ss << ", out_nvideo=" << nn_out_videos;
|
|
||||||
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISrsRtcConnectionHijacker::ISrsRtcConnectionHijacker()
|
ISrsRtcConnectionHijacker::ISrsRtcConnectionHijacker()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1679,6 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid)
|
||||||
{
|
{
|
||||||
req = NULL;
|
req = NULL;
|
||||||
cid_ = cid;
|
cid_ = cid;
|
||||||
stat_ = new SrsRtcConnectionStatistic();
|
|
||||||
hijacker_ = NULL;
|
hijacker_ = NULL;
|
||||||
|
|
||||||
sendonly_skt = NULL;
|
sendonly_skt = NULL;
|
||||||
|
@ -1818,7 +1745,6 @@ SrsRtcConnection::~SrsRtcConnection()
|
||||||
|
|
||||||
srs_freep(transport_);
|
srs_freep(transport_);
|
||||||
srs_freep(req);
|
srs_freep(req);
|
||||||
srs_freep(stat_);
|
|
||||||
srs_freep(pp_address_change);
|
srs_freep(pp_address_change);
|
||||||
srs_freep(pli_epp);
|
srs_freep(pli_epp);
|
||||||
}
|
}
|
||||||
|
@ -2304,8 +2230,7 @@ srs_error_t SrsRtcConnection::on_dtls_alert(std::string type, std::string desc)
|
||||||
SrsContextRestore(_srs_context->get_id());
|
SrsContextRestore(_srs_context->get_id());
|
||||||
switch_to_context();
|
switch_to_context();
|
||||||
|
|
||||||
srs_trace("RTC: session destroy by DTLS alert, username=%s, summary: %s",
|
srs_trace("RTC: session destroy by DTLS alert, username=%s", username_.c_str());
|
||||||
username_.c_str(), stat_->summary().c_str());
|
|
||||||
_srs_rtc_manager->remove(this);
|
_srs_rtc_manager->remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A worker coroutine to request the PLI.
|
// A worker coroutine to request the PLI.
|
||||||
class SrsRtcPLIWorker : virtual public ISrsCoroutineHandler
|
class SrsRtcPLIWorker : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsCoroutine* trd_;
|
SrsCoroutine* trd_;
|
||||||
|
@ -394,24 +394,6 @@ private:
|
||||||
void update_send_report_time(uint32_t ssrc, const SrsNtp& ntp);
|
void update_send_report_time(uint32_t ssrc, const SrsNtp& ntp);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The statistics for RTC connection.
|
|
||||||
class SrsRtcConnectionStatistic
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int nn_publishers; int nn_subscribers;
|
|
||||||
int nn_rr; int nn_xr; int nn_sr; int nn_nack; int nn_pli;
|
|
||||||
uint64_t nn_in_twcc; uint64_t nn_in_rtp; uint64_t nn_in_audios; uint64_t nn_in_videos;
|
|
||||||
uint64_t nn_out_twcc; uint64_t nn_out_rtp; uint64_t nn_out_audios; uint64_t nn_out_videos;
|
|
||||||
private:
|
|
||||||
srs_utime_t born;
|
|
||||||
srs_utime_t dead;
|
|
||||||
public:
|
|
||||||
SrsRtcConnectionStatistic();
|
|
||||||
virtual ~SrsRtcConnectionStatistic();
|
|
||||||
public:
|
|
||||||
std::string summary();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback for RTC connection.
|
// Callback for RTC connection.
|
||||||
class ISrsRtcConnectionHijacker
|
class ISrsRtcConnectionHijacker
|
||||||
{
|
{
|
||||||
|
@ -437,7 +419,7 @@ private:
|
||||||
|
|
||||||
// A RTC Peer Connection, SDP level object.
|
// A RTC Peer Connection, SDP level object.
|
||||||
//
|
//
|
||||||
// For performance, we use non-virtual public from resource,
|
// For performance, we use non-public from resource,
|
||||||
// see https://stackoverflow.com/questions/3747066/c-cannot-convert-from-base-a-to-derived-type-b-via-virtual-base-a
|
// see https://stackoverflow.com/questions/3747066/c-cannot-convert-from-base-a-to-derived-type-b-via-virtual-base-a
|
||||||
class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler
|
class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler
|
||||||
{
|
{
|
||||||
|
@ -449,7 +431,6 @@ private:
|
||||||
SrsRtcConnectionNackTimer* timer_nack_;
|
SrsRtcConnectionNackTimer* timer_nack_;
|
||||||
public:
|
public:
|
||||||
bool disposing_;
|
bool disposing_;
|
||||||
SrsRtcConnectionStatistic* stat_;
|
|
||||||
ISrsRtcConnectionHijacker* hijacker_;
|
ISrsRtcConnectionHijacker* hijacker_;
|
||||||
private:
|
private:
|
||||||
SrsRtcServer* server_;
|
SrsRtcServer* server_;
|
||||||
|
|
|
@ -144,7 +144,7 @@ protected:
|
||||||
virtual bool is_dtls_client() = 0;
|
virtual bool is_dtls_client() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsDtlsClientImpl : virtual public SrsDtlsImpl, virtual public ISrsCoroutineHandler
|
class SrsDtlsClientImpl : public SrsDtlsImpl, public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// ARQ thread, for role active(DTLS client).
|
// ARQ thread, for role active(DTLS client).
|
||||||
|
|
|
@ -55,7 +55,7 @@ SrsRtpRingBuffer::~SrsRtpRingBuffer()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < capacity_; ++i) {
|
for (int i = 0; i < capacity_; ++i) {
|
||||||
SrsRtpPacket2* pkt = queue_[i];
|
SrsRtpPacket2* pkt = queue_[i];
|
||||||
_srs_rtp_cache->recycle(pkt);
|
srs_freep(pkt);
|
||||||
}
|
}
|
||||||
srs_freepa(queue_);
|
srs_freepa(queue_);
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,7 @@ void SrsRtpRingBuffer::advance_to(uint16_t seq)
|
||||||
void SrsRtpRingBuffer::set(uint16_t at, SrsRtpPacket2* pkt)
|
void SrsRtpRingBuffer::set(uint16_t at, SrsRtpPacket2* pkt)
|
||||||
{
|
{
|
||||||
SrsRtpPacket2* p = queue_[at % capacity_];
|
SrsRtpPacket2* p = queue_[at % capacity_];
|
||||||
|
srs_freep(p);
|
||||||
if (p) {
|
|
||||||
_srs_rtp_cache->recycle(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
queue_[at % capacity_] = pkt;
|
queue_[at % capacity_] = pkt;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +167,7 @@ void SrsRtpRingBuffer::clear_histroy(uint16_t seq)
|
||||||
for (uint16_t i = 0; i < capacity_; i++) {
|
for (uint16_t i = 0; i < capacity_; i++) {
|
||||||
SrsRtpPacket2* p = queue_[i];
|
SrsRtpPacket2* p = queue_[i];
|
||||||
if (p && p->header.get_sequence() < seq) {
|
if (p && p->header.get_sequence() < seq) {
|
||||||
_srs_rtp_cache->recycle(p);
|
srs_freep(p);
|
||||||
queue_[i] = NULL;
|
queue_[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +178,7 @@ void SrsRtpRingBuffer::clear_all_histroy()
|
||||||
for (uint16_t i = 0; i < capacity_; i++) {
|
for (uint16_t i = 0; i < capacity_; i++) {
|
||||||
SrsRtpPacket2* p = queue_[i];
|
SrsRtpPacket2* p = queue_[i];
|
||||||
if (p) {
|
if (p) {
|
||||||
_srs_rtp_cache->recycle(p);
|
srs_freep(p);
|
||||||
queue_[i] = NULL;
|
queue_[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,61 +289,11 @@ srs_error_t SrsRtcServer::initialize()
|
||||||
return srs_error_wrap(err, "black hole");
|
return srs_error_wrap(err, "black hole");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rtp_cache_enabled = _srs_config->get_rtc_server_rtp_cache_enabled();
|
|
||||||
uint64_t rtp_cache_pkt_size = _srs_config->get_rtc_server_rtp_cache_pkt_size();
|
|
||||||
uint64_t rtp_cache_payload_size = _srs_config->get_rtc_server_rtp_cache_payload_size();
|
|
||||||
_srs_rtp_cache->setup(rtp_cache_enabled, rtp_cache_pkt_size);
|
|
||||||
_srs_rtp_raw_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
|
||||||
_srs_rtp_fua_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
|
||||||
|
|
||||||
bool rtp_msg_cache_enabled = _srs_config->get_rtc_server_rtp_msg_cache_enabled();
|
|
||||||
uint64_t rtp_msg_cache_msg_size = _srs_config->get_rtc_server_rtp_msg_cache_msg_size();
|
|
||||||
uint64_t rtp_msg_cache_buffer_size = _srs_config->get_rtc_server_rtp_msg_cache_buffer_size();
|
|
||||||
_srs_rtp_msg_cache_buffers->setup(rtp_msg_cache_enabled, rtp_msg_cache_buffer_size);
|
|
||||||
_srs_rtp_msg_cache_objs->setup(rtp_msg_cache_enabled, rtp_msg_cache_msg_size);
|
|
||||||
|
|
||||||
srs_trace("RTC: Object cache init, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw)",
|
|
||||||
rtp_cache_enabled, (int)(rtp_cache_pkt_size/1024/1024), _srs_rtp_cache->capacity()/10000,
|
|
||||||
(int)(rtp_cache_payload_size/1024/1024), _srs_rtp_raw_cache->capacity()/10000, _srs_rtp_fua_cache->capacity()/10000,
|
|
||||||
rtp_msg_cache_enabled, (int)(rtp_msg_cache_msg_size/1024/1024), _srs_rtp_msg_cache_objs->capacity()/10000,
|
|
||||||
(int)(rtp_msg_cache_buffer_size/1024/1024), _srs_rtp_msg_cache_buffers->capacity()/10000);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcServer::on_reload_rtc_server()
|
srs_error_t SrsRtcServer::on_reload_rtc_server()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
bool rtp_cache_enabled = _srs_config->get_rtc_server_rtp_cache_enabled();
|
|
||||||
uint64_t rtp_cache_pkt_size = _srs_config->get_rtc_server_rtp_cache_pkt_size();
|
|
||||||
uint64_t rtp_cache_payload_size = _srs_config->get_rtc_server_rtp_cache_payload_size();
|
|
||||||
if (_srs_rtp_cache->enabled() != rtp_cache_enabled) {
|
|
||||||
_srs_rtp_cache->setup(rtp_cache_enabled, rtp_cache_pkt_size);
|
|
||||||
_srs_rtp_raw_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
|
||||||
_srs_rtp_fua_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rtp_msg_cache_enabled = _srs_config->get_rtc_server_rtp_msg_cache_enabled();
|
|
||||||
uint64_t rtp_msg_cache_msg_size = _srs_config->get_rtc_server_rtp_msg_cache_msg_size();
|
|
||||||
uint64_t rtp_msg_cache_buffer_size = _srs_config->get_rtc_server_rtp_msg_cache_buffer_size();
|
|
||||||
if (_srs_rtp_msg_cache_buffers->enabled() != rtp_msg_cache_enabled) {
|
|
||||||
_srs_rtp_msg_cache_buffers->setup(rtp_msg_cache_enabled, rtp_msg_cache_buffer_size);
|
|
||||||
_srs_rtp_msg_cache_objs->setup(rtp_msg_cache_enabled, rtp_msg_cache_msg_size);
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed) {
|
|
||||||
srs_trace("RTC: Object cache reload, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw)",
|
|
||||||
rtp_cache_enabled, (int)(rtp_cache_pkt_size/1024/1024), _srs_rtp_cache->capacity()/10000,
|
|
||||||
(int)(rtp_cache_payload_size/1024/1024), _srs_rtp_raw_cache->capacity()/10000, _srs_rtp_fua_cache->capacity()/10000,
|
|
||||||
rtp_msg_cache_enabled, (int)(rtp_msg_cache_msg_size/1024/1024), _srs_rtp_msg_cache_objs->capacity()/10000,
|
|
||||||
(int)(rtp_msg_cache_buffer_size/1024/1024), _srs_rtp_msg_cache_buffers->capacity()/10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return srs_success;
|
return srs_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,8 +609,7 @@ srs_error_t SrsRtcServer::on_timer(srs_utime_t interval)
|
||||||
session->switch_to_context();
|
session->switch_to_context();
|
||||||
|
|
||||||
string username = session->username();
|
string username = session->username();
|
||||||
srs_trace("RTC: session destroy by timeout, username=%s, summary: %s", username.c_str(),
|
srs_trace("RTC: session destroy by timeout, username=%s", username.c_str());
|
||||||
session->stat_->summary().c_str());
|
|
||||||
|
|
||||||
// Use manager to free session and notify other objects.
|
// Use manager to free session and notify other objects.
|
||||||
_srs_rtc_manager->remove(session);
|
_srs_rtc_manager->remove(session);
|
||||||
|
|
|
@ -178,7 +178,7 @@ SrsRtcConsumer::~SrsRtcConsumer()
|
||||||
vector<SrsRtpPacket2*>::iterator it;
|
vector<SrsRtpPacket2*>::iterator it;
|
||||||
for (it = queue.begin(); it != queue.end(); ++it) {
|
for (it = queue.begin(); it != queue.end(); ++it) {
|
||||||
SrsRtpPacket2* pkt = *it;
|
SrsRtpPacket2* pkt = *it;
|
||||||
_srs_rtp_cache->recycle(pkt);
|
srs_freep(pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_cond_destroy(mw_wait);
|
srs_cond_destroy(mw_wait);
|
||||||
|
@ -661,19 +661,6 @@ srs_error_t SrsRtcStream::on_timer(srs_utime_t interval)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtpPacketCacheHelper::SrsRtpPacketCacheHelper()
|
|
||||||
{
|
|
||||||
pkt = _srs_rtp_cache->allocate();
|
|
||||||
|
|
||||||
// We MUST reset the packet, when got from cache.
|
|
||||||
pkt->reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsRtpPacketCacheHelper::~SrsRtpPacketCacheHelper()
|
|
||||||
{
|
|
||||||
_srs_rtp_cache->recycle(pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source)
|
SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source)
|
||||||
{
|
{
|
||||||
|
@ -844,45 +831,46 @@ srs_error_t SrsRtcFromRtmpBridger::on_audio(SrsSharedPtrMessage* msg)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::transcode(SrsAudioFrame* pkt)
|
srs_error_t SrsRtcFromRtmpBridger::transcode(SrsAudioFrame* audio)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
std::vector<SrsAudioFrame *> out_pkts;
|
std::vector<SrsAudioFrame *> out_audios;
|
||||||
if ((err = codec_->transcode(pkt, out_pkts)) != srs_success) {
|
if ((err = codec_->transcode(audio, out_audios)) != srs_success) {
|
||||||
return srs_error_wrap(err, "recode error");
|
return srs_error_wrap(err, "recode error");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save OPUS packets in shared message.
|
// Save OPUS packets in shared message.
|
||||||
if (out_pkts.empty()) {
|
if (out_audios.empty()) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<SrsAudioFrame *>::iterator it = out_pkts.begin(); it != out_pkts.end(); ++it) {
|
for (std::vector<SrsAudioFrame*>::iterator it = out_audios.begin(); it != out_audios.end(); ++it) {
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsAudioFrame* out_audio = *it;
|
||||||
SrsAutoFree(SrsRtpPacketCacheHelper, helper);
|
|
||||||
|
|
||||||
if ((err = package_opus(*it, helper)) != srs_success) {
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
|
SrsAutoFree(SrsRtpPacket2, pkt);
|
||||||
|
|
||||||
|
if ((err = package_opus(out_audio, pkt)) != srs_success) {
|
||||||
err = srs_error_wrap(err, "package opus");
|
err = srs_error_wrap(err, "package opus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = source_->on_rtp(helper->pkt)) != srs_success) {
|
if ((err = source_->on_rtp(pkt)) != srs_success) {
|
||||||
err = srs_error_wrap(err, "consume opus");
|
err = srs_error_wrap(err, "consume opus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codec_->free_frames(out_pkts);
|
codec_->free_frames(out_audios);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPacketCacheHelper* helper)
|
srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPacket2* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kAudioPayloadType);
|
pkt->header.set_payload_type(kAudioPayloadType);
|
||||||
pkt->header.set_ssrc(audio_ssrc);
|
pkt->header.set_ssrc(audio_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeAudio;
|
pkt->frame_type = SrsFrameTypeAudio;
|
||||||
|
@ -890,7 +878,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPack
|
||||||
pkt->header.set_sequence(audio_sequence++);
|
pkt->header.set_sequence(audio_sequence++);
|
||||||
pkt->header.set_timestamp(audio->dts * 48);
|
pkt->header.set_timestamp(audio->dts * 48);
|
||||||
|
|
||||||
SrsRtpRawPayload* raw = _srs_rtp_raw_cache->allocate();
|
SrsRtpRawPayload* raw = new SrsRtpRawPayload();
|
||||||
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
|
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
|
||||||
|
|
||||||
srs_assert(audio->nb_samples == 1);
|
srs_assert(audio->nb_samples == 1);
|
||||||
|
@ -923,22 +911,22 @@ srs_error_t SrsRtcFromRtmpBridger::on_video(SrsSharedPtrMessage* msg)
|
||||||
|
|
||||||
// Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A.
|
// Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A.
|
||||||
if (has_idr) {
|
if (has_idr) {
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
SrsAutoFree(SrsRtpPacketCacheHelper, helper);
|
SrsAutoFree(SrsRtpPacket2, pkt);
|
||||||
|
|
||||||
if ((err = package_stap_a(source_, msg, helper)) != srs_success) {
|
if ((err = package_stap_a(source_, msg, pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "package stap-a");
|
return srs_error_wrap(err, "package stap-a");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = source_->on_rtp(helper->pkt)) != srs_success) {
|
if ((err = source_->on_rtp(pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "consume sps/pps");
|
return srs_error_wrap(err, "consume sps/pps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If merge Nalus, we pcakges all NALUs(samples) as one NALU, in a RTP or FUA packet.
|
// If merge Nalus, we pcakges all NALUs(samples) as one NALU, in a RTP or FUA packet.
|
||||||
vector<SrsRtpPacketCacheHelper*> helpers;
|
vector<SrsRtpPacket2*> pkts;
|
||||||
if (merge_nalus && nn_samples > 1) {
|
if (merge_nalus && nn_samples > 1) {
|
||||||
if ((err = package_nalus(msg, samples, helpers)) != srs_success) {
|
if ((err = package_nalus(msg, samples, pkts)) != srs_success) {
|
||||||
return srs_error_wrap(err, "package nalus as one");
|
return srs_error_wrap(err, "package nalus as one");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -953,22 +941,22 @@ srs_error_t SrsRtcFromRtmpBridger::on_video(SrsSharedPtrMessage* msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample->size <= kRtpMaxPayloadSize) {
|
if (sample->size <= kRtpMaxPayloadSize) {
|
||||||
if ((err = package_single_nalu(msg, sample, helpers)) != srs_success) {
|
if ((err = package_single_nalu(msg, sample, pkts)) != srs_success) {
|
||||||
return srs_error_wrap(err, "package single nalu");
|
return srs_error_wrap(err, "package single nalu");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((err = package_fu_a(msg, sample, kRtpMaxPayloadSize, helpers)) != srs_success) {
|
if ((err = package_fu_a(msg, sample, kRtpMaxPayloadSize, pkts)) != srs_success) {
|
||||||
return srs_error_wrap(err, "package fu-a");
|
return srs_error_wrap(err, "package fu-a");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!helpers.empty()) {
|
if (!pkts.empty()) {
|
||||||
helpers.back()->pkt->header.set_marker(true);
|
pkts.back()->header.set_marker(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return consume_packets(helpers);
|
return consume_packets(pkts);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, vector<SrsSample*>& samples)
|
srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, vector<SrsSample*>& samples)
|
||||||
|
@ -1001,7 +989,7 @@ srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* f
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacketCacheHelper* helper)
|
srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -1017,7 +1005,6 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
|
||||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "sps/pps empty");
|
return srs_error_new(ERROR_RTC_RTP_MUXER, "sps/pps empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kVideoPayloadType);
|
pkt->header.set_payload_type(kVideoPayloadType);
|
||||||
pkt->header.set_ssrc(video_ssrc);
|
pkt->header.set_ssrc(video_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
|
@ -1061,7 +1048,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const vector<SrsSample*>& samples, vector<SrsRtpPacketCacheHelper*>& helpers)
|
srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const vector<SrsSample*>& samples, vector<SrsRtpPacket2*>& pkts)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -1097,10 +1084,9 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
|
||||||
|
|
||||||
if (nn_bytes < kRtpMaxPayloadSize) {
|
if (nn_bytes < kRtpMaxPayloadSize) {
|
||||||
// Package NALUs in a single RTP packet.
|
// Package NALUs in a single RTP packet.
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
helpers.push_back(helper);
|
pkts.push_back(pkt);
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kVideoPayloadType);
|
pkt->header.set_payload_type(kVideoPayloadType);
|
||||||
pkt->header.set_ssrc(video_ssrc);
|
pkt->header.set_ssrc(video_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
|
@ -1132,10 +1118,9 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
|
||||||
return srs_error_wrap(err, "read samples %d bytes, left %d, total %d", packet_size, nb_left, nn_bytes);
|
return srs_error_wrap(err, "read samples %d bytes, left %d, total %d", packet_size, nb_left, nn_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
helpers.push_back(helper);
|
pkts.push_back(pkt);
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kVideoPayloadType);
|
pkt->header.set_payload_type(kVideoPayloadType);
|
||||||
pkt->header.set_ssrc(video_ssrc);
|
pkt->header.set_ssrc(video_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
|
@ -1159,21 +1144,20 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single NAL Unit Packet @see https://tools.ietf.org/html/rfc6184#section-5.6
|
// Single NAL Unit Packet @see https://tools.ietf.org/html/rfc6184#section-5.6
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, vector<SrsRtpPacketCacheHelper*>& helpers)
|
srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, vector<SrsRtpPacket2*>& pkts)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
helpers.push_back(helper);
|
pkts.push_back(pkt);
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kVideoPayloadType);
|
pkt->header.set_payload_type(kVideoPayloadType);
|
||||||
pkt->header.set_ssrc(video_ssrc);
|
pkt->header.set_ssrc(video_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
pkt->header.set_sequence(video_sequence++);
|
pkt->header.set_sequence(video_sequence++);
|
||||||
pkt->header.set_timestamp(msg->timestamp * 90);
|
pkt->header.set_timestamp(msg->timestamp * 90);
|
||||||
|
|
||||||
SrsRtpRawPayload* raw = _srs_rtp_raw_cache->allocate();
|
SrsRtpRawPayload* raw = new SrsRtpRawPayload();
|
||||||
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
|
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
|
||||||
|
|
||||||
raw->payload = sample->bytes;
|
raw->payload = sample->bytes;
|
||||||
|
@ -1184,7 +1168,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, vector<SrsRtpPacketCacheHelper*>& helpers)
|
srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, vector<SrsRtpPacket2*>& pkts)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -1197,17 +1181,16 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
|
||||||
for (int i = 0; i < num_of_packet; ++i) {
|
for (int i = 0; i < num_of_packet; ++i) {
|
||||||
int packet_size = srs_min(nb_left, fu_payload_size);
|
int packet_size = srs_min(nb_left, fu_payload_size);
|
||||||
|
|
||||||
SrsRtpPacketCacheHelper* helper = new SrsRtpPacketCacheHelper();
|
SrsRtpPacket2* pkt = new SrsRtpPacket2();
|
||||||
helpers.push_back(helper);
|
pkts.push_back(pkt);
|
||||||
|
|
||||||
SrsRtpPacket2* pkt = helper->pkt;
|
|
||||||
pkt->header.set_payload_type(kVideoPayloadType);
|
pkt->header.set_payload_type(kVideoPayloadType);
|
||||||
pkt->header.set_ssrc(video_ssrc);
|
pkt->header.set_ssrc(video_ssrc);
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
pkt->header.set_sequence(video_sequence++);
|
pkt->header.set_sequence(video_sequence++);
|
||||||
pkt->header.set_timestamp(msg->timestamp * 90);
|
pkt->header.set_timestamp(msg->timestamp * 90);
|
||||||
|
|
||||||
SrsRtpFUAPayload2* fua = _srs_rtp_fua_cache->allocate();
|
SrsRtpFUAPayload2* fua = new SrsRtpFUAPayload2();
|
||||||
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA2);
|
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA2);
|
||||||
|
|
||||||
fua->nri = (SrsAvcNaluType)header;
|
fua->nri = (SrsAvcNaluType)header;
|
||||||
|
@ -1227,22 +1210,22 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacketCacheHelper*>& helpers)
|
srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket2*>& pkts)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// TODO: FIXME: Consume a range of packets.
|
// TODO: FIXME: Consume a range of packets.
|
||||||
for (int i = 0; i < (int)helpers.size(); i++) {
|
for (int i = 0; i < (int)pkts.size(); i++) {
|
||||||
SrsRtpPacketCacheHelper* helper = helpers[i];
|
SrsRtpPacket2* pkt = pkts[i];
|
||||||
if ((err = source_->on_rtp(helper->pkt)) != srs_success) {
|
if ((err = source_->on_rtp(pkt)) != srs_success) {
|
||||||
err = srs_error_wrap(err, "consume sps/pps");
|
err = srs_error_wrap(err, "consume sps/pps");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)helpers.size(); i++) {
|
for (int i = 0; i < (int)pkts.size(); i++) {
|
||||||
SrsRtpPacketCacheHelper* helper = helpers[i];
|
SrsRtpPacket2* pkt = pkts[i];
|
||||||
srs_freep(helper);
|
srs_freep(pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
@ -2192,29 +2175,10 @@ SrsRtcTrackDescription* SrsRtcStreamDescription::find_track_description_by_ssrc(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcTrackStatistic::SrsRtcTrackStatistic()
|
|
||||||
{
|
|
||||||
packets = 0;
|
|
||||||
last_packets = 0;
|
|
||||||
bytes = 0;
|
|
||||||
last_bytes = 0;
|
|
||||||
nacks = 0;
|
|
||||||
last_nacks = 0;
|
|
||||||
padding_packets = 0;
|
|
||||||
last_padding_packets = 0;
|
|
||||||
padding_bytes = 0;
|
|
||||||
last_padding_bytes = 0;
|
|
||||||
replay_packets = 0;
|
|
||||||
last_replay_packets = 0;
|
|
||||||
replay_bytes = 0;
|
|
||||||
last_replay_bytes = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsRtcRecvTrack::SrsRtcRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc, bool is_audio)
|
SrsRtcRecvTrack::SrsRtcRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc, bool is_audio)
|
||||||
{
|
{
|
||||||
session_ = session;
|
session_ = session;
|
||||||
track_desc_ = track_desc->copy();
|
track_desc_ = track_desc->copy();
|
||||||
statistic_ = new SrsRtcTrackStatistic();
|
|
||||||
nack_no_copy_ = false;
|
nack_no_copy_ = false;
|
||||||
|
|
||||||
if (is_audio) {
|
if (is_audio) {
|
||||||
|
@ -2233,7 +2197,6 @@ SrsRtcRecvTrack::~SrsRtcRecvTrack()
|
||||||
srs_freep(rtp_queue_);
|
srs_freep(rtp_queue_);
|
||||||
srs_freep(nack_receiver_);
|
srs_freep(nack_receiver_);
|
||||||
srs_freep(track_desc_);
|
srs_freep(track_desc_);
|
||||||
srs_freep(statistic_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcRecvTrack::has_ssrc(uint32_t ssrc)
|
bool SrsRtcRecvTrack::has_ssrc(uint32_t ssrc)
|
||||||
|
@ -2341,7 +2304,6 @@ srs_error_t SrsRtcRecvTrack::do_check_send_nacks(uint32_t& timeout_nacks)
|
||||||
|
|
||||||
uint32_t sent_nacks = 0;
|
uint32_t sent_nacks = 0;
|
||||||
session_->check_send_nacks(nack_receiver_, track_desc_->ssrc_, sent_nacks, timeout_nacks);
|
session_->check_send_nacks(nack_receiver_, track_desc_->ssrc_, sent_nacks, timeout_nacks);
|
||||||
statistic_->nacks += sent_nacks;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -2362,7 +2324,7 @@ void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppayload = _srs_rtp_raw_cache->allocate();
|
*ppayload = new SrsRtpRawPayload();
|
||||||
*ppt = SrsRtpPacketPayloadTypeRaw;
|
*ppt = SrsRtpPacketPayloadTypeRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2370,13 +2332,6 @@ srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// connection level statistic
|
|
||||||
session_->stat_->nn_in_audios++;
|
|
||||||
|
|
||||||
// track level statistic
|
|
||||||
statistic_->packets++;
|
|
||||||
statistic_->bytes += pkt->nb_bytes();
|
|
||||||
|
|
||||||
if ((err = source->on_rtp(pkt)) != srs_success) {
|
if ((err = source->on_rtp(pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "source on rtp");
|
return srs_error_wrap(err, "source on rtp");
|
||||||
}
|
}
|
||||||
|
@ -2421,10 +2376,10 @@ void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
|
||||||
*ppayload = new SrsRtpSTAPPayload();
|
*ppayload = new SrsRtpSTAPPayload();
|
||||||
*ppt = SrsRtpPacketPayloadTypeSTAP;
|
*ppt = SrsRtpPacketPayloadTypeSTAP;
|
||||||
} else if (v == kFuA) {
|
} else if (v == kFuA) {
|
||||||
*ppayload = _srs_rtp_fua_cache->allocate();
|
*ppayload = new SrsRtpFUAPayload2();
|
||||||
*ppt = SrsRtpPacketPayloadTypeFUA2;
|
*ppt = SrsRtpPacketPayloadTypeFUA2;
|
||||||
} else {
|
} else {
|
||||||
*ppayload = _srs_rtp_raw_cache->allocate();
|
*ppayload = new SrsRtpRawPayload();
|
||||||
*ppt = SrsRtpPacketPayloadTypeRaw;
|
*ppt = SrsRtpPacketPayloadTypeRaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2433,13 +2388,6 @@ srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// connection level statistic
|
|
||||||
session_->stat_->nn_in_videos++;
|
|
||||||
|
|
||||||
// track level statistic
|
|
||||||
statistic_->packets++;
|
|
||||||
statistic_->bytes += pkt->nb_bytes();
|
|
||||||
|
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
|
|
||||||
if ((err = source->on_rtp(pkt)) != srs_success) {
|
if ((err = source->on_rtp(pkt)) != srs_success) {
|
||||||
|
@ -2475,7 +2423,6 @@ SrsRtcSendTrack::SrsRtcSendTrack(SrsRtcConnection* session, SrsRtcTrackDescripti
|
||||||
{
|
{
|
||||||
session_ = session;
|
session_ = session;
|
||||||
track_desc_ = track_desc->copy();
|
track_desc_ = track_desc->copy();
|
||||||
statistic_ = new SrsRtcTrackStatistic();
|
|
||||||
nack_no_copy_ = false;
|
nack_no_copy_ = false;
|
||||||
|
|
||||||
if (is_audio) {
|
if (is_audio) {
|
||||||
|
@ -2491,7 +2438,6 @@ SrsRtcSendTrack::~SrsRtcSendTrack()
|
||||||
{
|
{
|
||||||
srs_freep(rtp_queue_);
|
srs_freep(rtp_queue_);
|
||||||
srs_freep(track_desc_);
|
srs_freep(track_desc_);
|
||||||
srs_freep(statistic_);
|
|
||||||
srs_freep(nack_epp);
|
srs_freep(nack_epp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2568,10 +2514,6 @@ srs_error_t SrsRtcSendTrack::on_recv_nack(const vector<uint16_t>& lost_seqs)
|
||||||
|
|
||||||
++_srs_pps_rnack2->sugar;
|
++_srs_pps_rnack2->sugar;
|
||||||
|
|
||||||
SrsRtcTrackStatistic* statistic = statistic_;
|
|
||||||
|
|
||||||
statistic->nacks++;
|
|
||||||
|
|
||||||
for(int i = 0; i < (int)lost_seqs.size(); ++i) {
|
for(int i = 0; i < (int)lost_seqs.size(); ++i) {
|
||||||
uint16_t seq = lost_seqs.at(i);
|
uint16_t seq = lost_seqs.at(i);
|
||||||
SrsRtpPacket2* pkt = fetch_rtp_packet(seq);
|
SrsRtpPacket2* pkt = fetch_rtp_packet(seq);
|
||||||
|
@ -2624,14 +2566,6 @@ srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket2* pkt)
|
||||||
// TODO: FIXME: Should update PT for RTX.
|
// TODO: FIXME: Should update PT for RTX.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update stats.
|
|
||||||
session_->stat_->nn_out_audios++;
|
|
||||||
|
|
||||||
// track level statistic
|
|
||||||
// TODO: FIXME: if send packets failed, statistic is no correct.
|
|
||||||
statistic_->packets++;
|
|
||||||
statistic_->bytes += pkt->nb_bytes();
|
|
||||||
|
|
||||||
if ((err = session_->do_send_packet(pkt)) != srs_success) {
|
if ((err = session_->do_send_packet(pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "raw send");
|
return srs_error_wrap(err, "raw send");
|
||||||
}
|
}
|
||||||
|
@ -2662,8 +2596,6 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt)
|
||||||
if (!track_desc_->is_active_) {
|
if (!track_desc_->is_active_) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcTrackStatistic* statistic = statistic_;
|
|
||||||
|
|
||||||
pkt->header.set_ssrc(track_desc_->ssrc_);
|
pkt->header.set_ssrc(track_desc_->ssrc_);
|
||||||
|
|
||||||
|
@ -2678,14 +2610,6 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt)
|
||||||
// TODO: FIXME: Should update PT for RTX.
|
// TODO: FIXME: Should update PT for RTX.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update stats.
|
|
||||||
session_->stat_->nn_out_videos++;
|
|
||||||
|
|
||||||
// track level statistic
|
|
||||||
// TODO: FIXME: if send packets failed, statistic is no correct.
|
|
||||||
statistic->packets++;
|
|
||||||
statistic->bytes += pkt->nb_bytes();
|
|
||||||
|
|
||||||
if ((err = session_->do_send_packet(pkt)) != srs_success) {
|
if ((err = session_->do_send_packet(pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "raw send");
|
return srs_error_wrap(err, "raw send");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ class SrsRtcStream;
|
||||||
class SrsRtcFromRtmpBridger;
|
class SrsRtcFromRtmpBridger;
|
||||||
class SrsAudioTranscoder;
|
class SrsAudioTranscoder;
|
||||||
class SrsRtpPacket2;
|
class SrsRtpPacket2;
|
||||||
class SrsRtpPacketCacheHelper;
|
|
||||||
class SrsSample;
|
class SrsSample;
|
||||||
class SrsRtcStreamDescription;
|
class SrsRtcStreamDescription;
|
||||||
class SrsRtcTrackDescription;
|
class SrsRtcTrackDescription;
|
||||||
|
@ -259,16 +258,6 @@ private:
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A helper class, to release the packet to cache.
|
|
||||||
class SrsRtpPacketCacheHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SrsRtpPacket2* pkt;
|
|
||||||
public:
|
|
||||||
SrsRtpPacketCacheHelper();
|
|
||||||
virtual ~SrsRtpPacketCacheHelper();
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
class SrsRtcFromRtmpBridger : public ISrsSourceBridger
|
class SrsRtcFromRtmpBridger : public ISrsSourceBridger
|
||||||
{
|
{
|
||||||
|
@ -298,16 +287,16 @@ public:
|
||||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
|
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
|
||||||
private:
|
private:
|
||||||
srs_error_t transcode(SrsAudioFrame* audio);
|
srs_error_t transcode(SrsAudioFrame* audio);
|
||||||
srs_error_t package_opus(SrsAudioFrame* audio, SrsRtpPacketCacheHelper* helper);
|
srs_error_t package_opus(SrsAudioFrame* audio, SrsRtpPacket2* pkt);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
|
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
|
||||||
private:
|
private:
|
||||||
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
|
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
|
||||||
srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacketCacheHelper* helper);
|
srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2* pkt);
|
||||||
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacketCacheHelper*>& helpers);
|
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket2*>& pkts);
|
||||||
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacketCacheHelper*>& helpers);
|
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket2*>& pkts);
|
||||||
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacketCacheHelper*>& helpers);
|
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts);
|
||||||
srs_error_t consume_packets(std::vector<SrsRtpPacketCacheHelper*>& helpers);
|
srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtmpFromRtcBridger : public ISrsRtcSourceBridger
|
class SrsRtmpFromRtcBridger : public ISrsRtcSourceBridger
|
||||||
|
@ -532,50 +521,10 @@ public:
|
||||||
SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc);
|
SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcTrackStatistic
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// packets received or sent.
|
|
||||||
uint32_t packets;
|
|
||||||
// packets received or sent at last statistic time.
|
|
||||||
uint32_t last_packets;
|
|
||||||
// bytes received or sent.
|
|
||||||
uint64_t bytes;
|
|
||||||
// bytes received or sent at last statistic time.
|
|
||||||
uint32_t last_bytes;
|
|
||||||
|
|
||||||
// nacks received or sent.
|
|
||||||
uint32_t nacks;
|
|
||||||
// nacks received or sent at last statistic time.
|
|
||||||
uint32_t last_nacks;
|
|
||||||
|
|
||||||
// padding packets received or sent.
|
|
||||||
uint32_t padding_packets;
|
|
||||||
// padding packets received or sent at last statistic time.
|
|
||||||
uint32_t last_padding_packets;
|
|
||||||
// padding bytes received or sent.
|
|
||||||
uint32_t padding_bytes;
|
|
||||||
// padding bytes received or sent at last statistic time.
|
|
||||||
uint32_t last_padding_bytes;
|
|
||||||
|
|
||||||
// replay packets received or sent.
|
|
||||||
uint32_t replay_packets;
|
|
||||||
// replay packets received or sent at last statistic time.
|
|
||||||
uint32_t last_replay_packets;
|
|
||||||
// replay bytes received or sent.
|
|
||||||
uint64_t replay_bytes;
|
|
||||||
// replay bytes received or sent at last statistic time.
|
|
||||||
uint64_t last_replay_bytes;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SrsRtcTrackStatistic();
|
|
||||||
};
|
|
||||||
|
|
||||||
class SrsRtcRecvTrack
|
class SrsRtcRecvTrack
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
SrsRtcTrackDescription* track_desc_;
|
SrsRtcTrackDescription* track_desc_;
|
||||||
SrsRtcTrackStatistic* statistic_;
|
|
||||||
protected:
|
protected:
|
||||||
SrsRtcConnection* session_;
|
SrsRtcConnection* session_;
|
||||||
SrsRtpRingBuffer* rtp_queue_;
|
SrsRtpRingBuffer* rtp_queue_;
|
||||||
|
@ -613,7 +562,7 @@ protected:
|
||||||
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
|
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcAudioRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
|
class SrsRtcAudioRecvTrack : public SrsRtcRecvTrack, public ISrsRtpPacketDecodeHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
|
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
|
||||||
|
@ -625,7 +574,7 @@ public:
|
||||||
virtual srs_error_t check_send_nacks();
|
virtual srs_error_t check_send_nacks();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcVideoRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
|
class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack, public ISrsRtpPacketDecodeHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
|
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
|
||||||
|
@ -642,7 +591,6 @@ class SrsRtcSendTrack
|
||||||
protected:
|
protected:
|
||||||
// send track description
|
// send track description
|
||||||
SrsRtcTrackDescription* track_desc_;
|
SrsRtcTrackDescription* track_desc_;
|
||||||
SrsRtcTrackStatistic* statistic_;
|
|
||||||
protected:
|
protected:
|
||||||
// The owner connection for this track.
|
// The owner connection for this track.
|
||||||
SrsRtcConnection* session_;
|
SrsRtcConnection* session_;
|
||||||
|
|
|
@ -83,8 +83,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The client provides the main logic control for RTMP clients.
|
// The client provides the main logic control for RTMP clients.
|
||||||
class SrsRtmpConn : virtual public ISrsStartableConneciton, virtual public ISrsReloadHandler
|
class SrsRtmpConn : public ISrsStartableConneciton, public ISrsReloadHandler
|
||||||
, virtual public ISrsCoroutineHandler, virtual public ISrsExpire
|
, public ISrsCoroutineHandler, public ISrsExpire
|
||||||
{
|
{
|
||||||
// For the thread to directly access any field of connection.
|
// For the thread to directly access any field of connection.
|
||||||
friend class SrsPublishRecvThread;
|
friend class SrsPublishRecvThread;
|
||||||
|
|
|
@ -997,9 +997,6 @@ srs_error_t SrsServer::http_handle()
|
||||||
if ((err = http_api_mux->handle("/api/v1/clusters", new SrsGoApiClusters())) != srs_success) {
|
if ((err = http_api_mux->handle("/api/v1/clusters", new SrsGoApiClusters())) != srs_success) {
|
||||||
return srs_error_wrap(err, "handle clusters");
|
return srs_error_wrap(err, "handle clusters");
|
||||||
}
|
}
|
||||||
if ((err = http_api_mux->handle("/api/v1/perf", new SrsGoApiPerf())) != srs_success) {
|
|
||||||
return srs_error_wrap(err, "handle perf");
|
|
||||||
}
|
|
||||||
#ifdef SRS_GB28181
|
#ifdef SRS_GB28181
|
||||||
if ((err = http_api_mux->handle("/api/v1/gb28181", new SrsGoApiGb28181())) != srs_success) {
|
if ((err = http_api_mux->handle("/api/v1/gb28181", new SrsGoApiGb28181())) != srs_success) {
|
||||||
return srs_error_wrap(err, "handle raw");
|
return srs_error_wrap(err, "handle raw");
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A buffered TCP listener.
|
// A buffered TCP listener.
|
||||||
class SrsBufferListener : virtual public SrsListener, virtual public ISrsTcpHandler
|
class SrsBufferListener : public SrsListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
|
@ -117,7 +117,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A TCP listener, for rtsp server.
|
// A TCP listener, for rtsp server.
|
||||||
class SrsRtspListener : virtual public SrsListener, virtual public ISrsTcpHandler
|
class SrsRtspListener : public SrsListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A TCP listener, for flv stream server.
|
// A TCP listener, for flv stream server.
|
||||||
class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHandler
|
class SrsHttpFlvListener : public SrsListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
|
@ -179,7 +179,7 @@ public:
|
||||||
virtual ~SrsGb28181Listener();
|
virtual ~SrsGb28181Listener();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGb28181TcpListener : virtual public SrsListener, virtual public ISrsTcpHandler
|
class SrsGb28181TcpListener : public SrsListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
|
@ -262,9 +262,9 @@ public:
|
||||||
|
|
||||||
// TODO: FIXME: Rename to SrsLiveServer.
|
// TODO: FIXME: Rename to SrsLiveServer.
|
||||||
// SRS RTMP server, initialize and listen, start connection service thread, destroy client.
|
// SRS RTMP server, initialize and listen, start connection service thread, destroy client.
|
||||||
class SrsServer : virtual public ISrsReloadHandler, virtual public ISrsSourceHandler
|
class SrsServer : public ISrsReloadHandler, public ISrsSourceHandler
|
||||||
, virtual public ISrsResourceManager, virtual public ISrsCoroutineHandler
|
, public ISrsResourceManager, public ISrsCoroutineHandler
|
||||||
, virtual public ISrsHourGlass
|
, public ISrsHourGlass
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// TODO: FIXME: Extract an HttpApiServer.
|
// TODO: FIXME: Extract an HttpApiServer.
|
||||||
|
|
|
@ -183,7 +183,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The consumer for SrsSource, that is a play client.
|
// The consumer for SrsSource, that is a play client.
|
||||||
class SrsConsumer : virtual public ISrsWakable
|
class SrsConsumer : public ISrsWakable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsRtmpJitter* jitter;
|
SrsRtmpJitter* jitter;
|
||||||
|
|
|
@ -229,27 +229,6 @@ srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatisticCategory::SrsStatisticCategory()
|
|
||||||
{
|
|
||||||
nn = 0;
|
|
||||||
|
|
||||||
a = 0;
|
|
||||||
b = 0;
|
|
||||||
c = 0;
|
|
||||||
d = 0;
|
|
||||||
e = 0;
|
|
||||||
|
|
||||||
f = 0;
|
|
||||||
g = 0;
|
|
||||||
h = 0;
|
|
||||||
i = 0;
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatisticCategory::~SrsStatisticCategory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatistic* SrsStatistic::_instance = NULL;
|
SrsStatistic* SrsStatistic::_instance = NULL;
|
||||||
|
|
||||||
SrsStatistic::SrsStatistic()
|
SrsStatistic::SrsStatistic()
|
||||||
|
@ -259,12 +238,6 @@ SrsStatistic::SrsStatistic()
|
||||||
clk = new SrsWallClock();
|
clk = new SrsWallClock();
|
||||||
kbps = new SrsKbps(clk);
|
kbps = new SrsKbps(clk);
|
||||||
kbps->set_io(NULL, NULL);
|
kbps->set_io(NULL, NULL);
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
|
||||||
perf_msgs = new SrsStatisticCategory();
|
|
||||||
perf_rtp = new SrsStatisticCategory();
|
|
||||||
perf_rtc = new SrsStatisticCategory();
|
|
||||||
perf_bytes = new SrsStatisticCategory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic::~SrsStatistic()
|
SrsStatistic::~SrsStatistic()
|
||||||
|
@ -298,12 +271,6 @@ SrsStatistic::~SrsStatistic()
|
||||||
rvhosts.clear();
|
rvhosts.clear();
|
||||||
streams.clear();
|
streams.clear();
|
||||||
rstreams.clear();
|
rstreams.clear();
|
||||||
|
|
||||||
srs_freep(perf_iovs);
|
|
||||||
srs_freep(perf_msgs);
|
|
||||||
srs_freep(perf_rtp);
|
|
||||||
srs_freep(perf_rtc);
|
|
||||||
srs_freep(perf_bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic* SrsStatistic::instance()
|
SrsStatistic* SrsStatistic::instance()
|
||||||
|
@ -587,157 +554,6 @@ srs_error_t SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsStatistic::perf_on_msgs(int nb_msgs)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_msgs, nb_msgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_msgs(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_msgs, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtc_packets(int nb_packets)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_rtc, nb_packets);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_rtc_packets(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_rtc, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtp_packets(int nb_packets)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_rtp, nb_packets);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_rtp_packets(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_rtp, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_writev_iovs(int nb_iovs)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_iovs, nb_iovs);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_writev_iovs(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_iovs, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtc_bytes(int nn_bytes, int nn_rtp_bytes, int nn_padding)
|
|
||||||
{
|
|
||||||
// a: AVFrame bytes.
|
|
||||||
// b: RTC bytes.
|
|
||||||
// c: RTC paddings.
|
|
||||||
perf_bytes->a += nn_bytes;
|
|
||||||
perf_bytes->b += nn_rtp_bytes;
|
|
||||||
perf_bytes->c += nn_padding;
|
|
||||||
|
|
||||||
perf_bytes->nn += nn_rtp_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_bytes(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
obj->set("avframe_bytes", SrsJsonAny::integer(perf_bytes->a));
|
|
||||||
obj->set("rtc_bytes", SrsJsonAny::integer(perf_bytes->b));
|
|
||||||
obj->set("rtc_padding", SrsJsonAny::integer(perf_bytes->c));
|
|
||||||
|
|
||||||
obj->set("nn", SrsJsonAny::integer(perf_bytes->nn));
|
|
||||||
|
|
||||||
return srs_success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::reset_perf()
|
|
||||||
{
|
|
||||||
srs_freep(perf_iovs);
|
|
||||||
srs_freep(perf_msgs);
|
|
||||||
srs_freep(perf_rtp);
|
|
||||||
srs_freep(perf_rtc);
|
|
||||||
srs_freep(perf_bytes);
|
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
|
||||||
perf_msgs = new SrsStatisticCategory();
|
|
||||||
perf_rtp = new SrsStatisticCategory();
|
|
||||||
perf_rtc = new SrsStatisticCategory();
|
|
||||||
perf_bytes = new SrsStatisticCategory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_packets(SrsStatisticCategory* p, int nb_msgs)
|
|
||||||
{
|
|
||||||
// The range for stat:
|
|
||||||
// 2, 3, 5, 9, 16, 32, 64, 128, 256
|
|
||||||
// that is:
|
|
||||||
// a: <2
|
|
||||||
// b: <3
|
|
||||||
// c: <5
|
|
||||||
// d: <9
|
|
||||||
// e: <16
|
|
||||||
// f: <32
|
|
||||||
// g: <64
|
|
||||||
// h: <128
|
|
||||||
// i: <256
|
|
||||||
// j: >=256
|
|
||||||
if (nb_msgs < 2) {
|
|
||||||
p->a++;
|
|
||||||
} else if (nb_msgs < 3) {
|
|
||||||
p->b++;
|
|
||||||
} else if (nb_msgs < 5) {
|
|
||||||
p->c++;
|
|
||||||
} else if (nb_msgs < 9) {
|
|
||||||
p->d++;
|
|
||||||
} else if (nb_msgs < 16) {
|
|
||||||
p->e++;
|
|
||||||
} else if (nb_msgs < 32) {
|
|
||||||
p->f++;
|
|
||||||
} else if (nb_msgs < 64) {
|
|
||||||
p->g++;
|
|
||||||
} else if (nb_msgs < 128) {
|
|
||||||
p->h++;
|
|
||||||
} else if (nb_msgs < 256) {
|
|
||||||
p->i++;
|
|
||||||
} else {
|
|
||||||
p->j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->nn += nb_msgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
srs_error_t err = srs_success;
|
|
||||||
|
|
||||||
// The range for stat:
|
|
||||||
// 2, 3, 5, 9, 16, 32, 64, 128, 256
|
|
||||||
// that is:
|
|
||||||
// a: <2
|
|
||||||
// b: <3
|
|
||||||
// c: <5
|
|
||||||
// d: <9
|
|
||||||
// e: <16
|
|
||||||
// f: <32
|
|
||||||
// g: <64
|
|
||||||
// h: <128
|
|
||||||
// i: <256
|
|
||||||
// j: >=256
|
|
||||||
if (p->a) obj->set("lt_2", SrsJsonAny::integer(p->a));
|
|
||||||
if (p->b) obj->set("lt_3", SrsJsonAny::integer(p->b));
|
|
||||||
if (p->c) obj->set("lt_5", SrsJsonAny::integer(p->c));
|
|
||||||
if (p->d) obj->set("lt_9", SrsJsonAny::integer(p->d));
|
|
||||||
if (p->e) obj->set("lt_16", SrsJsonAny::integer(p->e));
|
|
||||||
if (p->f) obj->set("lt_32", SrsJsonAny::integer(p->f));
|
|
||||||
if (p->g) obj->set("lt_64", SrsJsonAny::integer(p->g));
|
|
||||||
if (p->h) obj->set("lt_128", SrsJsonAny::integer(p->h));
|
|
||||||
if (p->i) obj->set("lt_256", SrsJsonAny::integer(p->i));
|
|
||||||
if (p->j) obj->set("gt_256", SrsJsonAny::integer(p->j));
|
|
||||||
|
|
||||||
obj->set("nn", SrsJsonAny::integer(p->nn));
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
||||||
{
|
{
|
||||||
SrsStatisticVhost* vhost = NULL;
|
SrsStatisticVhost* vhost = NULL;
|
||||||
|
|
|
@ -124,28 +124,7 @@ public:
|
||||||
virtual srs_error_t dumps(SrsJsonObject* obj);
|
virtual srs_error_t dumps(SrsJsonObject* obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsStatisticCategory
|
class SrsStatistic
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint64_t nn;
|
|
||||||
public:
|
|
||||||
uint64_t a;
|
|
||||||
uint64_t b;
|
|
||||||
uint64_t c;
|
|
||||||
uint64_t d;
|
|
||||||
uint64_t e;
|
|
||||||
public:
|
|
||||||
uint64_t f;
|
|
||||||
uint64_t g;
|
|
||||||
uint64_t h;
|
|
||||||
uint64_t i;
|
|
||||||
uint64_t j;
|
|
||||||
public:
|
|
||||||
SrsStatisticCategory();
|
|
||||||
virtual ~SrsStatisticCategory();
|
|
||||||
};
|
|
||||||
|
|
||||||
class SrsStatistic : public ISrsProtocolPerf
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static SrsStatistic *_instance;
|
static SrsStatistic *_instance;
|
||||||
|
@ -169,12 +148,6 @@ private:
|
||||||
// The server total kbps.
|
// The server total kbps.
|
||||||
SrsKbps* kbps;
|
SrsKbps* kbps;
|
||||||
SrsWallClock* clk;
|
SrsWallClock* clk;
|
||||||
// The perf stat for mw(merged write).
|
|
||||||
SrsStatisticCategory* perf_iovs;
|
|
||||||
SrsStatisticCategory* perf_msgs;
|
|
||||||
SrsStatisticCategory* perf_rtp;
|
|
||||||
SrsStatisticCategory* perf_rtc;
|
|
||||||
SrsStatisticCategory* perf_bytes;
|
|
||||||
private:
|
private:
|
||||||
SrsStatistic();
|
SrsStatistic();
|
||||||
virtual ~SrsStatistic();
|
virtual ~SrsStatistic();
|
||||||
|
@ -231,35 +204,6 @@ public:
|
||||||
// @param start the start index, from 0.
|
// @param start the start index, from 0.
|
||||||
// @param count the max count of clients to dump.
|
// @param count the max count of clients to dump.
|
||||||
virtual srs_error_t dumps_clients(SrsJsonArray* arr, int start, int count);
|
virtual srs_error_t dumps_clients(SrsJsonArray* arr, int start, int count);
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_msgs is the number of RTMP messages.
|
|
||||||
// For example, publish by FFMPEG, Audio and Video frames.
|
|
||||||
virtual void perf_on_msgs(int nb_msgs);
|
|
||||||
virtual srs_error_t dumps_perf_msgs(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_packets is the number of RTC packets.
|
|
||||||
// For example, a RTMP/AAC audio packet maybe transcoded to two RTC/opus packets.
|
|
||||||
virtual void perf_on_rtc_packets(int nb_packets);
|
|
||||||
virtual srs_error_t dumps_perf_rtc_packets(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_packets is the number of RTP packets.
|
|
||||||
// For example, a RTC/opus packet maybe package to three RTP packets.
|
|
||||||
virtual void perf_on_rtp_packets(int nb_packets);
|
|
||||||
virtual srs_error_t dumps_perf_rtp_packets(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
|
||||||
virtual void perf_on_writev_iovs(int nb_iovs);
|
|
||||||
virtual srs_error_t dumps_perf_writev_iovs(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for bytes, nn_bytes is the size of bytes, nb_padding is padding bytes.
|
|
||||||
virtual void perf_on_rtc_bytes(int nn_bytes, int nn_rtp_bytes, int nn_padding);
|
|
||||||
virtual srs_error_t dumps_perf_bytes(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Reset all perf stat data.
|
|
||||||
virtual void reset_perf();
|
|
||||||
private:
|
|
||||||
virtual void perf_on_packets(SrsStatisticCategory* p, int nb_msgs);
|
|
||||||
virtual srs_error_t dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj);
|
|
||||||
private:
|
private:
|
||||||
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
|
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
|
||||||
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);
|
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);
|
||||||
|
|
|
@ -46,13 +46,6 @@ extern SrsStageManager* _srs_stages;
|
||||||
extern SrsRtcBlackhole* _srs_blackhole;
|
extern SrsRtcBlackhole* _srs_blackhole;
|
||||||
extern SrsResourceManager* _srs_rtc_manager;
|
extern SrsResourceManager* _srs_rtc_manager;
|
||||||
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache;
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache;
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache;
|
|
||||||
|
|
||||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers;
|
|
||||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs;
|
|
||||||
|
|
||||||
extern SrsResourceManager* _srs_rtc_manager;
|
extern SrsResourceManager* _srs_rtc_manager;
|
||||||
extern SrsDtlsCertificate* _srs_rtc_dtls_certificate;
|
extern SrsDtlsCertificate* _srs_rtc_dtls_certificate;
|
||||||
|
|
||||||
|
@ -166,7 +159,6 @@ extern SrsPps* _srs_pps_objs_rraw;
|
||||||
extern SrsPps* _srs_pps_objs_rfua;
|
extern SrsPps* _srs_pps_objs_rfua;
|
||||||
extern SrsPps* _srs_pps_objs_rbuf;
|
extern SrsPps* _srs_pps_objs_rbuf;
|
||||||
extern SrsPps* _srs_pps_objs_rothers;
|
extern SrsPps* _srs_pps_objs_rothers;
|
||||||
extern SrsPps* _srs_pps_objs_drop;
|
|
||||||
|
|
||||||
SrsCircuitBreaker::SrsCircuitBreaker()
|
SrsCircuitBreaker::SrsCircuitBreaker()
|
||||||
{
|
{
|
||||||
|
@ -306,13 +298,6 @@ srs_error_t srs_thread_initialize()
|
||||||
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
||||||
_srs_circuit_breaker = new SrsCircuitBreaker();
|
_srs_circuit_breaker = new SrsCircuitBreaker();
|
||||||
|
|
||||||
_srs_rtp_cache = new SrsRtpObjectCacheManager<SrsRtpPacket2>(sizeof(SrsRtpPacket2));
|
|
||||||
_srs_rtp_raw_cache = new SrsRtpObjectCacheManager<SrsRtpRawPayload>(sizeof(SrsRtpRawPayload));
|
|
||||||
_srs_rtp_fua_cache = new SrsRtpObjectCacheManager<SrsRtpFUAPayload2>(sizeof(SrsRtpFUAPayload2));
|
|
||||||
|
|
||||||
_srs_rtp_msg_cache_buffers = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage) + kRtpPacketSize);
|
|
||||||
_srs_rtp_msg_cache_objs = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage));
|
|
||||||
|
|
||||||
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
||||||
_srs_rtc_dtls_certificate = new SrsDtlsCertificate();
|
_srs_rtc_dtls_certificate = new SrsDtlsCertificate();
|
||||||
|
|
||||||
|
@ -416,7 +401,6 @@ srs_error_t srs_thread_initialize()
|
||||||
_srs_pps_objs_rfua = new SrsPps();
|
_srs_pps_objs_rfua = new SrsPps();
|
||||||
_srs_pps_objs_rbuf = new SrsPps();
|
_srs_pps_objs_rbuf = new SrsPps();
|
||||||
_srs_pps_objs_rothers = new SrsPps();
|
_srs_pps_objs_rothers = new SrsPps();
|
||||||
_srs_pps_objs_drop = new SrsPps();
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 108
|
#define VERSION_REVISION 110
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -229,19 +229,6 @@ SrsSharedPtrMessage::~SrsSharedPtrMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsSharedPtrMessage::recycle()
|
|
||||||
{
|
|
||||||
// When recycle, unwrap if not the last reference.
|
|
||||||
if (ptr && ptr->shared_count > 0) {
|
|
||||||
ptr->shared_count--;
|
|
||||||
ptr = NULL;
|
|
||||||
payload = NULL;
|
|
||||||
size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsSharedPtrMessage::create(SrsCommonMessage* msg)
|
srs_error_t SrsSharedPtrMessage::create(SrsCommonMessage* msg)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -369,7 +356,7 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy()
|
||||||
|
|
||||||
SrsSharedPtrMessage* SrsSharedPtrMessage::copy2()
|
SrsSharedPtrMessage* SrsSharedPtrMessage::copy2()
|
||||||
{
|
{
|
||||||
SrsSharedPtrMessage* copy = _srs_rtp_msg_cache_objs->allocate();
|
SrsSharedPtrMessage* copy = new SrsSharedPtrMessage();
|
||||||
|
|
||||||
// We got an object from cache, the ptr might exists, so unwrap it.
|
// We got an object from cache, the ptr might exists, so unwrap it.
|
||||||
//srs_assert(!copy->ptr);
|
//srs_assert(!copy->ptr);
|
||||||
|
|
|
@ -312,8 +312,6 @@ public:
|
||||||
SrsSharedPtrMessage();
|
SrsSharedPtrMessage();
|
||||||
virtual ~SrsSharedPtrMessage();
|
virtual ~SrsSharedPtrMessage();
|
||||||
public:
|
public:
|
||||||
// For object cache to reset and reuse it.
|
|
||||||
bool recycle();
|
|
||||||
// Create shared ptr message,
|
// Create shared ptr message,
|
||||||
// copy header, manage the payload of msg,
|
// copy header, manage the payload of msg,
|
||||||
// set the payload to NULL to prevent double free.
|
// set the payload to NULL to prevent double free.
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* The reader and seeker.
|
* The reader and seeker.
|
||||||
*/
|
*/
|
||||||
class ISrsReadSeeker : virtual public ISrsReader, virtual public ISrsSeeker
|
class ISrsReadSeeker : public ISrsReader, public ISrsSeeker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsReadSeeker();
|
ISrsReadSeeker();
|
||||||
|
@ -115,7 +115,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* The generally writer, stream and vector writer.
|
* The generally writer, stream and vector writer.
|
||||||
*/
|
*/
|
||||||
class ISrsWriter : virtual public ISrsStreamWriter, virtual public ISrsVectorWriter
|
class ISrsWriter : public ISrsStreamWriter, public ISrsVectorWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsWriter();
|
ISrsWriter();
|
||||||
|
@ -125,7 +125,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* The writer and seeker.
|
* The writer and seeker.
|
||||||
*/
|
*/
|
||||||
class ISrsWriteSeeker : virtual public ISrsWriter, virtual public ISrsSeeker
|
class ISrsWriteSeeker : public ISrsWriter, public ISrsSeeker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsWriteSeeker();
|
ISrsWriteSeeker();
|
||||||
|
|
|
@ -41,7 +41,6 @@ SrsPps* _srs_pps_objs_rraw = NULL;
|
||||||
SrsPps* _srs_pps_objs_rfua = NULL;
|
SrsPps* _srs_pps_objs_rfua = NULL;
|
||||||
SrsPps* _srs_pps_objs_rbuf = NULL;
|
SrsPps* _srs_pps_objs_rbuf = NULL;
|
||||||
SrsPps* _srs_pps_objs_rothers = NULL;
|
SrsPps* _srs_pps_objs_rothers = NULL;
|
||||||
SrsPps* _srs_pps_objs_drop = NULL;
|
|
||||||
|
|
||||||
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
|
@ -786,89 +785,8 @@ SrsRtpPacket2::SrsRtpPacket2()
|
||||||
|
|
||||||
SrsRtpPacket2::~SrsRtpPacket2()
|
SrsRtpPacket2::~SrsRtpPacket2()
|
||||||
{
|
{
|
||||||
recycle_payload();
|
|
||||||
recycle_shared_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsRtpPacket2::reset()
|
|
||||||
{
|
|
||||||
nalu_type = SrsAvcNaluTypeReserved;
|
|
||||||
frame_type = SrsFrameTypeReserved;
|
|
||||||
cached_payload_size = 0;
|
|
||||||
decode_handler = NULL;
|
|
||||||
|
|
||||||
// It's important to reset the header.
|
|
||||||
header = SrsRtpHeader();
|
|
||||||
|
|
||||||
// Recyle the payload again, to ensure the packet is new one.
|
|
||||||
recycle_payload();
|
|
||||||
recycle_shared_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsRtpPacket2::recycle_payload()
|
|
||||||
{
|
|
||||||
if (!payload_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (payload_type_ == SrsRtpPacketPayloadTypeRaw && _srs_rtp_raw_cache->enabled()) {
|
|
||||||
_srs_rtp_raw_cache->recycle((SrsRtpRawPayload*)payload_);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (payload_type_ == SrsRtpPacketPayloadTypeFUA2 && _srs_rtp_fua_cache->enabled()) {
|
|
||||||
_srs_rtp_fua_cache->recycle((SrsRtpFUAPayload2*)payload_);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_freep(payload_);
|
srs_freep(payload_);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
payload_ = NULL;
|
|
||||||
payload_type_ = SrsRtpPacketPayloadTypeUnknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsRtpPacket2::recycle_shared_buffer()
|
|
||||||
{
|
|
||||||
if (!shared_buffer_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only recycle the message for UDP packets.
|
|
||||||
if (shared_buffer_->payload && shared_buffer_->size == kRtpPacketSize) {
|
|
||||||
if (_srs_rtp_msg_cache_objs->enabled() && shared_buffer_->count() > 0) {
|
|
||||||
// Recycle the small shared message objects.
|
|
||||||
_srs_rtp_msg_cache_objs->recycle(shared_buffer_);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_srs_rtp_msg_cache_buffers->enabled() && shared_buffer_->count() == 0) {
|
|
||||||
// Recycle the UDP large buffer.
|
|
||||||
_srs_rtp_msg_cache_buffers->recycle(shared_buffer_);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_freep(shared_buffer_);
|
srs_freep(shared_buffer_);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
shared_buffer_ = NULL;
|
|
||||||
actual_buffer_size_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsRtpPacket2::recycle()
|
|
||||||
{
|
|
||||||
// Clear the cache size, it may change when reuse it.
|
|
||||||
cached_payload_size = 0;
|
|
||||||
// Reset the handler, for decode only.
|
|
||||||
decode_handler = NULL;
|
|
||||||
|
|
||||||
// We only recycle the payload and shared messages,
|
|
||||||
// for header and fields, user will reset or copy it.
|
|
||||||
recycle_payload();
|
|
||||||
recycle_shared_buffer();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* SrsRtpPacket2::wrap(int size)
|
char* SrsRtpPacket2::wrap(int size)
|
||||||
|
@ -882,29 +800,16 @@ char* SrsRtpPacket2::wrap(int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a large enough message, with under-layer buffer.
|
// Create a large enough message, with under-layer buffer.
|
||||||
while (true) {
|
srs_freep(shared_buffer_);
|
||||||
srs_freep(shared_buffer_);
|
shared_buffer_ = new SrsSharedPtrMessage();
|
||||||
shared_buffer_ = _srs_rtp_msg_cache_buffers->allocate();
|
|
||||||
|
|
||||||
// If got a cached message(which has payload), but it's too small,
|
// Create under-layer buffer for new message
|
||||||
// we free it and allocate a larger one.
|
// For RTC, we use larger under-layer buffer for each packet.
|
||||||
if (shared_buffer_->payload && shared_buffer_->size < size) {
|
int nb_buffer = srs_max(size, kRtpPacketSize);
|
||||||
++_srs_pps_objs_rothers->sugar;
|
char* buf = new char[nb_buffer];
|
||||||
continue;
|
shared_buffer_->wrap(buf, nb_buffer);
|
||||||
}
|
|
||||||
|
|
||||||
// Create under-layer buffer for new message
|
++_srs_pps_objs_rbuf->sugar;
|
||||||
if (!shared_buffer_->payload) {
|
|
||||||
// For RTC, we use larger under-layer buffer for each packet.
|
|
||||||
int nb_buffer = srs_max(size, kRtpPacketSize);
|
|
||||||
char* buf = new char[nb_buffer];
|
|
||||||
shared_buffer_->wrap(buf, nb_buffer);
|
|
||||||
|
|
||||||
++_srs_pps_objs_rbuf->sugar;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shared_buffer_->payload;
|
return shared_buffer_->payload;
|
||||||
}
|
}
|
||||||
|
@ -933,7 +838,7 @@ char* SrsRtpPacket2::wrap(SrsSharedPtrMessage* msg)
|
||||||
|
|
||||||
SrsRtpPacket2* SrsRtpPacket2::copy()
|
SrsRtpPacket2* SrsRtpPacket2::copy()
|
||||||
{
|
{
|
||||||
SrsRtpPacket2* cp = _srs_rtp_cache->allocate();
|
SrsRtpPacket2* cp = new SrsRtpPacket2();
|
||||||
|
|
||||||
// We got packet from cache, the payload and message MUST be NULL,
|
// We got packet from cache, the payload and message MUST be NULL,
|
||||||
// because we had clear it in recycle.
|
// because we had clear it in recycle.
|
||||||
|
@ -1043,7 +948,7 @@ srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
|
||||||
|
|
||||||
// By default, we always use the RAW payload.
|
// By default, we always use the RAW payload.
|
||||||
if (!payload_) {
|
if (!payload_) {
|
||||||
payload_ = _srs_rtp_raw_cache->allocate();
|
payload_ = new SrsRtpRawPayload();
|
||||||
payload_type_ = SrsRtpPacketPayloadTypeRaw;
|
payload_type_ = SrsRtpPacketPayloadTypeRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,13 +986,6 @@ bool SrsRtpPacket2::is_keyframe()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache = NULL;
|
|
||||||
SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache = NULL;
|
|
||||||
SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache = NULL;
|
|
||||||
|
|
||||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers = NULL;
|
|
||||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs = NULL;
|
|
||||||
|
|
||||||
SrsRtpRawPayload::SrsRtpRawPayload()
|
SrsRtpRawPayload::SrsRtpRawPayload()
|
||||||
{
|
{
|
||||||
payload = NULL;
|
payload = NULL;
|
||||||
|
@ -1100,12 +998,6 @@ SrsRtpRawPayload::~SrsRtpRawPayload()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtpRawPayload::recycle()
|
|
||||||
{
|
|
||||||
payload=NULL; nn_payload=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsRtpRawPayload::nb_bytes()
|
uint64_t SrsRtpRawPayload::nb_bytes()
|
||||||
{
|
{
|
||||||
return nn_payload;
|
return nn_payload;
|
||||||
|
@ -1140,7 +1032,7 @@ srs_error_t SrsRtpRawPayload::decode(SrsBuffer* buf)
|
||||||
|
|
||||||
ISrsRtpPayloader* SrsRtpRawPayload::copy()
|
ISrsRtpPayloader* SrsRtpRawPayload::copy()
|
||||||
{
|
{
|
||||||
SrsRtpRawPayload* cp = _srs_rtp_raw_cache->allocate();
|
SrsRtpRawPayload* cp = new SrsRtpRawPayload();
|
||||||
|
|
||||||
cp->payload = payload;
|
cp->payload = payload;
|
||||||
cp->nn_payload = nn_payload;
|
cp->nn_payload = nn_payload;
|
||||||
|
@ -1566,16 +1458,6 @@ SrsRtpFUAPayload2::~SrsRtpFUAPayload2()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtpFUAPayload2::recycle()
|
|
||||||
{
|
|
||||||
start = end = false;
|
|
||||||
nri = nalu_type = (SrsAvcNaluType)0;
|
|
||||||
|
|
||||||
payload = NULL;
|
|
||||||
size = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t SrsRtpFUAPayload2::nb_bytes()
|
uint64_t SrsRtpFUAPayload2::nb_bytes()
|
||||||
{
|
{
|
||||||
return 2 + size;
|
return 2 + size;
|
||||||
|
@ -1643,7 +1525,7 @@ srs_error_t SrsRtpFUAPayload2::decode(SrsBuffer* buf)
|
||||||
|
|
||||||
ISrsRtpPayloader* SrsRtpFUAPayload2::copy()
|
ISrsRtpPayloader* SrsRtpFUAPayload2::copy()
|
||||||
{
|
{
|
||||||
SrsRtpFUAPayload2* cp = _srs_rtp_fua_cache->allocate();
|
SrsRtpFUAPayload2* cp = new SrsRtpFUAPayload2();
|
||||||
|
|
||||||
cp->nri = nri;
|
cp->nri = nri;
|
||||||
cp->start = start;
|
cp->start = start;
|
||||||
|
|
|
@ -315,15 +315,6 @@ public:
|
||||||
SrsRtpPacket2();
|
SrsRtpPacket2();
|
||||||
virtual ~SrsRtpPacket2();
|
virtual ~SrsRtpPacket2();
|
||||||
public:
|
public:
|
||||||
// User MUST reset the packet if got from cache,
|
|
||||||
// except copy(we will assign the header and copy payload).
|
|
||||||
void reset();
|
|
||||||
private:
|
|
||||||
void recycle_payload();
|
|
||||||
void recycle_shared_buffer();
|
|
||||||
public:
|
|
||||||
// Recycle the object to reuse it.
|
|
||||||
virtual bool recycle();
|
|
||||||
// Wrap buffer to shared_message, which is managed by us.
|
// Wrap buffer to shared_message, which is managed by us.
|
||||||
char* wrap(int size);
|
char* wrap(int size);
|
||||||
char* wrap(char* data, int size);
|
char* wrap(char* data, int size);
|
||||||
|
@ -357,112 +348,6 @@ public:
|
||||||
bool is_keyframe();
|
bool is_keyframe();
|
||||||
};
|
};
|
||||||
|
|
||||||
// For object cache manager to stat the object dropped.
|
|
||||||
#include <srs_kernel_kbps.hpp>
|
|
||||||
extern SrsPps* _srs_pps_objs_drop;
|
|
||||||
|
|
||||||
// The RTP packet or message cache manager.
|
|
||||||
template<typename T>
|
|
||||||
class SrsRtpObjectCacheManager
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
bool enabled_;
|
|
||||||
std::vector<T*> cache_objs_;
|
|
||||||
size_t capacity_;
|
|
||||||
size_t object_size_;
|
|
||||||
public:
|
|
||||||
// SrsRtpObjectCacheManager::SrsRtpObjectCacheManager
|
|
||||||
SrsRtpObjectCacheManager(size_t size_of_object) {
|
|
||||||
enabled_ = false;
|
|
||||||
capacity_ = 0;
|
|
||||||
object_size_ = size_of_object;
|
|
||||||
}
|
|
||||||
// SrsRtpObjectCacheManager::~SrsRtpObjectCacheManager
|
|
||||||
virtual ~SrsRtpObjectCacheManager() {
|
|
||||||
typedef typename std::vector<T*>::iterator iterator;
|
|
||||||
for (iterator it = cache_objs_.begin(); it != cache_objs_.end(); ++it) {
|
|
||||||
T* obj = *it;
|
|
||||||
srs_freep(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
// Setup the object cache, shrink if capacity changed.
|
|
||||||
// SrsRtpObjectCacheManager::setup
|
|
||||||
void setup(bool v, uint64_t memory) {
|
|
||||||
enabled_ = v;
|
|
||||||
capacity_ = (size_t)(memory / object_size_);
|
|
||||||
|
|
||||||
|
|
||||||
if (!enabled_) {
|
|
||||||
capacity_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shrink the cache.
|
|
||||||
while (cache_objs_.size() > capacity_) {
|
|
||||||
T* obj = cache_objs_.back();
|
|
||||||
cache_objs_.pop_back();
|
|
||||||
srs_freep(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Get the status of object cache.
|
|
||||||
// SrsRtpObjectCacheManager::enabled
|
|
||||||
inline bool enabled() {
|
|
||||||
return enabled_;
|
|
||||||
}
|
|
||||||
// SrsRtpObjectCacheManager::size
|
|
||||||
int size() {
|
|
||||||
return (int)cache_objs_.size();
|
|
||||||
}
|
|
||||||
// SrsRtpObjectCacheManager::capacity
|
|
||||||
int capacity() {
|
|
||||||
return (int)capacity_;
|
|
||||||
}
|
|
||||||
// Try to allocate from cache, create new object if no cache.
|
|
||||||
// SrsRtpObjectCacheManager::allocate
|
|
||||||
T* allocate() {
|
|
||||||
if (!enabled_ || cache_objs_.empty()) {
|
|
||||||
return new T();
|
|
||||||
}
|
|
||||||
|
|
||||||
T* obj = cache_objs_.back();
|
|
||||||
cache_objs_.pop_back();
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
// Recycle the object to cache.
|
|
||||||
// @remark User can directly free the packet.
|
|
||||||
// SrsRtpObjectCacheManager::recycle
|
|
||||||
void recycle(T* p) {
|
|
||||||
// The p may be NULL, because srs_freep(NULL) is ok.
|
|
||||||
if (!p) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If disabled, drop the object.
|
|
||||||
if (!enabled_) {
|
|
||||||
srs_freep(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If recycle the object fail, drop the cached object.
|
|
||||||
if (!p->recycle()) {
|
|
||||||
srs_freep(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If exceed the capacity, drop the object.
|
|
||||||
if (cache_objs_.size() > capacity_) {
|
|
||||||
++_srs_pps_objs_drop->sugar;
|
|
||||||
|
|
||||||
srs_freep(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recycle it.
|
|
||||||
cache_objs_.push_back(p);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Single payload data.
|
// Single payload data.
|
||||||
class SrsRtpRawPayload : public ISrsRtpPayloader
|
class SrsRtpRawPayload : public ISrsRtpPayloader
|
||||||
{
|
{
|
||||||
|
@ -474,8 +359,6 @@ public:
|
||||||
public:
|
public:
|
||||||
SrsRtpRawPayload();
|
SrsRtpRawPayload();
|
||||||
virtual ~SrsRtpRawPayload();
|
virtual ~SrsRtpRawPayload();
|
||||||
public:
|
|
||||||
bool recycle();
|
|
||||||
// interface ISrsRtpPayloader
|
// interface ISrsRtpPayloader
|
||||||
public:
|
public:
|
||||||
virtual uint64_t nb_bytes();
|
virtual uint64_t nb_bytes();
|
||||||
|
@ -574,8 +457,6 @@ public:
|
||||||
public:
|
public:
|
||||||
SrsRtpFUAPayload2();
|
SrsRtpFUAPayload2();
|
||||||
virtual ~SrsRtpFUAPayload2();
|
virtual ~SrsRtpFUAPayload2();
|
||||||
public:
|
|
||||||
bool recycle();
|
|
||||||
// interface ISrsRtpPayloader
|
// interface ISrsRtpPayloader
|
||||||
public:
|
public:
|
||||||
virtual uint64_t nb_bytes();
|
virtual uint64_t nb_bytes();
|
||||||
|
@ -584,15 +465,4 @@ public:
|
||||||
virtual ISrsRtpPayloader* copy();
|
virtual ISrsRtpPayloader* copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
// For RTP packets cache.
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache;
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache;
|
|
||||||
extern SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache;
|
|
||||||
|
|
||||||
// For shared message cache, with payload.
|
|
||||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers;
|
|
||||||
// For shared message cache, without payload.
|
|
||||||
// Note that user must unwrap the shared message, before recycle it.
|
|
||||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -646,7 +646,7 @@ int SrsIngestHlsInput::SrsTsPiece::fetch(string m3u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
// the context to output to rtmp server
|
// the context to output to rtmp server
|
||||||
class SrsIngestHlsOutput : virtual public ISrsTsHandler, virtual public ISrsAacHandler
|
class SrsIngestHlsOutput : public ISrsTsHandler, public ISrsAacHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsHttpUri* out_rtmp;
|
SrsHttpUri* out_rtmp;
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* the reader for the protocol to read from whatever channel.
|
* the reader for the protocol to read from whatever channel.
|
||||||
*/
|
*/
|
||||||
class ISrsProtocolReader : virtual public ISrsReader, virtual public ISrsProtocolStatistic
|
class ISrsProtocolReader : public ISrsReader, virtual public ISrsProtocolStatistic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsProtocolReader();
|
ISrsProtocolReader();
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* the writer for the protocol to write to whatever channel.
|
* the writer for the protocol to write to whatever channel.
|
||||||
*/
|
*/
|
||||||
class ISrsProtocolWriter : virtual public ISrsWriter, virtual public ISrsProtocolStatistic
|
class ISrsProtocolWriter : public ISrsWriter, virtual public ISrsProtocolStatistic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsProtocolWriter();
|
ISrsProtocolWriter();
|
||||||
|
@ -114,7 +114,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* The reader and writer.
|
* The reader and writer.
|
||||||
*/
|
*/
|
||||||
class ISrsProtocolReadWriter : virtual public ISrsProtocolReader, virtual public ISrsProtocolWriter
|
class ISrsProtocolReadWriter : public ISrsProtocolReader, public ISrsProtocolWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsProtocolReadWriter();
|
ISrsProtocolReadWriter();
|
||||||
|
|
|
@ -137,7 +137,7 @@ public:
|
||||||
* user->set_io(kbps, kbps);
|
* user->set_io(kbps, kbps);
|
||||||
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
||||||
*/
|
*/
|
||||||
class SrsKbps : virtual public ISrsProtocolStatistic, virtual public ISrsKbpsDelta
|
class SrsKbps : public ISrsProtocolStatistic, public ISrsKbpsDelta
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsKbpsSlice is;
|
SrsKbpsSlice is;
|
||||||
|
|
|
@ -217,14 +217,6 @@ 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;
|
||||||
|
@ -264,7 +256,6 @@ 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()
|
||||||
|
@ -312,11 +303,6 @@ 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;
|
||||||
|
@ -463,11 +449,6 @@ 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++) {
|
||||||
|
@ -481,10 +462,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
if (!msg->payload || msg->size <= 0) {
|
if (!msg->payload || msg->size <= 0) {
|
||||||
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.
|
||||||
|
@ -545,13 +522,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
if ((err = do_iovs_send(out_iovs, iov_index)) != srs_success) {
|
if ((err = do_iovs_send(out_iovs, iov_index)) != srs_success) {
|
||||||
return srs_error_wrap(err, "send iovs");
|
return srs_error_wrap(err, "send iovs");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify about perf stat.
|
|
||||||
if (perf) {
|
|
||||||
perf->perf_on_msgs(nb_msgs_merged_written);
|
|
||||||
perf->perf_on_writev_iovs(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.
|
||||||
|
@ -575,13 +545,6 @@ 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_on_msgs(nb_msgs_merged_written);
|
|
||||||
perf->perf_on_writev_iovs(iov_index);
|
|
||||||
nb_msgs_merged_written = 0; bytes_msgs_merged_written = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
#else
|
#else
|
||||||
// try to send use the c0c3 header cache,
|
// try to send use the c0c3 header cache,
|
||||||
|
@ -2257,11 +2220,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,19 +147,6 @@ protected:
|
||||||
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The performance statistic data collect.
|
|
||||||
class ISrsProtocolPerf
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ISrsProtocolPerf();
|
|
||||||
virtual ~ISrsProtocolPerf();
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_msgs is the number of RTMP messages,
|
|
||||||
virtual void perf_on_msgs(int nb_msgs) = 0;
|
|
||||||
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
|
||||||
virtual void perf_on_writev_iovs(int nb_iovs) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// The protocol provides the rtmp-message-protocol services,
|
// The protocol provides the rtmp-message-protocol services,
|
||||||
// To recv RTMP message from RTMP chunk stream,
|
// To recv RTMP message from RTMP chunk stream,
|
||||||
// and to send out RTMP message over RTMP chunk stream.
|
// and to send out RTMP message over RTMP chunk stream.
|
||||||
|
@ -181,8 +168,6 @@ private:
|
||||||
private:
|
private:
|
||||||
// The underlayer socket object, send/recv bytes.
|
// The underlayer socket object, send/recv bytes.
|
||||||
ISrsProtocolReadWriter* skt;
|
ISrsProtocolReadWriter* skt;
|
||||||
// The performance stat handler.
|
|
||||||
ISrsProtocolPerf* perf;
|
|
||||||
// The requests sent out, used to build the response.
|
// The requests sent out, used to build the response.
|
||||||
// key: transactionId
|
// key: transactionId
|
||||||
// value: the request command name
|
// value: the request command name
|
||||||
|
@ -242,8 +227,6 @@ public:
|
||||||
// @param v, whether auto response message when recv message.
|
// @param v, whether auto response message when recv message.
|
||||||
// @see: https://github.com/ossrs/srs/issues/217
|
// @see: https://github.com/ossrs/srs/issues/217
|
||||||
virtual void set_auto_response(bool v);
|
virtual void set_auto_response(bool v);
|
||||||
// Set the performance stat handler.
|
|
||||||
virtual void set_perf(ISrsProtocolPerf* v);
|
|
||||||
// Flush for manual response when the auto response is disabled
|
// Flush for manual response when the auto response is disabled
|
||||||
// by set_auto_response(false), we default use auto response, so donot
|
// by set_auto_response(false), we default use auto response, so donot
|
||||||
// need to call this api(the protocol sdk will auto send message).
|
// need to call this api(the protocol sdk will auto send message).
|
||||||
|
@ -654,8 +637,6 @@ public:
|
||||||
// @param v, whether auto response message when recv message.
|
// @param v, whether auto response message when recv message.
|
||||||
// @see: https://github.com/ossrs/srs/issues/217
|
// @see: https://github.com/ossrs/srs/issues/217
|
||||||
virtual void set_auto_response(bool v);
|
virtual void set_auto_response(bool v);
|
||||||
// Set the performance stat handler.
|
|
||||||
virtual void set_perf(ISrsProtocolPerf* v);
|
|
||||||
#ifdef SRS_PERF_MERGED_READ
|
#ifdef SRS_PERF_MERGED_READ
|
||||||
// To improve read performance, merge some packets then read,
|
// To improve read performance, merge some packets then read,
|
||||||
// When it on and read small bytes, we sleep to wait more data.,
|
// When it on and read small bytes, we sleep to wait more data.,
|
||||||
|
|
|
@ -46,7 +46,7 @@ class SrsTcpClient;
|
||||||
#define SRS_HTTP_CLIENT_TIMEOUT (30 * SRS_UTIME_SECONDS)
|
#define SRS_HTTP_CLIENT_TIMEOUT (30 * SRS_UTIME_SECONDS)
|
||||||
|
|
||||||
// The SSL client over TCP transport.
|
// The SSL client over TCP transport.
|
||||||
class SrsSslClient : virtual public ISrsReader, virtual public ISrsStreamWriter
|
class SrsSslClient : public ISrsReader, public ISrsStreamWriter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsTcpClient* transport;
|
SrsTcpClient* transport;
|
||||||
|
|
|
@ -257,7 +257,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Response reader use st socket.
|
// Response reader use st socket.
|
||||||
class SrsHttpResponseReader : virtual public ISrsHttpResponseReader
|
class SrsHttpResponseReader : public ISrsHttpResponseReader
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ISrsReader* skt;
|
ISrsReader* skt;
|
||||||
|
|
|
@ -174,7 +174,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockHttpHandler : virtual public ISrsHttpHandler, virtual public ISrsHttpMatchHijacker
|
class MockHttpHandler : public ISrsHttpHandler, public ISrsHttpMatchHijacker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
string bytes;
|
string bytes;
|
||||||
|
|
|
@ -36,7 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class MockResponseWriter : virtual public ISrsHttpResponseWriter, virtual public ISrsHttpHeaderFilter
|
class MockResponseWriter : public ISrsHttpResponseWriter, public ISrsHttpHeaderFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsHttpResponseWriter* w;
|
SrsHttpResponseWriter* w;
|
||||||
|
|
Loading…
Reference in a new issue