ROHC compression/decompression library
ts_sc_comp.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 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 "dllexport.h"
00033 
00034 #include <stdbool.h>
00035 
00036 
00037 /**
00038  * @brief State of scaled RTP Timestamp encoding
00039  *
00040  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
00041  * encoding.
00042  */
00043 typedef enum
00044 {
00045         /// Initialization state (TS_STRIDE value not yet computed)
00046         INIT_TS = 1,
00047         /// Initialization state (TS_STRIDE value computed and sent)
00048         INIT_STRIDE = 2,
00049         /// Compression state (TS_SCALED value computed and sent)
00050         SEND_SCALED = 3,
00051 } ts_sc_state;
00052 
00053 
00054 /**
00055  * @brief Scaled RTP Timestamp encoding object
00056  *
00057  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
00058  * encoding.
00059  */
00060 struct ts_sc_comp
00061 {
00062         /// The TS_STRIDE value
00063         uint32_t ts_stride;
00064 
00065         /// The TS_SCALED value
00066         uint32_t ts_scaled;
00067         /// A window used to encode the TS_SCALED value
00068         struct c_wlsb *scaled_window;
00069 
00070         /// The TS_OFFSET value
00071         uint32_t ts_offset;
00072 
00073         /// The timestamp (TS)
00074         uint32_t ts;
00075         /// The previous timestamp
00076         uint32_t old_ts;
00077 
00078         /// The sequence number (SN)
00079         uint16_t sn;
00080         /// The previous sequence number
00081         uint16_t old_sn;
00082 
00083         /// Whether timestamp is deductible from SN or not
00084         int is_deductible;
00085 
00086         /// The state of the scaled RTP Timestamp encoding object
00087         ts_sc_state state;
00088         /// The number of packets sent in state INIT_STRIDE
00089         size_t nr_init_stride_packets;
00090 
00091         /// The difference between old and current TS
00092         uint32_t ts_delta;
00093 };
00094 
00095 
00096 
00097 /*
00098  * Function prototypes
00099  */
00100 
00101 int ROHC_EXPORT c_create_sc(struct ts_sc_comp *const ts_sc,
00102                             const size_t wlsb_window_width);
00103 void ROHC_EXPORT c_destroy_sc(struct ts_sc_comp *const ts_sc);
00104 
00105 void ROHC_EXPORT c_add_ts(struct ts_sc_comp *const ts_sc,
00106                           const uint32_t ts,
00107                           const uint16_t sn);
00108 
00109 bool ROHC_EXPORT nb_bits_scaled(const struct ts_sc_comp ts_sc,
00110                                 size_t *const bits_nr);
00111 
00112 void ROHC_EXPORT add_scaled(const struct ts_sc_comp *const ts_sc,
00113                             uint16_t sn);
00114 
00115 uint32_t ROHC_EXPORT get_ts_stride(const struct ts_sc_comp ts_sc);
00116 uint32_t ROHC_EXPORT get_ts_scaled(const struct ts_sc_comp ts_sc);
00117 
00118 #endif
00119