OpenJPH Open-source implementation of JPEG2000 Part-15

Loading...
Searching...
No Matches
ojph::stex::packets_handler Class Reference

Interprets new packets, buffers them if needed. More...

`#include <stream_expand_support.h>`

## Public Member Functions
| packets_handler ()
| default constructor
| ~packets_handler ()
| default destructor
void | init (bool quiet, ui32 num_packets, frames_handler *frames)
| call this to initialize packets_handler
rtp_packet * | exchange (rtp_packet *p)
| Call this function to get a packet from the packet chain.
ui32 | get_num_lost_packets () const
| This function provides information about the observed number of lost packets.
void | flush ()
| This function is not used, and therefore it is not clear how to use it.

## Private Member Functions
void | consume_packet ()
| This function sends the packet in in_use (oldest) to frames handler object.

## Private Attributes
bool | quiet
| no informational info is printed when true
rtp_packet * | avail
| start of available packets chain
rtp_packet * | in_use
| start of used packet chain
ui32 | last_seq_num
| the last observed sequence number
ui32 | lost_packets
| number of lost packets – just statistics
frames_handler * | frames
| frames object
ui32 | num_packets
| maximum number of packets in packet_store
rtp_packet * | packet_store
| address of packet memory allocation

## Detailed Description

Interprets new packets, buffers them if needed.

This object primarily attempts to process the RTP packet. The main purpose is to buffer received packets if it is not clear where they fit. It also drops packets if they become old.

This object basically works as follows. The object buffers out-of-order packets, i.e., those with a sequence number higher than expected. Then, the object tries to push these packets when their sequence number comes. Packets are pushed to the frames_handler, using the "push" member function.

The buffer has limited size, when it becomes full, the oldest packet is pushed; this basically means that all missing packets are considered lost.

When a new packet is pushed, the object looks if it has the next packet in its buffer, if so, then it pushes one more packet. It does not attempt to push more than one packet from its buffer, because this might delay picking up the next packet from the operating system network stack.

Packets in the buffer are arranged according to their sequence number.

Definition at line 247 of file stream_expand_support.h.

## Constructor & Destructor Documentation

## ◆ packets_handler()

ojph::stex::packets_handler::packets_handler | ( |  | ) |
| inline

default constructor

Definition at line 253 of file stream_expand_support.h.

References avail, frames, in_use, last_seq_num, lost_packets, num_packets, packet_store, and quiet.

## ◆ ~packets_handler()

ojph::stex::packets_handler::~packets_handler | ( |  | ) |
| inline

default destructor

Definition at line 265 of file stream_expand_support.h.

References packet_store.

## Member Function Documentation

## ◆ consume_packet()

void ojph::stex::packets_handler::consume_packet | ( |  | ) |
| private

This function sends the packet in in_use (oldest) to frames handler object.

Definition at line 221 of file stream_expand_support.cpp.

References avail, frames, in_use, last_seq_num, and ojph::stex::rtp_packet::next.

Referenced by exchange().

## ◆ exchange()

rtp_packet * ojph::stex::packets_handler::exchange | ( | rtp_packet * | p | ) |

Call this function to get a packet from the packet chain.

This function is an input-output function. First time call to this function passes a null pointer, and gets a pointer to use. Subsequent calls passes the pointer that was obtained earlier to get a new pointer. This function supplies one pointer only.

Parameters

  p | a pointer to a packet that was previously obtained by calling this function.

Returns
  returns a pointer to a packet

Definition at line 120 of file stream_expand_support.cpp.

References avail, ojph::stex::clip_seq_num(), consume_packet(), ojph::stex::rtp_packet::get_seq_num(), in_use, ojph::stex::is_greater24(), ojph::stex::is_smaller24(), last_seq_num, lost_packets, ojph::stex::rtp_packet::next, ojph::stex::rtp_packet::num_bytes, and num_packets.

Referenced by main().

## ◆ flush()

void ojph::stex::packets_handler::flush | ( |  | ) |

This function is not used, and therefore it is not clear how to use it.

Definition at line 208 of file stream_expand_support.cpp.

References avail, in_use, and ojph::stex::rtp_packet::next.

## ◆ get_num_lost_packets()

ui32 ojph::stex::packets_handler::get_num_lost_packets | ( |  | ) | const
| inline

This function provides information about the observed number of lost packets.

Returns
  returns number of lost packets up to the time of the call

Definition at line 302 of file stream_expand_support.h.

References lost_packets.

Referenced by main().

## ◆ init()

void ojph::stex::packets_handler::init | ( | bool | quiet,
|  | ui32 | num_packets,
|  | frames_handler * | frames )

call this to initialize packets_handler

This function creates a chain of packets that is for packet re-ordering

Parameters

  quiet | no messages are printed when true – as of this writing the object prints no messages
  num_packets | the number of packets in the chain
  frames | a pointer to the frames_handler object that will be receive the packets

Definition at line 105 of file stream_expand_support.cpp.

References avail, frames, init(), num_packets, packet_store, and quiet.

Referenced by init(), and main().

## Member Data Documentation

## ◆ avail

rtp_packet* ojph::stex::packets_handler::avail
| private

start of available packets chain

Definition at line 320 of file stream_expand_support.h.

Referenced by consume_packet(), exchange(), flush(), init(), and packets_handler().

## ◆ frames

frames_handler* ojph::stex::packets_handler::frames
| private

frames object

Definition at line 324 of file stream_expand_support.h.

Referenced by consume_packet(), init(), and packets_handler().

## ◆ in_use

rtp_packet* ojph::stex::packets_handler::in_use
| private

start of used packet chain

Definition at line 321 of file stream_expand_support.h.

Referenced by consume_packet(), exchange(), flush(), and packets_handler().

## ◆ last_seq_num

ui32 ojph::stex::packets_handler::last_seq_num
| private

the last observed sequence number

Definition at line 322 of file stream_expand_support.h.

Referenced by consume_packet(), exchange(), and packets_handler().

## ◆ lost_packets

ui32 ojph::stex::packets_handler::lost_packets
| private

number of lost packets – just statistics

Definition at line 323 of file stream_expand_support.h.

Referenced by exchange(), get_num_lost_packets(), and packets_handler().

## ◆ num_packets

ui32 ojph::stex::packets_handler::num_packets
| private

maximum number of packets in packet_store

Definition at line 326 of file stream_expand_support.h.

Referenced by exchange(), init(), and packets_handler().

## ◆ packet_store

rtp_packet* ojph::stex::packets_handler::packet_store
| private

address of packet memory allocation

Definition at line 327 of file stream_expand_support.h.

Referenced by init(), packets_handler(), and ~packets_handler().

## ◆ quiet

bool ojph::stex::packets_handler::quiet
| private

no informational info is printed when true

Definition at line 319 of file stream_expand_support.h.

Referenced by init(), and packets_handler().

The documentation for this class was generated from the following files:

- /build/openjph/src/OpenJPH/src/apps/ojph_stream_expand/stream_expand_support.h
- /build/openjph/src/OpenJPH/src/apps/ojph_stream_expand/stream_expand_support.cpp