]> code.delx.au - pulseaudio/blobdiff - src/modules/rtp/rtp.c
Remove unnecessary #includes
[pulseaudio] / src / modules / rtp / rtp.c
index c09c321f32a4475b524d68aee9ed7d5f84372614..05c736a7525b836fce8a54eec33c1a9abc083cd7 100644 (file)
@@ -5,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
 #include <config.h>
 #endif
 
-#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <arpa/inet.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 
@@ -43,6 +41,7 @@
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/arpa-inet.h>
 
 #include "rtp.h"
 
@@ -162,13 +161,16 @@ pa_rtp_context* pa_rtp_context_init_recv(pa_rtp_context *c, int fd, size_t frame
     return c;
 }
 
-int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
+int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, struct timeval *tstamp) {
     int size;
     struct msghdr m;
+    struct cmsghdr *cm;
     struct iovec iov;
     uint32_t header;
     unsigned cc;
     ssize_t r;
+    uint8_t aux[1024];
+    pa_bool_t found_tstamp = FALSE;
 
     pa_assert(c);
     pa_assert(chunk);
@@ -208,8 +210,8 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
     m.msg_namelen = 0;
     m.msg_iov = &iov;
     m.msg_iovlen = 1;
-    m.msg_control = NULL;
-    m.msg_controllen = 0;
+    m.msg_control = aux;
+    m.msg_controllen = sizeof(aux);
     m.msg_flags = 0;
 
     r = recvmsg(c->fd, &m, 0);
@@ -275,6 +277,18 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
         pa_memchunk_reset(&c->memchunk);
     }
 
+    for (cm = CMSG_FIRSTHDR(&m); cm; cm = CMSG_NXTHDR(&m, cm))
+        if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SO_TIMESTAMP) {
+            memcpy(tstamp, CMSG_DATA(cm), sizeof(struct timeval));
+            found_tstamp = TRUE;
+            break;
+        }
+
+    if (!found_tstamp) {
+        pa_log_warn("Couldn't find SO_TIMESTAMP data in auxiliary recvmsg() data!");
+        memset(tstamp, 0, sizeof(tstamp));
+    }
+
     return 0;
 
 fail: