OpenJPH
Open-source implementation of JPEG2000 Part-15
|
Interprets new packets, buffers them if needed. More...
#include <stream_expand_support.h>
Public Member Functions | |
packets_handler () | |
default constructor More... | |
~packets_handler () | |
default destructor More... | |
void | init (bool quiet, ui32 num_packets, frames_handler *frames) |
call this to initialize packets_handler More... | |
rtp_packet * | exchange (rtp_packet *p) |
Call this function to get a packet from the packet chain. More... | |
ui32 | get_num_lost_packets () const |
This function provides information about the observed number of lost packets. More... | |
void | flush () |
This function is not used, and therefore it is not clear how to use it. More... | |
Private Member Functions | |
void | consume_packet () |
This function sends the packet in in_use (oldest) to frames handler object. More... | |
Private Attributes | |
bool | quiet |
no informational info is printed when true More... | |
rtp_packet * | avail |
start of available packets chain More... | |
rtp_packet * | in_use |
start of used packet chain More... | |
ui32 | last_seq_num |
the last observed sequence number More... | |
ui32 | lost_packets |
number of lost packets – just statistics More... | |
frames_handler * | frames |
frames object More... | |
ui32 | num_packets |
maximum number of packets in packet_store More... | |
rtp_packet * | packet_store |
address of packet memory allocation More... | |
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.
|
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.
|
inline |
|
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, ojph::stex::rtp_packet::get_seq_num(), in_use, last_seq_num, ojph::stex::rtp_packet::next, and ojph::stex::frames_handler::push().
Referenced by 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.
p | a pointer to a packet that was previously obtained by calling this function. |
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().
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.
|
inline |
This function provides information about the observed number of lost packets.
Definition at line 302 of file stream_expand_support.h.
References lost_packets.
Referenced by main().
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
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(), ojph::stex::rtp_packet::init(), num_packets, packet_store, and quiet.
|
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().
|
private |
frames object
Definition at line 324 of file stream_expand_support.h.
Referenced by consume_packet(), init(), and packets_handler().
|
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().
|
private |
the last observed sequence number
Definition at line 322 of file stream_expand_support.h.
Referenced by consume_packet(), exchange(), and packets_handler().
|
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().
|
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().
|
private |
address of packet memory allocation
Definition at line 327 of file stream_expand_support.h.
Referenced by init(), packets_handler(), and ~packets_handler().
|
private |
no informational info is printed when true
Definition at line 319 of file stream_expand_support.h.
Referenced by init(), and packets_handler().