mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
H265: Support HEVC over RTMP or HTTP-FLV. (#3272)
1. Support configure with --h265=on. 2. Parse HEVC(H.265) from FLV or RTMP packet. 3. Support HEVC over RTMP or HTTP-FLV. Co-authored-by: runner365 <shi.weibd@hotmail.com>
This commit is contained in:
parent
7e02d972ea
commit
178e40a5fc
17 changed files with 440 additions and 44 deletions
|
|
@ -621,11 +621,13 @@ srs_error_t SrsGopCache::cache(SrsSharedPtrMessage* shared_msg)
|
|||
|
||||
// got video, update the video count if acceptable
|
||||
if (msg->is_video()) {
|
||||
// drop video when not h.264
|
||||
if (!SrsFlvVideo::h264(msg->payload, msg->size)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// Drop video when not h.264 or h.265.
|
||||
bool codec_ok = SrsFlvVideo::h264(msg->payload, msg->size);
|
||||
#ifdef SRS_H265
|
||||
codec_ok = codec_ok ? : SrsFlvVideo::hevc(msg->payload, msg->size);
|
||||
#endif
|
||||
if (!codec_ok) return err;
|
||||
|
||||
cached_video_count++;
|
||||
audio_after_last_video_count = 0;
|
||||
}
|
||||
|
|
@ -1063,14 +1065,22 @@ srs_error_t SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_se
|
|||
|
||||
// when got video stream info.
|
||||
SrsStatistic* stat = SrsStatistic::instance();
|
||||
if ((err = stat->on_video_info(req_, SrsVideoCodecIdAVC, c->avc_profile, c->avc_level, c->width, c->height)) != srs_success) {
|
||||
|
||||
if (c->id == SrsVideoCodecIdAVC) {
|
||||
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, profile=%s, level=%s, %dx%d, %dkbps, %.1ffps, %.1fs)",
|
||||
msg->size, c->id, srs_avc_profile2str(c->avc_profile).c_str(), srs_avc_level2str(c->avc_level).c_str(),
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
if (err != srs_success) {
|
||||
return srs_error_wrap(err, "stat video");
|
||||
}
|
||||
|
||||
srs_trace("%dB video sh, codec(%d, profile=%s, level=%s, %dx%d, %dkbps, %.1ffps, %.1fs)",
|
||||
msg->size, c->id, srs_avc_profile2str(c->avc_profile).c_str(),
|
||||
srs_avc_level2str(c->avc_level).c_str(), c->width, c->height,
|
||||
c->video_data_rate / 1000, c->frame_rate, c->duration);
|
||||
}
|
||||
|
||||
// Ignore video data when no sps/pps
|
||||
|
|
|
|||
|
|
@ -622,6 +622,17 @@ void SrsStatistic::dumps_hints_kv(std::stringstream & ss)
|
|||
if (kbps->get_send_kbps_30s()) {
|
||||
ss << "&send=" << kbps->get_send_kbps_30s();
|
||||
}
|
||||
|
||||
#ifdef SRS_H265
|
||||
// For HEVC, we should check active stream which is HEVC codec.
|
||||
for (std::map<std::string, SrsStatisticStream*>::iterator it = streams.begin(); it != streams.end(); it++) {
|
||||
SrsStatisticStream* stream = it->second;
|
||||
if (stream->vcodec == SrsVideoCodecIdHEVC) {
|
||||
ss << "&h265=1";
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SrsStatistic::dumps_cls_summaries(SrsClsSugar* sugar)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue