Skip to content

Commit fecd3dd

Browse files
committed
avformat/whip: improve logic and add comments
Signed-off-by: Jack Lau <jacklau1222@qq.com>
1 parent 6443f08 commit fecd3dd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libavformat/whip.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ typedef struct WHIPContext {
327327
int history_size;
328328
RtpHistoryItem * history; /* ring buffer */
329329
int hist_head;
330-
int enable_nack_rtx;
330+
int enable_nack_rtx; /* TODO: using whip_flags */
331331
} WHIPContext;
332332

333333
/**
@@ -1943,17 +1943,17 @@ static int whip_write_packet(AVFormatContext *s, AVPacket *pkt)
19431943
* The length of this RTCP packet in 32-bit words minus one,
19441944
* including the header and any padding.
19451945
*/
1946-
int len = (AV_RB16(&whip->buf[ptr + 2]) + 1) * 4;
1947-
if (ptr + len < ret && len >= 12) {
1946+
int rtcp_len = (AV_RB16(&whip->buf[ptr + 2]) + 1) * 4;
1947+
/* SRTCP index(4 bytes) + HMAC (SRTP_AES128_CM_SHA1_80 10bytes) */
1948+
int srtcp_len = rtcp_len + 4 + 10;
1949+
if (srtcp_len == ret && rtcp_len >= 12) {
19481950
int i = 0;
1949-
/* SRTCP index(4 bytes) + HMAC (SRTP_AES128_CM_SHA1_80 10bytes) */
1950-
int srtcp_len = len + 4 + 10;
19511951
uint8_t *pkt = av_malloc(srtcp_len);
19521952
memcpy(pkt, whip->buf, srtcp_len);
19531953
int ret = ff_srtp_decrypt(&whip->srtp_recv, pkt, &srtcp_len);
19541954
if (ret < 0)
19551955
av_log(whip, AV_LOG_ERROR, "WHIP: SRTCP decrypt failed: %d\n", ret);
1956-
while (12 + i < len && ret >= 0) {
1956+
while (12 + i < rtcp_len && ret == 0) {
19571957
/**
19581958
* See https://datatracker.ietf.org/doc/html/rfc4585#section-6.1
19591959
* Handle multi NACKs in bundled packet.

0 commit comments

Comments
 (0)