1 #ifndef _JPIP_DATABIN_SERVER_H_
2 #define _JPIP_DATABIN_SERVER_H_
72 template<
int BIN_CLASS>
int WriteSegment(
int num_codestream,
int id,
FileSegment segment,
int offset = 0,
bool last =
true)
74 int cached = cache_model.
GetDataBin<BIN_CLASS>(num_codestream, id);
75 int res = 1, seg_cached = cached - offset;
77 if((cached != INT_MAX) && (((int)segment.
length - seg_cached) >= 0)) {
78 int free = data_writer.
GetFree() - MINIMUM_SPACE;
87 if((
int)segment.
length > free) {
99 int idx = range.
GetIndex(num_codestream);
100 if((
int)files.size() <= idx)
return -1;
101 file_ptr = files[idx];
104 if(!data_writer.
Write(
id, cached, *file_ptr, segment, last)) res = -1;
126 int res = 1, seg_cached = cached - offset;
128 if((cached != INT_MAX) && (((int)place_holder.
length() - seg_cached) > 0)) {
129 int free = data_writer.
GetFree() - MINIMUM_SPACE - place_holder.
length();
139 if(!data_writer.
WritePlaceHolder(
id, cached, *file, place_holder, last)) res = -1;
184 bool SetRequest(
const Request& req);
197 bool GenerateChunk(
char *buff,
int *len,
bool *last);
Range range
Range of codestreams.
Definition: databin_server.h:38
Class derived from the HTTP Request class that contains the required code for properly analyzing a JP...
Definition: request.h:31
WOI woi
Current WOI.
Definition: databin_server.h:36
int GetFree() const
Returns the number of bytes available.
Definition: databin_writer.h:195
File::Ptr file
Pointer to the associated image file.
Definition: databin_server.h:42
bool metareq
true if the last request contained a "metareq"
Definition: databin_server.h:40
The cache model of a JPIP client is handled using this class.
Definition: cache_model.h:38
Contains a set of classes to easy the handling of data and files, as well as the serialization.
Definition: data.h:9
DataBinWriter data_writer
Data-bin writer for generating the chunks.
Definition: databin_server.h:55
Class that identifies a WOI (Window Of Interest).
Definition: woi.h:24
Identifies a data segment of a file.
Definition: file_segment.h:20
FileSegment & RemoveFirst(int count)
Removes the first bytes of the segment.
Definition: file_segment.h:80
Class used to generate data-bin segments and write them into a memory buffer.
Definition: databin_writer.h:28
Contains the information of a place-holder.
Definition: place_holder.h:18
bool end_woi() const
Returns true if the end of the WOI has been reached, that is, there is not more associated packets to...
Definition: databin_server.h:165
DataBinWriter & Write(uint64_t bin_id, uint64_t bin_offset, const File &file, const FileSegment &segment, bool last_byte=false)
Writes a data-bin segment into the buffer.
Definition: databin_writer.cc:71
int GetIndex(int item) const
Returns the index of an item of the range.
Definition: range.h:94
bool end_woi_
true if the WOI has been completely sent
Definition: databin_server.h:41
virtual ~DataBinServer()
Definition: databin_server.h:199
int pending
Number of pending bytes.
Definition: databin_server.h:37
ImageIndex::Ptr im_index
Pointer to the associated image index.
Definition: databin_server.h:54
DataBinServer()
Initializes the obect.
Definition: databin_server.h:152
Class identifier for meta-data data-bins.
Definition: jpip.h:58
int WritePlaceHolder(int num_codestream, int id, const PlaceHolder &place_holder, int offset=0, bool last=false)
Writes a new place-holder segment, only if it is possible to write it completely. ...
Definition: databin_server.h:123
int GetDataBin(int num_codestream, int id)
Returns the amount of a data-bin item using the class DataBinSelector.
Definition: cache_model.h:355
DataBinWriter & SetDataBinClass(int databin_class)
Sets the current data-bin class.
Definition: databin_writer.h:143
Represents a range of integer values, defined by two values, first and last, which are assumed to be ...
Definition: range.h:20
WOIComposer woi_composer
WOI composer for determining the packets.
Definition: databin_server.h:53
int length() const
Returns the length of the place-holder.
Definition: place_holder.h:91
list< ImageIndex >::iterator Ptr
Pointer of an object of this class.
Definition: image_index.h:118
Contains the core functionality of a (JPIP) data-bin server, which maintains a cache model and is cap...
Definition: databin_server.h:33
Set of classes for handling (reading and indexing) image files with the format defined in the Part 1 ...
Definition: codestream_index.h:10
bool eof
true if the end has been reached and the last write operation could not be completed.
Definition: databin_server.h:49
DataBinWriter & SetCodestream(int value)
Sets the current codestream.
Definition: databin_writer.h:131
CacheModel cache_model
Cache model of the client.
Definition: databin_server.h:51
int AddToDataBin(int num_codestream, int id, int amount, bool complete=false)
Increases the amount of a data-bin item using the class DataBinSelector.
Definition: cache_model.h:370
vector< File::Ptr > files
List of files (for hyperlinked JPX files)
Definition: databin_server.h:52
By means of this class it is possible to find out the which packets of an image are associated to a W...
Definition: woi_composer.h:27
bool has_woi
true if the last request contained a WOI
Definition: databin_server.h:39
Set of classes related to the JPIP protocol, defined in the Part 9 of the JPEG2000 standard...
Definition: cache_model.h:13
int WriteSegment(int num_codestream, int id, FileSegment segment, int offset=0, bool last=true)
Writes a new data-bin segment or a part of it that is not already cached.
Definition: databin_server.h:72
SHARED_PTR< BaseFile< LockedAccess > > Ptr
Safe pointer to this class.
Definition: file.h:114
DataBinWriter & WritePlaceHolder(uint64_t bin_id, uint64_t bin_offset, const File &file, const PlaceHolder &place_holder, bool last_byte=false)
Writes a place-holder segment into the buffer.
Definition: databin_writer.cc:95
uint64_t length
Length of the data segment.
Definition: file_segment.h:24
int current_idx
Current codestream index.
Definition: databin_server.h:43