ROHC compression/decompression library
decomp_scaled_rtp_ts.h
Go to the documentation of this file.
1 /*
2  * Copyright 2007,2008 CNES
3  * Copyright 2011,2012,2013 Didier Barvaux
4  * Copyright 2007,2008 Thales Alenia Space
5  * Copyright 2007,2010,2012,2013,2014 Viveris Technologies
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file schemes/decomp_scaled_rtp_ts.h
24  * @brief Scaled RTP Timestamp decoding
25  * @author David Moreau from TAS
26  * @author Didier Barvaux <didier@barvaux.org>
27  */
28 
29 #ifndef ROHC_DECOMP_SCHEMES_SCALED_RTP_TS_H
30 #define ROHC_DECOMP_SCHEMES_SCALED_RTP_TS_H
31 
32 #include "rohc_traces.h"
33 #include "decomp_wlsb.h"
34 
35 #include <stdlib.h>
36 #include <stdint.h>
37 #include <stdbool.h>
38 
39 
40 /*
41  * Structure and types
42  */
43 
44 /**
45  * @brief The scaled RTP Timestamp decoding context
46  *
47  * See section 4.5.3 of RFC 3095 for details about Scaled RTP Timestamp
48  * decoding.
49  */
51 {
52  /// The last computed or received TS_STRIDE value (validated by CRC)
53  uint32_t ts_stride;
54 
55  /// The last computed or received TS_SCALED value (validated by CRC)
56  uint32_t ts_scaled;
57  /// The LSB-encoded TS_SCALED value
59 
60  /// The last computed or received TS_OFFSET value (validated by CRC)
61  uint32_t ts_offset;
62 
63  /** The last timestamp (TS) value */
64  uint32_t ts;
65  /** The LSB-encoded unscaled timestamp (TS) value */
67  /// The previous timestamp value
68  uint32_t old_ts;
69 
70  /// The sequence number (SN)
71  uint16_t sn;
72  /// The previous sequence number
73  uint16_t old_sn;
74 
75 
76  /* the attributes below are new TS_* values computed by not yet validated
77  by CRC check */
78 
79  /// The last computed or received TS_STRIDE value (not validated by CRC)
80  uint32_t new_ts_stride;
81  /// The last computed or received TS_SCALED value (not validated by CRC)
82  uint32_t new_ts_scaled;
83  /// The last computed or received TS_OFFSET value (not validated by CRC)
84  uint32_t new_ts_offset;
85 
86  /** The callback function used to manage traces */
88  /** The private context of the callback function used to manage traces */
90 };
91 
92 
93 /*
94  * Function prototypes
95  */
96 
97 void d_init_sc(struct ts_sc_decomp *const ts_scaled,
98  rohc_trace_callback2_t trace_cb,
99  void *const trace_cb_priv)
100  __attribute__((nonnull(1)));
101 
102 void ts_update_context(struct ts_sc_decomp *const ts_sc,
103  const uint32_t ts,
104  const uint16_t sn);
105 
106 void d_record_ts_stride(struct ts_sc_decomp *const ts_sc,
107  const uint32_t ts_stride);
108 
109 bool ts_decode_unscaled_bits(struct ts_sc_decomp *const ts_sc,
110  const uint32_t ts_unscaled_bits,
111  const size_t ts_unscaled_bits_nr,
112  uint32_t *const decoded_ts)
113  __attribute__((warn_unused_result));
114 
115 bool ts_decode_scaled_bits(struct ts_sc_decomp *const ts_sc,
116  const uint32_t ts_scaled_bits,
117  const size_t ts_scaled_bits_nr,
118  uint32_t *const decoded_ts)
119  __attribute__((warn_unused_result));
120 
121 uint32_t ts_deduce_from_sn(struct ts_sc_decomp *const ts_sc,
122  const uint16_t sn)
123  __attribute__((warn_unused_result));
124 
125 #endif
126 
void d_record_ts_stride(struct ts_sc_decomp *const ts_sc, const uint32_t ts_stride)
Store the newly-parsed TS_STRIDE value.
Definition: decomp_scaled_rtp_ts.c:146
uint32_t ts_scaled
The last computed or received TS_SCALED value (validated by CRC)
Definition: decomp_scaled_rtp_ts.h:56
uint32_t old_ts
The previous timestamp value.
Definition: decomp_scaled_rtp_ts.h:68
uint32_t new_ts_stride
The last computed or received TS_STRIDE value (not validated by CRC)
Definition: decomp_scaled_rtp_ts.h:80
struct rohc_lsb_decode lsb_ts_unscaled
Definition: decomp_scaled_rtp_ts.h:66
bool ts_decode_unscaled_bits(struct ts_sc_decomp *const ts_sc, const uint32_t ts_unscaled_bits, const size_t ts_unscaled_bits_nr, uint32_t *const decoded_ts)
Decode timestamp (TS) value with some LSB bits of the unscaled value.
Definition: decomp_scaled_rtp_ts.c:167
The scaled RTP Timestamp decoding context.
Definition: decomp_scaled_rtp_ts.h:50
The Least Significant Bits (LSB) decoding object.
Definition: decomp_wlsb.h:57
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
uint16_t old_sn
The previous sequence number.
Definition: decomp_scaled_rtp_ts.h:73
void * trace_callback_priv
Definition: decomp_scaled_rtp_ts.h:89
void ts_update_context(struct ts_sc_decomp *const ts_sc, const uint32_t ts, const uint16_t sn)
Store a new timestamp.
Definition: decomp_scaled_rtp_ts.c:84
Window-based Least Significant Bits (W-LSB) decoding.
void d_init_sc(struct ts_sc_decomp *const ts_scaled, rohc_trace_callback2_t trace_cb, void *const trace_cb_priv)
Initialize the scaled RTP Timestamp decoding context.
Definition: decomp_scaled_rtp_ts.c:52
rohc_trace_callback2_t trace_callback
Definition: decomp_scaled_rtp_ts.h:87
uint32_t new_ts_scaled
The last computed or received TS_SCALED value (not validated by CRC)
Definition: decomp_scaled_rtp_ts.h:82
uint32_t ts
Definition: decomp_scaled_rtp_ts.h:64
uint16_t sn
The sequence number (SN)
Definition: decomp_scaled_rtp_ts.h:71
uint32_t ts_stride
The last computed or received TS_STRIDE value (validated by CRC)
Definition: decomp_scaled_rtp_ts.h:53
bool ts_decode_scaled_bits(struct ts_sc_decomp *const ts_sc, const uint32_t ts_scaled_bits, const size_t ts_scaled_bits_nr, uint32_t *const decoded_ts)
Decode timestamp (TS) value with some LSB bits of the TS_SCALED value.
Definition: decomp_scaled_rtp_ts.c:259
ROHC definitions for traces.
uint32_t ts_offset
The last computed or received TS_OFFSET value (validated by CRC)
Definition: decomp_scaled_rtp_ts.h:61
uint32_t ts_deduce_from_sn(struct ts_sc_decomp *const ts_sc, const uint16_t sn)
Deduct timestamp (TS) from Sequence Number (SN)
Definition: decomp_scaled_rtp_ts.c:340
struct rohc_lsb_decode lsb_ts_scaled
The LSB-encoded TS_SCALED value.
Definition: decomp_scaled_rtp_ts.h:58
uint32_t new_ts_offset
The last computed or received TS_OFFSET value (not validated by CRC)
Definition: decomp_scaled_rtp_ts.h:84