Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .augment-guidelines
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ code_patterns:
public:
srs_error_t initialize();
};
scope: "Applies ONLY to fields (member variables) in classes and structs - NOT to functions, methods, or parameters"
scope: "Applies ONLY to fields (member variables) in classes and structs - NOT to functions, methods, comments, error messages, or parameters"
exceptions: "Only applies to SRS-defined classes/structs - do NOT change 3rd party code like llhttp"
rationale: "Consistent naming convention across SRS codebase for better code readability and maintenance - underscore distinguishes member variables from local variables and parameters"

Expand Down
4 changes: 4 additions & 0 deletions trunk/3rdparty/srs-bench/blackbox/hevc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ func TestSlow_SrtPublish_RtmpPlay_HEVC_Basic(t *testing.T) {
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.ts", streamID))
v.streamURL = fmt.Sprintf("rtmp://localhost:%v/live/%v", svr.RTMPPort(), streamID)
v.duration, v.timeout = duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
v.ffmpegCmdName = "ffmpeg7" // ffmpeg 5 don't support enhanced rtmp, so use ffmpeg 7 instead.
v.ffprobeCmdName = "ffprobe7"
})
wg.Add(1)
go func() {
Expand Down Expand Up @@ -807,6 +809,8 @@ func TestSlow_SrtPublish_HttpFlvPlay_HEVC_Basic(t *testing.T) {
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.ts", streamID))
v.streamURL = fmt.Sprintf("http://localhost:%v/live/%v.flv", svr.HTTPPort(), streamID)
v.duration, v.timeout = duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
v.ffmpegCmdName = "ffmpeg7" // ffmpeg 5 don't support enhanced rtmp, so use ffmpeg 7 instead.
v.ffprobeCmdName = "ffprobe7"
})
wg.Add(1)
go func() {
Expand Down
19 changes: 14 additions & 5 deletions trunk/3rdparty/srs-bench/blackbox/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ type ffmpegClient struct {
// The backend service process.
process *backendService

// FFmpeg cmd name
ffmpegCmdName string
// FFmpeg cli args, without ffmpeg binary.
args []string
// Let the process quit, do not cancel the case.
Expand All @@ -678,6 +680,7 @@ func NewFFmpeg(opts ...func(v *ffmpegClient)) FFmpegClient {
v := &ffmpegClient{
process: newBackendService(),
cancelCaseWhenQuit: true,
ffmpegCmdName: *srsFFmpeg,
}

// Do cleanup.
Expand All @@ -702,7 +705,7 @@ func (v *ffmpegClient) ReadyCtx() context.Context {
func (v *ffmpegClient) Run(ctx context.Context, cancel context.CancelFunc) error {
logger.Tf(ctx, "Starting FFmpeg by %v", strings.Join(v.args, " "))

v.process.name = *srsFFmpeg
v.process.name = v.ffmpegCmdName
v.process.args = v.args
v.process.env = os.Environ()
v.process.duration = v.ffmpegDuration
Expand Down Expand Up @@ -746,6 +749,10 @@ type ffprobeClient struct {
// The timeout to wait for task to done.
timeout time.Duration

// the FFprobe cmd name
ffprobeCmdName string
// the ffmpeg cmd name
ffmpegCmdName string
// Whether do DVR by FFmpeg, if using SRS DVR, please set to false.
dvrByFFmpeg bool
// The stream to DVR for probing. Ignore if not DVR by ffmpeg
Expand All @@ -764,8 +771,10 @@ type ffprobeClient struct {

func NewFFprobe(opts ...func(v *ffprobeClient)) FFprobeClient {
v := &ffprobeClient{
metadata: &ffprobeObject{},
dvrByFFmpeg: true,
metadata: &ffprobeObject{},
dvrByFFmpeg: true,
ffprobeCmdName: *srsFFprobe,
ffmpegCmdName: *srsFFmpeg,
}
v.doneCtx, v.doneCancel = context.WithCancel(context.Background())

Expand Down Expand Up @@ -842,7 +851,7 @@ func (v *ffprobeClient) doDVR(ctx context.Context) error {
}

process := newBackendService()
process.name = *srsFFmpeg
process.name = v.ffmpegCmdName
process.args = []string{
"-t", fmt.Sprintf("%v", int64(v.duration/time.Second)),
"-i", v.streamURL, "-c", "copy", "-y", v.dvrFile,
Expand All @@ -869,7 +878,7 @@ func (v *ffprobeClient) doDVR(ctx context.Context) error {

func (v *ffprobeClient) doProbe(ctx context.Context, cancel context.CancelFunc) error {
process := newBackendService()
process.name = *srsFFprobe
process.name = v.ffprobeCmdName
process.args = []string{
"-show_error", "-show_private_data", "-v", "quiet", "-find_stream_info",
"-analyzeduration", fmt.Sprintf("%v", int64(v.duration/time.Microsecond)),
Expand Down
2 changes: 2 additions & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ The changelog for SRS.
<a name="v7-changes"></a>

## SRS 7.0 Changelog
* v7.0, 2025-09-09, Merge [#4446](https://github.com/ossrs/srs/pull/4446): SRT2RTMP: fix srt bridge hevc to rtmp error. v7.0.84 (#4446)
* v7.0, 2025-09-09, Merge [#4482](https://github.com/ossrs/srs/pull/4482): AI: Fix naming issue for protocol module. v7.0.83 (#4482)
* v7.0, 2025-09-07, Merge [#4479](https://github.com/ossrs/srs/pull/4479): AI: Fix naming problem in kernel module. v7.0.82 (#4479)
* v7.0, 2025-09-06, Merge [#4478](https://github.com/ossrs/srs/pull/4478): AI: Add more utests for kernel module. v7.0.81 (#4478)
* v7.0, 2025-09-06, Merge [#4475](https://github.com/ossrs/srs/pull/4475): AI: Support anonymous coroutine with code block. v7.0.80 (#4475)
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ bool srs_config_apply_filter(SrsConfDirective *dvr_apply, ISrsRequest *req)
return true;
}

string id = req->app + "/" + req->stream;
string id = req->app_ + "/" + req->stream_;
if (std::find(args.begin(), args.end(), id) != args.end()) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_coworkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ SrsJsonAny *SrsCoWorkers::dumps(string vhost, string coworker, string app, strin
return SrsJsonAny::object()
->set("ip", SrsJsonAny::str(service_ip.c_str()))
->set("port", SrsJsonAny::integer(listen_port))
->set("vhost", SrsJsonAny::str(r->vhost.c_str()))
->set("vhost", SrsJsonAny::str(r->vhost_.c_str()))
->set("api", SrsJsonAny::str(backend.c_str()))
->set("routers", routers);
}
Expand Down
52 changes: 26 additions & 26 deletions trunk/src/app/srs_app_dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ srs_error_t SrsFragmentedMp4::initialize(ISrsRequest *r, bool video, int64_t tim
(uint32_t)sequence_number, file_home.c_str(), file_name.c_str());
}

string home = _srs_config->get_dash_path(r->vhost);
string home = _srs_config->get_dash_path(r->vhost_);
set_path(home + "/" + file_home + "/" + file_name);
// Set number of the fragment, use in mpd SegmentTemplate@startNumber later.
set_number(sequence_number);
Expand Down Expand Up @@ -177,7 +177,7 @@ SrsMpdWriter::~SrsMpdWriter()
void SrsMpdWriter::dispose()
{
if (req) {
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
string full_path = home + "/" + mpd_path;
if (unlink(full_path.c_str()) < 0) {
srs_warn("ignore remove mpd failed, %s", full_path.c_str());
Expand All @@ -201,15 +201,15 @@ srs_error_t SrsMpdWriter::on_publish()
{
ISrsRequest *r = req;

fragment = _srs_config->get_dash_fragment(r->vhost);
update_period = _srs_config->get_dash_update_period(r->vhost);
timeshit = _srs_config->get_dash_timeshift(r->vhost);
home = _srs_config->get_dash_path(r->vhost);
mpd_file = _srs_config->get_dash_mpd_file(r->vhost);
fragment = _srs_config->get_dash_fragment(r->vhost_);
update_period = _srs_config->get_dash_update_period(r->vhost_);
timeshit = _srs_config->get_dash_timeshift(r->vhost_);
home = _srs_config->get_dash_path(r->vhost_);
mpd_file = _srs_config->get_dash_mpd_file(r->vhost_);

string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream;
window_size_ = _srs_config->get_dash_window_size(r->vhost);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream_;
window_size_ = _srs_config->get_dash_window_size(r->vhost_);

srs_trace("DASH: Config fragment=%dms, period=%dms, window=%d, timeshit=%dms, home=%s, mpd=%s",
srsu2msi(fragment), srsu2msi(update_period), window_size_, srsu2msi(timeshit), home.c_str(), mpd_file.c_str());
Expand All @@ -230,11 +230,11 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments
return err;
}

string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
string full_path = home + "/" + mpd_path;
string full_home = srs_path_filepath_dir(full_path);

fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream;
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream_;

if ((err = srs_os_mkdir_all(full_home)) != srs_success) {
return srs_error_wrap(err, "Create MPD home failed, home=%s", full_home.c_str());
Expand All @@ -254,7 +254,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments
<< " publishTime=\"" << srs_time_to_utc_format_str(srs_time_now_cached()) << "\" " << endl
<< " minBufferTime=\"PT" << srs_fmt_sprintf("%.3f", 2 * last_duration) << "S\" >" << endl;

ss << " <BaseURL>" << req->stream << "/" << "</BaseURL>" << endl;
ss << " <BaseURL>" << req->stream_ << "/" << "</BaseURL>" << endl;

ss << " <Period start=\"PT0S\">" << endl;

Expand Down Expand Up @@ -425,8 +425,8 @@ srs_error_t SrsDashController::on_publish()

ISrsRequest *r = req;

fragment = _srs_config->get_dash_fragment(r->vhost);
home = _srs_config->get_dash_path(r->vhost);
fragment = _srs_config->get_dash_fragment(r->vhost_);
home = _srs_config->get_dash_path(r->vhost_);

if ((err = mpd->on_publish()) != srs_success) {
return srs_error_wrap(err, "mpd");
Expand Down Expand Up @@ -531,8 +531,8 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
return srs_error_wrap(err, "Write audio to fragment failed");
}

srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost);
int window_size = _srs_config->get_dash_window_size(req->vhost);
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost_);
int window_size = _srs_config->get_dash_window_size(req->vhost_);
int dash_window = 2 * window_size * fragment;
if (afragments->size() > window_size) {
int w = 0;
Expand All @@ -545,7 +545,7 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
afragments->shrink(dash_window);
}

bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost);
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost_);
// remove the m4s file.
afragments->clear_expired(dash_cleanup);

Expand Down Expand Up @@ -604,8 +604,8 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
return srs_error_wrap(err, "Write video to fragment failed");
}

srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost);
int window_size = _srs_config->get_dash_window_size(req->vhost);
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost_);
int window_size = _srs_config->get_dash_window_size(req->vhost_);
int dash_window = 2 * window_size * fragment;
if (vfragments->size() > window_size) {
int w = 0;
Expand All @@ -618,7 +618,7 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
vfragments->shrink(dash_window);
}

bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost);
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost_);
// remove the m4s file.
vfragments->clear_expired(dash_cleanup);

Expand Down Expand Up @@ -650,7 +650,7 @@ srs_error_t SrsDashController::refresh_init_mp4(SrsMediaPacket *msg, SrsFormat *
return err;
}

string full_home = home + "/" + req->app + "/" + req->stream;
string full_home = home + "/" + req->app_ + "/" + req->stream_;
if ((err = srs_os_mkdir_all(full_home)) != srs_success) {
return srs_error_wrap(err, "Create media home failed, home=%s", full_home.c_str());
}
Expand Down Expand Up @@ -703,7 +703,7 @@ void SrsDash::dispose()
}

// Ignore when dash_dispose disabled.
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost);
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost_);
if (!dash_dispose) {
return;
}
Expand All @@ -723,7 +723,7 @@ srs_error_t SrsDash::cycle()
return err;
}

srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost);
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost_);
if (dash_dispose <= 0) {
return err;
}
Expand All @@ -746,7 +746,7 @@ srs_error_t SrsDash::cycle()
srs_utime_t SrsDash::cleanup_delay()
{
// We use larger timeout to cleanup the HLS, after disposed it if required.
return _srs_config->get_dash_dispose(req->vhost) * 1.1;
return _srs_config->get_dash_dispose(req->vhost_) * 1.1;
}

// CRITICAL: This method is called AFTER the source has been added to the source pool
Expand Down Expand Up @@ -778,7 +778,7 @@ srs_error_t SrsDash::on_publish()
return err;
}

if (!_srs_config->get_dash_enabled(req->vhost)) {
if (!_srs_config->get_dash_enabled(req->vhost_)) {
return err;
}
enabled = true;
Expand Down
30 changes: 15 additions & 15 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ srs_error_t SrsDvrSegmenter::initialize(SrsDvrPlan *p, ISrsRequest *r)
req = r;
plan = p;

jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_dvr_time_jitter(req->vhost);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost);
jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_dvr_time_jitter(req->vhost_);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost_);

return srs_success;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ srs_error_t SrsDvrSegmenter::open()
return srs_error_wrap(err, "open encoder");
}

srs_trace("dvr stream %s to file %s", req->stream.c_str(), path.c_str());
srs_trace("dvr stream %s to file %s", req->stream_.c_str(), path.c_str());
return err;
}

