ROHC compression/decompression library
rohc_decomp.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 rohc_decomp.h
00019  * @brief ROHC decompression routines
00020  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
00021  * @author Didier Barvaux <didier@barvaux.org>
00022  * @author The hackers from ROHC for Linux
00023  * @author David Moreau from TAS
00024  */
00025 
00026 #ifndef DECOMP_H
00027 #define DECOMP_H
00028 
00029 #include "rohc.h"
00030 #include "rohc_comp.h"
00031 
00032 
00033 /** Macro that handles DLL export declarations gracefully */
00034 #ifdef DLL_EXPORT /* passed by autotools on command line */
00035         #define ROHC_EXPORT __declspec(dllexport)
00036 #else
00037         #define ROHC_EXPORT
00038 #endif
00039 
00040 
00041 /*
00042  * Declare the private ROHC decompressor structure that is defined inside the
00043  * library.
00044  */
00045 
00046 struct rohc_decomp;
00047 
00048 
00049 
00050 /*
00051  * Public structures and types
00052  */
00053 
00054 /**
00055  * @brief The ROHC decompressor states
00056  *
00057  * See 4.3.2 in the RFC 3095.
00058  *
00059  * @ingroup rohc_decomp
00060  */
00061 typedef enum
00062 {
00063         /// The No Context state
00064         NO_CONTEXT = 1,
00065         /// The Static Context state
00066         STATIC_CONTEXT = 2,
00067         /// The Full Context state
00068         FULL_CONTEXT = 3,
00069 } rohc_d_state;
00070 
00071 
00072 /**
00073  * @brief Some information about the last decompressed packet
00074  *
00075  * Versioning works as follow:
00076  *  - The 'version_major' field defines the compatibility level. If the major
00077  *    number given by user does not match the one expected by the library,
00078  *    an error is returned.
00079  *  - The 'version_minor' field defines the extension level. If the minor
00080  *    number given by user does not match the one expected by the library,
00081  *    only the fields supported in that minor version will be filled by
00082  *    \ref rohc_decomp_get_last_packet_info.
00083  *
00084  * Notes for developers:
00085  *  - Increase the major version if a field is removed.
00086  *  - Increase the major version if a field is added at the beginning or in
00087  *    the middle of the structure.
00088  *  - Increase the minor version if a field is added at the very end of the
00089  *    structure.
00090  *  - The version_major and version_minor fields must be located at the very
00091  *    beginning of the structure.
00092  *  - The structure must be packed.
00093  *
00094  * Supported versions:
00095  *  - Major = 0:
00096  *     - Minor = 0:
00097  *        version_major
00098  *        version_minor
00099  *        context_mode
00100  *        context_state
00101  *        profile_id
00102  *        nr_lost_packets
00103  *        nr_misordered_packets
00104  *        is_duplicated
00105  *
00106  * @ingroup rohc_decomp
00107  */
00108 typedef struct
00109 {
00110         /** The major version of this structure */
00111         unsigned short version_major;
00112         /** The minor version of this structure */
00113         unsigned short version_minor;
00114         /** The mode of the last context used by the compressor */
00115         rohc_mode context_mode;
00116         /** The state of the last context used by the compressor */
00117         rohc_d_state context_state;
00118         /** The profile ID of the last context used by the compressor */
00119         int profile_id;
00120         /** The number of (possible) lost packet(s) before last packet */
00121         unsigned long nr_lost_packets;
00122         /** The number of packet(s) before the last packet if late */
00123         unsigned long nr_misordered_packets;
00124         /** Is last packet a (possible) duplicated packet? */
00125         bool is_duplicated;
00126 } __attribute__((packed)) rohc_decomp_last_packet_info_t;
00127 
00128 
00129 
00130 /*
00131  * Functions related to decompressor:
00132  */
00133 
00134 struct rohc_decomp * ROHC_EXPORT rohc_alloc_decompressor(struct rohc_comp *compressor);
00135 void ROHC_EXPORT rohc_free_decompressor(struct rohc_decomp *decomp);
00136 
00137 int ROHC_EXPORT rohc_decompress(struct rohc_decomp *decomp, unsigned char *ibuf, int isize,
00138                     unsigned char *obuf, int osize);
00139 #if !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1
00140 int ROHC_EXPORT rohc_decompress_both(struct rohc_decomp *decomp, unsigned char *ibuf,
00141                          int isize, unsigned char *obuf, int osize, int large)
00142         ROHC_DEPRECATED("please do not use this function anymore, use "
00143                         "rohc_decomp_set_cid_type() and rohc_decomp_set_max_cid() "
00144                         "instead");
00145 #endif /* !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1 */
00146 
00147 
00148 /*
00149  * Functions related to statistics:
00150  */
00151 
00152 int ROHC_EXPORT rohc_d_statistics(struct rohc_decomp *decomp,
00153                                   unsigned int indent,
00154                                   char *buffer);
00155 
00156 void ROHC_EXPORT clear_statistics(struct rohc_decomp *decomp);
00157 
00158 const char * ROHC_EXPORT rohc_decomp_get_state_descr(const rohc_d_state state);
00159 
00160 bool ROHC_EXPORT rohc_decomp_get_last_packet_info(const struct rohc_decomp *const decomp,
00161                                                                                                                                   rohc_decomp_last_packet_info_t *const info)
00162         __attribute__((warn_unused_result));
00163 
00164 
00165 /*
00166  * Functions related to user interaction:
00167  */
00168 
00169 void ROHC_EXPORT user_interactions(struct rohc_decomp *decomp,
00170                                    int feedback_maxval);
00171 
00172 bool ROHC_EXPORT rohc_decomp_set_cid_type(struct rohc_decomp *const decomp,
00173                                           const rohc_cid_type_t cid_type)
00174         __attribute__((warn_unused_result));
00175 
00176 bool ROHC_EXPORT rohc_decomp_set_max_cid(struct rohc_decomp *const decomp,
00177                                          const size_t max_cid)
00178         __attribute__((warn_unused_result));
00179 
00180 bool ROHC_EXPORT rohc_decomp_set_mrru(struct rohc_decomp *const decomp,
00181                                       const size_t mrru)
00182         __attribute__((warn_unused_result));
00183 
00184 bool ROHC_EXPORT rohc_decomp_set_traces_cb(struct rohc_decomp *const decomp,
00185                                            rohc_trace_callback_t callback)
00186         __attribute__((warn_unused_result));
00187 
00188 
00189 #undef ROHC_EXPORT /* do not pollute outside this header */
00190 
00191 #endif
00192