diff mbox series

[FFmpeg-devel] avformat/rtpenc: add option to disable STAP for H.264

Message ID tencent_92A7C06AAE532C9C4E4BB666105085E6D006@qq.com
State New
Headers show
Series [FFmpeg-devel] avformat/rtpenc: add option to disable STAP for H.264
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Zhao Zhili Nov. 4, 2020, 5:17 p.m. UTC
Use non-interleaved mode but disable STAP is a valid use case, for
example, the receiver doesn't support STAP.
---
 libavformat/rtpenc.h           | 2 ++
 libavformat/rtpenc_h264_hevc.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h
index 62dc9ab10a..931287cbb3 100644
--- a/libavformat/rtpenc.h
+++ b/libavformat/rtpenc.h
@@ -70,6 +70,7 @@  typedef struct RTPMuxContext RTPMuxContext;
 #define FF_RTP_FLAG_SKIP_RTCP 4
 #define FF_RTP_FLAG_H264_MODE0 8
 #define FF_RTP_FLAG_SEND_BYE  16
+#define FF_RTP_FLAG_H264_NO_STAP 32
 
 #define FF_RTP_FLAG_OPTS(ctx, fieldname) \
     { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
@@ -77,6 +78,7 @@  typedef struct RTPMuxContext RTPMuxContext;
     { "rfc2190", "Use RFC 2190 packetization instead of RFC 4629 for H.263", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_RFC2190}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
     { "skip_rtcp", "Don't send RTCP sender reports", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_SKIP_RTCP}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
     { "h264_mode0", "Use mode 0 for H.264 in RTP", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_H264_MODE0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
+    { "h264_no_stap", "Disable single-time aggregation packet (STAP) for H.264 in RTP", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_H264_NO_STAP}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
     { "send_bye", "Send RTCP BYE packets when finishing", 0, AV_OPT_TYPE_CONST, {.i64 = FF_RTP_FLAG_SEND_BYE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \
 
 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
diff --git a/libavformat/rtpenc_h264_hevc.c b/libavformat/rtpenc_h264_hevc.c
index 0c88fc2a23..faa550abb2 100644
--- a/libavformat/rtpenc_h264_hevc.c
+++ b/libavformat/rtpenc_h264_hevc.c
@@ -65,7 +65,7 @@  static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last
 
         if (codec == AV_CODEC_ID_H264) {
             header_size = 1;
-            skip_aggregate = s->flags & FF_RTP_FLAG_H264_MODE0;
+            skip_aggregate = s->flags & (FF_RTP_FLAG_H264_MODE0 | FF_RTP_FLAG_H264_NO_STAP);
         } else {
             header_size = 2;
         }