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>
37 #define RTP_HEADER_LEN 12
40 typedef struct Rtp_Header *Rtp_Header;
42 struct Rtp_Packet_Struct {
48 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
49 unsigned int csrc_count:4; /* CSRC count */
50 unsigned int extension:1; /* header extension flag */
51 unsigned int padding:1; /* padding flag */
52 unsigned int version:2; /* protocol version */
53 unsigned int payload_type:7; /* payload type */
54 unsigned int marker:1; /* marker bit */
55 #elif G_BYTE_ORDER == G_BIG_ENDIAN
56 unsigned int version:2; /* protocol version */
57 unsigned int padding:1; /* padding flag */
58 unsigned int extension:1; /* header extension flag */
59 unsigned int csrc_count:4; /* CSRC count */
60 unsigned int marker:1; /* marker bit */
61 unsigned int payload_type:7; /* payload type */
63 #error "G_BYTE_ORDER should be big or little endian."
65 guint16 seq; /* sequence number */
66 guint32 timestamp; /* timestamp */
67 guint32 ssrc; /* synchronization source */
68 guint32 csrc[1]; /* optional CSRC list */
71 typedef struct Rtp_Packet_Struct *Rtp_Packet;
73 Rtp_Packet rtp_packet_new_take_data(gpointer data, guint data_len);
74 Rtp_Packet rtp_packet_new_copy_data(gpointer data, guint data_len);
75 Rtp_Packet rtp_packet_new_allocate(guint payload_len,
76 guint pad_len, guint csrc_count);
77 void rtp_packet_free(Rtp_Packet packet);
78 //Rtp_Packet rtp_packet_read(int fd, struct sockaddr *fromaddr, socklen_t *fromlen);
79 //void rtp_packet_send(Rtp_Packet packet, int fd, struct sockaddr *toaddr, socklen_t tolen);
80 guint8 rtp_packet_get_version(Rtp_Packet packet);
81 void rtp_packet_set_version(Rtp_Packet packet, guint8 version);
82 guint8 rtp_packet_get_padding(Rtp_Packet packet);
83 void rtp_packet_set_padding(Rtp_Packet packet, guint8 padding);
84 guint8 rtp_packet_get_csrc_count(Rtp_Packet packet);
85 guint8 rtp_packet_get_extension(Rtp_Packet packet);
86 void rtp_packet_set_extension(Rtp_Packet packet, guint8 extension);
87 void rtp_packet_set_csrc_count(Rtp_Packet packet, guint8 csrc_count);
88 guint8 rtp_packet_get_marker(Rtp_Packet packet);
89 void rtp_packet_set_marker(Rtp_Packet packet, guint8 marker);
90 guint8 rtp_packet_get_payload_type(Rtp_Packet packet);
91 void rtp_packet_set_payload_type(Rtp_Packet packet, guint8 payload_type);
92 guint16 rtp_packet_get_seq(Rtp_Packet packet);
93 void rtp_packet_set_seq(Rtp_Packet packet, guint16 seq);
94 guint32 rtp_packet_get_timestamp(Rtp_Packet packet);
95 void rtp_packet_set_timestamp(Rtp_Packet packet, guint32 timestamp);
96 guint32 rtp_packet_get_ssrc(Rtp_Packet packet);
97 void rtp_packet_set_ssrc(Rtp_Packet packet, guint32 ssrc);
98 guint rtp_packet_get_payload_len(Rtp_Packet packet);
99 gpointer rtp_packet_get_payload(Rtp_Packet packet);
100 guint rtp_packet_get_packet_len(Rtp_Packet packet);
106 #endif /* rtp-packet.h */