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

solve merge problem

This commit is contained in:
runner365 2020-01-25 16:24:04 +08:00
commit 8d277c6e8b
39 changed files with 411 additions and 434 deletions

View file

@ -6814,22 +6814,22 @@ string SrsConfig::get_vhost_http_dir(string vhost)
bool SrsConfig::get_vhost_http_remux_enabled(string vhost)
{
static bool DEFAULT = false;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("http_remux");
if (!conf) {
return DEFAULT;
}
conf = conf->get("enabled");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return SRS_CONF_PERFER_FALSE(conf->arg0());
}

View file

@ -609,13 +609,25 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque
return srs_error_wrap(err, "segmenter");
}
return err;
}
srs_error_t SrsDvrPlan::on_publish()
{
srs_error_t err = srs_success;
if ((err = async->start()) != srs_success) {
return srs_error_wrap(err, "async");
}
return err;
}
void SrsDvrPlan::on_unpublish()
{
async->stop();
}
srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata)
{
srs_error_t err = srs_success;
@ -699,6 +711,10 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan()
srs_error_t SrsDvrSessionPlan::on_publish()
{
srs_error_t err = srs_success;
if ((err = SrsDvrPlan::on_publish()) != srs_success) {
return err;
}
// support multiple publish.
if (dvr_enabled) {
@ -724,6 +740,8 @@ srs_error_t SrsDvrSessionPlan::on_publish()
void SrsDvrSessionPlan::on_unpublish()
{
SrsDvrPlan::on_unpublish();
// support multiple publish.
if (!dvr_enabled) {
return;
@ -766,6 +784,10 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S
srs_error_t SrsDvrSegmentPlan::on_publish()
{
srs_error_t err = srs_success;
if ((err = SrsDvrPlan::on_publish()) != srs_success) {
return err;
}
// support multiple publish.
if (dvr_enabled) {
@ -791,6 +813,16 @@ srs_error_t SrsDvrSegmentPlan::on_publish()
void SrsDvrSegmentPlan::on_unpublish()
{
srs_error_t err = srs_success;
SrsDvrPlan::on_unpublish();
if ((err = segment->close()) != srs_success) {
srs_warn("ignore err %s", srs_error_desc(err).c_str());
srs_freep(err);
}
dvr_enabled = false;
}
srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)

View file

@ -185,8 +185,8 @@ public:
virtual ~SrsDvrPlan();
public:
virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r);
virtual srs_error_t on_publish() = 0;
virtual void on_unpublish() = 0;
virtual srs_error_t on_publish();
virtual void on_unpublish();
virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata);
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);

View file

@ -416,9 +416,14 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri
return err;
}
SrsAmf0Object* ex = prop->to_object();
if ((prop = ex->ensure_property_string("redirect")) == NULL) {
return err;
// The redirect is tcUrl while redirect2 is RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
if ((prop = ex->ensure_property_string("redirect2")) == NULL) {
// TODO: FIXME: Remove it when SRS3 released, it's temporarily support for SRS3 alpha versions(a0 to a8).
if ((prop = ex->ensure_property_string("redirect")) == NULL) {
return err;
}
}
redirect = prop->to_str();

View file

@ -268,16 +268,27 @@ int SrsHlsMuxer::deviation()
}
srs_error_t SrsHlsMuxer::initialize()
{
return srs_success;
}
srs_error_t SrsHlsMuxer::on_publish(SrsRequest* req)
{
srs_error_t err = srs_success;
if ((err = async->start()) != srs_success) {
return srs_error_wrap(err, "async start");
}
return err;
}
srs_error_t SrsHlsMuxer::on_unpublish()
{
async->stop();
return srs_success;
}
srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
string path, string m3u8_file, string ts_file, srs_utime_t fragment, srs_utime_t window,
bool ts_floor, double aof_ratio, bool cleanup, bool wait_keyframe, bool keys,
@ -899,8 +910,11 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)
// TODO: FIXME: support load exists m3u8, to continue publish stream.
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
if ((err = muxer->on_publish(req)) != srs_success) {
return srs_error_wrap(err, "muxer publish");
}
// open muxer
if ((err = muxer->update_config(req, entry_prefix, path, m3u8_file, ts_file, hls_fragment,
hls_window, ts_floor, hls_aof_ratio, cleanup, wait_keyframe,hls_keys,hls_fragments_per_key,
hls_key_file, hls_key_file_path, hls_key_url)) != srs_success ) {
@ -924,6 +938,10 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)
srs_error_t SrsHlsController::on_unpublish()
{
srs_error_t err = srs_success;
if ((err = muxer->on_unpublish()) != srs_success) {
return srs_error_wrap(err, "muxer unpublish");
}
if ((err = muxer->flush_audio(tsmc)) != srs_success) {
return srs_error_wrap(err, "hls: flush audio");

View file

@ -185,6 +185,9 @@ public:
public:
// Initialize the hls muxer.
virtual srs_error_t initialize();
// When publish or unpublish stream.
virtual srs_error_t on_publish(SrsRequest* req);
virtual srs_error_t on_unpublish();
// When publish, update the config for muxer.
virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix,
std::string path, std::string m3u8_file, std::string ts_file,

View file

@ -1023,7 +1023,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
if (it == tflvs.end()) {
return err;
}
// hstrs always enabled.
// for origin, the http stream will be mount already when publish,
// so it must never enter this line for stream already mounted.
@ -1064,7 +1064,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
if (srs_string_count(upath, "/") != srs_string_count(entry->mount, "/")) {
return err;
}
// convert to concreate class.
SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(request);
srs_assert(hreq);
@ -1089,7 +1089,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
}
SrsSource* s = NULL;
if ((err = SrsSource::fetch_or_create(r, server, &s)) != srs_success) {
if ((err = _srs_sources->fetch_or_create(r, server, &s)) != srs_success) {
return srs_error_wrap(err, "source create");
}
srs_assert(s != NULL);
@ -1127,7 +1127,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming()
if (!conf->is_vhost()) {
continue;
}
if ((err = initialize_flv_entry(conf->arg0())) != srs_success) {
return srs_error_wrap(err, "init flv entries");
}
@ -1139,7 +1139,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming()
srs_error_t SrsHttpStreamServer::initialize_flv_entry(std::string vhost)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_remux_enabled(vhost)) {
return err;
}

View file

@ -496,7 +496,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
// find a source to serve.
SrsSource* source = NULL;
if ((err = SrsSource::fetch_or_create(req, server, &source)) != srs_success) {
if ((err = _srs_sources->fetch_or_create(req, server, &source)) != srs_success) {
return srs_error_wrap(err, "rtmp: fetch source");
}
srs_assert(source != NULL);
@ -621,8 +621,10 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source)
}
return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str());
}
srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s",
req->host.c_str(), req->port, host.c_str(), port, url.c_str());
string rurl = srs_generate_rtmp_url(host, port, req->host, req->vhost, req->app, req->stream, req->param);
srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s, rurl=%s",
req->host.c_str(), req->port, host.c_str(), port, url.c_str(), rurl.c_str());
// Ignore if host or port is invalid.
if (host.empty() || port == 0) {
@ -630,7 +632,7 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source)
}
bool accepted = false;
if ((err = rtmp->redirect(req, host, port, accepted)) != srs_success) {
if ((err = rtmp->redirect(req, rurl, accepted)) != srs_success) {
srs_error_reset(err);
} else {
return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected");

View file

@ -523,7 +523,7 @@ void SrsServer::dispose()
// @remark don't dispose ingesters, for too slow.
// dispose the source for hls and dvr.
SrsSource::dispose_all();
_srs_sources->dispose();
// @remark don't dispose all connections, for too slow.
@ -957,7 +957,7 @@ srs_error_t SrsServer::do_cycle()
}
// notice the stream sources to cycle.
if ((err = SrsSource::cycle_all()) != srs_success) {
if ((err = _srs_sources->cycle()) != srs_success) {
return srs_error_wrap(err, "source cycle");
}

View file

@ -154,7 +154,7 @@ int64_t SrsRtmpJitter::get_time()
SrsFastVector::SrsFastVector()
{
count = 0;
nb_msgs = SRS_PERF_MW_MSGS * 8;
nb_msgs = 8;
msgs = new SrsSharedPtrMessage*[nb_msgs];
}
@ -212,12 +212,12 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg)
{
// increase vector.
if (count >= nb_msgs) {
int size = nb_msgs * 2;
int size = srs_max(SRS_PERF_MW_MSGS * 8, nb_msgs * 2);
SrsSharedPtrMessage** buf = new SrsSharedPtrMessage*[size];
for (int i = 0; i < nb_msgs; i++) {
buf[i] = msgs[i];
}
srs_warn("fast vector incrase %d=>%d", nb_msgs, size);
srs_info("fast vector incrase %d=>%d", nb_msgs, size);
// use new array.
srs_freepa(msgs);
@ -1635,9 +1635,17 @@ srs_error_t SrsMetaCache::update_vsh(SrsSharedPtrMessage* msg)
return vformat->on_video(msg);
}
std::map<std::string, SrsSource*> SrsSource::pool;
SrsSourceManager* _srs_sources = new SrsSourceManager();
srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps)
SrsSourceManager::SrsSourceManager()
{
}
SrsSourceManager::~SrsSourceManager()
{
}
srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps)
{
srs_error_t err = srs_success;
@ -1665,7 +1673,7 @@ srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsS
return err;
}
SrsSource* SrsSource::fetch(SrsRequest* r)
SrsSource* SrsSourceManager::fetch(SrsRequest* r)
{
SrsSource* source = NULL;
@ -1679,12 +1687,12 @@ SrsSource* SrsSource::fetch(SrsRequest* r)
// we always update the request of resource,
// for origin auth is on, the token in request maybe invalid,
// and we only need to update the token of request, it's simple.
source->req->update_auth(r);
source->update_auth(r);
return source;
}
void SrsSource::dispose_all()
void SrsSourceManager::dispose()
{
std::map<std::string, SrsSource*>::iterator it;
for (it = pool.begin(); it != pool.end(); ++it) {
@ -1694,16 +1702,16 @@ void SrsSource::dispose_all()
return;
}
srs_error_t SrsSource::cycle_all()
srs_error_t SrsSourceManager::cycle()
{
int cid = _srs_context->get_id();
srs_error_t err = do_cycle_all();
srs_error_t err = do_cycle();
_srs_context->set_id(cid);
return err;
}
srs_error_t SrsSource::do_cycle_all()
srs_error_t SrsSourceManager::do_cycle()
{
srs_error_t err = srs_success;
@ -1744,7 +1752,7 @@ srs_error_t SrsSource::do_cycle_all()
return err;
}
void SrsSource::destroy()
void SrsSourceManager::destroy()
{
std::map<std::string, SrsSource*>::iterator it;
for (it = pool.begin(); it != pool.end(); ++it) {
@ -1994,6 +2002,11 @@ bool SrsSource::inactive()
return _can_publish;
}
void SrsSource::update_auth(SrsRequest* r)
{
req->update_auth(r);
}
bool SrsSource::can_publish(bool is_edge)
{
if (is_edge) {

View file

@ -438,32 +438,43 @@ public:
virtual srs_error_t update_vsh(SrsSharedPtrMessage* msg);
};
// live streaming source.
class SrsSource : public ISrsReloadHandler
// The source manager to create and refresh all stream sources.
class SrsSourceManager
{
friend class SrsOriginHub;
private:
static std::map<std::string, SrsSource*> pool;
std::map<std::string, SrsSource*> pool;
public:
SrsSourceManager();
virtual ~SrsSourceManager();
public:
// create source when fetch from cache failed.
// @param r the client request.
// @param h the event handler for source.
// @param pps the matched source, if success never be NULL.
static srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps);
virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps);
private:
// Get the exists source, NULL when not exists.
// update the request and return the exists source.
static SrsSource* fetch(SrsRequest* r);
virtual SrsSource* fetch(SrsRequest* r);
public:
// dispose and cycle all sources.
static void dispose_all();
static srs_error_t cycle_all();
virtual void dispose();
virtual srs_error_t cycle();
private:
static srs_error_t do_cycle_all();
virtual srs_error_t do_cycle();
public:
// when system exit, destroy the sources,
// For gmc to analysis mem leaks.
static void destroy();
virtual void destroy();
};
// Global singleton instance.
extern SrsSourceManager* _srs_sources;
// live streaming source.
class SrsSource : public ISrsReloadHandler
{
friend class SrsOriginHub;
private:
// For publish, it's the publish client id.
// For edge, it's the edge ingest id.
@ -531,6 +542,8 @@ public:
// Whether source is inactive, which means there is no publishing stream source.
// @remark For edge, it's inactive util stream has been pulled from origin.
virtual bool inactive();
// Update the authentication information in request.
virtual void update_auth(SrsRequest* r);
public:
virtual bool can_publish(bool is_edge);
virtual srs_error_t on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);

View file

@ -31,9 +31,6 @@
#include <sys/wait.h>
#include <netdb.h>
#ifdef SRS_OSX
#include <sys/sysctl.h>
#endif
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
@ -329,7 +326,6 @@ SrsProcSystemStat* srs_get_system_proc_stat()
bool get_proc_system_stat(SrsProcSystemStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/stat", "r");
if (f == NULL) {
srs_warn("open system cpu stat failed, ignore");
@ -359,10 +355,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r)
}
fclose(f);
#else
// TODO: FIXME: impelments it.
#endif
r.ok = true;
return true;
@ -370,7 +363,6 @@ bool get_proc_system_stat(SrsProcSystemStat& r)
bool get_proc_self_stat(SrsProcSelfStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/self/stat", "r");
if (f == NULL) {
srs_warn("open self cpu stat failed, ignore");
@ -397,10 +389,7 @@ bool get_proc_self_stat(SrsProcSelfStat& r)
&r.guest_time, &r.cguest_time);
fclose(f);
#else
// TODO: FIXME: impelments it.
#endif
r.ok = true;
return true;
@ -495,7 +484,6 @@ SrsDiskStat* srs_get_disk_stat()
bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/vmstat", "r");
if (f == NULL) {
srs_warn("open vmstat failed, ignore");
@ -515,10 +503,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
}
fclose(f);
#else
// TODO: FIXME: impelments it.
#endif
r.ok = true;
return true;
@ -535,7 +520,6 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
return true;
}
#ifndef SRS_OSX
FILE* f = fopen("/proc/diskstats", "r");
if (f == NULL) {
srs_warn("open vmstat failed, ignore");
@ -600,10 +584,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
}
fclose(f);
#else
// TODO: FIXME: impelments it.
#endif
r.ok = true;
return true;
@ -695,7 +676,6 @@ void srs_update_meminfo()
{
SrsMemInfo& r = _srs_system_meminfo;
#ifndef SRS_OSX
FILE* f = fopen("/proc/meminfo", "r");
if (f == NULL) {
srs_warn("open meminfo failed, ignore");
@ -721,10 +701,7 @@ void srs_update_meminfo()
}
fclose(f);
#else
// TODO: FIXME: impelments it.
#endif
r.sample_time = srsu2ms(srs_get_system_time());
r.MemActive = r.MemTotal - r.MemFree;
r.RealInUse = r.MemActive - r.Buffers - r.Cached;
@ -791,7 +768,6 @@ void srs_update_platform_info()
r.srs_startup_time = srsu2ms(srs_get_system_startup_time());
#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/uptime", "r");
if (f == NULL) {
@ -820,43 +796,6 @@ void srs_update_platform_info()
fclose(f);
}
#else
// man 3 sysctl
if (true) {
struct timeval tv;
size_t len = sizeof(timeval);
int mib[2];
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;
if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) {
srs_warn("sysctl boottime failed, ignore");
return;
}
time_t bsec = tv.tv_sec;
time_t csec = ::time(NULL);
r.os_uptime = difftime(csec, bsec);
}
// man 3 sysctl
if (true) {
struct loadavg la;
size_t len = sizeof(loadavg);
int mib[2];
mib[0] = CTL_VM;
mib[1] = VM_LOADAVG;
if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) {
srs_warn("sysctl loadavg failed, ignore");
return;
}
r.load_one_minutes = (double)la.ldavg[0] / la.fscale;
r.load_five_minutes = (double)la.ldavg[1] / la.fscale;
r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale;
}
#endif
r.ok = true;
}
@ -903,7 +842,6 @@ int srs_get_network_devices_count()
void srs_update_network_devices()
{
#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/dev", "r");
if (f == NULL) {
@ -940,9 +878,6 @@ void srs_update_network_devices()
fclose(f);
}
#else
// TODO: FIXME: impelments it.
#endif
}
SrsNetworkRtmpServer::SrsNetworkRtmpServer()
@ -990,7 +925,6 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
int nb_tcp_mem = 0;
int nb_udp4 = 0;
#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/sockstat", "r");
if (f == NULL) {
@ -1020,20 +954,9 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
fclose(f);
}
#else
// TODO: FIXME: impelments it.
nb_socks = 0;
nb_tcp4_hashed = 0;
nb_tcp_orphans = 0;
nb_tcp_tws = 0;
nb_tcp_total = 0;
nb_tcp_mem = 0;
nb_udp4 = 0;
#endif
int nb_tcp_estab = 0;
#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/snmp", "r");
if (f == NULL) {
@ -1063,10 +986,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
fclose(f);
}
#else
// TODO: FIXME: impelments it.
#endif
// @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c
// TODO: FIXME: ignore the slabstat, @see: get_slabstat()
if (true) {

View file

@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 97
#define VERSION_REVISION 106
// The macros generated by configure script.
#include <srs_auto_headers.hpp>

View file

@ -43,6 +43,8 @@ string srs_video_codec_id2str(SrsVideoCodecId codec)
return "VP6";
case SrsVideoCodecIdHEVC:
return "HEVC";
case SrsVideoCodecIdAV1:
return "AV1";
case SrsVideoCodecIdReserved:
case SrsVideoCodecIdReserved1:
case SrsVideoCodecIdReserved2:
@ -650,7 +652,10 @@ bool SrsFormat::is_aac_sequence_header()
bool SrsFormat::is_avc_sequence_header()
{
return vcodec && (vcodec->id == SrsVideoCodecIdAVC || vcodec->id == SrsVideoCodecIdHEVC)
bool h264 = (vcodec && vcodec->id == SrsVideoCodecIdAVC);
bool h265 = (vcodec && vcodec->id == SrsVideoCodecIdHEVC);
bool av1 = (vcodec && vcodec->id == SrsVideoCodecIdAV1);
return vcodec && (h264 || h265 || av1)
&& video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader;
}

View file

@ -62,6 +62,8 @@ enum SrsVideoCodecId
SrsVideoCodecIdAVC = 7,
// See page 79 at @doc https://github.com/CDN-Union/H265/blob/master/Document/video_file_format_spec_v10_1_ksyun_20170615.doc
SrsVideoCodecIdHEVC = 12,
// https://mp.weixin.qq.com/s/H3qI7zsON5sdf4oDJ9qlkg
SrsVideoCodecIdAV1 = 13,
};
std::string srs_video_codec_id2str(SrsVideoCodecId codec);

