mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
fix sample_rate error in statistic
This commit is contained in:
parent
101382afd0
commit
1ff0344f34
3 changed files with 16 additions and 12 deletions
|
@ -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],
|
||||
|
|
|
@ -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;
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ public:
|
|||
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,
|
||||
|
@ -169,8 +169,8 @@ public:
|
|||
// 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);
|
||||
|
|
Loading…
Reference in a new issue