Browse Source

MT#55283 split out common part of stream_fd_readable

Change-Id: Ic9d5432fbb152ced2953f8aa4a2a6683a69f45ec
pull/1826/head
Richard Fuchs 2 years ago
parent
commit
9ee075b088
1 changed files with 30 additions and 23 deletions
  1. +30
    -23
      daemon/media_socket.c

+ 30
- 23
daemon/media_socket.c View File

@ -3139,6 +3139,34 @@ out:
}
static void __stream_fd_readable(struct packet_handler_ctx *phc) {
struct stream_fd *sfd = phc->mp.sfd;
if (phc->mp.tv.tv_sec < 0) {
// kernel-handled RTCP
phc->kernel_handled = true;
// restore original actual timestamp
if (G_UNLIKELY(phc->mp.tv.tv_usec == 0))
phc->mp.tv.tv_sec = -phc->mp.tv.tv_sec;
else {
phc->mp.tv.tv_sec = -phc->mp.tv.tv_sec - 1;
phc->mp.tv.tv_usec = 1000000 - phc->mp.tv.tv_usec;
}
}
int ret;
if (sfd->stream && sfd->stream->jb) {
ret = buffer_packet(&phc->mp, &phc->s);
if (ret == 1)
ret = stream_packet(phc);
}
else
ret = stream_packet(phc);
if (G_UNLIKELY(ret < 0))
ilog(LOG_WARNING | LOG_FLAG_LIMIT, "Write error on media socket: %s", strerror(-ret));
}
static void stream_fd_readable(int fd, void *p) {
stream_fd *sfd = p;
int ret, iters;
@ -3209,32 +3237,11 @@ restart:
if (ret >= MAX_RTP_PACKET_SIZE)
ilog(LOG_WARNING | LOG_FLAG_LIMIT, "UDP packet possibly truncated");
if (phc.mp.tv.tv_sec < 0) {
// kernel-handled RTCP
phc.kernel_handled = true;
// restore original actual timestamp
if (G_UNLIKELY(phc.mp.tv.tv_usec == 0))
phc.mp.tv.tv_sec = -phc.mp.tv.tv_sec;
else {
phc.mp.tv.tv_sec = -phc.mp.tv.tv_sec - 1;
phc.mp.tv.tv_usec = 1000000 - phc.mp.tv.tv_usec;
}
}
str_init_len(&phc.s, buf + RTP_BUFFER_HEAD_ROOM, ret);
if (sfd->stream && sfd->stream->jb) {
ret = buffer_packet(&phc.mp, &phc.s);
if (ret == 1)
ret = stream_packet(&phc);
}
else
ret = stream_packet(&phc);
__stream_fd_readable(&phc);
if (G_UNLIKELY(ret < 0))
ilog(LOG_WARNING | LOG_FLAG_LIMIT, "Write error on media socket: %s", strerror(-ret));
else if (phc.update)
update = true;
update += phc.update;
}
// -1 active read events. If it's non-zero, another thread has received a read event,


Loading…
Cancel
Save