ROHC compression/decompression library
|
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>
Functions | |
static bool | c_rtp_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet) |
Create a new RTP context and initialize it thanks to the given IP/UDP/RTP packet. | |
static void | c_rtp_destroy (struct rohc_comp_ctxt *const context) |
Destroy the RTP context. | |
static bool | c_rtp_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet) |
Check if the given packet corresponds to the RTP profile. | |
static bool | rtp_is_udp_port_for_rtp (const struct rohc_comp *const comp, const uint16_t port) |
Check whether the given UDP port is reserved for RTP traffic. | |
static bool | c_rtp_use_udp_port (const struct rohc_comp_ctxt *const context, const unsigned int port) |
Tells if the selected profile uses the RTP port. | |
static bool | c_rtp_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet) |
Check if the IP/UDP/RTP packet belongs to the context. | |
static int | c_rtp_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset) |
Encode an IP/UDP/RTP packet according to a pattern decided by several different factors. | |
static void | rtp_decide_state (struct rohc_comp_ctxt *const context) |
Decide the state that should be used for the next packet compressed with the ROHC RTP profile. | |
static rohc_packet_t | c_rtp_decide_FO_packet (const struct rohc_comp_ctxt *context) |
Decide which packet to send when in First Order (FO) state. | |
static rohc_packet_t | c_rtp_decide_SO_packet (const struct rohc_comp_ctxt *context) |
Decide which packet to send when in Second Order (SO) state. | |
static rohc_ext_t | c_rtp_decide_extension (const struct rohc_comp_ctxt *context) |
Decide what extension shall be used in the UO-1/UO-2 packet. | |
static uint32_t | c_rtp_get_next_sn (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt) |
Determine the SN value for the next packet. | |
static bool | rtp_encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt) |
Encode uncompressed RTP fields. | |
static size_t | rtp_code_static_rtp_part (const struct rohc_comp_ctxt *const context, const unsigned char *const next_header, unsigned char *const dest, const size_t counter) |
Build the static part of the UDP/RTP headers. | |
static size_t | rtp_code_dynamic_rtp_part (const struct rohc_comp_ctxt *const context, const unsigned char *const next_header, unsigned char *const dest, const size_t counter) |
Build the dynamic part of the UDP/RTP headers. | |
static int | 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. | |
Variables | |
struct rohc_comp_profile | c_rtp_profile |
Define the compression part of the RTP profile as described in the RFC 3095. |
ROHC compression context for the RTP profile.
static bool c_rtp_check_context | ( | const struct rohc_comp_ctxt *const | context, |
const struct net_pkt *const | packet | ||
) | [static] |
Check if the IP/UDP/RTP packet belongs to the context.
Conditions are:
All the context but the last one are done by the c_udp_check_context() function.
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context |
packet | The IP/UDP/RTP packet to check |
static bool c_rtp_check_profile | ( | const struct rohc_comp *const | comp, |
const struct net_pkt *const | packet | ||
) | [static] |
Check if the given packet corresponds to the RTP profile.
Conditions are:
This function is one of the functions that must exist in one profile for the framework to work.
comp | The ROHC compressor |
packet | The packet to check |
static bool c_rtp_create | ( | struct rohc_comp_ctxt *const | context, |
const struct net_pkt *const | packet | ||
) | [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.
context | The compression context |
packet | The IP/UDP/RTP packet given to initialize the new context |
static rohc_ext_t c_rtp_decide_extension | ( | const struct rohc_comp_ctxt * | context | ) | [static] |
Decide what extension shall be used in the UO-1/UO-2 packet.
Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.
context | The compression context |
static rohc_packet_t c_rtp_decide_FO_packet | ( | const struct rohc_comp_ctxt * | 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.
context | The compression context |
static rohc_packet_t c_rtp_decide_SO_packet | ( | const struct rohc_comp_ctxt * | 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.
context | The compression context |
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.
context | The RTP compression context to destroy |
static int c_rtp_encode | ( | struct rohc_comp_ctxt *const | context, |
const struct net_pkt *const | uncomp_pkt, | ||
unsigned char *const | rohc_pkt, | ||
const size_t | rohc_pkt_max_len, | ||
rohc_packet_t *const | packet_type, | ||
size_t *const | payload_offset | ||
) | [static] |
Encode an IP/UDP/RTP packet according to a pattern decided by several different factors.
context | The compression context |
uncomp_pkt | The uncompressed packet to encode |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
packet_type | OUT: The type of ROHC packet that is created |
payload_offset | OUT: The offset for the payload in the IP packet |
static uint32_t c_rtp_get_next_sn | ( | const struct rohc_comp_ctxt *const | context, |
const struct net_pkt *const | uncomp_pkt | ||
) | [static] |
Determine the SN value for the next packet.
Profile SN is the 16-bit RTP SN.
context | The compression context |
uncomp_pkt | The uncompressed packet to encode |
static bool c_rtp_use_udp_port | ( | const struct rohc_comp_ctxt *const | context, |
const unsigned int | port | ||
) | [static] |
Tells if the selected profile uses the RTP port.
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context |
port | The port number to check |
static int 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.
context | The compression context |
udp | The UDP header |
rtp | The RTP header |
static size_t rtp_code_dynamic_rtp_part | ( | const struct rohc_comp_ctxt *const | context, |
const unsigned char *const | next_header, | ||
unsigned char *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.
context | The compression context |
next_header | The UDP/RTP headers |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
static size_t rtp_code_static_rtp_part | ( | const struct rohc_comp_ctxt *const | context, |
const unsigned char *const | next_header, | ||
unsigned char *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.
context | The compression context |
next_header | The UDP/RTP headers |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
static void rtp_decide_state | ( | struct rohc_comp_ctxt *const | context | ) | [static] |
Decide the state that should be used for the next packet compressed with the ROHC RTP profile.
The three states are:
context | The compression context |
static bool rtp_encode_uncomp_fields | ( | struct rohc_comp_ctxt *const | context, |
const struct net_pkt *const | uncomp_pkt | ||
) | [static] |
Encode uncompressed RTP fields.
Handle the RTP TS field.
context | The compression context |
uncomp_pkt | The uncompressed packet to encode |
static bool rtp_is_udp_port_for_rtp | ( | const struct rohc_comp *const | comp, |
const uint16_t | port | ||
) | [static] |
Check whether the given UDP port is reserved for RTP traffic.
comp | The compressor |
port | The UDP port to search for |
struct rohc_comp_profile c_rtp_profile |
{ .id = ROHC_PROFILE_RTP, .protocol = ROHC_IPPROTO_UDP, .create = c_rtp_create, .destroy = c_rtp_destroy, .check_profile = c_rtp_check_profile, .check_context = c_rtp_check_context, .encode = c_rtp_encode, .reinit_context = c_generic_reinit_context, .feedback = c_generic_feedback, .use_udp_port = c_rtp_use_udp_port, }
Define the compression part of the RTP profile as described in the RFC 3095.