ROHC compression/decompression library
Data Structures | Functions | Variables
d_rtp.c File Reference

ROHC decompression context for the RTP profile. More...

#include "d_udp.h"
#include "d_ip.h"
#include "rohc_traces_internal.h"
#include "rohc_bit_ops.h"
#include "rohc_debug.h"
#include "rohc_utils.h"
#include "sdvl.h"
#include "crc.h"
#include "schemes/decomp_scaled_rtp_ts.h"
#include "rohc_decomp_detect_packet.h"
#include "protocols/udp.h"
#include "protocols/rtp.h"
#include <string.h>
#include <assert.h>
Include dependency graph for d_rtp.c:

Data Structures

struct  d_rtp_context
 Define the RTP part of the decompression profile context. More...
 

Functions

static bool d_rtp_create (const struct rohc_decomp_ctxt *const context, struct rohc_decomp_rfc3095_ctxt **const persist_ctxt, struct rohc_decomp_volat_ctxt *const volat_ctxt)
 Create the RTP decompression context. More...
 
static void d_rtp_destroy (struct rohc_decomp_rfc3095_ctxt *const rfc3095_ctxt, const struct rohc_decomp_volat_ctxt *const volat_ctxt)
 Destroy the given RTP context. More...
 
static rohc_packet_t rtp_detect_packet_type (const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_packet, const size_t rohc_length, const size_t large_cid_len)
 Detect the type of ROHC packet for RTP profile. More...
 
static rohc_packet_t rtp_choose_uo1_variant (const struct rohc_decomp_ctxt *const context, const uint8_t *const packet, const size_t rohc_length)
 Choose between UO-1-RTP, UO-1-TS, and UO-1-ID variants. More...
 
static rohc_packet_t rtp_choose_uor2_variant (const struct rohc_decomp_ctxt *const context, const uint8_t *const packet, const size_t rohc_length, const size_t large_cid_len)
 Choose between UOR-2-RTP, UOR-2-TS, and UOR-2-ID variants. More...
 
static int rtp_parse_static_rtp (const struct rohc_decomp_ctxt *const context, const uint8_t *packet, size_t length, struct rohc_extr_bits *const bits)
 Parse the UDP/RTP static part of the ROHC packet. More...
 
static int rtp_parse_dynamic_rtp (const struct rohc_decomp_ctxt *const context, const uint8_t *packet, const size_t length, struct rohc_extr_bits *const bits)
 Parse the UDP/RTP dynamic part of the ROHC packet. More...
 
static int rtp_parse_ext3 (const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_data, const size_t rohc_data_len, const rohc_packet_t packet_type, struct rohc_extr_bits *const bits)
 Parse the extension 3 of the UO-1-ID or UOR-2* packet. More...
 
static bool is_uor2_reparse_required (const rohc_packet_t packet_type, const int are_all_ipv4_rnd)
 Does the UOR-2* packet need to be parsed again? More...
 
static int rtp_parse_rtp_hdr_fields (const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_data, const size_t rohc_data_len, struct rohc_extr_bits *const bits)
 Parse the RTP header flags and fields of extension 3. More...
 
static int rtp_parse_uo_remainder (const struct rohc_decomp_ctxt *const context, const uint8_t *packet, unsigned int length, struct rohc_extr_bits *const bits)
 Parse the UDP/RTP tail of the UO* ROHC packets. More...
 
static bool rtp_decode_values_from_bits (const struct rohc_decomp_ctxt *context, const struct rohc_extr_bits *const bits, struct rohc_decoded_values *const decoded)
 Decode UDP values from extracted bits. More...
 
static int rtp_build_uncomp_rtp (const struct rohc_decomp_ctxt *const context, const struct rohc_decoded_values *const decoded, uint8_t *const dest, const unsigned int payload_len)
 Build an uncompressed UDP/RTP header. More...
 
static void rtp_update_context (struct rohc_decomp_ctxt *const context, const struct rohc_decoded_values *const decoded)
 Update context with decoded UDP/RTP values. More...
 
static bool is_outer_ipv4_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the outer IP header IPv4 wrt context? More...
 
static bool is_outer_ipv4_rnd_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the outer IP header IPv4 and its IP-ID random wrt context? More...
 
static bool is_inner_ipv4_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the inner IP header IPv4 wrt context? More...
 
static bool is_inner_ipv4_rnd_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the inner IP header IPv4 and its IP-ID random wrt context? More...
 

Variables

const struct rohc_decomp_profile d_rtp_profile
 Define the decompression part of the RTP profile as described in the RFC 3095. More...
 

Detailed Description

ROHC decompression context for the RTP profile.

Author
David Moreau from TAS
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org

Function Documentation

