summaryrefslogtreecommitdiff
path: root/tools/rtp.h
blob: fa2ccf630f7c61ce7cc5486877148887278d5805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * rtp.h: RFC1889: RTP - A Transport Protocol for Real-Time Applications
 *
 * See the main source file 'xineliboutput.c' for copyright information and
 * how to reach the author.
 *
 * $Id: rtp.h,v 1.3 2007-03-29 14:22:31 phintuka Exp $
 *
 */

#ifndef XINELIBOUTPUT_RTP_H_
#define XINELIBOUTPUT_RTP_H_

#ifdef __APPLE__
# include <machine/endian.h>
#else
# include <endian.h>
#endif


#ifndef PACKED
#  define PACKED __attribute__((packed))
#endif

#if   __BYTE_ORDER == __BIG_ENDIAN
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#else
#  error __BYTE_ORDER not defined
#endif

#if defined __cplusplus
extern "C" {
#endif


/* Generic RTP header extension */
typedef struct stream_rtp_header_ext {

  union {
    uint8_t  raw[4];
    uint32_t rawd;

    struct {
      uint16_t type;
      uint16_t size; /* Size of ext_data field in DWORDS */
    } PACKED;
  } PACKED;

  uint8_t ext_data[0];

} PACKED stream_rtp_header_ext_t;


/* Common 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 */
    } PACKED;
  } PACKED;


  union {
    stream_rtp_header_ext_t hdr_ext[0];  
    uint8_t                 payload[0];  
  } PACKED;


} PACKED stream_rtp_header_t;

#if defined __cplusplus
};
#endif

#endif /* XINELIBOUTPUT_RTP_H_ */