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 ts_sc_comp.h 00019 * @brief Scaled RTP Timestamp encoding 00020 * @author David Moreau from TAS 00021 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00022 * @author Didier Barvaux <didier@barvaux.org> 00023 * 00024 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00025 * encoding. 00026 */ 00027 00028 #ifndef TS_SC_COMP_H 00029 #define TS_SC_COMP_H 00030 00031 #include "wlsb.h" 00032 #include "rohc_traces.h" 00033 00034 #ifdef __KERNEL__ 00035 # include <linux/types.h> 00036 #else 00037 # include <stdbool.h> 00038 #endif 00039 00040 #include "dllexport.h" 00041 00042 00043 /** 00044 * @brief State of scaled RTP Timestamp encoding 00045 * 00046 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00047 * encoding. 00048 */ 00049 typedef enum 00050 { 00051 /// Initialization state (TS_STRIDE value not yet computed) 00052 INIT_TS = 1, 00053 /// Initialization state (TS_STRIDE value computed and sent) 00054 INIT_STRIDE = 2, 00055 /// Compression state (TS_SCALED value computed and sent) 00056 SEND_SCALED = 3, 00057 } ts_sc_state; 00058 00059 00060 /** 00061 * @brief Scaled RTP Timestamp encoding object 00062 * 00063 * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp 00064 * encoding. 00065 */ 00066 struct ts_sc_comp 00067 { 00068 /// The TS_STRIDE value 00069 uint32_t ts_stride; 00070 00071 /// The TS_SCALED value 00072 uint32_t ts_scaled; 00073 /// A window used to encode the TS_SCALED value 00074 struct c_wlsb *scaled_window; 00075 00076 /// The TS_OFFSET value 00077 uint32_t ts_offset; 00078 00079 /// The timestamp (TS) 00080 uint32_t ts; 00081 /// The previous timestamp 00082 uint32_t old_ts; 00083 00084 /// The sequence number (SN) 00085 uint16_t sn; 00086 /// The previous sequence number 00087 uint16_t old_sn; 00088 00089 /// Whether timestamp is deducible from SN or not 00090 bool is_deducible; 00091 00092 /// The state of the scaled RTP Timestamp encoding object 00093 ts_sc_state state; 00094 /** Whether old SN/TS values are initialized or not */ 00095 bool are_old_val_init; 00096 /// The number of packets sent in state INIT_STRIDE 00097 size_t nr_init_stride_packets; 00098 00099 /// The difference between old and current TS 00100 uint32_t ts_delta; 00101 00102 /// The callback function used to get log messages 00103 rohc_trace_callback_t trace_callback; 00104 }; 00105 00106 00107 00108 /* 00109 * Function prototypes 00110 */ 00111 00112 int ROHC_EXPORT c_create_sc(struct ts_sc_comp *const ts_sc, 00113 const size_t wlsb_window_width, 00114 rohc_trace_callback_t callback); 00115 void ROHC_EXPORT c_destroy_sc(struct ts_sc_comp *const ts_sc); 00116 00117 void ROHC_EXPORT c_add_ts(struct ts_sc_comp *const ts_sc, 00118 const uint32_t ts, 00119 const uint16_t sn); 00120 00121 bool ROHC_EXPORT nb_bits_scaled(const struct ts_sc_comp ts_sc, 00122 size_t *const bits_nr); 00123 00124 void ROHC_EXPORT add_scaled(const struct ts_sc_comp *const ts_sc, 00125 uint16_t sn); 00126 00127 uint32_t ROHC_EXPORT get_ts_stride(const struct ts_sc_comp ts_sc); 00128 uint32_t ROHC_EXPORT get_ts_scaled(const struct ts_sc_comp ts_sc); 00129 00130 bool ROHC_EXPORT rohc_ts_sc_is_deducible(const struct ts_sc_comp ts_sc); 00131 00132 #endif 00133