summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2006-07-04 01:53:23 +0000
committerphintuka <phintuka>2006-07-04 01:53:23 +0000
commitc28700c6d8d2c075b9c653f5adcc1281b2bd694e (patch)
tree89e98efa2934f5a4a203ec2744de224acf445fa2
parent066f1d8f7d45a1b6a8d939e8b46dfcdf0ab79a93 (diff)
downloadxineliboutput-c28700c6d8d2c075b9c653f5adcc1281b2bd694e.tar.gz
xineliboutput-c28700c6d8d2c075b9c653f5adcc1281b2bd694e.tar.bz2
Added RTP definitions
-rw-r--r--xine_input_vdr_net.h199
1 files changed, 169 insertions, 30 deletions
diff --git a/xine_input_vdr_net.h b/xine_input_vdr_net.h
index f36127e2..5dfc75b2 100644
--- a/xine_input_vdr_net.h
+++ b/xine_input_vdr_net.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_input_vdr_net.h,v 1.1 2006-06-03 09:50:54 phintuka Exp $
+ * $Id: xine_input_vdr_net.h,v 1.2 2006-07-04 01:53:23 phintuka Exp $
*
*/
@@ -12,7 +12,7 @@
#define __XINE_INPUT_VDR_NET_H_
#include <arpa/inet.h>
-
+#include <endian.h>
/*
* Default port(s)
@@ -29,19 +29,21 @@
* Byte-order conversions
*/
-#define ntohll(val) ((int64_t)ntohull((uint64_t)val))
-#define htonll(val) ((int64_t)htonull((uint64_t)val))
-
-#define ntohull(val) \
- (ntohs(0x1234) == 0x1234 ? (val) : \
- (uint64_t) ntohl((uint32_t)((val) >> 32)) | \
- (uint64_t) ntohl((uint32_t)(val)) << 32)
-
-#define htonull(val) \
- (ntohs(0x1234) == 0x1234 ? (val) : \
- (uint64_t) htonl((uint32_t)((val) >> 32)) | \
- (uint64_t) htonl((uint32_t)(val)) << 32)
-
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ntohll(val) (val)
+# define htonll(val) (val)
+# define ntohull(val) (val)
+# define htonull(val) (val)
+#else
+# define ntohll(val) ((int64_t)ntohull((uint64_t)val))
+# define htonll(val) ((int64_t)htonull((uint64_t)val))
+# define ntohull(val) \
+ ((uint64_t) ntohl((uint32_t)((val) >> 32)) | \
+ (uint64_t) ntohl((uint32_t)(val)) << 32)
+# define htonull(val) \
+ ((uint64_t) htonl((uint32_t)((val) >> 32)) | \
+ (uint64_t) htonl((uint32_t)(val)) << 32)
+#endif
/*
* Network packet headers
@@ -50,19 +52,21 @@
#if defined __cplusplus
extern "C" {
#endif
+
+/*
+ * TCP / PIPE
+ */
+typedef struct stream_tcp_header {
+ uint64_t pos; /* stream position of first byte */
+ uint32_t len; /* length of following PES packet */
+} __attribute__ ((packed)) stream_tcp_header_t;
-#if 0
-typedef struct stream_rtp_header {
- /* input_rtp.c ? */
- int dummy;
-} __attribute__ ((packed)) stream_rtp_header_t;
-
-#define RTP_PAYLOAD(frame) (((uchar *)frame) + sizeof(stream_rtp_header_t))
-#endif
-
+#define TCP_PAYLOAD(frame) (((uchar *)frame) + sizeof(stream_tcp_header_t))
-#define UDP_SEQ_MASK 0xff
+/*
+ * UDP
+ */
typedef struct stream_udp_header {
uint64_t pos; /* stream position of first byte */
@@ -73,14 +77,149 @@ typedef struct stream_udp_header {
} __attribute__ ((packed)) stream_udp_header_t;
#define UDP_PAYLOAD(frame) (((uchar *)frame) + sizeof(stream_udp_header_t))
+#define UDP_SEQ_MASK 0xff
-typedef struct stream_tcp_header {
- uint64_t pos; /* stream position of first byte */
- uint32_t len; /* length of following PES packet */
-} __attribute__ ((packed)) stream_tcp_header_t;
+/*
+ * RTP (RFC 1889): A Transport Protocol for Real-Time Applications
+ */
+
+/* RTP data header */
+typedef struct stream_rtp_header {
+ union {
+ uint8_t raw[12];
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int version:2; /* protocol version */
+ unsigned int padding:1; /* padding flag */
+ unsigned int ext:1; /* header extension flag */
+ unsigned int cc:4; /* CSRC count */
+
+ unsigned int marker:1; /* marker bit */
+ unsigned int paytype:7; /* payload type */
+#else
+ unsigned int cc:4; /* CSRC count */
+ unsigned int ext:1; /* header extension flag */
+ unsigned int padding:1; /* padding flag */
+ unsigned int version:2; /* protocol version */
+
+ unsigned int paytype:7; /* payload type */
+ unsigned int marker:1; /* marker bit */
+#endif
+ uint16_t seq; /* sequence number */
+ uint32_t ts; /* timestamp */
+ uint32_t ssrc; /* synchronization source */
+
+ /*uint32_t csrc[0];*/ /* optional CSRC list */
+ };
+ };
+
+ uint8_t payload[0];
+
+} __attribute__ ((packed)) stream_rtp_header_t;
+
+#define RTP_VERSION 2
+#define RTP_MARKER_BIT 0x80
+#define RTP_PAYLOAD_TYPE 96 /* application */
+
+#define RTP_VERSION_BYTE (RTP_VERSION<<6)
+#define RTP_PAYLOAD_TYPE_M (RTP_PAYLOAD_TYPE|RTP_MARKER_BIT)
+
+#define RTP_PAYLOAD(frame) (((uchar *)frame) + sizeof(stream_rtp_header_t))
+
+/* RTCP packet types */
+typedef enum {
+ RTCP_SR = 200,
+ RTCP_RR = 201,
+ RTCP_SDES = 202,
+ RTCP_BYE = 203,
+ RTCP_APP = 204
+} rtcp_type_t;
+
+/* RTCP SDES types */
+typedef enum {
+ RTCP_SDES_END = 0,
+ RTCP_SDES_CNAME = 1,
+
+ RTCP_SDES_NAME = 2,
+ RTCP_SDES_EMAIL = 3,
+ RTCP_SDES_PHONE = 4,
+ RTCP_SDES_LOC = 5,
+ RTCP_SDES_TOOL = 6,
+ RTCP_SDES_NOTE = 7,
+ RTCP_SDES_PRIV = 8
+} rtcp_sdes_type_t;
+
+/* RTCP common header word */
+typedef struct {
+ union {
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int version:2; /* protocol version */
+ unsigned int padding:1; /* padding flag */
+ unsigned int count:5; /* varies by packet type */
+#else
+ unsigned int count:5; /* varies by packet type */
+ unsigned int padding:1; /* padding flag */
+ unsigned int version:2; /* protocol version */
+#endif
+ unsigned int ptype:8; /* RTCP packet type */
+
+ uint16_t length; /* pkt len in words, w/o this word */
+ };
+ uint8_t raw[4];
+ };
+} rtcp_common_t;
+
+/* RTCP RR (Reception report) */
+typedef struct {
+ uint32_t ssrc; /* data source being reported */
+ unsigned int fraction:8; /* fraction lost since last SR/RR */
+ int lost:24; /* cumul. no. pkts lost (signed!) */
+ uint32_t last_seq; /* extended last seq. no. received */
+ uint32_t jitter; /* interarrival jitter */
+ uint32_t lsr; /* last SR packet from this source */
+ uint32_t dlsr; /* delay since last SR packet */
+} rtcp_rr_t;
+
+/* RTCP SR (Sender report) */
+typedef struct {
+ uint32_t ssrc;
+ uint32_t ntp_sec; /* NTP timestamp, most significant word / seconds */
+ uint32_t ntp_frac;
+ uint32_t rtp_ts;
+ uint32_t psent; /* packets sent */
+ uint32_t osent; /* octets sent */
+ rtcp_rr_t rr[0]; /* variable-length list */
+} rtcp_sr_t;
+
+/* RTCP SDES item */
+typedef struct {
+ uint8_t type; /* type of item (rtcp_sdes_type_t) */
+ uint8_t length; /* length of item (in octets) */
+ char data[0]; /* text, not null-terminated */
+} rtcp_sdes_item_t;
+
+/* RTCP packet */
+typedef struct {
+ rtcp_common_t hdr;
+ union {
+ rtcp_sr_t sr;
+ struct {
+ uint32_t ssrc;
+ rtcp_rr_t rr[0];
+ } rr;
+ struct {
+ uint32_t ssrc; /* first SSRC/CSRC */
+ rtcp_sdes_item_t item[0]; /* list of SDES items */
+ } sdes;
+ struct {
+ uint32_t src[0]; /* list of sources */
+ /* can't express trailing text for reason */
+ } bye;
+ };
+} rtcp_packet_t;
-#define TCP_PAYLOAD(frame) (((uchar *)frame) + sizeof(stream_tcp_header_t))
#if defined __cplusplus
}