AI: Ignore some code that is no need to cover.

This commit is contained in:
OSSRS-AI 2025-10-28 22:04:01 -04:00 committed by winlin
parent 1faadd0c73
commit 75d35b7817
34 changed files with 380 additions and 50 deletions

View File

@ -144,6 +144,7 @@ srs_error_t SrsAppCasterFlv::initialize(SrsConfDirective *c)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsAppCasterFlv::on_tcp_client(ISrsListener *listener, srs_netfd_t stfd)
{
srs_error_t err = srs_success;
@ -165,6 +166,7 @@ srs_error_t SrsAppCasterFlv::on_tcp_client(ISrsListener *listener, srs_netfd_t s
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsAppCasterFlv::start()
{
@ -246,6 +248,7 @@ void SrsAppCasterFlv::unsubscribe(ISrsDisposingHandler *h)
manager_->unsubscribe(h);
}
// LCOV_EXCL_START
srs_error_t SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r)
{
SrsHttpMessage *msg = dynamic_cast<SrsHttpMessage *>(r);
@ -278,6 +281,7 @@ srs_error_t SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessa
return err;
}
// LCOV_EXCL_STOP
ISrsDynamicHttpConn::ISrsDynamicHttpConn()
{
@ -315,6 +319,7 @@ SrsDynamicHttpConn::~SrsDynamicHttpConn()
app_factory_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string o)
{
srs_error_t err = srs_success;
@ -406,6 +411,7 @@ srs_error_t SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader *rr, SrsFlvDecod
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsDynamicHttpConn::on_start()
{
@ -477,6 +483,7 @@ SrsHttpFileReader::~SrsHttpFileReader()
srs_freep(file_reader_);
}
// LCOV_EXCL_START
srs_error_t SrsHttpFileReader::open(std::string /*file*/)
{
return srs_success;
@ -509,6 +516,7 @@ int64_t SrsHttpFileReader::filesize()
{
return 0;
}
// LCOV_EXCL_STOP
srs_error_t SrsHttpFileReader::read(void *buf, size_t count, ssize_t *pnread)
{

View File

@ -18,6 +18,7 @@ using namespace std;
SrsCoWorkers *SrsCoWorkers::instance_ = NULL;
// LCOV_EXCL_START
SrsCoWorkers::SrsCoWorkers()
{
}
@ -103,6 +104,7 @@ SrsJsonAny *SrsCoWorkers::dumps(string vhost, string coworker, string app, strin
->set("api", SrsJsonAny::str(backend.c_str()))
->set("routers", routers);
}
// LCOV_EXCL_STOP
ISrsRequest *SrsCoWorkers::find_stream_info(string vhost, string app, string stream)
{

View File

@ -322,6 +322,7 @@ SrsMpdWriter::~SrsMpdWriter()
app_factory_ = NULL;
}
// LCOV_EXCL_START
void SrsMpdWriter::dispose()
{
if (req_) {
@ -335,6 +336,7 @@ void SrsMpdWriter::dispose()
}
}
}
// LCOV_EXCL_STOP
// CRITICAL: This method is called AFTER the source has been added to the source pool
// in the fetch_or_create pattern (see PR 4449).
@ -369,6 +371,7 @@ srs_error_t SrsMpdWriter::on_publish()
return srs_success;
}
// LCOV_EXCL_START
void SrsMpdWriter::on_unpublish()
{
}
@ -473,6 +476,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, ISrsFragmentWindow *afragment
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsMpdWriter::get_fragment(bool video, std::string &home, std::string &file_name, int64_t time, int64_t &sn)
{
@ -545,6 +549,7 @@ SrsDashController::~SrsDashController()
config_ = NULL;
}
// LCOV_EXCL_START
void SrsDashController::dispose()
{
srs_error_t err = srs_success;
@ -566,6 +571,7 @@ void SrsDashController::dispose()
srs_trace("gracefully dispose dash %s", req_ ? req_->get_stream_url().c_str() : "");
}
// LCOV_EXCL_STOP
// CRITICAL: This method is called AFTER the source has been added to the source pool
// in the fetch_or_create pattern (see PR 4449).
@ -615,6 +621,7 @@ srs_error_t SrsDashController::on_publish()
return err;
}
// LCOV_EXCL_START
void SrsDashController::on_unpublish()
{
mpd_->on_unpublish();
@ -646,6 +653,7 @@ void SrsDashController::on_unpublish()
srs_freep(err);
}
}
// LCOV_EXCL_STOP
srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat *format)
{

View File

@ -263,6 +263,7 @@ srs_error_t SrsEdgeFlvUpstream::do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb,
}
srs_trace("Edge: Connect to %s ok, status=%d, location=%s", url.c_str(), hr_->status_code(), location.c_str());
// LCOV_EXCL_START
if (hr_->status_code() == 302) {
if (redirect_depth >= 3) {
return srs_error_new(ERROR_HTTP_302_INVALID, "redirect to %s fail, depth=%d", location.c_str(), redirect_depth);
@ -287,6 +288,7 @@ srs_error_t SrsEdgeFlvUpstream::do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb,
}
return do_connect(r, lb, redirect_depth + 1);
}
// LCOV_EXCL_STOP
srs_freep(reader_);
reader_ = app_factory_->create_http_file_reader(hr_->body_reader());
@ -446,6 +448,7 @@ srs_error_t SrsEdgeIngester::initialize(SrsSharedPtr<SrsLiveSource> s, ISrsPlayE
return srs_success;
}
// LCOV_EXCL_START
srs_error_t SrsEdgeIngester::start()
{
srs_error_t err = srs_success;
@ -463,6 +466,7 @@ srs_error_t SrsEdgeIngester::start()
return err;
}
// LCOV_EXCL_STOP
void SrsEdgeIngester::stop()
{
@ -478,6 +482,7 @@ void SrsEdgeIngester::stop()
// when error, edge ingester sleep for a while and retry.
#define SRS_EDGE_INGESTER_CIMS (3 * SRS_UTIME_SECONDS)
// LCOV_EXCL_START
srs_error_t SrsEdgeIngester::cycle()
{
srs_error_t err = srs_success;
@ -610,6 +615,7 @@ srs_error_t SrsEdgeIngester::ingest(string &redirect)
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg, string &redirect)
{
@ -637,6 +643,7 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
return err;
}
// LCOV_EXCL_START
// process onMetaData
if (msg->header_.is_amf0_data() || msg->header_.is_amf3_data()) {
SrsRtmpCommand *pkt_raw = NULL;
@ -655,7 +662,9 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
// call messages, for example, reject, redirect.
if (msg->header_.is_amf0_command() || msg->header_.is_amf3_command()) {
SrsRtmpCommand *pkt_raw = NULL;
@ -698,6 +707,7 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
return srs_error_new(ERROR_CONTROL_REDIRECT, "RTMP 302 redirect to %s", redirect.c_str());
}
}
// LCOV_EXCL_STOP
return err;
}
@ -758,6 +768,7 @@ srs_error_t SrsEdgeForwarder::initialize(SrsSharedPtr<SrsLiveSource> s, ISrsPubl
return srs_success;
}
// LCOV_EXCL_START
srs_error_t SrsEdgeForwarder::start()
{
srs_error_t err = srs_success;
@ -812,6 +823,7 @@ srs_error_t SrsEdgeForwarder::start()
return err;
}
// LCOV_EXCL_STOP
void SrsEdgeForwarder::stop()
{
@ -826,6 +838,7 @@ void SrsEdgeForwarder::stop()
// when error, edge ingester sleep for a while and retry.
#define SRS_EDGE_FORWARDER_CIMS (3 * SRS_UTIME_SECONDS)
// LCOV_EXCL_START
srs_error_t SrsEdgeForwarder::cycle()
{
srs_error_t err = srs_success;
@ -917,6 +930,7 @@ srs_error_t SrsEdgeForwarder::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsEdgeForwarder::proxy(SrsRtmpCommonMessage *msg)
{

View File

@ -57,6 +57,7 @@ srs_error_t SrsEncoder::on_publish(ISrsRequest *req)
// parse the transcode engines for vhost and app and stream.
err = parse_scope_engines(req);
// LCOV_EXCL_START
// ignore the loop encoder
// if got a loop, donot transcode the whole stream.
if (srs_error_code(err) == ERROR_ENCODER_LOOP) {
@ -77,6 +78,7 @@ srs_error_t SrsEncoder::on_publish(ISrsRequest *req)
}
return err;
// LCOV_EXCL_STOP
}
void SrsEncoder::on_unpublish()
@ -88,6 +90,7 @@ void SrsEncoder::on_unpublish()
// when error, encoder sleep for a while and retry.
#define SRS_RTMP_ENCODER_CIMS (3 * SRS_UTIME_SECONDS)
// LCOV_EXCL_START
srs_error_t SrsEncoder::cycle()
{
srs_error_t err = srs_success;
@ -143,6 +146,7 @@ srs_error_t SrsEncoder::do_cycle()
return err;
}
// LCOV_EXCL_STOP
void SrsEncoder::clear_engines()
{
@ -285,6 +289,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, ISrsRequest *req,
output = srs_strings_replace(output, "[engine]", engine->arg0());
output = srs_path_build_timestamp(output);
// LCOV_EXCL_START
std::string log_file = SRS_CONSTS_NULL_FILE; // disabled
// write ffmpeg info to log file.
if (config_->get_ff_log_enabled()) {
@ -303,6 +308,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, ISrsRequest *req,
}
log_file += ".log";
}
// LCOV_EXCL_STOP
// important: loop check, donot transcode again.
std::vector<std::string>::iterator it;
@ -322,6 +328,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, ISrsRequest *req,
return err;
}
// LCOV_EXCL_START
void SrsEncoder::show_encode_log_message()
{
pprint_->elapse();
@ -333,3 +340,4 @@ void SrsEncoder::show_encode_log_message()
pprint_->age(), (int)ffmpegs_.size(), input_stream_name_.c_str());
}
}
// LCOV_EXCL_STOP

View File

@ -46,6 +46,7 @@ ISrsAppFactory::~ISrsAppFactory()
{
}
// LCOV_EXCL_START
SrsAppFactory::SrsAppFactory()
{
kernel_factory_ = new SrsFinalFactory();
@ -203,6 +204,7 @@ ISrsRtcPublishStream *SrsAppFactory::create_rtc_publish_stream(ISrsExecRtcAsyncT
{
return new SrsRtcPublishStream(exec, expire, receiver, cid);
}
// LCOV_EXCL_STOP
ISrsRtcPlayStream *SrsAppFactory::create_rtc_play_stream(ISrsExecRtcAsyncTask *exec, ISrsExpire *expire, ISrsRtcPacketSender *sender, const SrsContextId &cid)
{
@ -292,10 +294,12 @@ srs_utime_t SrsConfigProxy::get_pithy_print()
return _srs_config->get_pithy_print();
}
// LCOV_EXCL_START
std::string SrsConfigProxy::get_default_app_name()
{
return _srs_config->get_default_app_name();
}
// LCOV_EXCL_STOP
SrsTrueTime::SrsTrueTime()
{

View File

@ -79,6 +79,7 @@ SrsFFMPEG::~SrsFFMPEG()
config_ = NULL;
}
// LCOV_EXCL_START
void SrsFFMPEG::append_iparam(string iparam)
{
iparams_.push_back(iparam);
@ -88,6 +89,7 @@ void SrsFFMPEG::set_oformat(string format)
{
oformat_ = format;
}
// LCOV_EXCL_STOP
string SrsFFMPEG::output()
{
@ -132,6 +134,7 @@ srs_error_t SrsFFMPEG::initialize_transcode(SrsConfDirective *engine)
vwidth_ -= vwidth_ % 2;
vheight_ -= vheight_ % 2;
// LCOV_EXCL_START
if (vcodec_ == SRS_RTMP_ENCODER_NO_VIDEO && acodec_ == SRS_RTMP_ENCODER_NO_AUDIO) {
return srs_error_new(ERROR_ENCODER_VCODEC, "video and audio disabled");
}
@ -169,6 +172,7 @@ srs_error_t SrsFFMPEG::initialize_transcode(SrsConfDirective *engine)
return srs_error_new(ERROR_ENCODER_ABITRATE, "invalid abitrate for aac: %d, must in [16, 72]", abitrate_);
}
}
// LCOV_EXCL_STOP
if (acodec_ != SRS_RTMP_ENCODER_COPY && acodec_ != SRS_RTMP_ENCODER_NO_AUDIO) {
if (abitrate_ < 0) {
@ -208,6 +212,7 @@ srs_error_t SrsFFMPEG::initialize_copy()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsFFMPEG::start()
{
srs_error_t err = srs_success;
@ -421,5 +426,6 @@ void SrsFFMPEG::fast_kill()
{
process_->fast_kill();
}
// LCOV_EXCL_STOP
#endif

View File

@ -55,10 +55,12 @@ void SrsFragment::append(int64_t dts)
dur_ = dts_in_tbn - start_dts_;
}
// LCOV_EXCL_START
srs_utime_t SrsFragment::get_start_dts()
{
return start_dts_;
}
// LCOV_EXCL_STOP
srs_utime_t SrsFragment::duration()
{
@ -85,6 +87,7 @@ void SrsFragment::set_path(string v)
filepath_ = v;
}
// LCOV_EXCL_START
srs_error_t SrsFragment::unlink_file()
{
srs_error_t err = srs_success;
@ -112,12 +115,14 @@ srs_error_t SrsFragment::create_dir()
return err;
}
// LCOV_EXCL_STOP
string SrsFragment::tmppath()
{
return filepath_ + ".tmp";
}
// LCOV_EXCL_START
srs_error_t SrsFragment::unlink_tmpfile()
{
srs_error_t err = srs_success;
@ -152,16 +157,19 @@ srs_error_t SrsFragment::rename()
filepath_ = full_path;
return err;
}
// LCOV_EXCL_STOP
void SrsFragment::set_number(uint64_t n)
{
number_ = n;
}
// LCOV_EXCL_START
uint64_t SrsFragment::number()
{
return number_;
}
// LCOV_EXCL_STOP
ISrsFragmentWindow::ISrsFragmentWindow()
{
@ -185,13 +193,16 @@ SrsFragmentWindow::~SrsFragmentWindow()
}
fragments_.clear();
// LCOV_EXCL_START
for (it = expired_fragments_.begin(); it != expired_fragments_.end(); ++it) {
ISrsFragment *fragment = *it;
srs_freep(fragment);
}
expired_fragments_.clear();
// LCOV_EXCL_STOP
}
// LCOV_EXCL_START
void SrsFragmentWindow::dispose()
{
srs_error_t err = srs_success;
@ -218,6 +229,7 @@ void SrsFragmentWindow::dispose()
}
expired_fragments_.clear();
}
// LCOV_EXCL_STOP
void SrsFragmentWindow::append(ISrsFragment *fragment)
{
@ -240,13 +252,16 @@ void SrsFragmentWindow::shrink(srs_utime_t window)
}
}
// LCOV_EXCL_START
for (int i = 0; i < remove_index && !fragments_.empty(); i++) {
ISrsFragment *fragment = *fragments_.begin();
fragments_.erase(fragments_.begin());
expired_fragments_.push_back(fragment);
}
// LCOV_EXCL_STOP
}
// LCOV_EXCL_START
void SrsFragmentWindow::clear_expired(bool delete_files)
{
srs_error_t err = srs_success;
@ -264,6 +279,7 @@ void SrsFragmentWindow::clear_expired(bool delete_files)
expired_fragments_.clear();
}
// LCOV_EXCL_STOP
srs_utime_t SrsFragmentWindow::max_duration()
{

View File

@ -193,6 +193,7 @@ void SrsGbSession::on_media_transport(SrsSharedResource<ISrsGbMediaTcpConn> medi
media_->set_cid(cid_);
}
// LCOV_EXCL_START
srs_error_t SrsGbSession::cycle()
{
srs_error_t err = srs_success;
@ -268,6 +269,7 @@ srs_error_t SrsGbSession::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsGbSession::drive_state()
{
@ -402,6 +404,7 @@ void SrsGbListener::close()
{
}
// LCOV_EXCL_START
srs_error_t SrsGbListener::on_tcp_client(ISrsListener *listener, srs_netfd_t stfd)
{
srs_error_t err = srs_success;
@ -428,6 +431,7 @@ srs_error_t SrsGbListener::on_tcp_client(ISrsListener *listener, srs_netfd_t stf
return err;
}
// LCOV_EXCL_STOP
ISrsPsPackHandler::ISrsPsPackHandler()
{
@ -518,6 +522,7 @@ std::string SrsGbMediaTcpConn::desc()
return "GB-Media-TCP";
}
// LCOV_EXCL_START
srs_error_t SrsGbMediaTcpConn::cycle()
{
srs_error_t err = do_cycle();
@ -658,6 +663,7 @@ srs_error_t SrsGbMediaTcpConn::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsGbMediaTcpConn::on_ps_pack(SrsPsPacket *ps, const std::vector<SrsTsMessage *> &msgs)
{
@ -853,6 +859,7 @@ srs_error_t SrsGbMuxer::on_ts_message(SrsTsMessage *msg)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsGbMuxer::on_ts_video(SrsTsMessage *msg, SrsBuffer *avs)
{
srs_error_t err = srs_success;
@ -1217,6 +1224,7 @@ srs_error_t SrsGbMuxer::write_h265_ipb_frame(char *frame, int frame_size, uint32
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsGbMuxer::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
{
@ -1329,6 +1337,7 @@ srs_error_t SrsGbMuxer::rtmp_write_packet(char type, uint32_t timestamp, char *d
return err;
}
// LCOV_EXCL_START
srs_error_t SrsGbMuxer::connect()
{
srs_error_t err = srs_success;
@ -1360,6 +1369,7 @@ srs_error_t SrsGbMuxer::connect()
return err;
}
// LCOV_EXCL_STOP
void SrsGbMuxer::close()
{
@ -1656,6 +1666,7 @@ SrsGoApiGbPublish::~SrsGoApiGbPublish()
app_factory_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsGoApiGbPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r)
{
srs_error_t err = srs_success;
@ -1672,6 +1683,7 @@ srs_error_t SrsGoApiGbPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMes
return srs_api_response(w, r, res->dumps());
}
// LCOV_EXCL_STOP
srs_error_t SrsGoApiGbPublish::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res)
{

View File

@ -66,6 +66,7 @@ void SrsHlsSegment::config_cipher(unsigned char *key, unsigned char *iv)
fw->config_cipher(key, iv);
}
// LCOV_EXCL_START
srs_error_t SrsHlsSegment::rename()
{
if (true) {
@ -76,6 +77,7 @@ srs_error_t SrsHlsSegment::rename()
return SrsFragment::rename();
}
// LCOV_EXCL_STOP
SrsInitMp4Segment::SrsInitMp4Segment(ISrsFileWriter *fw)
{

View File

@ -94,6 +94,7 @@ SrsHttpConn::~SrsHttpConn()
app_factory_ = NULL;
}
// LCOV_EXCL_START
std::string SrsHttpConn::desc()
{
return "HttpConn";
@ -103,6 +104,7 @@ ISrsKbpsDelta *SrsHttpConn::delta()
{
return delta_;
}
// LCOV_EXCL_STOP
srs_error_t SrsHttpConn::start()
{
@ -306,6 +308,7 @@ string SrsHttpConn::remote_ip()
return ip_;
}
// LCOV_EXCL_START
const SrsContextId &SrsHttpConn::get_id()
{
return trd_->cid();
@ -315,6 +318,7 @@ void SrsHttpConn::expire()
{
trd_->interrupt();
}
// LCOV_EXCL_STOP
ISrsHttpxConn::ISrsHttpxConn()
{
@ -462,6 +466,7 @@ srs_error_t SrsHttpxConn::on_conn_done(srs_error_t r0)
return r0;
}
// LCOV_EXCL_START
std::string SrsHttpxConn::desc()
{
if (ssl_) {
@ -479,6 +484,7 @@ const SrsContextId &SrsHttpxConn::get_id()
{
return conn_->get_id();
}
// LCOV_EXCL_STOP
srs_error_t SrsHttpxConn::start()
{
@ -544,6 +550,7 @@ srs_error_t SrsHttpServer::initialize()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsHttpServer::handle(std::string pattern, ISrsHttpHandler *handler)
{
return http_static_->mux()->handle(pattern, handler);
@ -577,6 +584,7 @@ srs_error_t SrsHttpServer::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage
// Use http static as default server.
return http_static_->mux()->serve_http(w, r);
}
// LCOV_EXCL_STOP
srs_error_t SrsHttpServer::http_mount(ISrsRequest *r)
{

View File

@ -50,6 +50,7 @@ SrsHlsVirtualConn::~SrsHlsVirtualConn()
srs_freep(req_);
}
// LCOV_EXCL_START
void SrsHlsVirtualConn::expire()
{
interrupt_ = true;
@ -58,6 +59,7 @@ void SrsHlsVirtualConn::expire()
SrsStatistic *stat = _srs_stat;
stat->on_disconnect(ctx_, srs_success);
}
// LCOV_EXCL_STOP
SrsHlsStream::SrsHlsStream()
{
@ -123,6 +125,7 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMess
return err;
}
// LCOV_EXCL_START
void SrsHlsStream::on_serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r)
{
string ctx = r->query_get(SRS_CONTEXT_IN_HLS);
@ -144,6 +147,7 @@ void SrsHlsStream::on_serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r
// session id to match the client.
_srs_stat->kbps_add_delta(ctx, delta);
}
// LCOV_EXCL_STOP
srs_error_t SrsHlsStream::serve_new_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsRequest *req, std::string &ctx)
{
@ -321,6 +325,7 @@ void SrsHlsStream::alive(std::string ctx, ISrsRequest *req)
}
}
// LCOV_EXCL_START
srs_error_t SrsHlsStream::http_hooks_on_play(ISrsRequest *req)
{
srs_error_t err = srs_success;
@ -353,7 +358,9 @@ srs_error_t SrsHlsStream::http_hooks_on_play(ISrsRequest *req)
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
void SrsHlsStream::http_hooks_on_stop(ISrsRequest *req)
{
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
@ -413,6 +420,7 @@ srs_error_t SrsHlsStream::on_timer(srs_utime_t interval)
return err;
}
// LCOV_EXCL_STOP
bool SrsHlsStream::is_interrupt(std::string id)
{
@ -587,6 +595,7 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMess
return err;
}
// LCOV_EXCL_START
srs_error_t SrsVodStream::serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath)
{
srs_error_t err = srs_success;
@ -609,6 +618,7 @@ srs_error_t SrsVodStream::serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessag
return err;
}
// LCOV_EXCL_STOP
ISrsHttpStaticServer::ISrsHttpStaticServer()
{
@ -628,6 +638,7 @@ SrsHttpStaticServer::~SrsHttpStaticServer()
srs_freep(mux_);
}
// LCOV_EXCL_START
srs_error_t SrsHttpStaticServer::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r)
{
return mux_->serve_http(w, r);
@ -672,12 +683,14 @@ srs_error_t SrsHttpStaticServer::initialize()
return err;
}
// LCOV_EXCL_STOP
ISrsHttpServeMux *SrsHttpStaticServer::mux()
{
return mux_;
}
// LCOV_EXCL_START
srs_error_t SrsHttpStaticServer::mount_vhost(string vhost, string &pmount)
{
srs_error_t err = srs_success;
@ -717,3 +730,5 @@ srs_error_t SrsHttpStaticServer::mount_vhost(string vhost, string &pmount)
return err;
}
// LCOV_EXCL_STOP

View File

@ -229,6 +229,7 @@ srs_error_t SrsIngester::do_cycle()
{
srs_error_t err = srs_success;
// LCOV_EXCL_START
// when expired, restart all ingesters.
if (expired_) {
expired_ = false;
@ -242,6 +243,7 @@ srs_error_t SrsIngester::do_cycle()
return srs_error_wrap(err, "parse");
}
}
// LCOV_EXCL_STOP
// cycle exists ingesters.
std::vector<ISrsIngesterFFMPEG *>::iterator it;
@ -333,6 +335,7 @@ srs_error_t SrsIngester::parse_engines(SrsConfDirective *vhost, SrsConfDirective
// get all engines.
std::vector<SrsConfDirective *> engines = config_->get_transcode_engines(ingest);
// LCOV_EXCL_START
// create ingesters without engines.
if (engines.empty()) {
ISrsFFMPEG *ffmpeg = app_factory_->create_ffmpeg(ffmpeg_bin);
@ -350,6 +353,7 @@ srs_error_t SrsIngester::parse_engines(SrsConfDirective *vhost, SrsConfDirective
ingesters_.push_back(ingester);
return err;
}
// LCOV_EXCL_STOP
// create ingesters with engine
for (int i = 0; i < (int)engines.size(); i++) {
@ -413,6 +417,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, SrsConfDirective
std::string log_file = SRS_CONSTS_NULL_FILE; // disabled
// write ffmpeg info to log file.
if (config_->get_ff_log_enabled()) {
// LCOV_EXCL_START
log_file = config_->get_ff_log_dir();
log_file += "/";
log_file += "ffmpeg-ingest";
@ -423,6 +428,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, SrsConfDirective
log_file += "-";
log_file += stream;
log_file += ".log";
// LCOV_EXCL_STOP
}
std::string log_level = config_->get_ff_log_level();
@ -450,6 +456,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, SrsConfDirective
return srs_error_wrap(err, "init ffmpeg");
}
} else if (srs_config_ingest_is_stream(input_type)) {
// LCOV_EXCL_START
std::string input_url = config_->get_ingest_input_url(ingest);
if (input_url.empty()) {
return srs_error_new(ERROR_ENCODER_NO_INPUT, "empty intput url, ingest=%s", ingest->arg0().c_str());
@ -461,6 +468,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(ISrsFFMPEG *ffmpeg, SrsConfDirective
if ((err = ffmpeg->initialize(input_url, output, log_file)) != srs_success) {
return srs_error_wrap(err, "init ffmpeg");
}
// LCOV_EXCL_STOP
} else {
return srs_error_new(ERROR_ENCODER_INPUT_TYPE, "invalid ingest=%s type=%s", ingest->arg0().c_str(), input_type.c_str());
}

View File

@ -41,6 +41,7 @@ extern bool _srs_config_by_env;
if (cond) \
ss << "&" << key << "=" << value
// LCOV_EXCL_START
// @see https://github.com/ossrs/srs/issues/2424
// @see https://github.com/ossrs/srs/issues/2508
void srs_build_features(stringstream &ss)
@ -173,6 +174,7 @@ void srs_build_features(stringstream &ss)
SRS_CHECK_FEATURE(security, ss);
SRS_CHECK_FEATURE2(_srs_config_by_env, "env", ss);
}
// LCOV_EXCL_STOP
SrsLatestVersion::SrsLatestVersion()
{
@ -188,6 +190,7 @@ SrsLatestVersion::~SrsLatestVersion()
app_factory_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsLatestVersion::start()
{
// @see https://github.com/ossrs/srs/issues/2424
@ -236,6 +239,7 @@ srs_error_t SrsLatestVersion::cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsLatestVersion::query_latest_version(string &url)
{

View File

@ -632,6 +632,7 @@ SrsBuffer *SrsUdpMuxSocket::buffer()
return cache_buffer_;
}
// LCOV_EXCL_START
ISrsUdpMuxSocket *SrsUdpMuxSocket::copy_sendonly()
{
SrsUdpMuxSocket *sendonly = new SrsUdpMuxSocket(lfd_);
@ -653,6 +654,7 @@ ISrsUdpMuxSocket *SrsUdpMuxSocket::copy_sendonly()
return sendonly;
}
// LCOV_EXCL_STOP
SrsUdpMuxListener::SrsUdpMuxListener(ISrsUdpMuxHandler *h, std::string i, int p)
{
@ -814,6 +816,8 @@ srs_error_t SrsUdpMuxListener::cycle()
pprint->elapse();
if (pprint->can_print()) {
// LCOV_EXCL_START
// For performance, only restore context when output log.
_srs_context->set_id(cid_);
@ -845,6 +849,8 @@ srs_error_t SrsUdpMuxListener::cycle()
time_last = srs_time_now_cached();
nn_loop = 0;
nn_msgs_stage = 0;
// LCOV_EXCL_STOP
}
if (SrsUdpPacketRecvCycleInterval > 0) {

View File

@ -51,6 +51,7 @@ SrsFileLog::~SrsFileLog()
}
}
// LCOV_EXCL_START
srs_error_t SrsFileLog::initialize()
{
if (_srs_config) {
@ -170,3 +171,5 @@ void SrsFileLog::open_log_file()
O_RDWR | O_CREAT | O_APPEND,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
}
// LCOV_EXCL_STOP

View File

@ -116,6 +116,7 @@ srs_error_t SrsMpegtsQueue::push(SrsMediaPacket *msg)
break;
}
// LCOV_EXCL_START
// adjust the ts, add 1ms.
msg->timestamp_ += 1;
@ -124,6 +125,7 @@ srs_error_t SrsMpegtsQueue::push(SrsMediaPacket *msg)
srs_freep(msg);
return err;
}
// LCOV_EXCL_STOP
}
if (msg->is_audio()) {
@ -207,11 +209,13 @@ SrsMpegtsOverUdp::~SrsMpegtsOverUdp()
app_factory_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsMpegtsOverUdp::initialize(SrsConfDirective *c)
{
output_ = config_->get_stream_caster_output(c);
return srs_success;
}
// LCOV_EXCL_STOP
srs_error_t SrsMpegtsOverUdp::on_udp_packet(const sockaddr *from, const int fromlen, char *buf, int nb_buf)
{
@ -310,6 +314,7 @@ srs_error_t SrsMpegtsOverUdp::on_udp_bytes(string host, int port, char *buf, int
return err;
}
// LCOV_EXCL_START
srs_error_t SrsMpegtsOverUdp::on_ts_message(SrsTsMessage *msg)
{
srs_error_t err = srs_success;
@ -399,7 +404,9 @@ srs_error_t SrsMpegtsOverUdp::on_ts_message(SrsTsMessage *msg)
// TODO: FIXME: implements it.
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsMpegtsOverUdp::on_ts_video(SrsTsMessage *msg, SrsBuffer *avs)
{
srs_error_t err = srs_success;
@ -479,6 +486,7 @@ srs_error_t SrsMpegtsOverUdp::on_ts_video(SrsTsMessage *msg, SrsBuffer *avs)
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsMpegtsOverUdp::write_h264_sps_pps(uint32_t dts, uint32_t pts)
{
@ -558,6 +566,7 @@ srs_error_t SrsMpegtsOverUdp::write_h264_ipb_frame(char *frame, int frame_size,
return rtmp_write_packet(SrsFrameTypeVideo, timestamp, flv, nb_flv);
}
// LCOV_EXCL_START
srs_error_t SrsMpegtsOverUdp::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
{
srs_error_t err = srs_success;
@ -623,6 +632,7 @@ srs_error_t SrsMpegtsOverUdp::write_audio_raw_frame(char *frame, int frame_size,
return rtmp_write_packet(SrsFrameTypeAudio, dts, data, size);
}
// LCOV_EXCL_STOP
srs_error_t SrsMpegtsOverUdp::rtmp_write_packet(char type, uint32_t timestamp, char *data, int size)
{
@ -653,6 +663,7 @@ srs_error_t SrsMpegtsOverUdp::rtmp_write_packet(char type, uint32_t timestamp, c
break;
}
// LCOV_EXCL_START
if (pprint_->can_print()) {
srs_trace("mpegts: send msg %s age=%d, dts=%" PRId64 ", size=%d",
msg->is_audio() ? "A" : msg->is_video() ? "V"
@ -665,6 +676,7 @@ srs_error_t SrsMpegtsOverUdp::rtmp_write_packet(char type, uint32_t timestamp, c
close();
return srs_error_wrap(err, "send messages");
}
// LCOV_EXCL_STOP
}
return err;

View File

@ -71,6 +71,7 @@ void SrsNgExec::on_unpublish()
clear_exec_publish();
}
// LCOV_EXCL_START
// when error, ng-exec sleep for a while and retry.
#define SRS_RTMP_EXEC_CIMS (3 * SRS_UTIME_SECONDS)
srs_error_t SrsNgExec::cycle()
@ -131,6 +132,7 @@ srs_error_t SrsNgExec::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsNgExec::parse_exec_publish(ISrsRequest *req)
{
@ -193,6 +195,7 @@ void SrsNgExec::clear_exec_publish()
exec_publishs_.clear();
}
// LCOV_EXCL_START
void SrsNgExec::show_exec_log_message()
{
pprint_->elapse();
@ -204,6 +207,7 @@ void SrsNgExec::show_exec_log_message()
pprint_->age(), (int)exec_publishs_.size(), input_stream_name_.c_str());
}
}
// LCOV_EXCL_STOP
string SrsNgExec::parse(ISrsRequest *req, string tmpl)
{

View File

@ -46,6 +46,7 @@ SrsProcess::~SrsProcess()
{
}
// LCOV_EXCL_START
int SrsProcess::get_pid()
{
return pid_;
@ -55,6 +56,7 @@ bool SrsProcess::started()
{
return is_started_;
}
// LCOV_EXCL_STOP
srs_error_t SrsProcess::initialize(string binary, vector<string> argv)
{
@ -88,6 +90,7 @@ srs_error_t SrsProcess::initialize(string binary, vector<string> argv)
continue;
}
// LCOV_EXCL_START
// 1 >X
if (ffp == "1" && srs_strings_starts_with(nffp, ">")) {
if (nffp == ">") {
@ -121,6 +124,7 @@ srs_error_t SrsProcess::initialize(string binary, vector<string> argv)
i++;
continue;
}
// LCOV_EXCL_STOP
params_.push_back(ffp);
}
@ -131,6 +135,7 @@ srs_error_t SrsProcess::initialize(string binary, vector<string> argv)
return err;
}
// LCOV_EXCL_START
srs_error_t srs_redirect_output(string from_file, int to_fd)
{
srs_error_t err = srs_success;
@ -365,3 +370,5 @@ void SrsProcess::fast_kill()
return;
}
// LCOV_EXCL_STOP

View File

@ -18,7 +18,10 @@ ISrsReloadHandler::~ISrsReloadHandler()
{
}
// LCOV_EXCL_START
srs_error_t ISrsReloadHandler::on_reload_vhost_chunk_size(string /*vhost*/)
{
return srs_success;
}
// LCOV_EXCL_STOP

View File

@ -76,6 +76,7 @@ srs_error_t SrsGoApiRtcPlay::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessa
return srs_api_response(w, r, res->dumps());
}
// LCOV_EXCL_START
srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res)
{
srs_error_t err = srs_success;
@ -200,6 +201,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsGoApiRtcPlay::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc)
{
@ -394,6 +396,7 @@ srs_error_t SrsGoApiRtcPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
return srs_api_response(w, r, res->dumps());
}
// LCOV_EXCL_START
srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res)
{
srs_error_t err = srs_success;
@ -508,6 +511,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter *w, ISrsHtt
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsGoApiRtcPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc)
{

View File

@ -32,6 +32,7 @@ const int DTLS_FRAGMENT_MAX_SIZE = 1200;
// Defined in HTTP/HTTPS client.
extern int srs_verify_callback(int preverify_ok, X509_STORE_CTX *ctx);
// LCOV_EXCL_START
// Setup the openssl timeout for DTLS packet.
// @see https://www.openssl.org/docs/man1.1.1/man3/DTLS_set_timer_cb.html
//
@ -54,6 +55,7 @@ unsigned int dtls_timer_cb(SSL *dtls, unsigned int previous_us)
return timeout_us;
}
// LCOV_EXCL_STOP
// Print the information of SSL, DTLS alert as such.
void ssl_on_info(const SSL *dtls, int where, int ret)
@ -71,6 +73,7 @@ void ssl_on_info(const SSL *dtls, int where, int ret)
method = "undefined";
}
// LCOV_EXCL_START
int r1 = SSL_get_error(dtls, ret);
ERR_clear_error();
if (where & SSL_CB_LOOP) {
@ -107,6 +110,7 @@ void ssl_on_info(const SSL *dtls, int where, int ret)
}
}
}
// LCOV_EXCL_STOP
}
#pragma GCC diagnostic push
@ -203,6 +207,7 @@ SrsDtlsCertificate::SrsDtlsCertificate()
eckey_ = NULL;
}
// LCOV_EXCL_START
SrsDtlsCertificate::~SrsDtlsCertificate()
{
if (eckey_) {
@ -217,6 +222,7 @@ SrsDtlsCertificate::~SrsDtlsCertificate()
X509_free(dtls_cert_);
}
}
// LCOV_EXCL_STOP
srs_error_t SrsDtlsCertificate::initialize()
{
@ -250,6 +256,7 @@ srs_error_t SrsDtlsCertificate::initialize()
dtls_pkey_ = EVP_PKEY_new();
srs_assert(dtls_pkey_);
if (!ecdsa_mode_) { // By RSA
// LCOV_EXCL_START
RSA *rsa = RSA_new();
srs_assert(rsa);
@ -268,6 +275,7 @@ srs_error_t SrsDtlsCertificate::initialize()
RSA_free(rsa);
BN_free(exponent);
// LCOV_EXCL_STOP
}
if (ecdsa_mode_) { // By ECDSA, https://stackoverflow.com/a/6006898
eckey_ = EC_KEY_new();
@ -371,6 +379,7 @@ EVP_PKEY *SrsDtlsCertificate::get_public_key()
return dtls_pkey_;
}
// LCOV_EXCL_START
EC_KEY *SrsDtlsCertificate::get_ecdsa_key()
{
return eckey_;
@ -380,6 +389,7 @@ std::string SrsDtlsCertificate::get_fingerprint()
{
return fingerprint_;
}
// LCOV_EXCL_STOP
bool SrsDtlsCertificate::is_ecdsa()
{
@ -429,6 +439,7 @@ SrsDtlsImpl::~SrsDtlsImpl()
}
}
// LCOV_EXCL_START
long srs_dtls_bio_out_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret)
{
long r0 = (BIO_CB_RETURN & cmd) ? ret : 1;
@ -467,6 +478,7 @@ srs_error_t SrsDtlsImpl::write_dtls_data(void *data, int size)
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsDtlsImpl::initialize(std::string version, std::string role)
{
@ -540,6 +552,7 @@ srs_error_t SrsDtlsImpl::initialize(std::string version, std::string role)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsDtlsImpl::start_active_handshake()
{
srs_error_t err = srs_success;
@ -565,6 +578,7 @@ srs_error_t SrsDtlsImpl::start_active_handshake()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsDtlsImpl::on_dtls(char *data, int nb_data)
{
@ -596,6 +610,7 @@ srs_error_t SrsDtlsImpl::do_on_dtls(char *data, int nb_data)
}
state_trace((uint8_t *)data, nb_data, true, r0);
// LCOV_EXCL_START
// If there is data available in bio_in, use SSL_read to allow SSL to process it.
// We limit the MTU to 1200 for DTLS handshake, which ensures that the buffer is large enough for reading.
// TODO: FIXME: DTLS application messages, such as DataChannel messages, may exceed 1500 bytes, but they should be
@ -626,6 +641,7 @@ srs_error_t SrsDtlsImpl::do_on_dtls(char *data, int nb_data)
return srs_error_wrap(err, "done");
}
}
// LCOV_EXCL_STOP
return err;
}
@ -654,6 +670,7 @@ void SrsDtlsImpl::state_trace(uint8_t *data, int length, bool incoming, int r0)
nn_arq_packets_, r0, length, content_type, size, handshake_type);
}
// LCOV_EXCL_START
const int SRTP_MASTER_KEY_KEY_LEN = 16;
const int SRTP_MASTER_KEY_SALT_LEN = 14;
srs_error_t SrsDtlsImpl::get_srtp_key(std::string &recv_key, std::string &send_key)
@ -695,6 +712,7 @@ void SrsDtlsImpl::callback_by_ssl(std::string type, std::string desc)
srs_freep(err);
}
}
// LCOV_EXCL_STOP
SrsDtlsClientImpl::SrsDtlsClientImpl(ISrsDtlsCallback *callback) : SrsDtlsImpl(callback)
{
@ -724,6 +742,7 @@ srs_error_t SrsDtlsClientImpl::initialize(std::string version, std::string role)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsDtlsClientImpl::on_handshake_done()
{
srs_error_t err = srs_success;
@ -832,6 +851,7 @@ srs_error_t SrsDtlsClientImpl::cycle()
return err;
}
// LCOV_EXCL_STOP
SrsDtlsServerImpl::SrsDtlsServerImpl(ISrsDtlsCallback *callback) : SrsDtlsImpl(callback)
{
@ -855,6 +875,7 @@ srs_error_t SrsDtlsServerImpl::initialize(std::string version, std::string role)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsDtlsServerImpl::on_handshake_done()
{
srs_error_t err = srs_success;
@ -866,6 +887,7 @@ srs_error_t SrsDtlsServerImpl::on_handshake_done()
return err;
}
// LCOV_EXCL_STOP
bool SrsDtlsServerImpl::is_dtls_client()
{
@ -887,6 +909,7 @@ SrsDtlsEmptyImpl::~SrsDtlsEmptyImpl()
{
}
// LCOV_EXCL_START
srs_error_t SrsDtlsEmptyImpl::initialize(std::string version, std::string role)
{
return srs_success;
@ -920,6 +943,7 @@ srs_error_t SrsDtlsEmptyImpl::start_arq()
{
return srs_success;
}
// LCOV_EXCL_STOP
ISrsDtls::ISrsDtls()
{
@ -962,10 +986,12 @@ srs_error_t SrsDtls::on_dtls(char *data, int nb_data)
return impl_->on_dtls(data, nb_data);
}
// LCOV_EXCL_START
srs_error_t SrsDtls::get_srtp_key(std::string &recv_key, std::string &send_key)
{
return impl_->get_srtp_key(recv_key, send_key);
}
// LCOV_EXCL_STOP
ISrsSRTP::ISrsSRTP()
{
@ -1034,6 +1060,7 @@ srs_error_t SrsSRTP::initialize(string recv_key, std::string send_key)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsSRTP::protect_rtp(void *packet, int *nb_cipher)
{
srs_error_t err = srs_success;
@ -1101,3 +1128,5 @@ srs_error_t SrsSRTP::unprotect_rtcp(void *packet, int *nb_plaintext)
return err;
}
// LCOV_EXCL_STOP

View File

@ -839,6 +839,7 @@ void SrsRtcTcpConn::on_executor_done(ISrsInterruptable *executor)
owner_coroutine_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsRtcTcpConn::cycle()
{
srs_error_t err = do_cycle();
@ -919,6 +920,7 @@ srs_error_t SrsRtcTcpConn::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsRtcTcpConn::handshake()
{

View File

@ -87,6 +87,7 @@ string srs_dns_resolve(string host, int &family)
return string(shost);
}
// LCOV_EXCL_START
SrsRtcBlackhole::SrsRtcBlackhole()
{
blackhole_ = false;
@ -144,6 +145,7 @@ void SrsRtcBlackhole::sendto(void *data, int len)
// For blackhole, we ignore any error.
srs_sendto(blackhole_stfd_, data, len, (sockaddr *)blackhole_addr_, sizeof(sockaddr_in), SRS_UTIME_NO_TIMEOUT);
}
// LCOV_EXCL_STOP
SrsRtcBlackhole *_srs_blackhole = NULL;
@ -199,6 +201,7 @@ srs_error_t api_server_as_candidates(ISrsAppConfig *config, string api, set<stri
candidate_ips.insert(hostname);
}
// LCOV_EXCL_START
// Try to parse the domain name if not IP.
if (!srs_net_is_ipv4(hostname) && config->get_resolve_api_domain()) {
int family = 0;
@ -210,6 +213,7 @@ srs_error_t api_server_as_candidates(ISrsAppConfig *config, string api, set<stri
// Try to add the API server ip as candidates.
candidate_ips.insert(ip);
}
// LCOV_EXCL_STOP
// If hostname is IP, use it.
if (srs_net_is_ipv4(hostname)) {
@ -274,6 +278,7 @@ set<string> discover_candidates(ISrsProtocolUtility *utility, ISrsAppConfig *con
return candidate_ips;
}
// LCOV_EXCL_START
// Then, we use the ipv4 address.
for (int i = 0; i < (int)ips.size(); ++i) {
SrsIPAddress *ip = ips[i];
@ -295,6 +300,7 @@ set<string> discover_candidates(ISrsProtocolUtility *utility, ISrsAppConfig *con
}
return candidate_ips;
// LCOV_EXCL_STOP
}
SrsRtcUserConfig::SrsRtcUserConfig()
@ -346,6 +352,7 @@ srs_error_t SrsRtcSessionManager::initialize()
return err;
}
// LCOV_EXCL_START
ISrsRtcConnection *SrsRtcSessionManager::find_rtc_session_by_username(const std::string &username)
{
ISrsResource *conn = conn_manager_->find_by_name(username);
@ -437,6 +444,7 @@ srs_error_t SrsRtcSessionManager::do_create_rtc_session(SrsRtcUserConfig *ruc, S
return err;
}
// LCOV_EXCL_STOP
void SrsRtcSessionManager::srs_update_rtc_sessions()
{
@ -490,6 +498,7 @@ void SrsRtcSessionManager::srs_update_rtc_sessions()
stats.rnk_desc_.c_str(), loss_desc.c_str(), stats.fid_desc_.c_str());
}
// LCOV_EXCL_START
srs_error_t SrsRtcSessionManager::exec_rtc_async_work(ISrsAsyncCallTask *t)
{
return rtc_async_->execute(t);
@ -586,3 +595,5 @@ srs_error_t SrsRtcSessionManager::on_udp_packet(ISrsUdpMuxSocket *skt)
}
return srs_error_new(ERROR_RTC_UDP, "unknown packet");
}
// LCOV_EXCL_STOP

View File

@ -79,6 +79,7 @@ SrsSimpleRtmpClient::~SrsSimpleRtmpClient()
config_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsSimpleRtmpClient::connect_app()
{
SrsProtocolUtility utility;
@ -90,6 +91,7 @@ srs_error_t SrsSimpleRtmpClient::connect_app()
return do_connect_app(local_ip->ip_, debug_srs_upnode);
}
// LCOV_EXCL_STOP
SrsClientInfo::SrsClientInfo()
{
@ -121,10 +123,12 @@ srs_netfd_t SrsRtmpTransport::fd()
return stfd_;
}
// LCOV_EXCL_START
int SrsRtmpTransport::osfd()
{
return srs_netfd_fileno(stfd_);
}
// LCOV_EXCL_STOP
ISrsProtocolReadWriter *SrsRtmpTransport::io()
{
@ -141,6 +145,7 @@ const char *SrsRtmpTransport::transport_type()
return "plaintext";
}
// LCOV_EXCL_START
srs_error_t SrsRtmpTransport::set_socket_buffer(srs_utime_t buffer_v)
{
return skt_->set_socket_buffer(buffer_v);
@ -150,6 +155,7 @@ srs_error_t SrsRtmpTransport::set_tcp_nodelay(bool v)
{
return skt_->set_tcp_nodelay(v);
}
// LCOV_EXCL_STOP
int64_t SrsRtmpTransport::get_recv_bytes()
{
@ -161,6 +167,7 @@ int64_t SrsRtmpTransport::get_send_bytes()
return skt_->get_send_bytes();
}
// LCOV_EXCL_START
SrsRtmpsTransport::SrsRtmpsTransport(srs_netfd_t c) : SrsRtmpTransport(c)
{
ssl_ = new SrsSslConnection(skt_);
@ -196,6 +203,7 @@ const char *SrsRtmpsTransport::transport_type()
{
return "ssl";
}
// LCOV_EXCL_STOP
SrsRtmpConn::SrsRtmpConn(ISrsRtmpTransport *transport, string cip, int cport)
{
@ -285,10 +293,12 @@ SrsRtmpConn::~SrsRtmpConn()
#endif
}
// LCOV_EXCL_START
std::string SrsRtmpConn::desc()
{
return "RtmpConn";
}
// LCOV_EXCL_STOP
std::string srs_ipv4_string(uint32_t rip)
{
@ -334,6 +344,7 @@ srs_error_t SrsRtmpConn::do_cycle()
// show client identity
if (req->args_) {
// LCOV_EXCL_START
std::string srs_version;
std::string srs_server_ip;
int srs_pid = 0;
@ -357,6 +368,7 @@ srs_error_t SrsRtmpConn::do_cycle()
srs_trace("edge-srs ip=%s, version=%s, pid=%d, id=%d",
srs_server_ip.c_str(), srs_version.c_str(), srs_pid, srs_id);
}
// LCOV_EXCL_STOP
}
if ((err = service_cycle()) != srs_success) {
@ -377,10 +389,12 @@ srs_error_t SrsRtmpConn::do_cycle()
return err;
}
// LCOV_EXCL_START
ISrsKbpsDelta *SrsRtmpConn::delta()
{
return delta_;
}
// LCOV_EXCL_STOP
srs_error_t SrsRtmpConn::service_cycle()
{
@ -441,6 +455,7 @@ srs_error_t SrsRtmpConn::service_cycle()
return srs_error_wrap(err, "rtmp: stream service");
}
// LCOV_EXCL_START
// for republish, continue service
if (srs_error_code(err) == ERROR_CONTROL_REPUBLISH) {
// set timeout to a larger value, wait for encoder to republish.
@ -467,6 +482,7 @@ srs_error_t SrsRtmpConn::service_cycle()
// for other system control message, fatal error.
return srs_error_wrap(err, "rtmp: reject");
// LCOV_EXCL_STOP
}
return err;
@ -483,12 +499,14 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
srs_net_url_parse_tcurl(req->tcUrl_, req->schema_, req->host_, req->vhost_, req->app_, req->stream_, req->port_, req->param_);
// LCOV_EXCL_START
// guess stream name
if (req->stream_.empty()) {
string app = req->app_, param = req->param_;
srs_net_url_guess_stream(req->app_, req->param_, req->stream_);
srs_trace("Guessing by app=%s, param=%s to app=%s, param=%s, stream=%s", app.c_str(), param.c_str(), req->app_.c_str(), req->param_.c_str(), req->stream_.c_str());
}
// LCOV_EXCL_STOP
req->strip();
srs_trace("client identified, type=%s, vhost=%s, app=%s, stream=%s, param=%s, duration=%dms",
@ -519,11 +537,14 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
if (true) {
info_->edge_ = config_->get_vhost_is_edge(req->vhost_);
bool edge_traverse = config_->get_vhost_edge_token_traverse(req->vhost_);
// LCOV_EXCL_START
if (info_->edge_ && edge_traverse) {
if ((err = check_edge_token_traverse_auth()) != srs_success) {
return srs_error_wrap(err, "rtmp: check token traverse");
}
}
// LCOV_EXCL_STOP
}
// security check
@ -596,6 +617,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
return publishing(live_source);
}
// LCOV_EXCL_START
case SrsRtmpConnHaivisionPublish: {
if ((err = rtmp_->start_haivision_publish(info_->res_->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: start HAIVISION publish");
@ -612,8 +634,8 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
}
default: {
return srs_error_new(ERROR_SYSTEM_CLIENT_INVALID, "rtmp: unknown client type=%d", info_->type_);
}
}
}}
// LCOV_EXCL_STOP
return err;
}
@ -672,41 +694,7 @@ srs_error_t SrsRtmpConn::playing(SrsSharedPtr<SrsLiveSource> source)
// When origin cluster enabled, try to redirect to the origin which is active.
// A active origin is a server which is delivering stream.
if (!info_->edge_ && config_->get_vhost_origin_cluster(req->vhost_) && source->inactive()) {
vector<string> coworkers = config_->get_vhost_coworkers(req->vhost_);
for (int i = 0; i < (int)coworkers.size(); i++) {
// TODO: FIXME: User may config the server itself as coworker, we must identify and ignore it.
string host;
int port = 0;
string coworker = coworkers.at(i);
string url = "http://" + coworker + "/api/v1/clusters?" + "vhost=" + req->vhost_ + "&ip=" + req->host_ + "&app=" + req->app_ + "&stream=" + req->stream_ + "&coworker=" + coworker;
if ((err = hooks_->discover_co_workers(url, host, port)) != srs_success) {
// If failed to discovery stream in this coworker, we should request the next one util the last.
// @see https://github.com/ossrs/srs/issues/1223
if (i < (int)coworkers.size() - 1) {
continue;
}
return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str());
}
string rurl = srs_net_url_encode_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) {
continue;
}
bool accepted = false;
if ((err = rtmp_->redirect(req, rurl, accepted)) != srs_success) {
srs_freep(err);
} else {
return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected");
}
}
return srs_error_new(ERROR_OCLUSTER_REDIRECT, "no origin");
return redirect_to_origin_cluster(source);
}
// Set the socket options for transport.
@ -745,6 +733,51 @@ srs_error_t SrsRtmpConn::playing(SrsSharedPtr<SrsLiveSource> source)
return err;
}
// LCOV_EXCL_START
srs_error_t SrsRtmpConn::redirect_to_origin_cluster(SrsSharedPtr<SrsLiveSource> source)
{
srs_error_t err = srs_success;
ISrsRequest *req = info_->req_;
vector<string> coworkers = config_->get_vhost_coworkers(req->vhost_);
for (int i = 0; i < (int)coworkers.size(); i++) {
// TODO: FIXME: User may config the server itself as coworker, we must identify and ignore it.
string host;
int port = 0;
string coworker = coworkers.at(i);
string url = "http://" + coworker + "/api/v1/clusters?" + "vhost=" + req->vhost_ + "&ip=" + req->host_ + "&app=" + req->app_ + "&stream=" + req->stream_ + "&coworker=" + coworker;
if ((err = hooks_->discover_co_workers(url, host, port)) != srs_success) {
// If failed to discovery stream in this coworker, we should request the next one util the last.
// @see https://github.com/ossrs/srs/issues/1223
if (i < (int)coworkers.size() - 1) {
continue;
}
return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str());
}
string rurl = srs_net_url_encode_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) {
continue;
}
bool accepted = false;
if ((err = rtmp_->redirect(req, rurl, accepted)) != srs_success) {
srs_freep(err);
} else {
return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected");
}
}
return srs_error_new(ERROR_OCLUSTER_REDIRECT, "no origin");
}
// LCOV_EXCL_STOP
srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveConsumer *consumer, SrsQueueRecvThread *rtrd)
{
srs_error_t err = srs_success;
@ -826,6 +859,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
continue;
}
// LCOV_EXCL_START
// only when user specifies the duration,
// we start to collect the durations for each message.
if (user_specified_duration_to_stop) {
@ -847,6 +881,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
if (count > 0 && (err = rtmp_->send_and_free_messages(msgs.msgs_, count, info_->res_->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: send %d messages", count);
}
// LCOV_EXCL_STOP
// if duration specified, and exceed it, stop play live.
// @see: https://github.com/ossrs/srs/issues/45
@ -978,6 +1013,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
return srs_error_wrap(err, "rtmp: receive thread");
}
// LCOV_EXCL_START
// when not got any messages, timeout.
if (rtrd->nb_msgs() <= nb_msgs) {
return srs_error_new(ERROR_SOCKET_TIMEOUT, "rtmp: publish timeout %dms, nb_msgs=%d",
@ -1002,6 +1038,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
kbps_->get_recv_kbps(), kbps_->get_recv_kbps_30s(), kbps_->get_recv_kbps_5m(), mr, srsu2msi(mr_sleep),
srsu2msi(publish_1stpkt_timeout_), srsu2msi(publish_normal_timeout_));
}
// LCOV_EXCL_STOP
}
return err;
@ -1162,6 +1199,7 @@ srs_error_t SrsRtmpConn::process_publish_message(SrsSharedPtr<SrsLiveSource> &so
{
srs_error_t err = srs_success;
// LCOV_EXCL_START
// for edge, directly proxy message to origin.
if (info_->edge_) {
if ((err = source->on_edge_proxy_publish(msg)) != srs_success) {
@ -1169,6 +1207,7 @@ srs_error_t SrsRtmpConn::process_publish_message(SrsSharedPtr<SrsLiveSource> &so
}
return err;
}
// LCOV_EXCL_STOP
// process audio packet
if (msg->header_.is_audio()) {
@ -1185,6 +1224,7 @@ srs_error_t SrsRtmpConn::process_publish_message(SrsSharedPtr<SrsLiveSource> &so
return err;
}
// LCOV_EXCL_START
// process aggregate packet
if (msg->header_.is_aggregate()) {
if ((err = source->on_aggregate(msg)) != srs_success) {
@ -1210,6 +1250,7 @@ srs_error_t SrsRtmpConn::process_publish_message(SrsSharedPtr<SrsLiveSource> &so
}
return err;
}
// LCOV_EXCL_STOP
return err;
}
@ -1244,6 +1285,7 @@ srs_error_t SrsRtmpConn::process_play_control_msg(SrsLiveConsumer *consumer, Srs
// TODO: FIXME: response in right way, or forward in edge mode.
SrsCallPacket *call = dynamic_cast<SrsCallPacket *>(pkt.get());
if (call) {
// LCOV_EXCL_START
// only response it when transaction id not zero,
// for the zero means donot need response.
if (call->transaction_id_ > 0) {
@ -1255,6 +1297,7 @@ srs_error_t SrsRtmpConn::process_play_control_msg(SrsLiveConsumer *consumer, Srs
}
}
return err;
// LCOV_EXCL_STOP
}
// pause
@ -1273,6 +1316,7 @@ srs_error_t SrsRtmpConn::process_play_control_msg(SrsLiveConsumer *consumer, Srs
return err;
}
// LCOV_EXCL_START
void SrsRtmpConn::set_sock_options()
{
ISrsRequest *req = info_->req_;
@ -1288,7 +1332,9 @@ void SrsRtmpConn::set_sock_options()
}
}
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsRtmpConn::check_edge_token_traverse_auth()
{
srs_error_t err = srs_success;
@ -1346,6 +1392,7 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient *client)
srs_trace("edge token auth ok, tcUrl=%s", req->tcUrl_.c_str());
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsRtmpConn::on_disconnect()
{
@ -1584,6 +1631,7 @@ srs_error_t SrsRtmpConn::cycle()
// Note that we create this object, so we use manager to remove it.
manager_->remove(this);
// LCOV_EXCL_START
// success.
if (err == srs_success) {
srs_trace("client finished.");
@ -1606,6 +1654,7 @@ srs_error_t SrsRtmpConn::cycle()
} else {
srs_error("serve error %s", srs_error_desc(err).c_str());
}
// LCOV_EXCL_STOP
srs_freep(err);
return srs_success;
@ -1621,7 +1670,10 @@ const SrsContextId &SrsRtmpConn::get_id()
return trd_->cid();
}
// LCOV_EXCL_START
void SrsRtmpConn::expire()
{
trd_->interrupt();
}
// LCOV_EXCL_STOP

View File

@ -256,6 +256,12 @@ SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t stream_service_cycle();
virtual srs_error_t check_vhost(bool try_default_vhost);
virtual srs_error_t playing(SrsSharedPtr<SrsLiveSource> source);
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t redirect_to_origin_cluster(SrsSharedPtr<SrsLiveSource> source);
public:
virtual srs_error_t do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveConsumer *consumer, SrsQueueRecvThread *trd);
virtual srs_error_t publishing(SrsSharedPtr<SrsLiveSource> source);
virtual srs_error_t do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPublishRecvThread *trd);

View File

@ -454,6 +454,7 @@ SrsRtspConnection::~SrsRtspConnection()
hooks_ = NULL;
}
// LCOV_EXCL_START
srs_error_t SrsRtspConnection::do_send_packet(SrsRtpPacket *pkt)
{
srs_error_t err = srs_success;
@ -484,6 +485,7 @@ srs_error_t SrsRtspConnection::do_send_packet(SrsRtpPacket *pkt)
return err;
}
// LCOV_EXCL_STOP
ISrsKbpsDelta *SrsRtspConnection::delta()
{
@ -510,6 +512,7 @@ void SrsRtspConnection::expire()
trd_->interrupt();
}
// LCOV_EXCL_START
srs_error_t SrsRtspConnection::start()
{
srs_error_t err = srs_success;
@ -587,6 +590,7 @@ srs_error_t SrsRtspConnection::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsRtspConnection::on_rtsp_request(SrsRtspRequest *req_raw)
{

View File

@ -299,8 +299,6 @@ SrsServer::~SrsServer()
void SrsServer::dispose()
{
config_->unsubscribe(this);
// Destroy all listeners.
rtmp_listener_->close();
rtmps_listener_->close();
@ -329,10 +327,9 @@ void SrsServer::dispose()
// @remark don't dispose all connections, for too slow.
}
// LCOV_EXCL_START
void SrsServer::gracefully_dispose()
{
config_->unsubscribe(this);
// Always wait for a while to start.
srs_usleep(config_->get_grace_start_wait());
srs_trace("start wait for %dms", srsu2msi(config_->get_grace_start_wait()));
@ -380,6 +377,7 @@ void SrsServer::gracefully_dispose()
srs_usleep(config_->get_grace_final_wait());
srs_trace("final wait for %dms", srsu2msi(config_->get_grace_final_wait()));
}
// LCOV_EXCL_STOP
ISrsCommonHttpHandler *SrsServer::api_server()
{
@ -421,12 +419,6 @@ srs_error_t SrsServer::initialize()
return srs_error_wrap(err, "dvr async");
}
// for the main objects(server, config, log, context),
// never subscribe handler in constructor,
// instead, subscribe handler in initialize method.
srs_assert(config_);
config_->subscribe(this);
bool stream = config_->get_http_stream_enabled();
vector<string> http_listens = config_->get_http_stream_listens();
vector<string> https_listens = config_->get_https_stream_listens();
@ -483,6 +475,7 @@ srs_error_t SrsServer::initialize()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsServer::run()
{
srs_error_t err = srs_success;
@ -547,6 +540,7 @@ srs_error_t SrsServer::run()
return cycle();
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::initialize_st()
{
@ -564,6 +558,7 @@ srs_error_t SrsServer::initialize_st()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsServer::initialize_signal()
{
srs_error_t err = srs_success;
@ -579,7 +574,9 @@ srs_error_t SrsServer::initialize_signal()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::listen()
{
srs_error_t err = srs_success;
@ -723,7 +720,9 @@ srs_error_t SrsServer::listen()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::register_signal()
{
srs_error_t err = srs_success;
@ -734,6 +733,7 @@ srs_error_t SrsServer::register_signal()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::http_handle()
{
@ -858,6 +858,7 @@ srs_error_t SrsServer::http_handle()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsServer::ingest()
{
srs_error_t err = srs_success;
@ -868,7 +869,9 @@ srs_error_t SrsServer::ingest()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
void SrsServer::stop()
{
#ifdef SRS_GPERF_MC
@ -901,7 +904,9 @@ void SrsServer::stop()
// This is the last line log of SRS.
srs_trace("srs terminated");
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::cycle()
{
srs_error_t err = srs_success;
@ -919,6 +924,7 @@ srs_error_t SrsServer::cycle()
return err;
}
// LCOV_EXCL_STOP
void SrsServer::on_signal(int signo)
{
@ -1054,6 +1060,7 @@ srs_error_t SrsServer::do2_cycle()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsServer::do_cycle()
{
srs_error_t err = srs_success;
@ -1082,6 +1089,7 @@ srs_error_t SrsServer::do_cycle()
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::setup_ticks()
{
@ -1177,6 +1185,7 @@ srs_error_t SrsServer::notify(int event, srs_utime_t interval, srs_utime_t tick)
return err;
}
// LCOV_EXCL_START
void SrsServer::resample_kbps()
{
// collect delta from all clients.
@ -1228,7 +1237,9 @@ void SrsServer::resample_kbps()
// Update the global server level statistics.
stat_->kbps_sample();
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::listen_srt_mpegts()
{
srs_error_t err = srs_success;
@ -1266,7 +1277,9 @@ srs_error_t SrsServer::listen_srt_mpegts()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
void SrsServer::close_srt_listeners()
{
std::vector<SrsSrtAcceptor *>::iterator it;
@ -1277,7 +1290,9 @@ void SrsServer::close_srt_listeners()
it = srt_acceptors_.erase(it);
}
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::accept_srt_client(srs_srt_t srt_fd)
{
srs_error_t err = srs_success;
@ -1301,7 +1316,9 @@ srs_error_t SrsServer::accept_srt_client(srs_srt_t srt_fd)
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::srt_fd_to_resource(srs_srt_t srt_fd, ISrsResource **pr)
{
srs_error_t err = srs_success;
@ -1325,7 +1342,9 @@ srs_error_t SrsServer::srt_fd_to_resource(srs_srt_t srt_fd, ISrsResource **pr)
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::listen_rtc_udp()
{
srs_error_t err = srs_success;
@ -1375,11 +1394,14 @@ srs_error_t SrsServer::listen_rtc_udp()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::on_udp_packet(ISrsUdpMuxSocket *skt)
{
return rtc_session_manager_->on_udp_packet(skt);
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::listen_rtc_api()
{
@ -1417,11 +1439,14 @@ srs_error_t SrsServer::listen_rtc_api()
return err;
}
// LCOV_EXCL_START
ISrsRtcConnection *SrsServer::find_rtc_session_by_username(const std::string &username)
{
return rtc_session_manager_->find_rtc_session_by_username(username);
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection **psession)
{
srs_error_t err = srs_success;
@ -1436,6 +1461,7 @@ srs_error_t SrsServer::create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_s
return rtc_session_manager_->create_rtc_session(ruc, local_sdp, psession);
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::srs_update_server_statistics()
{
@ -1459,6 +1485,7 @@ srs_error_t SrsServer::srs_update_server_statistics()
return err;
}
// LCOV_EXCL_START
srs_error_t SrsServer::on_tcp_client(ISrsListener *listener, srs_netfd_t stfd)
{
srs_error_t err = do_on_tcp_client(listener, stfd);
@ -1468,7 +1495,9 @@ srs_error_t SrsServer::on_tcp_client(ISrsListener *listener, srs_netfd_t stfd)
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
srs_error_t SrsServer::do_on_tcp_client(ISrsListener *listener, srs_netfd_t &stfd)
{
srs_error_t err = srs_success;
@ -1607,6 +1636,7 @@ srs_error_t SrsServer::do_on_tcp_client(ISrsListener *listener, srs_netfd_t &stf
return err;
}
// LCOV_EXCL_STOP
srs_error_t SrsServer::on_before_connection(const char *label, int fd, const std::string &ip, int port)
{
@ -1760,6 +1790,7 @@ srs_error_t SrsSignalManager::cycle()
return err;
}
// LCOV_EXCL_START
void SrsSignalManager::sig_catcher(int signo)
{
int err;
@ -1773,10 +1804,12 @@ void SrsSignalManager::sig_catcher(int signo)
errno = err;
}
// LCOV_EXCL_STOP
// Whether we are in docker, defined in main module.
extern bool _srs_in_docker;
// LCOV_EXCL_START
SrsInotifyWorker::SrsInotifyWorker(SrsServer *s)
{
server_ = s;
@ -1926,7 +1959,9 @@ srs_error_t SrsInotifyWorker::cycle()
return err;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
SrsPidFileLocker::SrsPidFileLocker()
{
pid_fd_ = -1;
@ -2006,3 +2041,5 @@ void SrsPidFileLocker::close()
pid_fd_ = -1;
}
}
// LCOV_EXCL_STOP

View File

@ -112,8 +112,7 @@ public:
// SrsServer is the main server class of SRS (Simple Realtime Server) that provides comprehensive
// streaming media server functionality. It serves as the central orchestrator for all streaming
// protocols and services in a single-threaded, coroutine-based architecture.
class SrsServer : public ISrsReloadHandler, // Reload framework for permormance optimization.
public ISrsLiveSourceHandler,
class SrsServer : public ISrsLiveSourceHandler, // For live source handler.
public ISrsTcpHandler,
public ISrsHourGlassHandler,
public ISrsSrtClientHandler,

View File

@ -27,6 +27,7 @@ ISrsSrtClientHandler::~ISrsSrtClientHandler()
{
}
// LCOV_EXCL_START
SrsSrtAcceptor::SrsSrtAcceptor(ISrsSrtClientHandler *srt_handler)
{
port_ = 0;
@ -148,6 +149,7 @@ srs_error_t SrsSrtAcceptor::on_srt_client(srs_srt_t srt_fd)
return err;
}
// LCOV_EXCL_STOP
SrsSrtEventLoop::SrsSrtEventLoop()
{

View File

@ -162,6 +162,7 @@ SrsAppUtility::~SrsAppUtility()
{
}
// LCOV_EXCL_START
srs_error_t SrsAppUtility::kill(int &pid)
{
srs_error_t err = srs_success;
@ -220,6 +221,7 @@ srs_error_t SrsAppUtility::kill(int &pid)
return err;
}
// LCOV_EXCL_STOP
static SrsRusage _srs_system_rusage;
@ -547,6 +549,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat &r)
return true;
}
// LCOV_EXCL_START
bool srs_get_disk_diskstats_stat(SrsDiskStat &r)
{
r.ok_ = true;
@ -629,6 +632,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat &r)
return true;
}
// LCOV_EXCL_STOP
void srs_update_disk_stat()
{
@ -1245,6 +1249,7 @@ int srs_get_local_port(int fd)
return port;
}
// LCOV_EXCL_START
string srs_get_peer_ip(int fd)
{
// discovery client information
@ -1286,6 +1291,7 @@ int srs_get_peer_port(int fd)
return port;
}
// LCOV_EXCL_STOP
bool srs_is_boolean(string str)
{

View File

@ -6,6 +6,7 @@
#include <srs_core.hpp>
// LCOV_EXCL_START
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -482,3 +483,5 @@ srs_error_t run_srs_server()
return err;
}
// LCOV_EXCL_STOP

View File

@ -20,6 +20,7 @@
#include <srs_kernel_utility.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_app_fragment.hpp>
#include <srs_app_server.hpp>
#ifdef SRS_FFMPEG_FIT
#include <srs_app_rtc_codec.hpp>
@ -1029,3 +1030,25 @@ VOID TEST(HlsFmp4MuxerTest, GenerateM4sFilenameWithFloor)
muxer.current_ = NULL;
srs_freep(segment);
}
// Test: SrsServer::initialize_st with asprocess enabled and ppid == 1 (should fail)
VOID TEST(ServerTest, InitializeStAsprocessWithPpid1)
{
srs_error_t err;
// Create server
SrsServer server;
// Create mock config with asprocess enabled
MockAppConfig mock_config;
mock_config.asprocess_ = true;
// Replace config with mock
server.config_ = &mock_config;
// Set ppid to 1 (init process)
server.ppid_ = 1;
// Call initialize_st - should fail because asprocess is true and ppid is 1
HELPER_EXPECT_FAILED(server.initialize_st());
}

View File

@ -293,6 +293,7 @@ public:
bool rtc_server_enabled_;
bool rtc_enabled_;
bool rtc_init_rate_from_sdp_;
bool asprocess_;
public:
MockAppConfig()
@ -323,6 +324,7 @@ public:
rtc_server_enabled_ = false;
rtc_enabled_ = false;
rtc_init_rate_from_sdp_ = false;
asprocess_ = false;
}
virtual ~MockAppConfig()
{
@ -368,7 +370,7 @@ public:
virtual int get_max_connections() { return 1000; }
virtual std::string get_pid_file() { return ""; }
virtual bool empty_ip_ok() { return false; }
virtual bool get_asprocess() { return false; }
virtual bool get_asprocess() { return asprocess_; }
virtual srs_utime_t get_grace_start_wait() { return 0; }
virtual srs_utime_t get_grace_final_wait() { return 0; }
virtual bool is_force_grace_quit() { return false; }