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

Merge SRS3.0

This commit is contained in:
winlin 2020-10-31 19:25:56 +08:00
commit 8c1eca98b0
23 changed files with 82 additions and 76 deletions

View file

@ -91,7 +91,7 @@ bool _bandwidth_is_stopped_publish(SrsBandwidthPacket* pkt)
{
return pkt->is_stopped_publish();
}
srs_error_t _srs_expect_bandwidth_packet(SrsRtmpServer* rtmp, _CheckPacketType pfn)
srs_error_t srs_expect_bandwidth_packet(SrsRtmpServer* rtmp, _CheckPacketType pfn)
{
srs_error_t err = srs_success;
@ -241,7 +241,7 @@ srs_error_t SrsBandwidth::play_start(SrsBandwidthSample* sample, SrsKbpsLimit* l
}
}
if ((err = _srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_starting_play)) != srs_success) {
if ((err = srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_starting_play)) != srs_success) {
return srs_error_wrap(err, "expect bandwidth");
}
@ -304,7 +304,7 @@ srs_error_t SrsBandwidth::play_stop(SrsBandwidthSample* sample, SrsKbpsLimit* /*
}
}
if ((err = _srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_stopped_play)) != srs_success) {
if ((err = srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_stopped_play)) != srs_success) {
return srs_error_wrap(err, "expect bandwidth");
}
@ -328,7 +328,7 @@ srs_error_t SrsBandwidth::publish_start(SrsBandwidthSample* sample, SrsKbpsLimit
}
}
if ((err = _srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_starting_publish)) != srs_success) {
if ((err = srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_starting_publish)) != srs_success) {
return srs_error_wrap(err, "expect packet");
}
@ -388,7 +388,7 @@ srs_error_t SrsBandwidth::publish_stop(SrsBandwidthSample* sample, SrsKbpsLimit*
// we just ignore the packet and send the bandwidth test data.
bool is_flash = (_req->swfUrl != "");
if (!is_flash) {
if ((err = _srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_stopped_publish)) != srs_success) {
if ((err = srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_stopped_publish)) != srs_success) {
return srs_error_wrap(err, "expect bandwidth");
}
}
@ -422,7 +422,7 @@ srs_error_t SrsBandwidth::do_final(SrsBandwidthSample& play_sample, SrsBandwidth
bool is_flash = (_req->swfUrl != "");
if (!is_flash) {
// ignore any error.
err = _srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_final);
err = srs_expect_bandwidth_packet(_rtmp, _bandwidth_is_final);
srs_error_reset(err);
}

View file

@ -57,7 +57,7 @@ using namespace std;
#include <srs_kernel_utility.hpp>
#include <srs_rtmp_stack.hpp>
using namespace _srs_internal;
using namespace srs_internal;
// @global the version to identify the core.
const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER;
@ -92,7 +92,7 @@ bool is_common_space(char ch)
return (ch == ' ' || ch == '\t' || ch == SRS_CR || ch == SRS_LF);
}
namespace _srs_internal
namespace srs_internal
{
SrsConfigBuffer::SrsConfigBuffer()
{
@ -5272,20 +5272,20 @@ int SrsConfig::get_time_jitter(string vhost)
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return _srs_time_jitter_string2int(DEFAULT);
return srs_time_jitter_string2int(DEFAULT);
}
conf = conf->get("play");
if (!conf) {
return _srs_time_jitter_string2int(DEFAULT);
return srs_time_jitter_string2int(DEFAULT);
}
conf = conf->get("time_jitter");
if (!conf || conf->arg0().empty()) {
return _srs_time_jitter_string2int(DEFAULT);
return srs_time_jitter_string2int(DEFAULT);
}
return _srs_time_jitter_string2int(conf->arg0());
return srs_time_jitter_string2int(conf->arg0());
}
bool SrsConfig::get_mix_correct(string vhost)
@ -7505,15 +7505,15 @@ int SrsConfig::get_dvr_time_jitter(string vhost)
SrsConfDirective* conf = get_dvr(vhost);
if (!conf) {
return _srs_time_jitter_string2int(DEFAULT);
return srs_time_jitter_string2int(DEFAULT);
}
conf = conf->get("time_jitter");
if (!conf || conf->arg0().empty()) {
return _srs_time_jitter_string2int(DEFAULT);
return srs_time_jitter_string2int(DEFAULT);
}
return _srs_time_jitter_string2int(conf->arg0());
return srs_time_jitter_string2int(conf->arg0());
}
bool SrsConfig::get_http_api_enabled()

View file

@ -77,7 +77,7 @@ bool srs_vector_actual_equals(const std::vector<T>& a, const std::vector<T>& b)
return true;
}
namespace _srs_internal
namespace srs_internal
{
// The buffer of config content.
class SrsConfigBuffer
@ -229,7 +229,7 @@ public:
// Parse utilities
public:
// Parse config directive from file buffer.
virtual srs_error_t parse(_srs_internal::SrsConfigBuffer* buffer);
virtual srs_error_t parse(srs_internal::SrsConfigBuffer* buffer);
// Marshal the directive to writer.
// @param level, the root is level0, all its directives are level1, and so on.
virtual srs_error_t persistence(SrsFileWriter* writer, int level);
@ -253,13 +253,13 @@ private:
// 1. read a token(directive args and a ret flag),
// 2. initialize the directive by args, args[0] is name, args[1-N] is args of directive,
// 3. if ret flag indicates there are child-directives, read_conf(directive, block) recursively.
virtual srs_error_t parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type);
virtual srs_error_t parse_conf(srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type);
// Read a token from buffer.
// A token, is the directive args and a flag indicates whether has child-directives.
// @param args, the output directive args, the first is the directive name, left is the args.
// @param line_start, the actual start line of directive.
// @return, an error code indicates error or has child-directives.
virtual srs_error_t read_token(_srs_internal::SrsConfigBuffer* buffer, std::vector<std::string>& args, int& line_start);
virtual srs_error_t read_token(srs_internal::SrsConfigBuffer* buffer, std::vector<std::string>& args, int& line_start);
};
// The config service provider.
@ -425,7 +425,7 @@ protected:
// Parse config from the buffer.
// @param buffer, the config buffer, user must delete it.
// @remark, use protected for the utest to override with mock.
virtual srs_error_t parse_buffer(_srs_internal::SrsConfigBuffer* buffer);
virtual srs_error_t parse_buffer(srs_internal::SrsConfigBuffer* buffer);
// global env
public:
// Get the current work directory.

View file

@ -1141,9 +1141,9 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
// trigger edge to fetch from origin.
bool vhost_is_edge = _srs_config->get_vhost_is_edge(r->vhost);
srs_trace("flv: source url=%s, is_edge=%d, source_id=[%d][%s]",
r->get_stream_url().c_str(), vhost_is_edge, ::getpid(), s->source_id().c_str());
srs_trace("flv: source url=%s, is_edge=%d, source_id=%s/%s",
r->get_stream_url().c_str(), vhost_is_edge, s->source_id().c_str(), s->pre_source_id().c_str());
return err;
}

View file

@ -524,8 +524,8 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
}
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
srs_trace("source url=%s, ip=%s, cache=%d, is_edge=%d, source_id=[%d][%s]",
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, info->edge, ::getpid(), source->source_id().c_str());
srs_trace("source url=%s, ip=%s, cache=%d, is_edge=%d, source_id=%s/%s",
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, info->edge, source->source_id().c_str(), source->pre_source_id().c_str());
source->set_cache(enabled_cache);
switch (info->type) {

View file

@ -66,7 +66,7 @@ using namespace std;
// the time to cleanup source.
#define SRS_SOURCE_CLEANUP (30 * SRS_UTIME_SECONDS)
int _srs_time_jitter_string2int(std::string time_jitter)
int srs_time_jitter_string2int(std::string time_jitter)
{
if (time_jitter == "full") {
return SrsRtmpJitterAlgorithmFULL;
@ -519,7 +519,7 @@ srs_error_t SrsConsumer::dump_packets(SrsMessageArray* msgs, int& count)
count = 0;
if (should_update_source_id) {
srs_trace("update source_id=%s[%s]", source->source_id().c_str(), source->source_id().c_str());
srs_trace("update source_id=%s/%s", source->source_id().c_str(), source->pre_source_id().c_str());
should_update_source_id = false;
}
@ -2070,13 +2070,10 @@ srs_error_t SrsSource::on_source_id_changed(SrsContextId id)
if (!_source_id.compare(id)) {
return err;
}
if (_pre_source_id.empty()) {
_pre_source_id = id;
} else if (_pre_source_id.compare(_source_id)) {
_pre_source_id = _source_id;
}
_source_id = id;
// notice all consumer
@ -2559,7 +2556,10 @@ void SrsSource::on_unpublish()
_can_publish = true;
_source_id = SrsContextId();
if (!_source_id.empty()) {
_pre_source_id = _source_id;
}
// notify the handler.
srs_assert(handler);
SrsStatistic* stat = SrsStatistic::instance();

View file

@ -72,7 +72,7 @@ enum SrsRtmpJitterAlgorithm
SrsRtmpJitterAlgorithmZERO,
SrsRtmpJitterAlgorithmOFF
};
int _srs_time_jitter_string2int(std::string time_jitter);
int srs_time_jitter_string2int(std::string time_jitter);
// Time jitter detect and correct, to ensure the rtmp stream is monotonically.
class SrsRtmpJitter