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
10 changes: 6 additions & 4 deletions .augment-guidelines
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ code_patterns:

naming_conventions:
- pattern: "field_naming"
description: "MANDATORY - All class and struct fields must end with underscore (_)"
description: "MANDATORY - All class and struct fields (member variables) must end with underscore (_), but NOT functions/methods"
usage: |
WRONG: Fields without underscore
class SrsBuffer {
Expand All @@ -175,17 +175,19 @@ code_patterns:
bool enabled;
};

CORRECT: Fields with underscore
CORRECT: Fields with underscore, functions without underscore
class SrsBuffer {
private:
char *p_;
int size_;
public:
bool enabled_;
public:
srs_error_t initialize();
};
scope: "Applies to ALL fields (private, protected, public) in both classes and structs"
scope: "Applies ONLY to fields (member variables) in classes and structs - NOT to functions, methods, 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"
rationale: "Consistent naming convention across SRS codebase for better code readability and maintenance - underscore distinguishes member variables from local variables and parameters"

commenting_style:
- pattern: "C++ style comments"
Expand Down
2 changes: 1 addition & 1 deletion trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ if [[ $SRS_UTEST == YES ]]; then
"srs_utest_mp4" "srs_utest_service" "srs_utest_app" "srs_utest_rtc" "srs_utest_config2"
"srs_utest_protocol" "srs_utest_protocol2" "srs_utest_kernel2" "srs_utest_protocol3"
"srs_utest_st" "srs_utest_rtc2" "srs_utest_rtc3" "srs_utest_fmp4" "srs_utest_source_lock"
"srs_utest_stream_token" "srs_utest_rtc_recv_track" "srs_utest_st2")
"srs_utest_stream_token" "srs_utest_rtc_recv_track" "srs_utest_st2" "srs_utest_hevc_structs")
# Always include SRT utest
MODULE_FILES+=("srs_utest_srt")
if [[ $SRS_GB28181 == YES ]]; then
Expand Down
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>

## SRS 7.0 Changelog
* 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)
* v7.0, 2025-09-05, Merge [#4474](https://github.com/ossrs/srs/pull/4474): WebRTC: Fix race condition in RTC nack timer callbacks. v7.0.79 (#4474)
Expand Down
10 changes: 5 additions & 5 deletions trunk/src/app/srs_app_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ ISrsResource *SrsResourceManager::at(int index)

ISrsResource *SrsResourceManager::find_by_id(std::string id)
{
++_srs_pps_ids->sugar;
++_srs_pps_ids->sugar_;
map<string, ISrsResource *>::iterator it = conns_id_.find(id);
return (it != conns_id_.end()) ? it->second : NULL;
}
Expand All @@ -188,18 +188,18 @@ ISrsResource *SrsResourceManager::find_by_fast_id(uint64_t id)
{
SrsResourceFastIdItem *item = &conns_level0_cache_[(id | id >> 32) % nn_level0_cache_];
if (item->available && item->fast_id == id) {
++_srs_pps_fids_level0->sugar;
++_srs_pps_fids_level0->sugar_;
return item->impl;
}

++_srs_pps_fids->sugar;
++_srs_pps_fids->sugar_;
map<uint64_t, ISrsResource *>::iterator it = conns_fast_id_.find(id);
return (it != conns_fast_id_.end()) ? it->second : NULL;
}

ISrsResource *SrsResourceManager::find_by_name(std::string name)
{
++_srs_pps_ids->sugar;
++_srs_pps_ids->sugar_;
map<string, ISrsResource *>::iterator it = conns_name_.find(name);
return (it != conns_name_.end()) ? it->second : NULL;
}
Expand Down Expand Up @@ -334,7 +334,7 @@ void SrsResourceManager::do_clear()
i, conn->desc().c_str(), conn, (int)conns_.size(), (int)copy.size(), (int)zombies_.size());
}

++_srs_pps_dispose->sugar;
++_srs_pps_dispose->sugar_;

dispose(conn);
}
Expand Down
44 changes: 22 additions & 22 deletions trunk/src/app/srs_app_dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,26 @@ srs_error_t SrsFragmentedMp4::write(SrsMediaPacket *shared_msg, SrsFormat *forma
srs_error_t err = srs_success;

if (shared_msg->is_audio()) {
uint8_t *sample = (uint8_t *)format->raw;
uint32_t nb_sample = (uint32_t)format->nb_raw;
uint8_t *sample = (uint8_t *)format->raw_;
uint32_t nb_sample = (uint32_t)format->nb_raw_;

uint32_t dts = (uint32_t)shared_msg->timestamp;
uint32_t dts = (uint32_t)shared_msg->timestamp_;
err = enc->write_sample(SrsMp4HandlerTypeSOUN, 0x00, dts, dts, sample, nb_sample);
} else if (shared_msg->is_video()) {
SrsVideoAvcFrameType frame_type = format->video->frame_type;
uint32_t cts = (uint32_t)format->video->cts;
SrsVideoAvcFrameType frame_type = format->video_->frame_type_;
uint32_t cts = (uint32_t)format->video_->cts_;

uint32_t dts = (uint32_t)shared_msg->timestamp;
uint32_t dts = (uint32_t)shared_msg->timestamp_;
uint32_t pts = dts + cts;

uint8_t *sample = (uint8_t *)format->raw;
uint32_t nb_sample = (uint32_t)format->nb_raw;
uint8_t *sample = (uint8_t *)format->raw_;
uint32_t nb_sample = (uint32_t)format->nb_raw_;
err = enc->write_sample(SrsMp4HandlerTypeVIDE, frame_type, dts, pts, sample, nb_sample);
} else {
return err;
}

append(shared_msg->timestamp);
append(shared_msg->timestamp_);

return err;
}
Expand Down Expand Up @@ -258,7 +258,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments

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

