changed parameter and file names regarding JPT-stream to JPIP-stream, which handles...
[openjpeg.git] / applications / jpip / libopenjpip / msgqueue_manager.h
1 /*
2  * $Id: msgqueue_manager.h 53 2011-05-09 16:55:39Z kaori $
3  *
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
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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.
17  *
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.
29  */
30
31 #ifndef         MSGQUEUE_MANAGER_H_
32 # define        MSGQUEUE_MANAGER_H_
33
34 #include <stdio.h>
35 #include "bool.h"
36 #include "byte_manager.h"
37 #include "target_manager.h"
38 #include "placeholder_manager.h"
39
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
48   Byte8_t aux;                //!<
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
52 } message_param_t;
53
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
60 } msgqueue_param_t;
61
62 /**
63  * generate message queue
64  *
65  * @param[in] stateless if this is a stateless message queue
66  * @param[in] target    reference target pointer
67  * @return generated message queue pointer
68  */
69 msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target);
70
71 /**
72  * delete message queue
73  *
74  * @param[in] msgqueue address of the message queue pointer
75  */
76 void delete_msgqueue( msgqueue_param_t **msgqueue);
77
78 /**
79  * print message queue
80  *
81  * @param[in] msgqueue message queue pointer
82  */
83 void print_msgqueue( msgqueue_param_t *msgqueue);
84
85
86 /**
87  * enqueue main header data-bin into message queue
88  *
89  * @param[in,out] msgqueue message queue pointer
90  */
91 void enqueue_mainheader( msgqueue_param_t *msgqueue);
92
93
94 /**
95  * enqueue tile data-bin into message queue
96  *
97  * @param[in]     tile_id  tile id starting from 0
98  * @param[in]     level    decomposition level
99  * @param[in,out] msgqueue message queue pointer
100  */
101 void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue);
102
103
104 /**
105  * enqueue Metadata-bin into message queue
106  *
107  * @param[in]     meta_id  metadata-bin id
108  * @param[in,out] msgqueue message queue pointer
109  */
110 void enqueue_metadata( int meta_id, msgqueue_param_t *msgqueue);
111
112
113 /**
114  * emit stream from message queue
115  *
116  * @param[in] msgqueue message queue pointer
117  */
118 void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue);
119
120
121 /**
122  * parse JPT- JPP- stream to message queue
123  *
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
128  */
129 void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue);
130
131 /**
132  * parse JPT- JPP- stream to message queue
133  *
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
138  */
139 void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist);
140
141
142 /**
143  * reconstruct j2k codestream from message queue
144  *
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
151  */
152 Byte_t * recons_j2k( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t csn, int minlev, Byte8_t *j2klen);
153
154
155 /**
156  * reconstruct jp2 file codestream from message queue
157  *
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
163  */
164 Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t csn, Byte8_t *jp2len);
165
166
167 #endif      /* !MSGQUEUE_MANAGER_H_ */