Expand Down Expand Up @@ -200,7 +200,7 @@ string SrsDvrSegmenter::generate_path()
{
// the path in config, for example,
// /data/[vhost]/[app]/[stream]/[2006]/[01]/[02]/[15].[04].[05].[999].flv
std::string path_config = _srs_config->get_dvr_path(req->vhost);
std::string path_config = _srs_config->get_dvr_path(req->vhost_);

// add [stream].[timestamp].flv as filename for dir
if (!srs_strings_ends_with(path_config, ".flv", ".mp4")) {
Expand All @@ -209,7 +209,7 @@ string SrsDvrSegmenter::generate_path()

// the flv file path
std::string flv_path = path_config;
flv_path = srs_path_build_stream(flv_path, req->vhost, req->app, req->stream);
flv_path = srs_path_build_stream(flv_path, req->vhost_, req->app_, req->stream_);
flv_path = srs_path_build_timestamp(flv_path);

return flv_path;
Expand Down Expand Up @@ -525,7 +525,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
{
srs_error_t err = srs_success;

if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}

Expand All @@ -535,7 +535,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
vector<string> hooks;

if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_dvr(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_dvr(req->vhost_);
if (conf) {
hooks = conf->args;
}
Expand All @@ -554,7 +554,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
string SrsDvrAsyncCallOnDvr::to_string()
{
std::stringstream ss;
ss << "vhost=" << req->vhost << ", file=" << path;
ss << "vhost=" << req->vhost_ << ", file=" << path;
return ss.str();
}

Expand Down Expand Up @@ -706,7 +706,7 @@ srs_error_t SrsDvrSessionPlan::on_publish(ISrsRequest *r)
return err;
}

if (!_srs_config->get_dvr_enabled(req->vhost)) {
if (!_srs_config->get_dvr_enabled(req->vhost_)) {
return err;
}

Expand Down Expand Up @@ -763,9 +763,9 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub *h, SrsDvrSegmenter *s, I
return srs_error_wrap(err, "segment plan");
}

wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost_);

cduration = _srs_config->get_dvr_duration(req->vhost);
cduration = _srs_config->get_dvr_duration(req->vhost_);

return srs_success;
}
Expand All @@ -783,7 +783,7 @@ srs_error_t SrsDvrSegmentPlan::on_publish(ISrsRequest *r)
return err;
}

if (!_srs_config->get_dvr_enabled(req->vhost)) {
if (!_srs_config->get_dvr_enabled(req->vhost_)) {
return err;
}

Expand Down Expand Up @@ -934,15 +934,15 @@ srs_error_t SrsDvr::initialize(SrsOriginHub *h, ISrsRequest *r)
req = r->copy();
hub = h;

SrsConfDirective *conf = _srs_config->get_dvr_apply(r->vhost);
SrsConfDirective *conf = _srs_config->get_dvr_apply(r->vhost_);
actived = srs_config_apply_filter(conf, r);

srs_freep(plan);
if ((err = SrsDvrPlan::create_plan(r->vhost, &plan)) != srs_success) {
if ((err = SrsDvrPlan::create_plan(r->vhost_, &plan)) != srs_success) {
return srs_error_wrap(err, "create plan");
}

std::string path = _srs_config->get_dvr_path(r->vhost);
std::string path = _srs_config->get_dvr_path(r->vhost_);
SrsDvrSegmenter *segmenter = NULL;
if (srs_strings_ends_with(path, ".mp4")) {
segmenter = new SrsDvrMp4Segmenter();
Expand Down
Loading
Loading