View file

@ -291,7 +291,7 @@ bool SrsSharedPtrMessage::check(int stream_id)
// we donot use the complex basic header,
// ensure the basic header is 1bytes.
if (ptr->header.perfer_cid < 2) {
if (ptr->header.perfer_cid < 2 || ptr->header.perfer_cid > 63) {
srs_info("change the chunk_id=%d to default=%d", ptr->header.perfer_cid, RTMP_CID_ProtocolControl);
ptr->header.perfer_cid = RTMP_CID_ProtocolControl;
}

View file

@ -313,6 +313,7 @@ srs_error_t SrsTsContext::encode(ISrsStreamWriter* writer, SrsTsMessage* msg, Sr
case SrsVideoCodecIdOn2VP6WithAlphaChannel:
case SrsVideoCodecIdScreenVideoVersion2:
case SrsVideoCodecIdHEVC:
case SrsVideoCodecIdAV1:
vs = SrsTsStreamReserved;
break;
}

View file

@ -1666,7 +1666,7 @@ int srs_mp4_to_flv_tag(srs_mp4_t mp4, srs_mp4_sample_t* s, char* type, uint32_t*
// E.4.3.1 VIDEODATA, flv_v10_1.pdf, page 5
p.write_1bytes(uint8_t(s->frame_type<<4) | uint8_t(s->codec));
if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC) {
if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC || s->codec == SrsVideoCodecIdAV1) {
*type = SRS_RTMP_TYPE_VIDEO;
p.write_1bytes(uint8_t(s->frame_trait == (uint16_t)SrsVideoAvcFrameTraitSequenceHeader? 0:1));

View file

@ -119,7 +119,7 @@ srs_error_t do_main(int argc, char** argv)
// config already applied to log.
srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
srs_trace("contributors: " SRS_AUTO_CONSTRIBUTORS);
srs_trace("contributors: %s", SRS_AUTO_CONSTRIBUTORS);
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s",
_srs_config->cwd().c_str(), cwd.c_str(), SRS_AUTO_BUILD_DATE, SRS_AUTO_USER_CONFIGURE, SRS_AUTO_UNAME);
srs_trace("configure detail: " SRS_AUTO_CONFIGURE);
@ -237,16 +237,6 @@ void show_macro_features()
if (true) {
stringstream ss;
ss << "SRS on ";
#ifdef SRS_OSX
ss << "OSX";
#endif
#ifdef SRS_PI
ss << "RespberryPi";
#endif
#ifdef SRS_CUBIE
ss << "CubieBoard";
#endif
#if defined(__amd64__)
ss << " amd64";
#endif
@ -259,9 +249,11 @@ void show_macro_features()
#if defined(__arm__)
ss << "arm";
#endif
#ifndef SRS_OSX
ss << ", glibc" << (int)__GLIBC__ << "." << (int)__GLIBC_MINOR__;
#if defined(__aarch64__)
ss << " aarch64";
#endif
#if defined(SRS_AUTO_CROSSBUILD)
ss << "(crossbuild)";
#endif
ss << ", conf:" << _srs_config->config() << ", limit:" << _srs_config->get_max_connections()

View file

@ -2415,17 +2415,20 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser
}
#define SRS_RTMP_REDIRECT_TIMEOUT (3 * SRS_UTIME_SECONDS)
srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted)
srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string url, bool& accepted)
{
srs_error_t err = srs_success;
if (true) {
string url = srs_generate_rtmp_url(host, port, r->host, r->vhost, r->app, r->stream, r->param);
SrsAmf0Object* ex = SrsAmf0Any::object();
ex->set("code", SrsAmf0Any::number(302));
ex->set("redirect", SrsAmf0Any::str(url.c_str()));
// The redirect is tcUrl while redirect2 is RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
string tcUrl = srs_path_dirname(url);
ex->set("redirect", SrsAmf0Any::str(tcUrl.c_str()));
ex->set("redirect2", SrsAmf0Any::str(url.c_str()));
SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
pkt->data->set(StatusLevel, SrsAmf0Any::str(StatusLevelError));

View file

@ -707,9 +707,9 @@ public:
// @param server_ip the ip of server.
virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL);
// Redirect the connection to another rtmp server.
// @param the hostname or ip of target.
// @param a RTMP url to redirect to.
// @param whether the client accept the redirect.
virtual srs_error_t redirect(SrsRequest* r, std::string host, int port, bool& accepted);
virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted);
// Reject the connect app request.
virtual void response_connect_reject(SrsRequest* req, const char* desc);
// Response client the onBWDone message.

