Skip to content

Commit

Permalink
For #1747, Support HEVC/H.265 in SRT/RTMP/HLS.
Browse files Browse the repository at this point in the history
  • Loading branch information
runner365 authored and winlinvip committed Jul 11, 2020
1 parent 70c3fc7 commit a438133
Show file tree
Hide file tree
Showing 15 changed files with 1,605 additions and 125 deletions.
6 changes: 6 additions & 0 deletions trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ else
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
fi

if [ $SRS_H265 = YES ]; then
srs_define_macro "SRS_H265" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_H265" $SRS_AUTO_HEADERS_H
fi

if [ $SRS_SIMULATOR = YES ]; then
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
else
Expand Down
5 changes: 5 additions & 0 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ help=no
SRS_HDS=NO
SRS_SRT=NO
SRS_RTC=YES
SRS_H265=YES
SRS_GB28181=NO
SRS_CXX11=NO
SRS_CXX14=NO
Expand Down Expand Up @@ -157,6 +158,7 @@ Features:
--cxx11=on|off Whether enable the C++11 support for SRS.
--cxx14=on|off Whether enable the C++14 support for SRS.
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code) for SRS.
--h265=on|off Whether build the H.265 support for SRS.
--prefix=<path> The absolute installation path for srs. Default: $SRS_PREFIX
--gcov=on|off Whether enable the GCOV compiler options.
Expand Down Expand Up @@ -324,6 +326,8 @@ function parse_user_option() {
--rtc) if [[ $value == off ]]; then SRS_RTC=NO; else SRS_RTC=YES; fi ;;
--simulator) if [[ $value == off ]]; then SRS_SIMULATOR=NO; else SRS_SIMULATOR=YES; fi ;;

--h265) if [[ $value == off ]]; then SRS_H265=NO; else SRS_H265=YES; fi ;;

--with-gb28181) SRS_GB28181=YES ;;
--without-gb28181) SRS_GB28181=NO ;;
--gb28181) if [[ $value == off ]]; then SRS_GB28181=NO; else SRS_GB28181=YES; fi ;;
Expand Down Expand Up @@ -539,6 +543,7 @@ function regenerate_options() {
if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=off"; fi
if [ $SRS_SRT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=off"; fi
if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=off"; fi
if [ $SRS_H265 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=off"; fi
if [ $SRS_SIMULATOR = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=off"; fi
if [ $SRS_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=off"; fi
if [ $SRS_CXX11 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=off"; fi
Expand Down
3 changes: 3 additions & 0 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
if [[ $SRS_H265 == YES ]]; then
MODULE_FILES+=("srs_raw_hevc")
fi
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}"
#
Expand Down
8 changes: 7 additions & 1 deletion trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ srs_error_t SrsHlsMuxer::segment_open()
std::string default_vcodec_str = _srs_config->get_hls_vcodec(req->vhost);
if (default_vcodec_str == "h264") {
default_vcodec = SrsVideoCodecIdAVC;
} else if (default_vcodec_str == "h265") {
default_vcodec = SrsVideoCodecIdHEVC;
} else if (default_vcodec_str == "vn") {
default_vcodec = SrsVideoCodecIdDisabled;
} else {
Expand Down Expand Up @@ -1319,7 +1321,11 @@ srs_error_t SrsHls::on_video(SrsSharedPtrMessage* shared_video, SrsFormat* forma
}

srs_assert(format->vcodec);
if (format->vcodec->id != SrsVideoCodecIdAVC) {
bool ignore_frame = (format->vcodec->id != SrsVideoCodecIdAVC);
#ifdef SRS_H265
ignore_frame = ignore_frame && (format->vcodec->id != SrsVideoCodecIdHEVC);
#endif
if (ignore_frame) {
return err;
}

Expand Down
7 changes: 5 additions & 2 deletions trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,11 @@ 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)) {
bool ignore_frame = !SrsFlvVideo::h264(msg->payload, msg->size);
#ifdef SRS_H265
ignore_frame = ignore_frame && !SrsFlvVideo::hevc(msg->payload, msg->size);
#endif
if (ignore_frame) {
return err;
}

Expand Down
Loading

0 comments on commit a438133

Please sign in to comment.