if (format->acodec && !afragments->empty()) {
if (format->acodec_ && !afragments->empty()) {
int start_index = srs_max(0, afragments->size() - window_size_);
ss << " <AdaptationSet mimeType=\"audio/mp4\" segmentAlignment=\"true\" startWithSAP=\"1\">" << endl;
ss << " <Representation id=\"audio\" bandwidth=\"48000\" codecs=\"mp4a.40.2\">" << endl;
Expand All @@ -277,10 +277,10 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments
ss << " </AdaptationSet>" << endl;
}

if (format->vcodec && !vfragments->empty()) {
if (format->vcodec_ && !vfragments->empty()) {
int start_index = srs_max(0, vfragments->size() - window_size_);
int w = format->vcodec->width;
int h = format->vcodec->height;
int w = format->vcodec_->width_;
int h = format->vcodec_->height_;
ss << " <AdaptationSet mimeType=\"video/mp4\" segmentAlignment=\"true\" startWithSAP=\"1\">" << endl;
ss << " <Representation id=\"video\" bandwidth=\"800000\" codecs=\"avc1.64001e\" " << "width=\"" << w << "\" height=\"" << h << "\">" << endl;
ss << " <SegmentTemplate initialization=\"$RepresentationID$-init.mp4\" "
Expand Down Expand Up @@ -490,7 +490,7 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
return refresh_init_mp4(shared_audio, format);
}

audio_dts = shared_audio->timestamp;
audio_dts = shared_audio->timestamp_;

if (!acurrent) {
acurrent = new SrsFragmentedMp4();
Expand All @@ -510,7 +510,7 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
// The video is reaped, audio must be reaped right now to align the timestamp of video.
video_reaped_ = false;
// Append current timestamp to calculate right duration.
acurrent->append(shared_audio->timestamp);
acurrent->append(shared_audio->timestamp_);
if ((err = acurrent->reap(audio_dts)) != srs_success) {
return srs_error_wrap(err, "reap current");
}
Expand Down Expand Up @@ -562,7 +562,7 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
return refresh_init_mp4(shared_video, format);
}

video_dts = shared_video->timestamp;
video_dts = shared_video->timestamp_;

if (!vcurrent) {
vcurrent = new SrsFragmentedMp4();
Expand All @@ -577,10 +577,10 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
mpd->set_availability_start_time(srs_time_now_cached() - first_dts_ * SRS_UTIME_MILLISECONDS);
}

bool reopen = format->video->frame_type == SrsVideoAvcFrameTypeKeyFrame && vcurrent->duration() >= fragment;
bool reopen = format->video_->frame_type_ == SrsVideoAvcFrameTypeKeyFrame && vcurrent->duration() >= fragment;
if (reopen) {
// Append current timestamp to calculate right duration.
vcurrent->append(shared_video->timestamp);
vcurrent->append(shared_video->timestamp_);
if ((err = vcurrent->reap(video_dts)) != srs_success) {
return srs_error_wrap(err, "reap current");
}
Expand Down Expand Up @@ -630,7 +630,7 @@ srs_error_t SrsDashController::refresh_mpd(SrsFormat *format)
srs_error_t err = srs_success;

// TODO: FIXME: Support pure audio streaming.
if (!format || !format->acodec || !format->vcodec) {
if (!format || !format->acodec_ || !format->vcodec_) {
return err;
}

Expand All @@ -645,7 +645,7 @@ srs_error_t SrsDashController::refresh_init_mp4(SrsMediaPacket *msg, SrsFormat *
{
srs_error_t err = srs_success;

if (msg->size() <= 0 || (msg->is_video() && !format->vcodec->is_avc_codec_ok()) || (msg->is_audio() && !format->acodec->is_aac_codec_ok())) {
if (msg->size() <= 0 || (msg->is_video() && !format->vcodec_->is_avc_codec_ok()) || (msg->is_audio() && !format->acodec_->is_aac_codec_ok())) {
srs_warn("DASH: Ignore empty sequence header.");
return err;
}
Expand Down Expand Up @@ -804,7 +804,7 @@ srs_error_t SrsDash::on_audio(SrsMediaPacket *shared_audio, SrsFormat *format)
return err;
}

if (!format->acodec) {
if (!format->acodec_) {
return err;
}

Expand All @@ -826,7 +826,7 @@ srs_error_t SrsDash::on_video(SrsMediaPacket *shared_video, SrsFormat *format)
return err;
}

if (!format->vcodec) {
if (!format->vcodec_) {
return err;
}

Expand Down
50 changes: 25 additions & 25 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ string SrsDvrSegmenter::generate_path()

srs_error_t SrsDvrSegmenter::on_update_duration(SrsMediaPacket *msg)
{
fragment->append(msg->timestamp);
fragment->append(msg->timestamp_);
return srs_success;
}

Expand Down Expand Up @@ -372,7 +372,7 @@ srs_error_t SrsDvrFlvSegmenter::encode_audio(SrsMediaPacket *audio, SrsFormat *f

char *payload = audio->payload();
int size = audio->size();
if ((err = enc->write_audio(audio->timestamp, payload, size)) != srs_success) {
if ((err = enc->write_audio(audio->timestamp_, payload, size)) != srs_success) {
return srs_error_wrap(err, "write audio");
}

Expand All @@ -385,8 +385,8 @@ srs_error_t SrsDvrFlvSegmenter::encode_video(SrsMediaPacket *video, SrsFormat *f

char *payload = video->payload();
int size = video->size();
bool sh = (format->video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader);
bool keyframe = (!sh && format->video->frame_type == SrsVideoAvcFrameTypeKeyFrame);
bool sh = (format->video_->avc_packet_type_ == SrsVideoAvcFrameTraitSequenceHeader);
bool keyframe = (!sh && format->video_->frame_type_ == SrsVideoAvcFrameTypeKeyFrame);

if (keyframe) {
has_keyframe = true;
Expand All @@ -398,7 +398,7 @@ srs_error_t SrsDvrFlvSegmenter::encode_video(SrsMediaPacket *video, SrsFormat *f
return err;
}

if ((err = enc->write_video(video->timestamp, payload, size)) != srs_success) {
if ((err = enc->write_video(video->timestamp_, payload, size)) != srs_success) {
return srs_error_wrap(err, "write video");
}

Expand Down Expand Up @@ -448,23 +448,23 @@ srs_error_t SrsDvrMp4Segmenter::encode_audio(SrsMediaPacket *audio, SrsFormat *f
{
srs_error_t err = srs_success;

SrsAudioCodecId sound_format = format->acodec->id;
SrsAudioSampleRate sound_rate = format->acodec->sound_rate;
SrsAudioSampleBits sound_size = format->acodec->sound_size;
SrsAudioChannels channels = format->acodec->sound_type;
SrsAudioCodecId sound_format = format->acodec_->id_;
SrsAudioSampleRate sound_rate = format->acodec_->sound_rate_;
SrsAudioSampleBits sound_size = format->acodec_->sound_size_;
SrsAudioChannels channels = format->acodec_->sound_type_;

SrsAudioAacFrameTrait ct = format->audio->aac_packet_type;
SrsAudioAacFrameTrait ct = format->audio_->aac_packet_type_;
if (ct == SrsAudioAacFrameTraitSequenceHeader || ct == SrsAudioMp3FrameTraitSequenceHeader) {
enc->acodec = sound_format;
enc->sample_rate = sound_rate;
enc->sound_bits = sound_size;
enc->channels = channels;
enc->acodec_ = sound_format;
enc->sample_rate_ = sound_rate;
enc->sound_bits_ = sound_size;
enc->channels_ = channels;
}

uint8_t *sample = (uint8_t *)format->raw;
uint32_t nb_sample = (uint32_t)format->nb_raw;
uint8_t *sample = (uint8_t *)format->raw_;
uint32_t nb_sample = (uint32_t)format->nb_raw_;

uint32_t dts = (uint32_t)audio->timestamp;
uint32_t dts = (uint32_t)audio->timestamp_;
if ((err = enc->write_sample(format, SrsMp4HandlerTypeSOUN, 0x00, ct, dts, dts, sample, nb_sample)) != srs_success) {
return srs_error_wrap(err, "write sample");
}
Expand All @@ -476,21 +476,21 @@ srs_error_t SrsDvrMp4Segmenter::encode_video(SrsMediaPacket *video, SrsFormat *f
{
srs_error_t err = srs_success;

SrsVideoAvcFrameType frame_type = format->video->frame_type;
SrsVideoCodecId codec_id = format->vcodec->id;
SrsVideoAvcFrameType frame_type = format->video_->frame_type_;
SrsVideoCodecId codec_id = format->vcodec_->id_;

SrsVideoAvcFrameTrait ct = format->video->avc_packet_type;
uint32_t cts = (uint32_t)format->video->cts;
SrsVideoAvcFrameTrait ct = format->video_->avc_packet_type_;
uint32_t cts = (uint32_t)format->video_->cts_;

if (ct == SrsVideoAvcFrameTraitSequenceHeader) {
enc->vcodec = codec_id;
enc->vcodec_ = codec_id;
}

uint32_t dts = (uint32_t)video->timestamp;
uint32_t dts = (uint32_t)video->timestamp_;
uint32_t pts = dts + cts;

uint8_t *sample = (uint8_t *)format->raw;
uint32_t nb_sample = (uint32_t)format->nb_raw;
uint8_t *sample = (uint8_t *)format->raw_;
uint32_t nb_sample = (uint32_t)format->nb_raw_;
if ((err = enc->write_sample(format, SrsMp4HandlerTypeVIDE, frame_type, ct, dts, pts, sample, nb_sample)) != srs_success) {
return srs_error_wrap(err, "write sample");
}
Expand Down
16 changes: 8 additions & 8 deletions trunk/src/app/srs_app_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ srs_error_t SrsEdgeFlvUpstream::decode_message(SrsRtmpCommonMessage *msg, SrsRtm

SrsRtmpCommand *packet = NULL;
SrsBuffer stream(msg->payload(), msg->size());
SrsMessageHeader &header = msg->header;
SrsMessageHeader &header = msg->header_;

if (header.is_amf0_data() || header.is_amf3_data()) {
std::string command;
Expand Down Expand Up @@ -619,29 +619,29 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
srs_error_t err = srs_success;

// process audio packet
if (msg->header.is_audio()) {
if (msg->header_.is_audio()) {
if ((err = source_->on_audio(msg)) != srs_success) {
return srs_error_wrap(err, "source consume audio");
}
}

// process video packet
if (msg->header.is_video()) {
if (msg->header_.is_video()) {
if ((err = source_->on_video(msg)) != srs_success) {
return srs_error_wrap(err, "source consume video");
}
}

// process aggregate packet
if (msg->header.is_aggregate()) {
if (msg->header_.is_aggregate()) {
if ((err = source_->on_aggregate(msg)) != srs_success) {
return srs_error_wrap(err, "source consume aggregate");
}
return err;
}

// process onMetaData
if (msg->header.is_amf0_data() || msg->header.is_amf3_data()) {
if (msg->header_.is_amf0_data() || msg->header_.is_amf3_data()) {
SrsRtmpCommand *pkt_raw = NULL;
if ((err = upstream->decode_message(msg, &pkt_raw)) != srs_success) {
return srs_error_wrap(err, "decode message");
Expand All @@ -660,7 +660,7 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
}

// call messages, for example, reject, redirect.
if (msg->header.is_amf0_command() || msg->header.is_amf3_command()) {
if (msg->header_.is_amf0_command() || msg->header_.is_amf3_command()) {
SrsRtmpCommand *pkt_raw = NULL;
if ((err = upstream->decode_message(msg, &pkt_raw)) != srs_success) {
return srs_error_wrap(err, "decode message");
Expand Down Expand Up @@ -919,14 +919,14 @@ srs_error_t SrsEdgeForwarder::proxy(SrsRtmpCommonMessage *msg)

// the msg is auto free by source,
// so we just ignore, or copy then send it.
if (msg->size() <= 0 || msg->header.is_set_chunk_size() || msg->header.is_window_ackledgement_size() || msg->header.is_ackledgement()) {
if (msg->size() <= 0 || msg->header_.is_set_chunk_size() || msg->header_.is_window_ackledgement_size() || msg->header_.is_ackledgement()) {
return err;
}

SrsMediaPacket copy;
msg->to_msg(&copy);

copy.stream_id = sdk->sid();
copy.stream_id_ = sdk->sid();
if ((err = queue->enqueue(copy.copy())) != srs_success) {
return srs_error_wrap(err, "enqueue message");
}
Expand Down
Loading
Loading