Skip to content

Commit

Permalink
fix sample_rate error in statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
duiniuluantanqin committed Oct 30, 2024
1 parent 101382a commit 1ff0344
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,15 +956,19 @@ srs_error_t SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)

// when got audio stream info.
SrsStatistic* stat = SrsStatistic::instance();
if ((err = stat->on_audio_info(req_, format->acodec->id, c->sound_rate, c->sound_type, c->aac_object)) != srs_success) {
return srs_error_wrap(err, "stat audio");
}


if (format->acodec->id == SrsAudioCodecIdMP3) {
if ((err = stat->on_audio_info(req_, format->acodec->id, srs_flv_srates[c->sound_rate], flv_sound_types[c->sound_type], c->aac_object)) != srs_success) {
return srs_error_wrap(err, "stat audio");
}
srs_trace("%dB audio sh, codec(%d, %dbits, %dchannels, %dHZ)",
msg->size, c->id, flv_sample_sizes[c->sound_size], flv_sound_types[c->sound_type],
srs_flv_srates[c->sound_rate]);
} else {
if ((err = stat->on_audio_info(req_, format->acodec->id, srs_aac_srates[c->aac_sample_rate], c->aac_channels, c->aac_object)) != srs_success) {
return srs_error_wrap(err, "stat audio");
}
srs_trace("%dB audio sh, codec(%d, profile=%s, %dchannels, %dkbps, %dHZ), flv(%dbits, %dchannels, %dHZ)",
msg->size, c->id, srs_aac_object2str(c->aac_object).c_str(), c->aac_channels,
c->audio_data_rate / 1000, srs_aac_srates[c->aac_sample_rate],
Expand Down
10 changes: 5 additions & 5 deletions trunk/src/app/srs_app_statistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ SrsStatisticStream::SrsStatisticStream()

has_audio = false;
acodec = SrsAudioCodecIdReserved1;
asample_rate = SrsAudioSampleRateReserved;
asound_type = SrsAudioChannelsReserved;
asample_rate = 0;
asound_type = 0;
aac_object = SrsAacObjectTypeReserved;
width = 0;
height = 0;
Expand Down Expand Up @@ -168,8 +168,8 @@ srs_error_t SrsStatisticStream::dumps(SrsJsonObject* obj)
obj->set("audio", audio);

audio->set("codec", SrsJsonAny::str(srs_audio_codec_id2str(acodec).c_str()));
audio->set("sample_rate", SrsJsonAny::integer(srs_flv_srates[asample_rate]));
audio->set("channel", SrsJsonAny::integer(asound_type + 1));
audio->set("sample_rate", SrsJsonAny::integer(asample_rate));
audio->set("channel", SrsJsonAny::integer(asound_type));
audio->set("profile", SrsJsonAny::str(srs_aac_object2str(aac_object).c_str()));
}

Expand Down Expand Up @@ -376,7 +376,7 @@ srs_error_t SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec,
return err;
}

srs_error_t SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioChannels asound_type, SrsAacObjectType aac_object)
srs_error_t SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, int asample_rate, int asound_type, SrsAacObjectType aac_object)
{
srs_error_t err = srs_success;

Expand Down
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_statistic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct SrsStatisticStream
public:
bool has_audio;
SrsAudioCodecId acodec;
SrsAudioSampleRate asample_rate;
SrsAudioChannels asound_type;
int asample_rate;
int asound_type;
// The audio specified
// audioObjectType, in 1.6.2.1 AudioSpecificConfig, page 33,
// 1.5.1.1 Audio object type definition, page 23,
Expand Down Expand Up @@ -169,8 +169,8 @@ class SrsStatistic
// When got video info for stream.
virtual srs_error_t on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, int avc_profile, int avc_level, int width, int height);
// When got audio info for stream.
virtual srs_error_t on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate,
SrsAudioChannels asound_type, SrsAacObjectType aac_object);
virtual srs_error_t on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, int asample_rate,
int asound_type, SrsAacObjectType aac_object);
// When got videos, update the frames.
// We only stat the total number of video frames.
virtual srs_error_t on_video_frames(SrsRequest* req, int nb_frames);
Expand Down

0 comments on commit 1ff0344

Please sign in to comment.