OpenJPH
Open-source implementation of JPEG2000 Part-15
|
Assumes packets arrive in order. More...
#include <stream_expand_support.h>
Public Member Functions | |
frames_handler () | |
default construction | |
~frames_handler () | |
default destructor | |
void | init (bool quiet, const char *target_name, thds::thread_pool *thread_pool) |
call this function to initialize this object | |
void | push (rtp_packet *p) |
call this function to push rtp_packets to this object | |
void | get_stats (ui32 &total_frames, ui32 &trunc_frames, ui32 &lost_frames) |
call this function to collect statistics about frames | |
bool | flush () |
This function is not used, and therefore it is not clear how to use it. | |
void | increment_num_complete_files () |
other threads call this function to let frames_handler know that processing is done. | |
Private Member Functions | |
void | check_files_in_processing () |
call this function to process stex_file for which processing is complete | |
void | send_to_processing () |
Handles complete/truncated files and send them for storing. | |
Private Attributes | |
bool | quiet |
no informational info is printed when true | |
ui32 | num_threads |
number of threads used for saving | |
const char * | target_name |
target file name template | |
ui32 | num_files |
maximum number of in-flight files. | |
ui32 | last_seq_number |
last observed sequence number | |
ui32 | last_time_stamp |
last observed time stamp | |
ui32 | total_frames |
total number of frames that were observed | |
ui32 | trunc_frames |
truncated frames (because of a packet lostt) | |
ui32 | lost_frames |
frames for which main header was not received | |
stex_file * | files_store |
address for allocated files | |
stex_file * | in_use |
the frame that is being filled with data | |
stex_file * | avail |
available frames structures | |
stex_file * | processing |
frames that are being saved | |
std::atomic_int32_t | num_complete_files |
thds::thread_pool * | thread_pool |
thread pool for processing frames | |
j2k_frame_storer * | storers_store |
address for allocated frame storers | |
Assumes packets arrive in order.
Definition at line 428 of file stream_expand_support.h.
|
inline |
default construction
Definition at line 434 of file stream_expand_support.h.
References avail, files_store, in_use, last_seq_number, last_time_stamp, lost_frames, num_complete_files, num_files, num_threads, processing, quiet, storers_store, target_name, thread_pool, total_frames, and trunc_frames.
ojph::stex::frames_handler::~frames_handler | ( | ) |
default destructor
Definition at line 257 of file stream_expand_support.cpp.
References files_store, and storers_store.
|
private |
call this function to process stex_file for which processing is complete
This function moves stex_file from processing to avail if storing is complete.
Definition at line 405 of file stream_expand_support.cpp.
References avail, ojph::stex::stex_file::done, ojph::stex::stex_file::frame_idx, ojph::stex::stex_file::last_seen_seq, ojph::stex::stex_file::next, num_complete_files, processing, and ojph::stex::stex_file::time_stamp.
bool ojph::stex::frames_handler::flush | ( | ) |
This function is not used, and therefore it is not clear how to use it.
Definition at line 386 of file stream_expand_support.cpp.
References avail, check_files_in_processing(), ojph::mem_outfile::close(), ojph::stex::stex_file::f, in_use, ojph::stex::stex_file::next, and processing.
void ojph::stex::frames_handler::get_stats | ( | ui32 & | total_frames, |
ui32 & | trunc_frames, | ||
ui32 & | lost_frames | ||
) |
call this function to collect statistics about frames
The function just copies collected statistics
total_frames | returns the number of observed total frames |
trunc_frames | returns the number of truncated frames |
lost_frames | returns the number of lost frames – for which the main header payload packet was not received, but time stamp was observed |
Definition at line 377 of file stream_expand_support.cpp.
References lost_frames, total_frames, and trunc_frames.
Referenced by main().
|
inline |
other threads call this function to let frames_handler know that processing is done.
This function basically increment the number of objects that need to be moved from processing to avail.
Definition at line 506 of file stream_expand_support.h.
References num_complete_files.
Referenced by ojph::stex::stex_file::notify_file_completion().
void ojph::stex::frames_handler::init | ( | bool | quiet, |
const char * | target_name, | ||
thds::thread_pool * | thread_pool | ||
) |
call this function to initialize this object
The function just copies collected statistics
quiet | when true, no messages are printed – as of this writing the object prints no messages |
target_name | a template for the saved file names |
thread_pool | a thread pool for processing j2k codestreams (saving) |
Definition at line 266 of file stream_expand_support.cpp.
References avail, ojph::mem_outfile::close(), ojph::stex::stex_file::f, files_store, ojph::thds::thread_pool::get_num_threads(), ojph::stex::stex_file::init(), ojph::stex::j2k_frame_storer::init(), num_files, num_threads, ojph::mem_outfile::open(), quiet, storers_store, target_name, and thread_pool.
Referenced by main().
void ojph::stex::frames_handler::push | ( | rtp_packet * | p | ) |
call this function to push rtp_packets to this object
Packets received by this object has to be sequentially increasing; older packets are ignored. That is, a packet with a sequential number smaller than the last observed sequential number is ignored.
p | returns a pointer to the packet. |
Definition at line 291 of file stream_expand_support.cpp.
References avail, check_files_in_processing(), ojph::stex::clip_seq_num(), ojph::stex::stex_file::done, ojph::stex::stex_file::f, ojph::stex::stex_file::frame_idx, ojph::stex::rtp_packet::get_data(), ojph::stex::rtp_packet::get_data_size(), ojph::stex::rtp_packet::get_packet_type(), ojph::stex::rtp_packet::get_seq_num(), ojph::stex::rtp_packet::get_time_stamp(), in_use, ojph::stex::is_greater32(), ojph::stex::rtp_packet::is_marked(), ojph::stex::is_smaller24(), ojph::stex::is_smaller32(), ojph::stex::stex_file::last_seen_seq, last_seq_number, last_time_stamp, lost_frames, ojph::stex::stex_file::next, ojph::mem_outfile::open(), ojph::stex::rtp_packet::PT_BODY, send_to_processing(), ojph::stex::stex_file::time_stamp, total_frames, trunc_frames, and ojph::mem_outfile::write().
Referenced by ojph::stex::packets_handler::consume_packet().
|
private |
Handles complete/truncated files and send them for storing.
This function moves stex_file from in_use to processing if there are further processors (such as a storer) or to avail if there are no processors.
Definition at line 447 of file stream_expand_support.cpp.
References ojph::thds::thread_pool::add_task(), avail, ojph::mem_outfile::close(), ojph::stex::stex_file::done, ojph::stex::stex_file::f, in_use, ojph::stex::stex_file::next, processing, ojph::stex::stex_file::storer, target_name, and thread_pool.
Referenced by push().
|
private |
available frames structures
Definition at line 541 of file stream_expand_support.h.
Referenced by check_files_in_processing(), flush(), frames_handler(), init(), push(), and send_to_processing().
|
private |
address for allocated files
Definition at line 539 of file stream_expand_support.h.
Referenced by frames_handler(), init(), and ~frames_handler().
|
private |
the frame that is being filled with data
Definition at line 540 of file stream_expand_support.h.
Referenced by flush(), frames_handler(), push(), and send_to_processing().
|
private |
last observed sequence number
Definition at line 534 of file stream_expand_support.h.
Referenced by frames_handler(), and push().
|
private |
last observed time stamp
Definition at line 535 of file stream_expand_support.h.
Referenced by frames_handler(), and push().
|
private |
frames for which main header was not received
Definition at line 538 of file stream_expand_support.h.
Referenced by frames_handler(), get_stats(), and push().
|
private |
Definition at line 544 of file stream_expand_support.h.
Referenced by check_files_in_processing(), frames_handler(), and increment_num_complete_files().
|
private |
maximum number of in-flight files.
Definition at line 533 of file stream_expand_support.h.
Referenced by frames_handler(), and init().
|
private |
number of threads used for saving
Definition at line 531 of file stream_expand_support.h.
Referenced by frames_handler(), and init().
|
private |
frames that are being saved
Definition at line 542 of file stream_expand_support.h.
Referenced by check_files_in_processing(), flush(), frames_handler(), and send_to_processing().
|
private |
no informational info is printed when true
Definition at line 530 of file stream_expand_support.h.
Referenced by frames_handler(), and init().
|
private |
address for allocated frame storers
Definition at line 548 of file stream_expand_support.h.
Referenced by frames_handler(), init(), and ~frames_handler().
|
private |
target file name template
Definition at line 532 of file stream_expand_support.h.
Referenced by frames_handler(), init(), and send_to_processing().
|
private |
thread pool for processing frames
Definition at line 546 of file stream_expand_support.h.
Referenced by frames_handler(), init(), and send_to_processing().
|
private |
total number of frames that were observed
Definition at line 536 of file stream_expand_support.h.
Referenced by frames_handler(), get_stats(), and push().
|
private |
truncated frames (because of a packet lostt)
Definition at line 537 of file stream_expand_support.h.
Referenced by frames_handler(), get_stats(), and push().