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