View file

@ -115,7 +115,12 @@ srs_error_t srs_fd_reuseport(int fd)
#if defined(SO_REUSEPORT)
int v = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) {
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd);
#ifdef SRS_AUTO_CROSSBUILD
srs_warn("SO_REUSEPORT disabled for crossbuild");
return srs_success;
#else
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd);
#endif
}
#else
#warning "SO_REUSEPORT is not supported by your OS"

View file

@ -46,23 +46,18 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext();
SrsConfig* _srs_config = NULL;
SrsServer* _srs_server = NULL;
// Disable coroutine test for OSX.
#if !defined(SRS_OSX)
#include <srs_app_st.hpp>
#endif
// Initialize global settings.
srs_error_t prepare_main() {
srs_error_t err = srs_success;
#if !defined(SRS_OSX)
if ((err = srs_st_init()) != srs_success) {
return srs_error_wrap(err, "init st");
}
srs_freep(_srs_context);
_srs_context = new SrsThreadContext();
#endif
return err;
}

View file

@ -27,9 +27,6 @@ using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_app_fragment.hpp>
// Disable coroutine test for OSX.
#if !defined(SRS_OSX)
#include <srs_app_st.hpp>
VOID TEST(AppCoroutineTest, Dummy)
@ -375,5 +372,3 @@ VOID TEST(AppFragmentTest, CheckDuration)
}
}
#endif

