#include <stddef.h> /* offsetof */
+/** get the struct this entry is embedded in */
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
*/
#define LIST_POISON2 ((void *) 0x00200200)
-/**
- * Simple doubly linked list implementation.
- *
+/** Simple doubly linked list implementation. */
+struct list_head {
+ /** pointer to the next list entry */
+ struct list_head *next;
+ /** pointer to the previous list entry */
+ struct list_head *prev;
+};
+
+/** must be called before using any other list functions */
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+
+/*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
-struct list_head {
- struct list_head *next, *prev;
-};
-#define INIT_LIST_HEAD(ptr) do { \
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
/*
* Insert a new entry between two known consecutive entries.
+/*
+ * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ */
+
/** \file ortp.h some macros used by ortp_send.c and ortp_recv.c*/
+
+/** the possible packet types */
enum ortp_audio_packet_type {ORTP_EOF, ORTP_BOF, ORTP_HEADER, ORTP_DATA};
+/** number of bytes of the paraslash ortp header */
#define ORTP_AUDIO_HEADER_LEN 10
+/** write type of this packet to \a buf */
#define WRITE_PACKET_TYPE(buf, x) (buf)[0] = (unsigned char)((x)&0xff)
+/** get type of this packet */
#define READ_PACKET_TYPE(buf) (unsigned)(buf)[0]
+/** write the chunk time for this packet to \a buf */
#define WRITE_CHUNK_TIME(buf, x) (buf)[1] = (unsigned char)((x)&0xff);\
(buf)[2] = (unsigned char)(((x)>>8)&0xff);\
(buf)[3] = (unsigned char)(((x)>>16)&0xff);\
(buf)[4] = (unsigned char)(((x)>>24)&0xff);
+
+/** get the chunk time of this packet */
#define READ_CHUNK_TIME(buf) (unsigned char)(buf)[1] + \
((unsigned char)(buf)[2] << 8) + \
((unsigned char)(buf)[3] << 16) + \
((unsigned char)(buf)[4] << 24)
+/** write the chunk timestamp */
#define WRITE_CHUNK_TS(buf, x) (buf)[5] = (unsigned char)((x) & 0xff); \
(buf)[6] = (unsigned char)(((x >> 8) & 0xff));
+/** get the chunk timestamp */
#define READ_CHUNK_TS(buf) (unsigned char)(buf)[5] + \
((unsigned char)(buf)[6] << 8)
+/** write the stream type (header or headerless) */
#define WRITE_STREAM_TYPE(buf, x) (buf)[7] = (unsigned char)((x)&0xff)
+/** get the type of the stream (header or headerless) */
#define READ_STREAM_TYPE(buf) (unsigned)(buf)[7]
+/** write the length of the header (only used for streams with header) */
#define WRITE_HEADER_LEN(buf, x) (buf)[8] = (unsigned char)((x) & 0xff); \
(buf)[9] = (unsigned char)(((x >> 8) & 0xff));
+
+/** get the length of the header (only used for packets containing a header) */
#define READ_HEADER_LEN(buf) (unsigned char)(buf)[8] + \
((unsigned char)(buf)[9] << 8)
-