ROHC compression/decompression library
|
00001 /* 00002 * Copyright 2010,2011,2012,2013 Didier Barvaux 00003 * Copyright 2007,2009,2010,2012,2013 Viveris Technologies 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 /** 00021 * @file src/comp/schemes/scaled_rtp_ts.h 00022 * @brief Scaled RTP Timestamp encoding 00023 * @author David Moreau from TAS 00024 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00025 * @author Didier Barvaux <didier@barvaux.org> 00026 * 00027 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00028 * encoding. 00029 */ 00030 00031 #ifndef ROHC_COMP_SCHEMES_SCALED_RTP_TS_H 00032 #define ROHC_COMP_SCHEMES_SCALED_RTP_TS_H 00033 00034 #include "wlsb.h" 00035 #include "rohc_traces.h" 00036 00037 #ifdef __KERNEL__ 00038 # include <linux/types.h> 00039 #else 00040 # include <stdbool.h> 00041 #endif 00042 00043 #include "dllexport.h" 00044 00045 #include "config.h" /* for ROHC_ENABLE_DEPRECATED_API */ 00046 00047 00048 /** 00049 * @brief State of scaled RTP Timestamp encoding 00050 * 00051 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00052 * encoding. 00053 */ 00054 typedef enum 00055 { 00056 /// Initialization state (TS_STRIDE value not yet computed) 00057 INIT_TS = 1, 00058 /// Initialization state (TS_STRIDE value computed and sent) 00059 INIT_STRIDE = 2, 00060 /// Compression state (TS_SCALED value computed and sent) 00061 SEND_SCALED = 3, 00062 } ts_sc_state; 00063 00064 00065 /** 00066 * @brief Scaled RTP Timestamp encoding object 00067 * 00068 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00069 * encoding. 00070 */ 00071 struct ts_sc_comp 00072 { 00073 /// The TS_STRIDE value 00074 uint32_t ts_stride; 00075 00076 /// The TS_SCALED value 00077 uint32_t ts_scaled; 00078 /** The W-LSB object used to encode the TS_SCALED value */ 00079 struct c_wlsb *ts_scaled_wlsb; 00080 00081 /// The TS_OFFSET value 00082 uint32_t ts_offset; 00083 00084 /// The timestamp (TS) 00085 uint32_t ts; 00086 /** The W-LSB object used to encode the TS value */ 00087 struct c_wlsb *ts_unscaled_wlsb; 00088 /// The previous timestamp 00089 uint32_t old_ts; 00090 00091 /// The sequence number (SN) 00092 uint16_t sn; 00093 /// The previous sequence number 00094 uint16_t old_sn; 00095 00096 /// Whether timestamp is deducible from SN or not 00097 bool is_deducible; 00098 00099 /// The state of the scaled RTP Timestamp encoding object 00100 ts_sc_state state; 00101 /** Whether old SN/TS values are initialized or not */ 00102 bool are_old_val_init; 00103 /// The number of packets sent in state INIT_STRIDE 00104 size_t nr_init_stride_packets; 00105 00106 /// The difference between old and current TS 00107 uint32_t ts_delta; 00108 00109 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00110 /** The old callback function used to manage traces */ 00111 rohc_trace_callback_t trace_callback; 00112 #endif 00113 /** The new callback function used to manage traces */ 00114 rohc_trace_callback2_t trace_callback2; 00115 /** The private context of the callback function used to manage traces */ 00116 void *trace_callback_priv; 00117 }; 00118 00119 00120 00121 /* 00122 * Function prototypes 00123 */ 00124 00125 bool ROHC_EXPORT c_create_sc(struct ts_sc_comp *const ts_sc, 00126 const size_t wlsb_window_width, 00127 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00128 rohc_trace_callback_t trace_cb, 00129 #endif 00130 rohc_trace_callback2_t trace_cb2, 00131 void *const trace_cb_priv) 00132 __attribute__((warn_unused_result)); 00133 void ROHC_EXPORT c_destroy_sc(struct ts_sc_comp *const ts_sc); 00134 00135 void ROHC_EXPORT c_add_ts(struct ts_sc_comp *const ts_sc, 00136 const uint32_t ts, 00137 const uint16_t sn); 00138 00139 bool ROHC_EXPORT nb_bits_unscaled(const struct ts_sc_comp *const ts_sc, 00140 size_t *const bits_nr) 00141 __attribute__((nonnull(1), warn_unused_result)); 00142 void ROHC_EXPORT add_unscaled(const struct ts_sc_comp *const ts_sc, 00143 const uint16_t sn); 00144 00145 bool ROHC_EXPORT nb_bits_scaled(const struct ts_sc_comp *const ts_sc, 00146 size_t *const bits_nr) 00147 __attribute__((nonnull(1), warn_unused_result)); 00148 void ROHC_EXPORT add_scaled(const struct ts_sc_comp *const ts_sc, 00149 const uint16_t sn); 00150 00151 uint32_t ROHC_EXPORT get_ts_stride(const struct ts_sc_comp *const ts_sc) 00152 __attribute__((nonnull(1), warn_unused_result, pure)); 00153 uint32_t ROHC_EXPORT get_ts_scaled(const struct ts_sc_comp *const ts_sc) 00154 __attribute__((nonnull(1), warn_unused_result, pure)); 00155 uint32_t ROHC_EXPORT get_ts_unscaled(const struct ts_sc_comp *const ts_sc) 00156 __attribute__((nonnull(1), warn_unused_result, pure)); 00157 00158 bool ROHC_EXPORT rohc_ts_sc_is_deducible(const struct ts_sc_comp *const ts_sc) 00159 __attribute__((nonnull(1), warn_unused_result, pure)); 00160 00161 #endif 00162