ROHC compression/decompression library
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 */ 00016 00017 /** 00018 * @file c_rtp.h 00019 * @brief ROHC compression context for the RTP profile. 00020 * @author David Moreau from TAS 00021 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00022 */ 00023 00024 #ifndef C_RTP_H 00025 #define C_RTP_H 00026 00027 #include "c_generic.h" 00028 #include "ts_sc_comp.h" 00029 #include "protocols/udp.h" 00030 #include "protocols/rtp.h" 00031 00032 00033 /** 00034 * @brief Define the RTP and UDP specific temporary variables in the profile 00035 * compression context. 00036 * 00037 * This object must be used by the RTP-specific decompression context 00038 * sc_rtp_context. 00039 * 00040 * @see sc_rtp_context 00041 */ 00042 struct rtp_tmp_vars 00043 { 00044 /// The number of UDP/RTP fields that changed in the UDP/RTP headers 00045 int send_rtp_dynamic; 00046 00047 /// The number of bits needed to encode ts_send 00048 size_t nr_ts_bits; 00049 00050 /// The number of bits of TS to place in the extension 3 header 00051 size_t nr_ts_bits_ext3; 00052 00053 /// The real timestamp of the last RTP message 00054 uint32_t timestamp; 00055 00056 /// The TS field to send (ts_scaled or ts) 00057 uint32_t ts_send; 00058 00059 /// Whether the M bit is set in the RTP header or not 00060 int m_set; 00061 00062 /// Whether the Payload Type (PT) field changed or not 00063 int rtp_pt_changed; 00064 }; 00065 00066 00067 /** 00068 * @brief Define the RTP part of the profile decompression context. 00069 * 00070 * This object must be used with the generic part of the decompression 00071 * context c_generic_context. 00072 * 00073 * @warning The 2 first fields MUST stay at the beginning of the structure 00074 * to be compatible with \ref sc_udp_context 00075 * 00076 * @see c_generic_context 00077 */ 00078 struct sc_rtp_context 00079 { 00080 /// @brief The number of times the UDP checksum field was added to the 00081 /// compressed header 00082 int udp_checksum_change_count; 00083 00084 /// The previous UDP header 00085 struct udphdr old_udp; 00086 00087 /// @brief The number of times the RTP Payload Type (PT) field was added to 00088 /// the compressed header 00089 int rtp_pt_change_count; 00090 00091 /// The previous RTP header 00092 struct rtphdr old_rtp; 00093 00094 /// @brief RTP-specific temporary variables that are used during one single 00095 /// compression of packet 00096 struct rtp_tmp_vars tmp; 00097 00098 /// Scaled RTP Time Stamp 00099 int tss; 00100 00101 /// Whether the Time Stride field is present or not 00102 int tis; 00103 00104 /// Structure to encode the TS field 00105 struct ts_sc_comp ts_sc; 00106 }; 00107 00108 00109 /* 00110 * Function prototypes. 00111 */ 00112 00113 int c_rtp_create(struct c_context *const context, const struct ip_packet *ip); 00114 void c_rtp_destroy(struct c_context *const context); 00115 00116 int c_rtp_check_context(const struct c_context *context, 00117 const struct ip_packet *ip); 00118 00119 int c_rtp_encode(struct c_context *const context, 00120 const struct ip_packet *ip, 00121 const int packet_size, 00122 unsigned char *const dest, 00123 const int dest_size, 00124 rohc_packet_t *const packet_type, 00125 int *const payload_offset); 00126 00127 void rtp_decide_state(struct c_context *const context); 00128 00129 int rtp_code_uo_remainder(struct c_context *context, 00130 const unsigned char *next_header, 00131 unsigned char *dest, 00132 int counter); 00133 00134 #endif 00135