ROHC compression/decompression library
c_rtp.h
Go to the documentation of this file.
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 "rtp.h"
00030 
00031 #include <netinet/ip.h>
00032 #include <netinet/udp.h>
00033 
00034 
00035 /**
00036  * @brief Define the RTP and UDP specific temporary variables in the profile
00037  *        compression context.
00038  *
00039  * This object must be used by the RTP-specific decompression context
00040  * sc_rtp_context.
00041  *
00042  * @see sc_rtp_context
00043  */
00044 struct rtp_tmp_vars
00045 {
00046         /// The number of UDP/RTP fields that changed in the UDP/RTP headers
00047         int send_rtp_dynamic;
00048 
00049         /// The number of bits needed to encode ts_send
00050         size_t nr_ts_bits;
00051 
00052         /// The number of bits of TS to place in the extension 3 header
00053         size_t nr_ts_bits_ext3;
00054 
00055         /// The real timestamp of the last RTP message
00056         uint32_t timestamp;
00057 
00058         /// The TS field to send (ts_scaled or ts)
00059         uint32_t ts_send;
00060 
00061         /// Whether the M bit is set in the RTP header or not
00062         int m_set;
00063 
00064         /// Whether the Payload Type (PT) field changed or not
00065         int rtp_pt_changed;
00066 };
00067 
00068 
00069 /**
00070  * @brief Define the RTP part of the profile decompression context.
00071  *
00072  * This object must be used with the generic part of the decompression
00073  * context c_generic_context.
00074  *
00075  * @warning The 2 first fields MUST stay at the beginning of the structure
00076  *          to be compatible with \ref sc_udp_context
00077  *
00078  * @see c_generic_context
00079  */
00080 struct sc_rtp_context
00081 {
00082         /// @brief The number of times the UDP checksum field was added to the
00083         ///        compressed header
00084         int udp_checksum_change_count;
00085 
00086         /// The previous UDP header
00087         struct udphdr old_udp;
00088 
00089         /// @brief The number of times the RTP Payload Type (PT) field was added to
00090         ///        the compressed header
00091         int rtp_pt_change_count;
00092 
00093         /// The previous RTP header
00094         struct rtphdr old_rtp;
00095 
00096         /// @brief RTP-specific temporary variables that are used during one single
00097         ///        compression of packet
00098         struct rtp_tmp_vars tmp;
00099 
00100         /// A window used to encode the TS field
00101         struct c_wlsb *ts_window;
00102 
00103         /// Scaled RTP Time Stamp
00104         int tss;
00105 
00106         /// Whether the Time Stride field is present or not
00107         int tis;
00108 
00109         /// Structure to encode the TS field
00110         struct ts_sc_comp ts_sc;
00111 };
00112 
00113 
00114 /*
00115  * Function prototypes.
00116  */
00117 
00118 int c_rtp_create(struct c_context *const context, const struct ip_packet *ip);
00119 void c_rtp_destroy(struct c_context *const context);
00120 
00121 int c_rtp_check_context(const struct c_context *context,
00122                         const struct ip_packet *ip);
00123 
00124 int c_rtp_encode(struct c_context *const context,
00125                  const struct ip_packet *ip,
00126                  const int packet_size,
00127                  unsigned char *const dest,
00128                  const int dest_size,
00129                  rohc_packet_t *const packet_type,
00130                  int *const payload_offset);
00131 
00132 void rtp_decide_state(struct c_context *const context);
00133 
00134 int rtp_code_UO_packet_tail(struct c_context *context,
00135                             const unsigned char *next_header,
00136                             unsigned char *dest,
00137                             int counter);
00138 
00139 
00140 #endif
00141