ROHC compression/decompression library
comp_scaled_rtp_ts.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010,2011,2012,2013 Didier Barvaux
3  * Copyright 2007,2009,2010,2012,2013 Viveris Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file schemes/comp_scaled_rtp_ts.h
22  * @brief Scaled RTP Timestamp encoding
23  * @author David Moreau from TAS
24  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
25  * @author Didier Barvaux <didier@barvaux.org>
26  *
27  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
28  * encoding.
29  */
30 
31 #ifndef ROHC_COMP_SCHEMES_SCALED_RTP_TS_H
32 #define ROHC_COMP_SCHEMES_SCALED_RTP_TS_H
33 
34 #include "comp_wlsb.h"
35 #include "rohc_traces.h"
36 
37 #include <stdbool.h>
38 
39 
40 /**
41  * @brief State of scaled RTP Timestamp encoding
42  *
43  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
44  * encoding.
45  */
46 typedef enum
47 {
48  /// Initialization state (TS_STRIDE value not yet computed)
49  INIT_TS = 1,
50  /// Initialization state (TS_STRIDE value computed and sent)
52  /// Compression state (TS_SCALED value computed and sent)
54 } ts_sc_state;
55 
56 
57 /**
58  * @brief Scaled RTP Timestamp encoding object
59  *
60  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
61  * encoding.
62  */
63 struct ts_sc_comp
64 {
65  /// The TS_STRIDE value
66  uint32_t ts_stride;
67 
68  /// The TS_SCALED value
69  uint32_t ts_scaled;
70  /** The W-LSB object used to encode the TS_SCALED value */
72 
73  /// The TS_OFFSET value
74  uint32_t ts_offset;
75 
76  /// The timestamp (TS)
77  uint32_t ts;
78  /** The W-LSB object used to encode the TS value */
80  /// The previous timestamp
81  uint32_t old_ts;
82 
83  /// The sequence number (SN)
84  uint16_t sn;
85  /// The previous sequence number
86  uint16_t old_sn;
87 
88  /// Whether timestamp is deducible from SN or not
90 
91  /// The state of the scaled RTP Timestamp encoding object
93  /** Whether old SN/TS values are initialized or not */
95  /// The number of packets sent in state INIT_STRIDE
97 
98  /// The difference between old and current TS
99  uint32_t ts_delta;
100 
101  /** The callback function used to manage traces */
103  /** The private context of the callback function used to manage traces */
105 };
106 
107 
108 
109 /*
110  * Function prototypes
111  */
112 
113 void c_init_sc(struct ts_sc_comp *const ts_sc,
114  const size_t wlsb_window_width,
115  rohc_trace_callback2_t trace_cb,
116  void *const trace_cb_priv)
117  __attribute__((nonnull(1)));
118 
119 void c_add_ts(struct ts_sc_comp *const ts_sc,
120  const uint32_t ts,
121  const uint16_t sn);
122 
123 void nb_bits_unscaled(const struct ts_sc_comp *const ts_sc,
124  size_t *const bits_nr_less_equal_than_2,
125  size_t *const bits_nr_more_than_2)
126  __attribute__((nonnull(1, 2, 3)));
127 void add_unscaled(struct ts_sc_comp *const ts_sc, const uint16_t sn)
128  __attribute__((nonnull(1)));
129 
130 void nb_bits_scaled(const struct ts_sc_comp *const ts_sc,
131  size_t *const bits_nr_less_equal_than_2,
132  size_t *const bits_nr_more_than_2)
133  __attribute__((nonnull(1, 2, 3)));
134 void add_scaled(struct ts_sc_comp *const ts_sc, const uint16_t sn)
135  __attribute__((nonnull(1)));
136 
137 uint32_t get_ts_stride(const struct ts_sc_comp *const ts_sc)
138  __attribute__((nonnull(1), warn_unused_result, pure));
139 uint32_t get_ts_scaled(const struct ts_sc_comp *const ts_sc)
140  __attribute__((nonnull(1), warn_unused_result, pure));
141 uint32_t get_ts_unscaled(const struct ts_sc_comp *const ts_sc)
142  __attribute__((nonnull(1), warn_unused_result, pure));
143 
144 bool rohc_ts_sc_is_deducible(const struct ts_sc_comp *const ts_sc)
145  __attribute__((nonnull(1), warn_unused_result, pure));
146 
147 #endif
148 
struct c_wlsb ts_scaled_wlsb
Definition: comp_scaled_rtp_ts.h:71
void nb_bits_scaled(const struct ts_sc_comp *const ts_sc, size_t *const bits_nr_less_equal_than_2, size_t *const bits_nr_more_than_2)
Return the number of bits needed to encode TS_SCALED.
Definition: comp_scaled_rtp_ts.c:381
uint32_t get_ts_unscaled(const struct ts_sc_comp *const ts_sc)
Return the unscaled TS value.
Definition: comp_scaled_rtp_ts.c:448
Scaled RTP Timestamp encoding object.
Definition: comp_scaled_rtp_ts.h:63
struct c_wlsb ts_unscaled_wlsb
Definition: comp_scaled_rtp_ts.h:79
void add_scaled(struct ts_sc_comp *const ts_sc, const uint16_t sn)
Add a new TS_SCALED value to the ts_sc_comp object.
Definition: comp_scaled_rtp_ts.c:412
uint32_t get_ts_scaled(const struct ts_sc_comp *const ts_sc)
Return the TS_SCALED value.
Definition: comp_scaled_rtp_ts.c:436
uint32_t ts_offset
The TS_OFFSET value.
Definition: comp_scaled_rtp_ts.h:74
uint32_t get_ts_stride(const struct ts_sc_comp *const ts_sc)
Return the TS_STRIDE value.
Definition: comp_scaled_rtp_ts.c:424
Initialization state (TS_STRIDE value computed and sent)
Definition: comp_scaled_rtp_ts.h:51
uint32_t ts_scaled
The TS_SCALED value.
Definition: comp_scaled_rtp_ts.h:69
bool rohc_ts_sc_is_deducible(const struct ts_sc_comp *const ts_sc)
Whether TimeStamp (TS) is deducible from the Sequence Number (SN) or not.
Definition: comp_scaled_rtp_ts.c:461
bool are_old_val_init
Definition: comp_scaled_rtp_ts.h:94
rohc_trace_callback2_t trace_callback
Definition: comp_scaled_rtp_ts.h:102
void add_unscaled(struct ts_sc_comp *const ts_sc, const uint16_t sn)
Add a new unscaled TS value to the ts_sc_comp object.
Definition: comp_scaled_rtp_ts.c:364
uint16_t sn
The sequence number (SN)
Definition: comp_scaled_rtp_ts.h:84
void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...)
The function prototype for the trace callback.
Definition: rohc_traces.h:118
uint32_t old_ts
The previous timestamp.
Definition: comp_scaled_rtp_ts.h:81
Window-based Least Significant Bits (W-LSB) encoding.
One W-LSB encoding object.
Definition: comp_wlsb.h:56
ts_sc_state state
The state of the scaled RTP Timestamp encoding object.
Definition: comp_scaled_rtp_ts.h:92
void c_init_sc(struct ts_sc_comp *const ts_sc, const size_t wlsb_window_width, rohc_trace_callback2_t trace_cb, void *const trace_cb_priv)
Create the ts_sc_comp object.
Definition: comp_scaled_rtp_ts.c:52
bool is_deducible
Whether timestamp is deducible from SN or not.
Definition: comp_scaled_rtp_ts.h:89
void nb_bits_unscaled(const struct ts_sc_comp *const ts_sc, size_t *const bits_nr_less_equal_than_2, size_t *const bits_nr_more_than_2)
Return the number of bits needed to encode unscaled TS.
Definition: comp_scaled_rtp_ts.c:347
Compression state (TS_SCALED value computed and sent)
Definition: comp_scaled_rtp_ts.h:53
uint32_t ts
The timestamp (TS)
Definition: comp_scaled_rtp_ts.h:77
ts_sc_state
State of scaled RTP Timestamp encoding.
Definition: comp_scaled_rtp_ts.h:46
void c_add_ts(struct ts_sc_comp *const ts_sc, const uint32_t ts, const uint16_t sn)
Store the new TS, calculate new values and update the state.
Definition: comp_scaled_rtp_ts.c:90
void * trace_callback_priv
Definition: comp_scaled_rtp_ts.h:104
ROHC definitions for traces.
uint32_t ts_stride
The TS_STRIDE value.
Definition: comp_scaled_rtp_ts.h:66
size_t nr_init_stride_packets
The number of packets sent in state INIT_STRIDE.
Definition: comp_scaled_rtp_ts.h:96
uint16_t old_sn
The previous sequence number.
Definition: comp_scaled_rtp_ts.h:86
uint32_t ts_delta
The difference between old and current TS.
Definition: comp_scaled_rtp_ts.h:99
Initialization state (TS_STRIDE value not yet computed)
Definition: comp_scaled_rtp_ts.h:49