1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

H265: Demux sps for log print and statistic streams.(#3271) (#3286)

* BitBuffer: add method to implement bit read operation.

* Codec: demux hevc sps for profile level resolution.

* Statistic: refine hevc profile level resolution.

* Kernel: return error code for demux hevc.

* Kernel: check bitstream length for hevc sps.

* UTest: add BitBuffer read bits utest.

* Kernel: refine print log and utest.

* Kernel: add comment for hevc sps.

Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
chundonglinlin 2022-12-04 22:46:14 +08:00 committed by GitHub
parent e6c395e473
commit a0803b556b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 729 additions and 19 deletions

View file

@ -1074,9 +1074,10 @@ srs_error_t SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_se
c->width, c->height, c->video_data_rate / 1000, c->frame_rate, c->duration);
#ifdef SRS_H265
} else if (c->id == SrsVideoCodecIdHEVC) {
// TODO: FIXME: Use the correct information for HEVC.
err = stat->on_video_info(req_, c->id, c->avc_profile, c->avc_level, c->width, c->height);
srs_trace("%dB video sh, codec(%d)", msg->size, c->id);
err = stat->on_video_info(req_, c->id, c->hevc_profile, c->hevc_level, c->width, c->height);
srs_trace("%dB video sh, codec(%d, profile=%s, level=%s, %dx%d, %dkbps, %.1ffps, %.1fs)",
msg->size, c->id, srs_hevc_profile2str(c->hevc_profile).c_str(), srs_hevc_level2str(c->hevc_level).c_str(),
c->width, c->height, c->video_data_rate / 1000, c->frame_rate, c->duration);
#endif
}
if (err != srs_success) {

View file

@ -143,8 +143,20 @@ srs_error_t SrsStatisticStream::dumps(SrsJsonObject* obj)
obj->set("video", video);
video->set("codec", SrsJsonAny::str(srs_video_codec_id2str(vcodec).c_str()));
video->set("profile", SrsJsonAny::str(srs_avc_profile2str(avc_profile).c_str()));
video->set("level", SrsJsonAny::str(srs_avc_level2str(avc_level).c_str()));
if (vcodec == SrsVideoCodecIdAVC) {
video->set("profile", SrsJsonAny::str(srs_avc_profile2str(avc_profile).c_str()));
video->set("level", SrsJsonAny::str(srs_avc_level2str(avc_level).c_str()));
#ifdef SRS_H265
} else if (vcodec == SrsVideoCodecIdHEVC) {
video->set("profile", SrsJsonAny::str(srs_hevc_profile2str(hevc_profile).c_str()));
video->set("level", SrsJsonAny::str(srs_hevc_level2str(hevc_level).c_str()));
#endif
} else {
video->set("profile", SrsJsonAny::str("Other"));
video->set("level", SrsJsonAny::str("Other"));
}
video->set("width", SrsJsonAny::integer(width));
video->set("height", SrsJsonAny::integer(height));
}
@ -335,7 +347,7 @@ SrsStatisticClient* SrsStatistic::find_client(string client_id)
return NULL;
}
srs_error_t SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level, int width, int height)
srs_error_t SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, int profile, int level, int width, int height)
{
srs_error_t err = srs_success;
@ -344,9 +356,20 @@ srs_error_t SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec,
stream->has_video = true;
stream->vcodec = vcodec;
stream->avc_profile = avc_profile;
stream->avc_level = avc_level;
if (vcodec == SrsVideoCodecIdAVC) {
stream->avc_profile = (SrsAvcProfile)profile;
stream->avc_level = (SrsAvcLevel)level;
#ifdef SRS_H265
} else if (vcodec == SrsVideoCodecIdHEVC) {
stream->hevc_profile = (SrsHevcProfile)profile;
stream->hevc_level = (SrsHevcLevel)level;
#endif
} else {
stream->avc_profile = (SrsAvcProfile)profile;
stream->avc_level = (SrsAvcLevel)level;
}
stream->width = width;
stream->height = height;

View file

@ -70,6 +70,12 @@ public:
SrsAvcProfile avc_profile;
// The level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
SrsAvcLevel avc_level;
#ifdef SRS_H265
// The profile_idc, T-REC-H.265-202108-I!!PDF-E.pdf, page 559.
SrsHevcProfile hevc_profile;
// The level_idc, T-REC-H.265-202108-I!!PDF-E.pdf, page 684.
SrsHevcLevel hevc_level;
#endif
// The width and height in codec info.
int width;
int height;
@ -157,8 +163,7 @@ public:
virtual SrsStatisticClient* find_client(std::string client_id);
public:
// When got video info for stream.
virtual srs_error_t on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, SrsAvcProfile avc_profile,
SrsAvcLevel avc_level, int width, int height);
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);