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

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

#include "d_rtp.h"
#include "rohc_bit_ops.h"
#include "rohc_traces.h"
#include "rohc_debug.h"
#include "ts_sc_decomp.h"
#include "sdvl.h"
#include "crc.h"
#include <netinet/ip.h>
#include <netinet/udp.h>
Include dependency graph for d_rtp.c:

Defines

#define RTP_CONST_DYN_PART_SIZE   9
 The size (in bytes) of the constant RTP dynamic part.

Functions

unsigned int rtp_detect_ir_size (struct d_context *context, unsigned char *packet, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR header.
unsigned int rtp_detect_ir_dyn_size (struct d_context *context, unsigned char *packet, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR-DYN header.
int rtp_decode_uo_tail_rtp (struct d_generic_context *context, const unsigned char *packet, unsigned int length, unsigned char *dest)
 Decode the UDP/RTP tail of the UO* ROHC packets.
void * d_rtp_create (void)
 Create the RTP decompression context.
int rtp_get_static_part (void)
 Get the size of the static part of an IR packet.
int rtp_decode_static_rtp (struct d_generic_context *context, const unsigned char *packet, unsigned int length, unsigned char *dest)
 Decode the UDP/RTP static part of the ROHC packet.
int rtp_decode_dynamic_rtp (struct d_generic_context *context, const unsigned char *packet, unsigned int length, unsigned char *dest)
 Decode the UDP/RTP dynamic part of the ROHC packet.
int rtp_build_uncompressed_rtp (struct d_generic_context *context, struct d_generic_changes *active, unsigned char *dest, int payload_size)
 Build an uncompressed UDP/RTP header.

Variables

struct d_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>

Define Documentation

#define RTP_CONST_DYN_PART_SIZE   9

The size (in bytes) of the constant RTP dynamic part.

According to RFC3095 section 5.7.7.6: 1 (flags V, P, RX, CC) + 1 (flags M, PT) + 2 (RTP SN) + 4 (RTP TS) + 1 (CSRC list) = 9 bytes

The size of the Generic CSRC list field is considered constant because generic CSRC list is not supported yet and thus 1 byte of zero is used.

Referenced by rtp_decode_dynamic_rtp(), rtp_detect_ir_dyn_size(), and rtp_detect_ir_size().


Function Documentation

void* d_rtp_create ( void  )
int rtp_build_uncompressed_rtp ( struct d_generic_context context,
struct d_generic_changes active,
unsigned char *  dest,
int  payload_size 
)

Build an uncompressed UDP/RTP header.

Parameters:
contextThe generic decompression context
activeThe UDP/RTP header changes
destThe buffer to store the UDP/RTP header (MUST be at least of sizeof(struct udphdr) + sizeof(struct rtphdr) length)
payload_sizeThe length of the UDP/RTP payload
Returns:
The length of the next header (ie. the UDP/RTP header), -1 in case of error

References d_generic_changes::next_header, rohc_debugf, d_generic_context::specific, and d_rtp_context::udp_checksum_present.

Referenced by d_rtp_create().

int rtp_decode_dynamic_rtp ( struct d_generic_context context,
const unsigned char *  packet,
unsigned int  length,
unsigned char *  dest 
)
int rtp_decode_static_rtp ( struct d_generic_context context,
const unsigned char *  packet,
unsigned int  length,
unsigned char *  dest 
)

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

Parameters:
contextThe generic decompression context
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
destThe decoded UDP/RTP header
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References rohc_debugf, rtphdr::ssrc, and udp_decode_static_udp().

Referenced by d_rtp_create().

int rtp_decode_uo_tail_rtp ( struct d_generic_context context,
const unsigned char *  packet,
unsigned int  length,
unsigned char *  dest 
)

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

Parameters:
contextThe generic decompression context
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
destThe decoded UDP/RTP header
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References GET_NEXT_16_BITS, rohc_debugf, d_generic_context::specific, and d_rtp_context::udp_checksum_present.

Referenced by d_rtp_create().

unsigned int rtp_detect_ir_dyn_size ( struct d_context context,
unsigned char *  packet,
unsigned int  plen,
unsigned int  large_cid_len 
)

Find the length of the IR-DYN header.

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


 Basic structure of the IR-DYN packet (5.7.7.2):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         : if for small CIDs and CID != 0
    +---+---+---+---+---+---+---+---+
 2  | 1   1   1   1   1   0   0   0 | IR-DYN packet type
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /     0-2 octets of CID info    / 1-2 octets if for large CIDs
    :                               :
    +---+---+---+---+---+---+---+---+
 4  |            Profile            | 1 octet
    +---+---+---+---+---+---+---+---+
 5  |              CRC              | 1 octet
    +---+---+---+---+---+---+---+---+
    |                               |
 6  /         Dynamic chain         / variable length
    |                               |
    +---+---+---+---+---+---+---+---+
 7  |             SN                | 2 octets if not RTP
    +---+---+---+---+---+---+---+---+
    :                               :
 8  /           Payload             / variable length
    :                               :
     - - - - - - - - - - - - - - - -

The function computes the length of the fields 2 + 4-7, ie. the first byte, the Profile and CRC fields and the dynamic chains (outer and inner IP headers + UDP header + RTP header) and the SN (0 byte in case of RTP).

Parameters:
contextThe decompression context
packetThe IR-DYN packet after the Add-CID byte if present (ie. the field 2 in the figure)
plenThe length of the IR-DYN packet minus the Add-CID byte
large_cid_lenThe size of the large CID field (ie. field 3 in the figure)
Returns:
The length of the IR-DYN header, 0 if an error occurs

References d_generic_detect_ir_dyn_size(), d_sdvalue_size(), rohc_debugf, and RTP_CONST_DYN_PART_SIZE.

unsigned int rtp_detect_ir_size ( struct d_context context,
unsigned char *  packet,
unsigned int  plen,
unsigned int  large_cid_len 
)

Find the length of the IR header.

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


 Basic structure of the IR packet (5.7.7.1):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  |         Add-CID octet         |  if for small CIDs and CID != 0
    +---+---+---+---+---+---+---+---+
 2  | 1   1   1   1   1   1   0 | D |
    +---+---+---+---+---+---+---+---+
    |                               |
 3  /    0-2 octets of CID info     /  1-2 octets if for large CIDs
    |                               |
    +---+---+---+---+---+---+---+---+
 4  |            Profile            |  1 octet
    +---+---+---+---+---+---+---+---+
 5  |              CRC              |  1 octet
    +---+---+---+---+---+---+---+---+
    |                               |
 6  |         Static chain          |  variable length
    |                               |
    +---+---+---+---+---+---+---+---+
    |                               |
 7  |         Dynamic chain         |  present if D = 1, variable length
    |                               |
    +---+---+---+---+---+---+---+---+
 8  |             SN                |  2 octets if not RTP
    +---+---+---+---+---+---+---+---+
    |                               |
 9  |           Payload             |  variable length
    |                               |
     - - - - - - - - - - - - - - - -

The function computes the length of the fields 2 + 4-8, ie. the first byte, the Profile and CRC fields and the static and dynamic chains (outer and inner IP headers + UDP header + RTP header) and the SN (0 byte in case of RTP).

Parameters:
contextThe decompression context
packetThe pointer on the IR packet minus the Add-CID byte (ie. the field 2 in the figure)
plenThe length of the IR packet minus the Add-CID byte
large_cid_lenThe size of the large CID field (ie. field 3 in the figure)
Returns:
The length of the IR header, 0 if an error occurs

References d_generic_detect_ir_size(), d_sdvalue_size(), rohc_debugf, RTP_CONST_DYN_PART_SIZE, and rtp_get_static_part().

int rtp_get_static_part ( void  )

Get the size of the static part of an IR packet.

Returns:
The size of the static part of an IR packet

Referenced by rtp_detect_ir_size().


Variable Documentation

Initial value:

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