Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/toolchain
compile_flags.txt
divinus
/test/*_test
22 changes: 5 additions & 17 deletions src/rtsp/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>

#include "rtsp_server.h"
#include "common.h"
Expand Down Expand Up @@ -38,23 +37,11 @@ struct __transfer_set_t {

static unsigned int __frame_ts_video, __frame_ts_audio;

static inline void __wait_out(int fd)
{
struct pollfd p = { .fd = fd, .events = POLLOUT };
poll(&p, 1, 100);
}

static int __tcp_flush(struct connection_item_t *con)
{
unsigned int sent = 0;
while (sent < con->tx_len) {
int r = send(con->client_fd, con->tx_buf + sent, con->tx_len - sent, 0);
if (r > 0) sent += r;
else if (r < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) { __wait_out(con->client_fd); }
else { con->tx_len = 0; return FAILURE; }
}
int ret = __tcp_send_all(con->client_fd, con->tx_buf, con->tx_len);
con->tx_len = 0;
return SUCCESS;
return ret;
}

static int __tcp_flush_each(struct list_t *e, void *v)
Expand All @@ -79,6 +66,9 @@ static int __tcp_flush_each(struct list_t *e, void *v)

static inline int __transfer_nal_h26x(struct list_head_t *trans_list, unsigned char *nalptr, size_t nalsize, char isH265)
{
/* Checked before the header is read: an empty pack comes with no data */
if (nalsize < 4) return SUCCESS;

struct nal_rtp_t rtp;
unsigned int nri = isH265 ? (nalptr[0] & 0x81) : (nalptr[0] & 0x60);
unsigned int pt = isH265 ? (nalptr[0] >> 1 & 0x3F) : (nalptr[0] & 0x1F);
Expand All @@ -94,8 +84,6 @@ 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 < 4) return SUCCESS;

if (nalsize <= __RTP_MAXPAYLOADSIZE) {
/* single packet */
/* SPS, PPS, SEI is not marked */
Expand Down
Loading