static bool d_rtp_create ( const struct rohc_decomp_ctxt *const  context,
struct rohc_decomp_rfc3095_ctxt **const  persist_ctxt,
struct rohc_decomp_volat_ctxt *const  volat_ctxt 
)
static

Create the RTP decompression context.

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
contextThe decompression context
[out]persist_ctxtThe persistent part of the decompression context
[out]volat_ctxtThe volatile part of the decompression context
Returns
true if the RTP context was successfully created, false if a problem occurred
static void d_rtp_destroy ( struct rohc_decomp_rfc3095_ctxt *const  rfc3095_ctxt,
const struct rohc_decomp_volat_ctxt *const  volat_ctxt 
)
static

Destroy the given RTP context.

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
rfc3095_ctxtThe persistent decompression context for the RFC3095 profiles
volat_ctxtThe volatile decompression context
static bool is_inner_ipv4_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const  ctxt)
inlinestatic

Is the inner IP header IPv4 wrt context?

Parameters
ctxtThe generic decompression context
Returns
true if IPv4, false otherwise
static bool is_inner_ipv4_rnd_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const  ctxt)
inlinestatic

Is the inner IP header IPv4 and its IP-ID random wrt context?

Parameters
ctxtThe generic decompression context
Returns
true if IPv4, false otherwise
static bool is_outer_ipv4_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const  ctxt)
inlinestatic

Is the outer IP header IPv4 wrt context?

Parameters
ctxtThe generic decompression context
Returns
true if IPv4, false otherwise
static bool is_outer_ipv4_rnd_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const  ctxt)
inlinestatic

Is the outer IP header IPv4 and its IP-ID random wrt context?

Parameters
ctxtThe generic decompression context
Returns
true if IPv4, false otherwise
static bool is_uor2_reparse_required ( const rohc_packet_t  packet_type,
const int  are_all_ipv4_rnd 
)
inlinestatic

Does the UOR-2* packet need to be parsed again?

When parsing a UOR-2* packet, if RND changes, the packet might need to be parsed again with another UOR-2* packet type in mind:

  • UOR-2-RTP needs to be parsed again as UOR-2-ID or UOR-2-TS if one of the RND flags becomes 0.
  • UOR-2-ID needs to be parsed again as UOR-2-RTP if none of the RND flags is 0 anymore.
  • UOR-2-TS needs to be parsed again as UOR-2-RTP if none of the RND flags is 0 anymore.
Parameters
packet_typeThe packet type
are_all_ipv4_rndWhether all RND values for outer and inner IP headers are set to 1
Returns
Whether packet shall be parsed again or not
static int rtp_build_uncomp_rtp ( const struct rohc_decomp_ctxt *const  context,
const struct rohc_decoded_values *const  decoded,
uint8_t *const  dest,
const unsigned int  payload_len 
)
static

Build an uncompressed UDP/RTP header.

Parameters
contextThe decompression context
decodedThe values decoded from the ROHC header
destThe buffer to store the UDP/RTP header (MUST be at least of sizeof(struct udphdr) + sizeof(struct rtphdr) length)
payload_lenThe length of the UDP/RTP payload
Returns
The length of the next header (ie. the UDP/RTP header), -1 in case of error
static rohc_packet_t rtp_choose_uo1_variant ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  packet,
const size_t  rohc_length 
)
static

Choose between UO-1-RTP, UO-1-TS, and UO-1-ID variants.

This function is useful to choose which packet type to try to parse in the UO-1* families.

Parameters
contextThe decompression context
packetThe ROHC packet
rohc_lengthThe length of the ROHC packet
Returns
The packet type
static rohc_packet_t rtp_choose_uor2_variant ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  packet,
const size_t  rohc_length,
const size_t  large_cid_len 
)
static

Choose between UOR-2-RTP, UOR-2-TS, and UOR-2-ID variants.

This function is useful to choose which packet type to try to decode (may change later, causing a packet reparse) in the UOR-2* family.

Parameters
contextThe decompression context
packetThe ROHC packet
rohc_lengthThe length of the ROHC packet
large_cid_lenThe length of the optional large CID field
Returns
The packet type
static bool rtp_decode_values_from_bits ( const struct rohc_decomp_ctxt context,
const struct rohc_extr_bits *const  bits,
struct rohc_decoded_values *const  decoded 
)
static

Decode UDP values from extracted bits.

The following values are decoded:

  • UDP source port
  • UDP destination port
  • UDP checksum
  • RTP TimeStamp (TS)
  • RTP Marker (M) flag
  • RTP eXtension (R-X) flag
  • RTP Padding (R-P) flag
  • RTP Payload Type (R-PT)
