Complete the move of the RTP plugin
[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 <glib.h>
26 #include <netinet/in.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 enum {
33   RTP_VERSION = 2,
34   RTP_HEADER_LEN = 12,
35   RTP_MTU = 2048
36 };
37
38 typedef struct Rtp_Header *Rtp_Header;
39
40 struct Rtp_Packet_Struct {
41   gpointer data;
42   guint data_len;
43 };
44
45 struct Rtp_Header {
46 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
47   unsigned int csrc_count:4;    /* CSRC count */
48   unsigned int extension:1;     /* header extension flag */
49   unsigned int padding:1;       /* padding flag */
50   unsigned int version:2;       /* protocol version */
51   unsigned int payload_type:7;  /* payload type */
52   unsigned int marker:1;        /* marker bit */
53 #elif G_BYTE_ORDER == G_BIG_ENDIAN
54   unsigned int version:2;       /* protocol version */
55   unsigned int padding:1;       /* padding flag */
56   unsigned int extension:1;     /* header extension flag */
57   unsigned int csrc_count:4;    /* CSRC count */
58   unsigned int marker:1;        /* marker bit */
59   unsigned int payload_type:7;  /* payload type */
60 #else
61 #error "G_BYTE_ORDER should be big or little endian."
62 #endif
63   guint16 seq;                  /* sequence number */
64   guint32 timestamp;            /* timestamp */
65   guint32 ssrc;                 /* synchronization source */
66   guint32 csrc[1];              /* optional CSRC list */
67 };
68
69 typedef struct Rtp_Packet_Struct *Rtp_Packet;
70
71 Rtp_Packet rtp_packet_new_take_data(gpointer data, guint data_len);
72 Rtp_Packet rtp_packet_new_copy_data(gpointer data, guint data_len);
73 Rtp_Packet rtp_packet_new_allocate(guint payload_len,
74                                    guint pad_len, guint csrc_count);
75 void rtp_packet_free(Rtp_Packet packet);
76 Rtp_Packet rtp_packet_read(int fd, struct sockaddr *fromaddr, socklen_t *fromlen);
77 void rtp_packet_send(Rtp_Packet packet, int fd, struct sockaddr *toaddr, socklen_t tolen);
78 guint8 rtp_packet_get_version(Rtp_Packet packet);
79 void rtp_packet_set_version(Rtp_Packet packet, guint8 version);
80 guint8 rtp_packet_get_padding(Rtp_Packet packet);
81 void rtp_packet_set_padding(Rtp_Packet packet, guint8 padding);
82 guint8 rtp_packet_get_csrc_count(Rtp_Packet packet);
83 guint8 rtp_packet_get_extension(Rtp_Packet packet);
84 void rtp_packet_set_extension(Rtp_Packet packet, guint8 extension);
85 void rtp_packet_set_csrc_count(Rtp_Packet packet, guint8 csrc_count);
86 guint8 rtp_packet_get_marker(Rtp_Packet packet);
87 void rtp_packet_set_marker(Rtp_Packet packet, guint8 marker);
88 guint8 rtp_packet_get_payload_type(Rtp_Packet packet);
89 void rtp_packet_set_payload_type(Rtp_Packet packet, guint8 payload_type);
90 guint16 rtp_packet_get_seq(Rtp_Packet packet);
91 void rtp_packet_set_seq(Rtp_Packet packet, guint16 seq);
92 guint32 rtp_packet_get_timestamp(Rtp_Packet packet);
93 void rtp_packet_set_timestamp(Rtp_Packet packet, guint32 timestamp);
94 guint32 rtp_packet_get_ssrc(Rtp_Packet packet);
95 void rtp_packet_set_ssrc(Rtp_Packet packet, guint32 ssrc);
96 guint rtp_packet_get_payload_len(Rtp_Packet packet);
97 gpointer rtp_packet_get_payload(Rtp_Packet packet);
98 guint rtp_packet_get_packet_len(Rtp_Packet packet);
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif /* rtp-packet.h */