1 #ifndef _JPIP_DATABIN_SERVER_H_
2 #define _JPIP_DATABIN_SERVER_H_
25 using namespace jpeg2000;
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) {
93 data_writer.SetCodestream(num_codestream);
94 data_writer.SetDataBinClass(BIN_CLASS);
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;
105 else cache_model.AddToDataBin<BIN_CLASS>(num_codestream, id, segment.
length, last);
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();
136 data_writer.SetCodestream(num_codestream);
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
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
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
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
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
bool eof
true if the end has been reached and the last write operation could not be completed.
Definition: databin_server.h:49
CacheModel cache_model
Cache model of the client.
Definition: databin_server.h:51
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
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
uint64_t length
Length of the data segment.
Definition: file_segment.h:24
int current_idx
Current codestream index.
Definition: databin_server.h:43