2 * $Id: msgqueue_manager.h 53 2011-05-09 16:55:39Z kaori $
4 * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
5 * Copyright (c) 2002-2011, Professor Benoit Macq
6 * Copyright (c) 2010-2011, Kaori Hagihara
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef MSGQUEUE_MANAGER_H_
32 # define MSGQUEUE_MANAGER_H_
36 #include "byte_manager.h"
37 #include "target_manager.h"
38 #include "placeholder_manager.h"
40 //! message parameters
41 typedef struct message_param{
42 bool last_byte; //!< if message contains the last byte of the data-bin
43 Byte8_t in_class_id; //!< in-class identifier A.2.3
44 Byte8_t class_id; //!< class identifiers
45 Byte8_t csn; //!< index of the codestream
46 Byte8_t bin_offset; //!< offset of the data in this message from the start of the data-bin
47 Byte8_t length; //!< message byte length
49 Byte8_t res_offset; //!< offset in the resource
50 placeholder_param_t *phld; //!< placeholder pointer in index
51 struct message_param *next; //!< pointer to the next message
54 //! message queue parameters
55 typedef struct msgqueue_param{
56 message_param_t *first; //!< first message pointer of the list
57 message_param_t *last; //!< last message pointer of the list
58 bool stateless; //!< if this is a stateless message queue
59 target_param_t *target; //!< reference target pointer
63 * generate message queue
65 * @param[in] stateless if this is a stateless message queue
66 * @param[in] target reference target pointer
67 * @return generated message queue pointer
69 msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target);
72 * delete message queue
74 * @param[in] msgqueue address of the message queue pointer
76 void delete_msgqueue( msgqueue_param_t **msgqueue);
81 * @param[in] msgqueue message queue pointer
83 void print_msgqueue( msgqueue_param_t *msgqueue);
87 * enqueue main header data-bin into message queue
89 * @param[in,out] msgqueue message queue pointer
91 void enqueue_mainheader( msgqueue_param_t *msgqueue);
95 * enqueue tile data-bin into message queue
97 * @param[in] tile_id tile id starting from 0
98 * @param[in] level decomposition level
99 * @param[in,out] msgqueue message queue pointer
101 void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue);
105 * enqueue Metadata-bin into message queue
107 * @param[in] meta_id metadata-bin id
108 * @param[in,out] msgqueue message queue pointer
110 void enqueue_metadata( int meta_id, msgqueue_param_t *msgqueue);
114 * emit stream from message queue
116 * @param[in] msgqueue message queue pointer
118 void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue);
122 * parse JPT- JPP- stream to message queue
124 * @param[in] JPIPstream JPT- JPP- stream data pointer
125 * @param[in] streamlen JPIPstream length
126 * @param[in] offset offset of the stream from the whole beginning
127 * @param[in,out] msgqueue adding message queue pointer
129 void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue);
132 * parse JPT- JPP- stream to message queue
134 * @param[in] msgqueue reference message queue pointer
135 * @param[in] stream stream data pointer
136 * @param[in] streamlen stream length
137 * @param[in] metadatalist adding metadata list pointer
139 void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist);
143 * reconstruct j2k codestream from message queue
145 * @param[in] msgqueue message queue pointer
146 * @param[in] stream original stream
147 * @param[in] csn codestream number
148 * @param[in] minlev minimum decomposition level
149 * @param[out] j2klen pointer to the j2k codestream length
150 * @return generated reconstructed j2k codestream
152 Byte_t * recons_j2k( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t csn, int minlev, Byte8_t *j2klen);
156 * reconstruct jp2 file codestream from message queue
158 * @param[in] msgqueue message queue pointer
159 * @param[in] stream original stream
160 * @param[in] csn codestream number
161 * @param[out] jp2len pointer to the jp2 codestream length
162 * @return generated reconstructed jp2 codestream
164 Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t csn, Byte8_t *jp2len);
167 #endif /* !MSGQUEUE_MANAGER_H_ */