rtp.c File Reference

Network Adaptation layer for RTP packets. More...

#include <netinet/in.h>
#include "contributors.h"
#include "global.h"
#include "errorconcealment.h"
#include "rtp.h"
#include "fmo.h"
#include "sei.h"
#include "memalloc.h"

Include dependency graph for rtp.c:

Go to the source code of this file.

Functions

int RTPReadPacket (RTPpacket_t *p, int bitstream)
void OpenRTPFile (ImageParameters *p_Img, char *fn)
void CloseRTPFile (ImageParameters *p_Img)
int GetRTPNALU (ImageParameters *p_Img, NALU_t *nalu)
int DecomposeRTPpacket (RTPpacket_t *p)
void DumpRTPHeader (RTPpacket_t *p)


Detailed Description

Network Adaptation layer for RTP packets.

Author:
Main contributors (see contributors.h for copyright, address and affiliation details)

Definition in file rtp.c.


Function Documentation

void CloseRTPFile ( ImageParameters *  p_Img  ) 

Closes the bit stream file.

Definition at line 129 of file rtp.c.

Referenced by initBitsFile().

int DecomposeRTPpacket ( RTPpacket_t *  p  ) 

DecomposeRTPpacket interprets the RTP packet and writes the various structure members of the RTPpacket_t structure.

Returns:
0 in case of success negative error code in case of failure
Parameters:
p Caller is responsible to allocate enough memory for the generated payload in parameter->payload. Typically a malloc of paclen-12 bytes is sufficient
Side effects
none
Date:
30 Spetember 2001
Author:
Stephan Wenger stewe@cs.tu-berlin.de

Definition at line 239 of file rtp.c.

References DumpRTPHeader().

Referenced by RTPReadPacket().

Here is the call graph for this function:

void DumpRTPHeader ( RTPpacket_t *  p  ) 

DumpRTPHeader is a debug tool that dumps a human-readable interpretation of the RTP header.

Returns:
n.a.
Parameters:
p the RTP packet to be dumped, after DecompositeRTPpacket()
Side effects
Debug output to stdout
Date:
30 Spetember 2001
Author:
Stephan Wenger stewe@cs.tu-berlin.de

Definition at line 303 of file rtp.c.

Referenced by DecomposeRTPpacket().

int GetRTPNALU ( ImageParameters *  p_Img,
NALU_t nalu 
)

Fills nalu->buf and nalu->len with the payload of an RTP packet. Other fields in nalu-> remain uninitialized (will be taken care of by NALUtoRBSP.

Returns:
4 in case of ok (for compatibility with GetAnnexbNALU) 0 if there is nothing any more to read (EOF) -1 in case of any error

< triggers sequence number initialization on first call

< store the last RTP sequence number for loss detection

Definition at line 154 of file rtp.c.

References nalu_t::buf, nalu_t::forbidden_bit, nalu_t::len, nalu_t::lost_packets, nalu_t::max_size, MAXRTPPACKETSIZE, nalu_t::nal_reference_idc, nalu_t::nal_unit_type, no_mem_exit(), and RTPReadPacket().

Referenced by initBitsFile().

Here is the call graph for this function:

void OpenRTPFile ( ImageParameters *  p_Img,
char *  fn 
)

Opens the bit stream file named fn.

Returns:
none

Definition at line 113 of file rtp.c.

References error(), errortext, and ET_SIZE.

Referenced by initBitsFile().

Here is the call graph for this function:

int RTPReadPacket ( RTPpacket_t *  p,
int  bitstream 
)

RTPReadPacket reads one packet from file.

A quick guide to the basics of the RTP decoder implementation

This module contains the RTP packetization, de-packetization, and the handling of Parameter Sets, see VCEG-N52 and accompanying documents. Note: Compound packets are not yet implemented!

The interface between every NAL (including the RTP NAL) and the VCL is based on Slices. The slice data structure on which the VCL is working is defined in the type Slice (in defines.h). This type contains the various fields of the slice header and a partition array, which itself contains the data partitions the slice consists of. When data partitioning is not used, then the whole slice bit string is stored in partition #0. When individual partitions are missing, this is indicated by the size of the bit strings in the partition array. A complete missing slice (e.g. if a Full Slice packet was lost) is indicated in a similar way.

part of the slice structure is the error indication (ei-flag). The Ei-flag is set in such cases in which at least one partition of a slice is damaged or missing.When data partitioning is used, it can happen that one partition does not contain any symbols but the ei_flag is cleared, which indicates the intentional missing of symbols of that partition. A typical example for this behaviour is the Intra Slice, which does not have symnbols in its type C partition.

The VCL requests new data to work on through the call of readSliceRTP(). This function calls the main state machine of this module in ReadRTPpaacket().

ReadRTPpacket assumes, when called, that in an error free environment a complete slice, consisting of one Full Slice RTP packet, or three Partition packets of types A, B, C with consecutive sequence numbers, can be read. It first interprets any trailing SUPP and Parameter Update (Header) packets. Then it reads one video data packet. Two cases have to be distinguished:

1. Type A, or Full Slice packet In this case, the PictureID and the macroblock mumbers are used to identify the potential loss of a slice. A slice is lost, when the StartMB of the newly read slice header is not equal to the current state of the decoder 1.1 Loss detected In this case the last packet is unread (fseek back), and a dummy slice containing the missing macroblocks is conveyed to the VCL. At the next call of the NAL, the same packet is read again, but this time no packet loss is detected by the above algorithm, 1.2. No loss In this case it is checked whether a Full Slice packet or a type A data partition was read 1.2.1 Full Slice The Full Slice packet is conveyed to the NAL 1.2.2 Type A Partition The function RTPReadDataPartitionedSlice() is called, which collects the remaining type B, C partitions and handles them appropriately.

Paraneter Update Packets (aka Header packets) are in an SDP-like syntax and are interpreted by a simple parser in the function RTPInterpretParameterSetPacket()

Each Slice header contaions the information on which parameter set to be used. The function RTPSetImgInp() copies the information of the relevant parameter set in the VCL's global variables p_Img-> and p_Inp-> IMPORTANT: any changes in the semantics of the p_Img-> and p_Inp-> structure members must be represented in this function as well!

A note to the stream-buffer data structure: The stream buffer always contains only the contents of the partition in question, and not the slice/partition header. Decoding has to start at bitoffset 0 (CAVLC) or bytreoffset 0 (CABAC).

The remaining functions should be self-explanatory.

Returns:
0: EOF negative: error positive: size of RTP packet in bytes
Parameters:
p packet data structure, with memory for p->packet allocated
bitstream target file
Side effects:
  • File pointer in bits moved
  • p->xxx filled by reading and Decomposepacket()
Date:
04 November, 2001
Author:
Stephan Wenger, stewe@cs.tu-berlin.de

Definition at line 348 of file rtp.c.

References DecomposeRTPpacket(), H264PAYLOADTYPE, H264SSRC, and MAXRTPPACKETSIZE.

Referenced by GetRTPNALU().

Here is the call graph for this function:


Documentation generated with DoxyGen