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/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 void d_rtp_destroy (void *const context)
 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 unsigned char *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 unsigned char *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_uo_remainder (const struct rohc_decomp_ctxt *const context, const unsigned char *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 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 decoded, unsigned char *dest, const unsigned int payload_len)
 Build an uncompressed UDP/RTP header.
static void rtp_update_context (const struct rohc_decomp_ctxt *context, const struct rohc_decoded_values decoded)
 Update context with decoded UDP/RTP values.
static bool is_outer_ipv4_ctxt (const struct d_generic_context *const ctxt)
 Is the outer IP header IPv4 wrt context?
static bool is_outer_ipv4_rnd_ctxt (const struct d_generic_context *const ctxt)
 Is the outer IP header IPv4 and its IP-ID random wrt context?
static bool is_inner_ipv4_ctxt (const struct d_generic_context *const ctxt)
 Is the inner IP header IPv4 wrt context?
static bool is_inner_ipv4_rnd_ctxt (const struct d_generic_context *const ctxt)
 Is the inner IP header IPv4 and its IP-ID random wrt context?
void * d_rtp_create (const struct rohc_decomp_ctxt *const context)
 Create the RTP decompression 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

void* d_rtp_create ( const struct rohc_decomp_ctxt *const  context)

Create the RTP decompression context.

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

Returns:
The newly-created RTP decompression context
static void d_rtp_destroy ( void *const  context) [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:
contextThe RTP compression context to destroy
static bool is_inner_ipv4_ctxt ( const struct d_generic_context *const  ctxt) [inline, static]

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 d_generic_context *const  ctxt) [inline, static]

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 d_generic_context *const  ctxt) [inline, static]

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 d_generic_context *const  ctxt) [inline, static]

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 
) [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_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  decoded,
unsigned char *  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  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 unsigned char *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_static_rtp ( const struct rohc_decomp_ctxt *const  context,
const unsigned char *  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 unsigned char *  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 ( const struct rohc_decomp_ctxt context,
const struct rohc_decoded_values  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

Initial value:
{
        .id              = ROHC_PROFILE_RTP, 
        .new_context     = d_rtp_create,
        .free_context    = d_rtp_destroy,
        .decode          = d_generic_decode,
        .detect_pkt_type = rtp_detect_packet_type,
        .get_sn          = d_generic_get_sn,
}

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