Parameters
contextThe decompression context
bitsThe extracted bits
decodedOUT: The corresponding decoded values
Returns
true if decoding is successful, false otherwise
static rohc_packet_t rtp_detect_packet_type ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  rohc_packet,
const size_t  rohc_length,
const size_t  large_cid_len 
)
static

Detect the type of ROHC packet for RTP profile.

Parameters
contextThe decompression context
rohc_packetThe ROHC packet
rohc_lengthThe length of the ROHC packet
large_cid_lenThe length of the optional large CID field
Returns
The packet type
static int rtp_parse_dynamic_rtp ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *  packet,
const size_t  length,
struct rohc_extr_bits *const  bits 
)
static

Parse the UDP/RTP dynamic part of the ROHC packet.

Parameters
contextThe decompression context
packetThe ROHC packet to parse
lengthThe length of the ROHC packet
bitsOUT: The bits extracted from the ROHC header
Returns
The number of bytes read in the ROHC packet, -1 in case of failure
static int rtp_parse_ext3 ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  rohc_data,
const size_t  rohc_data_len,
const rohc_packet_t  packet_type,
struct rohc_extr_bits *const  bits 
)
static

Parse the extension 3 of the UO-1-ID or UOR-2* packet.

 Extension 3 for RTP profile (5.7.5):

       0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
 1  |  1     1  |  S  |R-TS | Tsc |  I  | ip  | rtp |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 2  |            Inner IP header flags        | ip2 |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 3  |            Outer IP header flags              |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 4  |                      SN                       |  if S = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
4.1 /                      TS                       / 1-4 octets, if R-TS = 1
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 5  /            Inner IP header fields             /  variable,
    |                                               |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 6  |                     IP-ID                     |  2 octets, if I = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 7  /            Outer IP header fields             /  variable,
    |                                               |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |  variable,
 8  /          RTP Header flags and fields          /  if rtp = 1
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+
Parameters
contextThe decompression context
rohc_dataThe ROHC data to parse
rohc_data_lenThe length of the ROHC data to parse
packet_typeThe type of ROHC packet to parse
bitsIN: the bits already found in base header OUT: the bits found in the extension header 3
Returns
The data length read from the ROHC packet, -2 in case packet must be reparsed, -1 in case of error
static int rtp_parse_rtp_hdr_fields ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  rohc_data,
const size_t  rohc_data_len,
struct rohc_extr_bits *const  bits 
)
static

Parse the RTP header flags and fields of extension 3.

 RTP header flags and fields

       0     1     2     3     4     5     6     7
     ..... ..... ..... ..... ..... ..... ..... .....
 1  |   Mode    |R-PT |  M  | R-X |CSRC | TSS | TIS |  if rtp = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 2  | R-P |             RTP PT                      |  if R-PT = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 3  /           Compressed CSRC list                /  if CSRC = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 4  /                  TS_STRIDE                    /  1-4 oct if TSS = 1
     ..... ..... ..... ..... ..... ..... ..... ....
 5  /           TIME_STRIDE (milliseconds)          /  1-4 oct if TIS = 1
     ..... ..... ..... ..... ..... ..... ..... .....
Parameters
contextThe decompression context
rohc_dataThe ROHC data to parse
rohc_data_lenThe length of the ROHC data to parse
bitsIN: the bits already found in base header OUT: the bits found in the extension header 3
Returns
The data length read from the ROHC packet, -1 in case of error
static int rtp_parse_static_rtp ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *  packet,
size_t  length,
struct rohc_extr_bits *const  bits 
)
static

Parse the UDP/RTP static part of the ROHC packet.

Parameters
contextThe decompression context
packetThe ROHC packet to parse
lengthThe length of the ROHC packet
bitsOUT: The bits extracted from the ROHC header
Returns
The number of bytes read in the ROHC packet, -1 in case of failure
static int rtp_parse_uo_remainder ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *  packet,
unsigned int  length,
struct rohc_extr_bits *const  bits 
)
static

Parse the UDP/RTP tail of the UO* ROHC packets.

Parameters
contextThe decompression context
packetThe ROHC packet to parse
lengthThe length of the ROHC packet
bitsOUT: The bits extracted from the ROHC header
Returns
The number of bytes read in the ROHC packet, -1 in case of failure
static void rtp_update_context ( struct rohc_decomp_ctxt *const  context,
const struct rohc_decoded_values *const  decoded 
)
static

Update context with decoded UDP/RTP values.

The following decoded values are updated in context:

  • UDP source port
  • UDP destination port
  • RTP TimeStamp (TS)
  • all other static/dynamic RTP fields
Parameters
contextThe decompression context
decodedThe decoded values to update in the context

Variable Documentation

