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.
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.
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.
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.
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.
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.
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.
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.
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?
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.
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.
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.
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.
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.
static bool is_outer_ipv4_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the outer IP header IPv4 wrt context?
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?
static bool is_inner_ipv4_ctxt (const struct rohc_decomp_rfc3095_ctxt *const ctxt)
 Is the inner IP header IPv4 wrt context?
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?

Variables

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

Detailed Description

ROHC decompression context for the RTP profile.

Author:
David Moreau from TAS
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.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:
context The decompression context
[out] persist_ctxt The persistent part of the decompression context
[out] volat_ctxt The 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_ctxt The persistent decompression context for the RFC3095 profiles
volat_ctxt The volatile decompression context
static bool is_inner_ipv4_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const   ctxt  )  [inline, static]

Is the inner IP header IPv4 wrt context?

Parameters:
ctxt The generic decompression context
Returns:
true if IPv4, false otherwise
static bool is_inner_ipv4_rnd_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const   ctxt  )  [inline, static]

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

Parameters:
ctxt The generic decompression context
Returns:
true if IPv4, false otherwise
static bool is_outer_ipv4_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const   ctxt  )  [inline, static]

Is the outer IP header IPv4 wrt context?

Parameters:
ctxt The generic decompression context
Returns:
true if IPv4, false otherwise
static bool is_outer_ipv4_rnd_ctxt ( const struct rohc_decomp_rfc3095_ctxt *const   ctxt  )  [inline, static]

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

Parameters:
ctxt The 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 
) [inline, static]

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_type The packet type
are_all_ipv4_rnd Whether 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:
context The decompression context
decoded The values decoded from the ROHC header
dest The buffer to store the UDP/RTP header (MUST be at least of sizeof(struct udphdr) + sizeof(struct rtphdr) length)
payload_len The 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:
context The decompression context
packet The ROHC packet
rohc_length The 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:
context The decompression context
packet The ROHC packet
rohc_length The length of the ROHC packet
large_cid_len The 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:
context The decompression context
bits The extracted bits
decoded OUT: 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:
context The decompression context
rohc_packet The ROHC packet
rohc_length The length of the ROHC packet
large_cid_len The 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:
context The decompression context
packet The ROHC packet to parse
length The length of the ROHC packet
bits OUT: 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:
context The decompression context
rohc_data The ROHC data to parse
rohc_data_len The length of the ROHC data to parse
packet_type The type of ROHC packet to parse
bits IN: 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:
context The decompression context
rohc_data The ROHC data to parse
rohc_data_len The length of the ROHC data to parse
bits IN: 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:
context The decompression context
packet The ROHC packet to parse
length The length of the ROHC packet
bits OUT: 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:
context The decompression context
packet The ROHC packet to parse
length The length of the ROHC packet
bits OUT: 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:
context The decompression context
decoded The decoded values to update in the context

Variable Documentation

Initial value:

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


Generated on 4 Jul 2018 for ROHC compression/decompression library by  doxygen 1.6.1