gst-indent
[platform/upstream/gst-plugins-good.git] / gst / rtp / rtp-packet.h
1 /*
2   Gnome-o-Phone - A program for internet telephony
3   Copyright (C) 1999  Roland Dreier
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9   
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14   
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18   
19   $Id$
20 */
21
22 #ifndef _RTP_PACKET_H
23 #define _RTP_PACKET_H 1
24
25 #include <sys/types.h>
26 #include <glib.h>
27
28 #ifdef __sun
29 #include <sys/uio.h>
30 #endif
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37 #define RTP_VERSION 2
38 #define RTP_HEADER_LEN 12
39 #define RTP_MTU 2048
40
41   typedef struct Rtp_Header *Rtp_Header;
42
43   struct Rtp_Packet_Struct
44   {
45     gpointer data;
46     guint data_len;
47   };
48
49   struct Rtp_Header
50   {
51 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
52     unsigned int csrc_count:4;  /* CSRC count */
53     unsigned int extension:1;   /* header extension flag */
54     unsigned int padding:1;     /* padding flag */
55     unsigned int version:2;     /* protocol version */
56     unsigned int payload_type:7;        /* payload type */
57     unsigned int marker:1;      /* marker bit */
58 #elif G_BYTE_ORDER == G_BIG_ENDIAN
59     unsigned int version:2;     /* protocol version */
60     unsigned int padding:1;     /* padding flag */
61     unsigned int extension:1;   /* header extension flag */
62     unsigned int csrc_count:4;  /* CSRC count */
63     unsigned int marker:1;      /* marker bit */
64     unsigned int payload_type:7;        /* payload type */
65 #else
66 #error "G_BYTE_ORDER should be big or little endian."
67 #endif
68     guint16 seq;                /* sequence number */
69     guint32 timestamp;          /* timestamp */
70     guint32 ssrc;               /* synchronization source */
71     guint32 csrc[1];            /* optional CSRC list */
72   };
73
74   typedef struct Rtp_Packet_Struct *Rtp_Packet;
75
76   Rtp_Packet rtp_packet_new_take_data (gpointer data, guint data_len);
77   Rtp_Packet rtp_packet_new_copy_data (gpointer data, guint data_len);
78   Rtp_Packet rtp_packet_new_allocate (guint payload_len,
79       guint pad_len, guint csrc_count);
80   void rtp_packet_free (Rtp_Packet packet);
81 //Rtp_Packet rtp_packet_read(int fd, struct sockaddr *fromaddr, socklen_t *fromlen);
82 //void rtp_packet_send(Rtp_Packet packet, int fd, struct sockaddr *toaddr, socklen_t tolen);
83   guint8 rtp_packet_get_version (Rtp_Packet packet);
84   void rtp_packet_set_version (Rtp_Packet packet, guint8 version);
85   guint8 rtp_packet_get_padding (Rtp_Packet packet);
86   void rtp_packet_set_padding (Rtp_Packet packet, guint8 padding);
87   guint8 rtp_packet_get_csrc_count (Rtp_Packet packet);
88   guint8 rtp_packet_get_extension (Rtp_Packet packet);
89   void rtp_packet_set_extension (Rtp_Packet packet, guint8 extension);
90   void rtp_packet_set_csrc_count (Rtp_Packet packet, guint8 csrc_count);
91   guint8 rtp_packet_get_marker (Rtp_Packet packet);
92   void rtp_packet_set_marker (Rtp_Packet packet, guint8 marker);
93   guint8 rtp_packet_get_payload_type (Rtp_Packet packet);
94   void rtp_packet_set_payload_type (Rtp_Packet packet, guint8 payload_type);
95   guint16 rtp_packet_get_seq (Rtp_Packet packet);
96   void rtp_packet_set_seq (Rtp_Packet packet, guint16 seq);
97   guint32 rtp_packet_get_timestamp (Rtp_Packet packet);
98   void rtp_packet_set_timestamp (Rtp_Packet packet, guint32 timestamp);
99   guint32 rtp_packet_get_ssrc (Rtp_Packet packet);
100   void rtp_packet_set_ssrc (Rtp_Packet packet, guint32 ssrc);
101   guint rtp_packet_get_payload_len (Rtp_Packet packet);
102   gpointer rtp_packet_get_payload (Rtp_Packet packet);
103   guint rtp_packet_get_packet_len (Rtp_Packet packet);
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif                          /* rtp-packet.h */