mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch '3.0release' into develop
This commit is contained in:
commit
c107eb62ed
8 changed files with 2846 additions and 871 deletions
|
@ -80,36 +80,6 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER;
|
|||
*/
|
||||
srs_error_t srs_config_dumps_engine(SrsConfDirective* dir, SrsJsonObject* engine);
|
||||
|
||||
/**
|
||||
* whether the two vector actual equals, for instance,
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [2, 1, 0]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 2, 1]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2, 3]) ==== false
|
||||
* srs_vector_actual_equals([1, 2, 3], [0, 1, 2]) ==== false
|
||||
*/
|
||||
template<typename T>
|
||||
bool srs_vector_actual_equals(const vector<T>& a, const vector<T>& b)
|
||||
{
|
||||
// all elements of a in b.
|
||||
for (int i = 0; i < (int)a.size(); i++) {
|
||||
const T& e = a.at(i);
|
||||
if (::find(b.begin(), b.end(), e) == b.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// all elements of b in a.
|
||||
for (int i = 0; i < (int)b.size(); i++) {
|
||||
const T& e = b.at(i);
|
||||
if (::find(a.begin(), a.end(), e) == a.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* whether the ch is common space.
|
||||
*/
|
||||
|
@ -132,7 +102,8 @@ namespace _srs_internal
|
|||
{
|
||||
srs_freepa(start);
|
||||
}
|
||||
|
||||
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t SrsConfigBuffer::fullfill(const char* filename)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -160,6 +131,7 @@ namespace _srs_internal
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
bool SrsConfigBuffer::empty()
|
||||
{
|
||||
|
@ -250,6 +222,14 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b, string excep
|
|||
return true;
|
||||
}
|
||||
|
||||
void set_config_directive(SrsConfDirective* parent, string dir, string value)
|
||||
{
|
||||
SrsConfDirective* d = parent->get_or_create(dir);
|
||||
d->name = dir;
|
||||
d->args.clear();
|
||||
d->args.push_back(value);
|
||||
}
|
||||
|
||||
bool srs_config_hls_is_on_error_ignore(string strategy)
|
||||
{
|
||||
return strategy == "ignore";
|
||||
|
@ -413,7 +393,7 @@ srs_error_t srs_config_transform_vhost(SrsConfDirective* root)
|
|||
if (enabled) {
|
||||
SrsConfDirective* mr = publish->get_or_create("mr");
|
||||
mr->args = enabled->args;
|
||||
srs_warn("transform: vhost.mr.enabled to vhost.publish.mr.enabled for %s", dir->name.c_str());
|
||||
srs_warn("transform: vhost.mr.enabled to vhost.publish.mr for %s", dir->name.c_str());
|
||||
}
|
||||
|
||||
SrsConfDirective* latency = conf->get("latency");
|
||||
|
@ -525,6 +505,7 @@ srs_error_t srs_config_transform_vhost(SrsConfDirective* root)
|
|||
return err;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t srs_config_dumps_engine(SrsConfDirective* dir, SrsJsonObject* engine)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -626,6 +607,7 @@ srs_error_t srs_config_dumps_engine(SrsConfDirective* dir, SrsJsonObject* engine
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
SrsConfDirective::SrsConfDirective()
|
||||
{
|
||||
|
@ -890,6 +872,7 @@ srs_error_t SrsConfDirective::persistence(SrsFileWriter* writer, int level)
|
|||
return err;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
SrsJsonArray* SrsConfDirective::dumps_args()
|
||||
{
|
||||
SrsJsonArray* arr = SrsJsonAny::array();
|
||||
|
@ -919,6 +902,7 @@ SrsJsonAny* SrsConfDirective::dumps_arg0_to_boolean()
|
|||
{
|
||||
return SrsJsonAny::boolean(arg0() == "on");
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
// see: ngx_conf_parse
|
||||
srs_error_t SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveType type)
|
||||
|
@ -1148,24 +1132,6 @@ bool SrsConfig::is_dolphin()
|
|||
return dolphin;
|
||||
}
|
||||
|
||||
void SrsConfig::set_config_directive(SrsConfDirective* parent, string dir, string value)
|
||||
{
|
||||
SrsConfDirective* d = parent->get(dir);
|
||||
|
||||
if (!d) {
|
||||
d = new SrsConfDirective();
|
||||
if (!dir.empty()) {
|
||||
d->name = dir;
|
||||
}
|
||||
parent->directives.push_back(d);
|
||||
}
|
||||
|
||||
d->args.clear();
|
||||
if (!value.empty()) {
|
||||
d->args.push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SrsConfig::subscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
@ -1190,6 +1156,7 @@ void SrsConfig::unsubscribe(ISrsReloadHandler* handler)
|
|||
subscribes.erase(it);
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t SrsConfig::reload()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -1216,6 +1183,7 @@ srs_error_t SrsConfig::reload()
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
srs_error_t SrsConfig::reload_vhost(SrsConfDirective* old_root)
|
||||
{
|
||||
|
@ -1882,6 +1850,7 @@ srs_error_t SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirecti
|
|||
}
|
||||
|
||||
// see: ngx_get_options
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t SrsConfig::parse_options(int argc, char** argv)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -3157,6 +3126,7 @@ srs_error_t SrsConfig::raw_disable_dvr(string vhost, string stream, bool& applie
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
srs_error_t SrsConfig::do_reload_listen()
|
||||
{
|
||||
|
@ -3344,6 +3314,7 @@ string SrsConfig::config()
|
|||
return config_file;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t SrsConfig::parse_argv(int& i, char** argv)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -3459,6 +3430,7 @@ srs_error_t SrsConfig::parse_file(const char* filename)
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
srs_error_t SrsConfig::check_config()
|
||||
{
|
||||
|
@ -3864,6 +3836,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
return err;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
srs_error_t SrsConfig::check_number_connections()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -3913,12 +3886,13 @@ srs_error_t SrsConfig::check_number_connections()
|
|||
|
||||
return err;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
srs_error_t SrsConfig::parse_buffer(SrsConfigBuffer* buffer)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// We use a new root to parse buffer, to allow parse multiple times.
|
||||
// We use a new root to parse buffer, to allow parse multiple times.
|
||||
srs_freep(root);
|
||||
root = new SrsConfDirective();
|
||||
|
||||
|
@ -4565,7 +4539,7 @@ bool SrsConfig::get_mr_enabled(string vhost)
|
|||
|
||||
srs_utime_t SrsConfig::get_mr_sleep(string vhost)
|
||||
{
|
||||
static srs_utime_t DEFAULT = SRS_PERF_MR_SLEEP;
|
||||
static srs_utime_t DEFAULT = SRS_PERF_MR_SLEEP;
|
||||
|
||||
SrsConfDirective* conf = get_vhost(vhost);
|
||||
if (!conf) {
|
||||
|
@ -4587,7 +4561,7 @@ srs_utime_t SrsConfig::get_mr_sleep(string vhost)
|
|||
|
||||
srs_utime_t SrsConfig::get_mw_sleep(string vhost)
|
||||
{
|
||||
static srs_utime_t DEFAULT = SRS_PERF_MW_SLEEP;
|
||||
static srs_utime_t DEFAULT = SRS_PERF_MW_SLEEP;
|
||||
|
||||
SrsConfDirective* conf = get_vhost(vhost);
|
||||
if (!conf) {
|
||||
|
@ -5257,7 +5231,9 @@ vector<string> SrsConfig::get_engine_perfile(SrsConfDirective* conf)
|
|||
}
|
||||
|
||||
perfile.push_back(srs_prefix_underscores_ifno(option->name));
|
||||
perfile.push_back(option->arg0());
|
||||
if (!option->arg0().empty()) {
|
||||
perfile.push_back(option->arg0());
|
||||
}
|
||||
}
|
||||
|
||||
return perfile;
|
||||
|
@ -5299,7 +5275,9 @@ vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* conf)
|
|||
}
|
||||
|
||||
vfilter.push_back(srs_prefix_underscores_ifno(filter->name));
|
||||
vfilter.push_back(filter->arg0());
|
||||
if (!filter->arg0().empty()) {
|
||||
vfilter.push_back(filter->arg0());
|
||||
}
|
||||
}
|
||||
|
||||
return vfilter;
|
||||
|
@ -5453,7 +5431,9 @@ vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* conf)
|
|||
}
|
||||
|
||||
vparams.push_back(srs_prefix_underscores_ifno(filter->name));
|
||||
vparams.push_back(filter->arg0());
|
||||
if (!filter->arg0().empty()) {
|
||||
vparams.push_back(filter->arg0());
|
||||
}
|
||||
}
|
||||
|
||||
return vparams;
|
||||
|
@ -5543,7 +5523,9 @@ vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* conf)
|
|||
}
|
||||
|
||||
aparams.push_back(srs_prefix_underscores_ifno(filter->name));
|
||||
aparams.push_back(filter->arg0());
|
||||
if (!filter->arg0().empty()) {
|
||||
aparams.push_back(filter->arg0());
|
||||
}
|
||||
}
|
||||
|
||||
return aparams;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <srs_app_reload.hpp>
|
||||
#include <srs_app_async_call.hpp>
|
||||
|
@ -46,6 +47,35 @@ class SrsRequest;
|
|||
class SrsJsonArray;
|
||||
class SrsConfDirective;
|
||||
|
||||
/**
|
||||
* whether the two vector actual equals, for instance,
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [2, 1, 0]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 2, 1]) ==== true
|
||||
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2, 3]) ==== false
|
||||
* srs_vector_actual_equals([1, 2, 3], [0, 1, 2]) ==== false
|
||||
*/
|
||||
template<typename T>
|
||||
bool srs_vector_actual_equals(const std::vector<T>& a, const std::vector<T>& b)
|
||||
{
|
||||
// all elements of a in b.
|
||||
for (int i = 0; i < (int)a.size(); i++) {
|
||||
const T& e = a.at(i);
|
||||
if (std::find(b.begin(), b.end(), e) == b.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// all elements of b in a.
|
||||
for (int i = 0; i < (int)b.size(); i++) {
|
||||
const T& e = b.at(i);
|
||||
if (std::find(a.begin(), a.end(), e) == a.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace _srs_internal
|
||||
{
|
||||
|
@ -278,9 +308,7 @@ public:
|
|||
public:
|
||||
// Whether srs is in dolphin mode.
|
||||
virtual bool is_dolphin();
|
||||
private:
|
||||
virtual void set_config_directive(SrsConfDirective* parent, std::string dir, std::string value);
|
||||
// Reload
|
||||
// Reload
|
||||
public:
|
||||
// For reload handler to register itself,
|
||||
// when config service do the reload, callback the handler.
|
||||
|
|
|
@ -1195,24 +1195,24 @@ srs_error_t SrsFormat::audio_aac_demux(SrsBuffer* stream, int64_t timestamp)
|
|||
int8_t sound_size = (sound_format >> 1) & 0x01;
|
||||
int8_t sound_rate = (sound_format >> 2) & 0x03;
|
||||
sound_format = (sound_format >> 4) & 0x0f;
|
||||
|
||||
|
||||
SrsAudioCodecId codec_id = (SrsAudioCodecId)sound_format;
|
||||
acodec->id = codec_id;
|
||||
|
||||
|
||||
acodec->sound_type = (SrsAudioChannels)sound_type;
|
||||
acodec->sound_rate = (SrsAudioSampleRate)sound_rate;
|
||||
acodec->sound_size = (SrsAudioSampleBits)sound_size;
|
||||
|
||||
|
||||
// we support h.264+mp3 for hls.
|
||||
if (codec_id == SrsAudioCodecIdMP3) {
|
||||
return srs_error_new(ERROR_HLS_TRY_MP3, "try mp3");
|
||||
}
|
||||
|
||||
|
||||
// only support aac
|
||||
if (codec_id != SrsAudioCodecIdAAC) {
|
||||
return srs_error_new(ERROR_HLS_DECODE_ERROR, "not supported codec %d", codec_id);
|
||||
}
|
||||
|
||||
|
||||
if (!stream->require(1)) {
|
||||
return srs_error_new(ERROR_HLS_DECODE_ERROR, "aac decode aac_packet_type");
|
||||
}
|
||||
|
|
|
@ -3884,6 +3884,11 @@ SrsMp4DecodingTime2SampleBox::~SrsMp4DecodingTime2SampleBox()
|
|||
srs_error_t SrsMp4DecodingTime2SampleBox::initialize_counter()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// If only sps/pps and no frames, there is no stts entries.
|
||||
if (entries.empty()) {
|
||||
return err;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if (index >= entries.size()) {
|
||||
|
@ -4005,6 +4010,11 @@ SrsMp4CompositionTime2SampleBox::~SrsMp4CompositionTime2SampleBox()
|
|||
srs_error_t SrsMp4CompositionTime2SampleBox::initialize_counter()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// If only sps/pps and no frames, there is no stts entries.
|
||||
if (entries.empty()) {
|
||||
return err;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if (index >= entries.size()) {
|
||||
|
@ -4812,7 +4822,7 @@ srs_error_t SrsMp4SampleManager::write(SrsMp4MovieBox* moov)
|
|||
vector<SrsMp4Sample*>::iterator it;
|
||||
for (it = samples.begin(); it != samples.end(); ++it) {
|
||||
SrsMp4Sample* sample = *it;
|
||||
if (sample->dts != sample->pts) {
|
||||
if (sample->dts != sample->pts && sample->type == SrsFrameTypeVideo) {
|
||||
has_cts = true;
|
||||
break;
|
||||
}
|
||||
|
@ -5760,7 +5770,7 @@ srs_error_t SrsMp4Encoder::flush()
|
|||
mvhd->duration_in_tbn = srs_max(vduration, aduration);
|
||||
mvhd->next_track_ID = 1; // Starts from 1, increase when use it.
|
||||
|
||||
if (nb_videos) {
|
||||
if (nb_videos || !pavcc.empty()) {
|
||||
SrsMp4TrackBox* trak = new SrsMp4TrackBox();
|
||||
moov->add_trak(trak);
|
||||
|
||||
|
@ -5824,7 +5834,7 @@ srs_error_t SrsMp4Encoder::flush()
|
|||
avcC->avc_config = pavcc;
|
||||
}
|
||||
|
||||
if (nb_audios) {
|
||||
if (nb_audios || !pasc.empty()) {
|
||||
SrsMp4TrackBox* trak = new SrsMp4TrackBox();
|
||||
moov->add_trak(trak);
|
||||
|
||||
|
|
|
@ -51,12 +51,18 @@ extern int _srs_tmp_port;
|
|||
extern srs_utime_t _srs_tmp_timeout;
|
||||
|
||||
// For errors.
|
||||
#define HELPER_EXPECT_SUCCESS(x) EXPECT_TRUE(srs_success == (err = x)); srs_freep(err)
|
||||
#define HELPER_EXPECT_SUCCESS(x) \
|
||||
if ((err = x) != srs_success) fprintf(stderr, "err %s", srs_error_desc(err).c_str()); \
|
||||
EXPECT_TRUE(srs_success == err); \
|
||||
srs_freep(err)
|
||||
#define HELPER_EXPECT_FAILED(x) EXPECT_TRUE(srs_success != (err = x)); srs_freep(err)
|
||||
|
||||
// For errors, assert.
|
||||
// @remark The err is leak when error, but it's ok in utest.
|
||||
#define HELPER_ASSERT_SUCCESS(x) ASSERT_TRUE(srs_success == (err = x)); srs_freep(err)
|
||||
#define HELPER_ASSERT_SUCCESS(x) \
|
||||
if ((err = x) != srs_success) fprintf(stderr, "err %s", srs_error_desc(err).c_str()); \
|
||||
ASSERT_TRUE(srs_success == err); \
|
||||
srs_freep(err)
|
||||
#define HELPER_ASSERT_FAILED(x) ASSERT_TRUE(srs_success != (err = x)); srs_freep(err)
|
||||
|
||||
// For init array data.
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -74,6 +74,7 @@ public:
|
|||
virtual int64_t tellg();
|
||||
virtual int64_t filesize();
|
||||
virtual char* data();
|
||||
virtual string str();
|
||||
public:
|
||||
virtual srs_error_t write(void* buf, size_t count, ssize_t* pnwrite);
|
||||
virtual srs_error_t lseek(off_t offset, int whence, off_t* seeked);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue