Skip to content

Commit

Permalink
(Continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 18, 2024
1 parent 70f1089 commit e7d2c78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/rtsp/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ static inline int __transfer_nal_h26x(struct list_head_t *trans_list, unsigned c
p_header->cc = 0;
p_header->pt = 96 & 0x7F;

if(nalsize <= __RTP_MAXPAYLOADSIZE){
if (nalsize < 4) return SUCCESS;

if (nalsize <= __RTP_MAXPAYLOADSIZE){
/* single packet */
/* SPS, PPS, SEI is not marked */
if ((isH265 && pt < H265_NAL_TYPE_VPS) ||
Expand All @@ -72,7 +74,7 @@ static inline int __transfer_nal_h26x(struct list_head_t *trans_list, unsigned c
rtp.rtpsize = nalsize + sizeof(rtp_hdr_t);

ASSERT(__rtp_send_h26x(&rtp,trans_list) == SUCCESS, return FAILURE);
} else {
} else {
nalptr += isH265 ? 2 : 1;
nalsize -= isH265 ? 2 : 1;

Expand Down Expand Up @@ -118,7 +120,6 @@ static inline int __transfer_nal_h26x(struct list_head_t *trans_list, unsigned c
memcpy(&(payload[head]), nalptr, nalsize);

ASSERT(__rtp_send_h26x(&rtp, trans_list) == SUCCESS, return FAILURE);

}

return SUCCESS;
Expand Down Expand Up @@ -216,20 +217,19 @@ static inline int __retrieve_sprop(rtsp_handle h, unsigned char *buf, size_t len
mime_encoded_handle base16 = NULL;

/* check VPS is set */
if(!(h->sprop_vps_b64)){
if(h->isH265 && !(h->sprop_vps_b64)){
nalptr = buf;
single_len = 0;
while (__split_nal(buf,&nalptr,&single_len,len) == SUCCESS) {
if (nalptr[0] & 0x7E >> 1 == H265_NAL_TYPE_VPS) {
ASSERT(single_len >= 4, return FAILURE);
ASSERT(base64 = mime_base64_create((char *)&(nalptr[0]),single_len), return FAILURE);

DASSERT(base64->base == 64, return FAILURE);

/* optimistic lock */
rtsp_lock(h);
if(h->sprop_vps_b64) {
DBG("pps is set by another thread?\n");
DBG("vps is set by another thread?\n");
mime_encoded_delete(base64);
} else {
h->sprop_vps_b64 = base64;
Expand All @@ -248,8 +248,8 @@ static inline int __retrieve_sprop(rtsp_handle h, unsigned char *buf, size_t len
single_len = 0;

while (__split_nal(buf,&nalptr,&single_len,len) == SUCCESS) {
if (nalptr[0] & 0x1F == H264_NAL_TYPE_SPS ||
nalptr[0] & 0x7E >> 1 == H265_NAL_TYPE_SPS) {
if ((!(h->isH265) && nalptr[0] & 0x1F == H264_NAL_TYPE_SPS) ||
(h->isH265 && nalptr[0] & 0x7E >> 1 == H265_NAL_TYPE_SPS)) {
ASSERT(base64 = mime_base64_create((char *)&(nalptr[0]),single_len), return FAILURE);
ASSERT(base16 = mime_base16_create((char *)&(nalptr[1]),3), return FAILURE);

Expand Down Expand Up @@ -284,8 +284,8 @@ static inline int __retrieve_sprop(rtsp_handle h, unsigned char *buf, size_t len
nalptr = buf;
single_len = 0;
while (__split_nal(buf,&nalptr,&single_len,len) == SUCCESS) {
if (nalptr[0] & 0x1F == H264_NAL_TYPE_PPS ||
nalptr[0] & 0x7E >> 1 == H265_NAL_TYPE_PPS) {
if ((!(h->isH265) && nalptr[0] & 0x1F == H264_NAL_TYPE_PPS) ||
(h->isH265 && nalptr[0] & 0x7E >> 1 == H265_NAL_TYPE_PPS)) {
ASSERT(single_len >= 4, return FAILURE);
ASSERT(base64 = mime_base64_create((char *)&(nalptr[0]),single_len), return FAILURE);

Expand Down
1 change: 1 addition & 0 deletions src/rtsp/rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ void rtsp_finish(rtsp_handle h)
bufpool_delete(h->con_pool);
bufpool_delete(h->transfer_pool);

mime_encoded_delete(h->sprop_vps_b64);
mime_encoded_delete(h->sprop_sps_b64);
mime_encoded_delete(h->sprop_sps_b16);
mime_encoded_delete(h->sprop_pps_b64);
Expand Down

0 comments on commit e7d2c78

Please sign in to comment.