Skip to content

Commit 8125e35

Browse files
runner365winlinvip
authored andcommitted
H265: Support HEVC over RTMP or HTTP-FLV.
1. Support configure with --h265=on. 2. Parse HEVC(H.265) from FLV or RTMP packet. 3. Support HEVC over RTMP or HTTP-FLV.
1 parent 7e02d97 commit 8125e35

File tree

12 files changed

+421
-33
lines changed

12 files changed

+421
-33
lines changed

trunk/Dockerfile.builds

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN cd /srs/trunk && ./configure --srt=off --gb28181=off --nasm=off --srtp-nasm=
1313

1414
FROM ossrs/srs:dev-cache AS centos7-all
1515
COPY . /srs
16-
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on && make
16+
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --h265=on && make
1717

1818
FROM ossrs/srs:dev-cache AS centos7-ansi-no-ffmpeg
1919
COPY . /srs
@@ -26,7 +26,7 @@ RUN cd /srs/trunk && ./configure --srt=off --gb28181=off --cxx11=off --cxx14=off
2626

2727
FROM ossrs/srs:dev6-cache AS centos6-all
2828
COPY . /srs
29-
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --cxx11=off --cxx14=off --sanitizer=off && make
29+
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --h265=on --cxx11=off --cxx14=off --sanitizer=off && make
3030

3131
########################################################
3232
FROM ossrs/srs:ubuntu16-cache AS ubuntu16-baseline
@@ -35,7 +35,7 @@ RUN cd /srs/trunk && ./configure --srt=off --gb28181=off && make
3535

3636
FROM ossrs/srs:ubuntu16-cache AS ubuntu16-all
3737
COPY . /srs
38-
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on && make
38+
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --h265=on && make
3939

4040
########################################################
4141
FROM ossrs/srs:ubuntu18-cache AS ubuntu18-baseline
@@ -44,7 +44,7 @@ RUN cd /srs/trunk && ./configure --srt=off --gb28181=off && make
4444

4545
FROM ossrs/srs:ubuntu18-cache AS ubuntu18-all
4646
COPY . /srs
47-
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on && make
47+
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --h265=on && make
4848

4949
########################################################
5050
FROM ossrs/srs:ubuntu20-cache AS ubuntu20-baseline
@@ -53,7 +53,7 @@ RUN cd /srs/trunk && ./configure --srt=off --gb28181=off && make
5353

5454
FROM ossrs/srs:ubuntu20-cache AS ubuntu20-all
5555
COPY . /srs
56-
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on && make
56+
RUN cd /srs/trunk && ./configure --srt=on --gb28181=on --h265=on && make
5757

5858
########################################################
5959
FROM ossrs/srs:ubuntu16-cross-arm AS ubuntu16-cross-armv7

trunk/Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ COPY . /srs
66
WORKDIR /srs/trunk
77

88
# Note that we must enable the gcc7 or link failed.
9-
RUN scl enable devtoolset-7 -- ./configure --srt=on --gb28181=on --utest=on
9+
RUN scl enable devtoolset-7 -- ./configure --srt=on --gb28181=on --h265=on --utest=on
1010
RUN scl enable devtoolset-7 -- make utest
1111

1212
# Build benchmark tool.

trunk/auto/auto_headers.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ else
8686
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
8787
fi
8888

89+
if [[ $SRS_H265 == YES ]]; then
90+
srs_define_macro "SRS_H265" $SRS_AUTO_HEADERS_H
91+
else
92+
srs_undefine_macro "SRS_H265" $SRS_AUTO_HEADERS_H
93+
fi
94+
8995
if [[ $SRS_SIMULATOR == YES ]]; then
9096
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
9197
else

trunk/auto/options.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ help=no
66
SRS_HDS=NO
77
SRS_SRT=YES
88
SRS_RTC=YES
9+
SRS_H265=NO
910
SRS_GB28181=NO
1011
SRS_CXX11=YES
1112
SRS_CXX14=NO
@@ -136,6 +137,7 @@ Features:
136137
--cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
137138
--backtrace=on|off Whether show backtrace when crashing. Default: $(value2switch $SRS_BACKTRACE)
138139
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
140+
--h265=on|off Whether build the HEVC(H.265) support. Default: $(value2switch $SRS_H265)
139141
140142
--prefix=<path> The absolute installation path. Default: $SRS_PREFIX
141143
--config=<path> The default config file for SRS. Default: $SRS_DEFAULT_CONFIG
@@ -305,6 +307,7 @@ function parse_user_option() {
305307
--generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
306308
--single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
307309
--ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
310+
--h265) SRS_H265=$(switch2value $value) ;;
308311
--gb28181) SRS_GB28181=$(switch2value $value) ;;
309312

310313
--cxx11) SRS_CXX11=$(switch2value $value) ;;
@@ -587,6 +590,7 @@ function regenerate_options() {
587590
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cherrypy=$(value2switch $SRS_CHERRYPY)"
588591
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=$(value2switch $SRS_SRT)"
589592
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=$(value2switch $SRS_RTC)"
593+
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=$(value2switch $SRS_H265)"
590594
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=$(value2switch $SRS_GB28181)"
591595
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=$(value2switch $SRS_SIMULATOR)"
592596
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=$(value2switch $SRS_CXX11)"

trunk/conf/hevc.flv.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
listen 1935;
2+
max_connections 1000;
3+
daemon off;
4+
srs_log_tank console;
5+
http_api {
6+
enabled on;
7+
listen 1985;
8+
}
9+
http_server {
10+
enabled on;
11+
listen 8080;
12+
}
13+
vhost __defaultVhost__ {
14+
http_remux {
15+
enabled on;
16+
mount [vhost]/[app]/[stream].flv;
17+
}
18+
}

trunk/doc/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ The changelog for SRS.
88

99
## SRS 6.0 Changelog
1010

11-
* v5.0, 2022-11-22, Merge [#3268](https://github.com/ossrs/srs/pull/3268): H265: Update mpegts.js to play HEVC over HTTP-TS/FLV. v6.0.1
11+
* v6.0, 2022-11-22, Merge [#3272](https://github.com/ossrs/srs/pull/3272): H265: Support HEVC over RTMP or HTTP-FLV. v6.0.2
12+
* v6.0, 2022-11-22, Merge [#3268](https://github.com/ossrs/srs/pull/3268): H265: Update mpegts.js to play HEVC over HTTP-TS/FLV. v6.0.1
1213
* v6.0, 2022-11-22, Init SRS 6. v6.0.0
1314

1415
<a name="v5-changes"></a>

trunk/src/app/srs_app_source.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,13 @@ srs_error_t SrsGopCache::cache(SrsSharedPtrMessage* shared_msg)
621621

622622
// got video, update the video count if acceptable
623623
if (msg->is_video()) {
624-
// drop video when not h.264
625-
if (!SrsFlvVideo::h264(msg->payload, msg->size)) {
626-
return err;
627-
}
628-
624+
// Drop video when not h.264 or h.265.
625+
bool codec_ok = SrsFlvVideo::h264(msg->payload, msg->size);
626+
#ifdef SRS_H265
627+
codec_ok = codec_ok ? : SrsFlvVideo::hevc(msg->payload, msg->size);
628+
#endif
629+
if (!codec_ok) return err;
630+
629631
cached_video_count++;
630632
audio_after_last_video_count = 0;
631633
}

trunk/src/app/srs_app_statistic.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,17 @@ void SrsStatistic::dumps_hints_kv(std::stringstream & ss)
622622
if (kbps->get_send_kbps_30s()) {
623623
ss << "&send=" << kbps->get_send_kbps_30s();
624624
}
625+
626+
#ifdef SRS_H265
627+
// For HEVC, we should check active stream which is HEVC codec.
628+
for (std::map<std::string, SrsStatisticStream*>::iterator it = streams.begin(); it != streams.end(); it++) {
629+
SrsStatisticStream* stream = it->second;
630+
if (stream->vcodec == SrsVideoCodecIdHEVC) {
631+
ss << "&h265=1";
632+
break;
633+
}
634+
}
635+
#endif
625636
}
626637

627638
void SrsStatistic::dumps_cls_summaries(SrsClsSugar* sugar)

trunk/src/core/srs_core_version6.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#define VERSION_MAJOR 6
1111
#define VERSION_MINOR 0
12-
#define VERSION_REVISION 1
12+
#define VERSION_REVISION 2
1313

1414
#endif

0 commit comments

Comments
 (0)