68 return (c > 0u && c <= 0x7FFFFFFFu);
82 return (c >= 0x80000000u && c <= 0xFFFFFFFFu);
108 assert(this->num_packets == 0);
154 while (t->
next != NULL &&
167 else if (t->
next == NULL) {
199 assert(
avail != NULL);
243 int t =
done.fetch_add(-1, std::memory_order_acq_rel);
319 assert(
in_use->
done.load(std::memory_order_acquire) == 0);
412 while(f != NULL && nf > 0)
416 if (f->
done.load(std::memory_order_acquire) == 0)
453 in_use->
done.store(1, std::memory_order_relaxed);
size_t write(const void *ptr, size_t size) override
Call this function to write data to the memory file.
void open(size_t initial_size=65536, bool clear_mem=false)
Call this function to open a memory file.
Assumes packets arrive in order.
ui32 num_threads
number of threads used for saving
j2k_frame_storer * storers_store
address for allocated frame storers
ui32 total_frames
total number of frames that were observed
stex_file * in_use
the frame that is being filled with data
void push(rtp_packet *p)
call this function to push rtp_packets to this object
bool flush()
This function is not used, and therefore it is not clear how to use it.
void get_stats(ui32 &total_frames, ui32 &trunc_frames, ui32 &lost_frames)
call this function to collect statistics about frames
stex_file * processing
frames that are being saved
stex_file * avail
available frames structures
ui32 last_time_stamp
last observed time stamp
ui32 last_seq_number
last observed sequence number
ui32 trunc_frames
truncated frames (because of a packet lostt)
void check_files_in_processing()
call this function to process stex_file for which processing is complete
void increment_num_complete_files()
other threads call this function to let frames_handler know that processing is done.
~frames_handler()
default destructor
void send_to_processing()
Handles complete/truncated files and send them for storing.
ui32 lost_frames
frames for which main header was not received
void init(bool quiet, const char *target_name, thds::thread_pool *thread_pool)
call this function to initialize this object
const char * target_name
target file name template
thds::thread_pool * thread_pool
thread pool for processing frames
bool quiet
no informational info is printed when true
std::atomic_int32_t num_complete_files
ui32 num_files
maximum number of in-flight files.
stex_file * files_store
address for allocated files
rtp_packet * packet_store
address of packet memory allocation
rtp_packet * exchange(rtp_packet *p)
Call this function to get a packet from the packet chain.
frames_handler * frames
frames object
void consume_packet()
This function sends the packet in in_use (oldest) to frames handler object.
bool quiet
no informational info is printed when true
ui32 num_packets
maximum number of packets in packet_store
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
void flush()
This function is not used, and therefore it is not clear how to use it.
rtp_packet * avail
start of available packets chain
void init(bool quiet, ui32 num_packets, frames_handler *frames)
call this to initialize packets_handler
Implements a pool of threads, and can queue tasks.
void add_task(worker_thread_base *task)
Adds a task to the thread pool.
size_t get_num_threads()
Returns the number of threads in the thread pool.
static bool is_smaller32(ui32 a, ui32 b)
static bool is_smaller24(ui32 a, ui32 b)
static bool is_greater32(ui32 a, ui32 b)
static bool is_greater24(ui32 a, ui32 b)
static ui32 clip_seq_num(ui32 n)
Saves a j2k frame to disk without decoding.
void init(stex_file *file, const char *name_template)
call this function to initialize its members
inteprets RTP header and payload, and holds received packets.
ui32 num_bytes
number of bytes
rtp_packet * next
used for linking packets
void init(rtp_packet *next)
Call this to link packets.
holds in memory j2k codestream together with other info
frames_handler * parent
the object holding this frame
ojph::mem_outfile f
holds in-memory j2k codestream
ui32 frame_idx
frame number in the sequence
void init(frames_handler *parent, stex_file *next, j2k_frame_storer *storer, const char *name_template)
call this function to initialize stex_file
void notify_file_completion()
other threads can call this function to signal completion of processing.
ui32 last_seen_seq
the last seen RTP sequence number
stex_file * next
used to create files chain
ui32 time_stamp
time stamp at which this file must be displayed
std::atomic_int done
saving is completed when 0 is reached
j2k_frame_storer * storer
stores a j2k frame using another thread