View file

@ -3028,6 +3028,7 @@ VOID TEST(KernelCodecTest, CoverAll)
EXPECT_TRUE("H264" == srs_video_codec_id2str(SrsVideoCodecIdAVC));
EXPECT_TRUE("VP6" == srs_video_codec_id2str(SrsVideoCodecIdOn2VP6));
EXPECT_TRUE("HEVC" == srs_video_codec_id2str(SrsVideoCodecIdHEVC));
EXPECT_TRUE("AV1" == srs_video_codec_id2str(SrsVideoCodecIdAV1));
EXPECT_TRUE("Other" == srs_video_codec_id2str(SrsVideoCodecIdScreenVideo));
}
@ -3293,6 +3294,9 @@ VOID TEST(KernelCodecTest, IsSequenceHeaderSpecial)
f.vcodec->id = SrsVideoCodecIdHEVC;
EXPECT_FALSE(f.is_avc_sequence_header());
f.vcodec->id = SrsVideoCodecIdAV1;
EXPECT_FALSE(f.is_avc_sequence_header());
f.video->avc_packet_type = SrsVideoAvcFrameTraitSequenceHeader;
EXPECT_TRUE(f.is_avc_sequence_header());
}
@ -4647,7 +4651,10 @@ VOID TEST(KernelTSTest, CoverContextEncode)
err = ctx.encode(&f, &m, SrsVideoCodecIdHEVC, SrsAudioCodecIdOpus);
HELPER_EXPECT_FAILED(err);
err = ctx.encode(&f, &m, SrsVideoCodecIdAV1, SrsAudioCodecIdOpus);
HELPER_EXPECT_FAILED(err);
err = ctx.encode_pat_pmt(&f, 0, SrsTsStreamReserved, 0, SrsTsStreamReserved);
HELPER_EXPECT_FAILED(err);
}