const struct rohc_decomp_profile d_rtp_profile
Initial value:
=
{
.msn_max_bits = 16,
.detect_pkt_type = rtp_detect_packet_type,
}
bool rfc3095_decomp_decode_bits(const struct rohc_decomp_ctxt *const context, const struct rohc_extr_bits *const bits, const size_t payload_len, struct rohc_decoded_values *const decoded)
Decode values from extracted bits.
Definition: rohc_decomp_rfc3095.c:5604
static bool d_rtp_create(const struct rohc_decomp_ctxt *const context, struct rohc_decomp_rfc3095_ctxt **const persist_ctxt, struct rohc_decomp_volat_ctxt *const volat_ctxt)
Create the RTP decompression context.
Definition: d_rtp.c:172
Definition: rohc.h:217
bool rfc3095_decomp_attempt_repair(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const struct rohc_ts pkt_arrival_time, struct rohc_decomp_crc_corr_ctxt *const crc_corr, struct rohc_extr_bits *const extr_bits)
Attempt a packet/context repair upon CRC failure.
Definition: rohc_decomp_rfc3095.c:5407
uint32_t rohc_decomp_rfc3095_get_sn(const struct rohc_decomp_ctxt *const context)
Get the reference SN value of the context.
Definition: rohc_decomp_rfc3095.c:1354
bool(* rohc_decomp_attempt_repair_t)(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const struct rohc_ts pkt_arrival_time, struct rohc_decomp_crc_corr_ctxt *const crc_corr, void *const extr_bits)
Definition: rohc_decomp_internals.h:386
bool(* rohc_decomp_decode_bits_t)(const struct rohc_decomp_ctxt *const context, const void *const extr_bits, const size_t payload_len, void *const decoded_values)
Definition: rohc_decomp_internals.h:364
static rohc_packet_t rtp_detect_packet_type(const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_packet, const size_t rohc_length, const size_t large_cid_len)
Detect the type of ROHC packet for RTP profile.
Definition: d_rtp.c:328
static void d_rtp_destroy(struct rohc_decomp_rfc3095_ctxt *const rfc3095_ctxt, const struct rohc_decomp_volat_ctxt *const volat_ctxt)
Destroy the given RTP context.
Definition: d_rtp.c:296
bool(* rohc_decomp_new_context_t)(const struct rohc_decomp_ctxt *const context, void **const persist_ctxt, struct rohc_decomp_volat_ctxt *const volat_ctxt)
Definition: rohc_decomp_internals.h:340
bool rfc3095_decomp_parse_pkt(const struct rohc_decomp_ctxt *const context, const struct rohc_buf rohc_packet, const size_t large_cid_len, rohc_packet_t *const packet_type, struct rohc_decomp_crc *const extr_crc, struct rohc_extr_bits *const bits, size_t *const rohc_hdr_len)
Parse one IR, IR-DYN, UO-0, UO-1*, or UOR-2* packet.
Definition: rohc_decomp_rfc3095.c:536
void rfc3095_decomp_update_ctxt(struct rohc_decomp_ctxt *const context, const struct rohc_decoded_values *const decoded, const size_t payload_len, bool *const do_change_mode)
Update context with decoded values.
Definition: rohc_decomp_rfc3095.c:6110
void(* rohc_decomp_free_context_t)(void *const persist_ctxt, const struct rohc_decomp_volat_ctxt *const volat_ctxt)
Definition: rohc_decomp_internals.h:345
bool(* rohc_decomp_parse_pkt_t)(const struct rohc_decomp_ctxt *const context, const struct rohc_buf rohc_packet, const size_t large_cid_len, rohc_packet_t *const packet_type, struct rohc_decomp_crc *const extr_crc, void *const extr_bits, size_t *const rohc_hdr_len)
Definition: rohc_decomp_internals.h:355
rohc_status_t rfc3095_decomp_build_hdrs(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const rohc_packet_t packet_type, const struct rohc_decomp_crc *const extr_crc, const struct rohc_decoded_values *const decoded, const size_t payload_len, struct rohc_buf *const uncomp_hdrs, size_t *const uncomp_hdrs_len)
Build the uncompressed headers.
Definition: rohc_decomp_rfc3095.c:4961
void(* rohc_decomp_update_ctxt_t)(struct rohc_decomp_ctxt *const context, const void *const decoded_values, const size_t payload_len, bool *const do_change_mode)
Definition: rohc_decomp_internals.h:380
rohc_status_t(* rohc_decomp_build_hdrs_t)(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const rohc_packet_t packet_type, const struct rohc_decomp_crc *const extr_crc, const void *const decoded_values, const size_t payload_len, struct rohc_buf *const uncomp_hdrs, size_t *const uncomp_hdrs_len)
Definition: rohc_decomp_internals.h:370

Define the decompression part of the RTP profile as described in the RFC 3095.