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

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

#include "c_rtp.h"
#include "c_udp.h"
#include "rohc_traces_internal.h"
#include "rohc_packets.h"
#include "rohc_utils.h"
#include "sdvl.h"
#include "crc.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Include dependency graph for c_rtp.c:

Functions

static bool c_rtp_create (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Create a new RTP context and initialize it thanks to the given IP/UDP/RTP packet. More...
 
static void c_rtp_destroy (struct rohc_comp_ctxt *const context)
 Destroy the RTP context. More...
 
static int c_rtp_encode (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
 Encode an IP/UDP/RTP packet according to a pattern decided by several different factors. More...
 
static rohc_packet_t c_rtp_decide_FO_packet (const struct rohc_comp_ctxt *const context)
 Decide which packet to send when in First Order (FO) state. More...
 
static rohc_packet_t c_rtp_decide_SO_packet (const struct rohc_comp_ctxt *const context)
 Decide which packet to send when in Second Order (SO) state. More...
 
static rohc_packet_t c_rtp_decide_UOR2_pkt (const struct rohc_comp_ctxt *const ctxt, const size_t nr_ipv4_non_rnd, const size_t nr_ipv4_non_rnd_with_bits)
 Decide which UOR2* packet to send. More...
 
static rohc_ext_t c_rtp_decide_extension (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type)
 Decide what extension shall be used in the UO-1-ID/UOR-2 packet. More...
 
static uint32_t c_rtp_get_next_sn (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Determine the SN value for the next packet. More...
 
static bool rtp_encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Encode uncompressed RTP fields. More...
 
static size_t rtp_code_static_rtp_part (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
 Build the static part of the UDP/RTP headers. More...
 
static size_t rtp_code_dynamic_rtp_part (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
 Build the dynamic part of the UDP/RTP headers. More...
 
static void rtp_changed_rtp_dynamic (const struct rohc_comp_ctxt *const context, const struct udphdr *const udp, const struct rtphdr *const rtp)
 Check if the dynamic part of the UDP/RTP headers changed. More...
 

Variables

const struct rohc_comp_profile c_rtp_profile
 Define the compression part of the RTP profile as described in the RFC 3095. More...
 

Detailed Description

ROHC compression 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

◆ c_rtp_create()

static bool c_rtp_create ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

Create a new RTP context and initialize it thanks to the given IP/UDP/RTP packet.

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

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to initialize the new context
Returns
true if successful, false otherwise

◆ c_rtp_decide_extension()

static rohc_ext_t c_rtp_decide_extension ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type 
)
static

Decide what extension shall be used in the UO-1-ID/UOR-2 packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
packet_typeThe type of ROHC packet that is created
Returns
The extension code among ROHC_EXT_NO, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3 if successful, ROHC_EXT_UNKNOWN otherwise

◆ c_rtp_decide_FO_packet()

static rohc_packet_t c_rtp_decide_FO_packet ( const struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in First Order (FO) state.

Packets that can be used are the IR-DYN and UO-2 packets.

See also
decide_packet
Parameters
contextThe compression context
Returns
The packet type among:
  • ROHC_PACKET_UOR_2_RTP
  • ROHC_PACKET_UOR_2_TS
  • ROHC_PACKET_UOR_2_ID
  • ROHC_PACKET_IR_DYN

◆ c_rtp_decide_SO_packet()

static rohc_packet_t c_rtp_decide_SO_packet ( const struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in Second Order (SO) state.

Packets that can be used are the UO-0, UO-1 and UO-2 (with or without extensions) packets.

See also
decide_packet
Parameters
contextThe compression context
Returns
The packet type among:
  • ROHC_PACKET_UO_0
  • ROHC_PACKET_UO_1_RTP
  • ROHC_PACKET_UO_1_TS
  • ROHC_PACKET_UO_1_ID
  • ROHC_PACKET_UOR_2_RTP
  • ROHC_PACKET_UOR_2_TS
  • ROHC_PACKET_UOR_2_ID
  • ROHC_PACKET_IR_DYN

◆ c_rtp_decide_UOR2_pkt()

static rohc_packet_t c_rtp_decide_UOR2_pkt ( const struct rohc_comp_ctxt *const  ctxt,
const size_t  nr_ipv4_non_rnd,
const size_t  nr_ipv4_non_rnd_with_bits 
)
static

Decide which UOR2* packet to send.

See also
decide_packet
Parameters
ctxtThe compression context
nr_ipv4_non_rndThe nr of IPv4 headers with non-random IP-ID
nr_ipv4_non_rnd_with_bitsThe nr of IPv4 headers with non-random IP-ID and some IP-ID bits to transmit
Returns
The packet type among:
  • ROHC_PACKET_UOR_2_RTP
  • ROHC_PACKET_UOR_2_TS
  • ROHC_PACKET_UOR_2_ID

◆ c_rtp_destroy()

static void c_rtp_destroy ( struct rohc_comp_ctxt *const  context)
static

Destroy the 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

◆ c_rtp_encode()

static int c_rtp_encode ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type 
)
static

Encode an IP/UDP/RTP packet according to a pattern decided by several different factors.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeOUT: The type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ c_rtp_get_next_sn()

static uint32_t c_rtp_get_next_sn ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

Determine the SN value for the next packet.

Profile SN is the 16-bit RTP SN.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
Returns
The SN

◆ rtp_changed_rtp_dynamic()

static void rtp_changed_rtp_dynamic ( const struct rohc_comp_ctxt *const  context,
const struct udphdr *const  udp,
const struct rtphdr *const  rtp 
)
static

Check if the dynamic part of the UDP/RTP headers changed.

Parameters
contextThe compression context
udpThe UDP header
rtpThe RTP header

◆ rtp_code_dynamic_rtp_part()

static size_t rtp_code_dynamic_rtp_part ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter 
)
static

Build the dynamic part of the UDP/RTP headers.

 Dynamic part of UDP header (5.7.7.5):

    +---+---+---+---+---+---+---+---+
 1  /           Checksum            /   2 octets
    +---+---+---+---+---+---+---+---+

 Dynamic part of RTP header (5.7.7.6):

    +---+---+---+---+---+---+---+---+
 2  |  V=2  | P | RX|      CC       |  (RX is NOT the RTP X bit)
    +---+---+---+---+---+---+---+---+
 3  | M |            PT             |
    +---+---+---+---+---+---+---+---+
 4  /      RTP Sequence Number      /  2 octets
    +---+---+---+---+---+---+---+---+
 5  /   RTP Timestamp (absolute)    /  4 octets
    +---+---+---+---+---+---+---+---+
 6  /      Generic CSRC list        /  variable length
    +---+---+---+---+---+---+---+---+
 7  : Reserved  | X |  Mode |TIS|TSS:  if RX = 1
    +---+---+---+---+---+---+---+---+
 8  :         TS_Stride             :  1-4 octets, if TSS = 1
    +---+---+---+---+---+---+---+---+
 9  :         Time_Stride           :  1-4 octets, if TIS = 1
    +---+---+---+---+---+---+---+---+

Parts 6 & 9 are not supported yet. The TIS flag in part 7 is not supported.

Parameters
contextThe compression context
next_headerThe UDP/RTP headers
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer

◆ rtp_code_static_rtp_part()

static size_t rtp_code_static_rtp_part ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter 
)
static

Build the static part of the UDP/RTP headers.

 Static part of UDP header (5.7.7.5):

    +---+---+---+---+---+---+---+---+
 1  /          Source Port          /   2 octets
    +---+---+---+---+---+---+---+---+
 2  /       Destination Port        /   2 octets
    +---+---+---+---+---+---+---+---+

 Static part of RTP header (5.7.7.6):

    +---+---+---+---+---+---+---+---+
 3  /             SSRC              /   4 octets
    +---+---+---+---+---+---+---+---+

Parts 1 & 2 are done by the udp_code_static_udp_part() function. Part 3 is done by this function.

Parameters
contextThe compression context
next_headerThe UDP/RTP headers
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer
See also
udp_code_static_udp_part

◆ rtp_encode_uncomp_fields()

static bool rtp_encode_uncomp_fields ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

Encode uncompressed RTP fields.

Handle the RTP TS field.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
Returns
true in case of success, false otherwise

Variable Documentation

◆ c_rtp_profile

const struct rohc_comp_profile c_rtp_profile
Initial value:
=
{
.create = c_rtp_create,
.destroy = c_rtp_destroy,
.encode = c_rtp_encode,
}
static bool c_rtp_create(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
Create a new RTP context and initialize it thanks to the given IP/UDP/RTP packet. ...
Definition: c_rtp.c:112
Definition: rohc_profiles.h:83
bool rohc_comp_rfc3095_feedback(struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
Update the profile when feedback is received.
Definition: rohc_comp_rfc3095.c:756
static int c_rtp_encode(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
Encode an IP/UDP/RTP packet according to a pattern decided by several different factors.
Definition: c_rtp.c:656
static void c_rtp_destroy(struct rohc_comp_ctxt *const context)
Destroy the RTP context.
Definition: c_rtp.c:203

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