2 Gnome-o-Phone - A program for internet telephony
3 Copyright (C) 1999 Roland Dreier
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.
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.
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.
23 #define _RTP_PACKET_H 1
25 #include <sys/types.h>
38 #define RTP_HEADER_LEN 12
41 typedef struct Rtp_Header *Rtp_Header;
43 struct Rtp_Packet_Struct
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 */
66 #error "G_BYTE_ORDER should be big or little endian."
68 guint16 seq; /* sequence number */
69 guint32 timestamp; /* timestamp */
70 guint32 ssrc; /* synchronization source */
71 guint32 csrc[1]; /* optional CSRC list */
74 typedef struct Rtp_Packet_Struct *Rtp_Packet;
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);
109 #endif /* rtp-packet.h */