View file

@ -1751,7 +1751,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
string host = "target.net";
int port = 8888;
bool accepted = false;
HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted));
string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
if (true) {
MockBufferIO tio;
@ -1776,6 +1777,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
prop = ex->get_property("redirect");
ASSERT_TRUE(prop && prop->is_string());
// The recirect is tcUrl, not RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574995475
EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str());
prop = ex->get_property("redirect2");
ASSERT_TRUE(prop && prop->is_string());
// The recirect2 is RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str());
srs_freep(msg);
@ -1808,7 +1817,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
string host = "target.net";
int port = 8888;
bool accepted = false;
HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted));
string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
EXPECT_TRUE(accepted);
if (true) {
@ -1834,6 +1844,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
prop = ex->get_property("redirect");
ASSERT_TRUE(prop && prop->is_string());
// The recirect is tcUrl, not RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574995475
EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str());
prop = ex->get_property("redirect2");
ASSERT_TRUE(prop && prop->is_string());
// The recirect2 is RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str());
srs_freep(msg);

View file

@ -835,6 +835,7 @@ public:
SrsSTCoroutine trd;
srs_netfd_t fd;
MockOnCycleThread3() : trd("mock", this, 0) {
fd = NULL;
};
virtual ~MockOnCycleThread3() {
trd.stop();
@ -1087,6 +1088,7 @@ public:
SrsSTCoroutine trd;
srs_netfd_t fd;
MockOnCycleThread4() : trd("mock", this, 0) {
fd = NULL;
};
virtual ~MockOnCycleThread4() {
trd.stop();