OpenJPEG 2.1.0

openjpip.h

Go to the documentation of this file.
00001 /*
00002  * $Id: openjpip.h 2835 2014-04-03 15:30:57Z antonin $
00003  *
00004  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
00005  * Copyright (c) 2002-2014, Professor Benoit Macq
00006  * Copyright (c) 2010-2011, Kaori Hagihara
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
00019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028  * POSSIBILITY OF SUCH DAMAGE.
00029  */
00030 
00031 #ifndef         OPENJPIP_H_
00032 # define        OPENJPIP_H_
00033 
00034 #include "session_manager.h"
00035 #include "target_manager.h"
00036 #include "query_parser.h"
00037 #include "msgqueue_manager.h"
00038 #include "sock_manager.h"
00039 #include "auxtrans_manager.h"
00040 
00041 #ifdef SERVER
00042 
00043 #include "fcgi_stdio.h"
00044 #define logstream FCGI_stdout
00045 
00046 #else
00047 
00048 #define FCGI_stdout stdout
00049 #define FCGI_stderr stderr
00050 #define logstream stderr
00051 
00052 #include "cache_manager.h"
00053 #include "byte_manager.h"
00054 #include "imgsock_manager.h"
00055 
00056 #include "metadata_manager.h"
00057 #include "ihdrbox_manager.h"
00058 #include "index_manager.h"
00059 
00060 #endif /*SERVER*/
00061 
00062 /* 
00063  *==========================================================
00064  * JPIP server API
00065  *==========================================================
00066  */
00067  
00068  #ifdef SERVER
00069 
00071 typedef struct server_record{
00072   sessionlist_param_t *sessionlist; 
00073   targetlist_param_t *targetlist;   
00074   auxtrans_param_t auxtrans;
00075 } server_record_t;
00076 
00078 typedef struct QR{
00079   query_param_t *query;             
00080   msgqueue_param_t *msgqueue;       
00081   channel_param_t *channel;         
00082 } QR_t;
00083 
00091 server_record_t * init_JPIPserver( int tcp_auxport, int udp_auxport);
00092 
00098 void terminate_JPIPserver( server_record_t **rec);
00099 
00106 QR_t * parse_querystring( const char *query_string);
00107 
00115 OPJ_BOOL process_JPIPrequest( server_record_t *rec, QR_t *qr);
00116 
00123 void send_responsedata( server_record_t *rec, QR_t *qr);
00124 
00131 void end_QRprocess( server_record_t *rec, QR_t **qr);
00132 
00143 void local_log( OPJ_BOOL query, OPJ_BOOL messages, OPJ_BOOL sessions, OPJ_BOOL targets, QR_t *qr, server_record_t *rec);
00144 
00145 #endif /*SERVER*/
00146 
00147 /* 
00148  *==========================================================
00149  *      JPIP decoding server API
00150  *==========================================================
00151  */
00152 
00153 #ifndef SERVER
00154 
00156 typedef struct dec_server_record{
00157   cachelist_param_t *cachelist; 
00158   Byte_t *jpipstream;           
00159   OPJ_SIZE_T jpipstreamlen;            
00160   msgqueue_param_t *msgqueue;   
00161   SOCKET listening_socket;      
00162 } dec_server_record_t;
00163 
00164 
00166 typedef SOCKET client_t;
00167 
00174 OPJ_API dec_server_record_t * OPJ_CALLCONV init_dec_server( int port);
00175 
00181 OPJ_API void OPJ_CALLCONV terminate_dec_server( dec_server_record_t **rec);
00182 
00189 OPJ_API client_t OPJ_CALLCONV accept_connection( dec_server_record_t *rec);
00190 
00198 OPJ_API OPJ_BOOL OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec);
00199 
00200 #endif /*SERVER*/
00201 
00202 /* 
00203  *==========================================================
00204  *     JPIP tool API
00205  *==========================================================
00206  */
00207 
00208 #ifndef SERVER
00209 
00210 /*
00211  * jpip to JP2 or J2K
00212  */
00213 
00215 typedef struct jpip_dec_param{
00216   Byte_t *jpipstream;                 
00217   Byte8_t jpiplen;                    
00218   msgqueue_param_t *msgqueue;         
00219   metadatalist_param_t *metadatalist; 
00220   ihdrbox_param_t *ihdrbox;           
00221   Byte_t *jp2kstream;                 
00222   Byte8_t jp2klen;                    
00223 } jpip_dec_param_t;
00224 
00231 OPJ_API jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( OPJ_BOOL jp2);
00232 
00238 OPJ_API void OPJ_CALLCONV destroy_jpipdecoder( jpip_dec_param_t **dec);
00239 
00247 OPJ_API OPJ_BOOL OPJ_CALLCONV fread_jpip( const char fname[], jpip_dec_param_t *dec);
00248 
00254 OPJ_API void OPJ_CALLCONV decode_jpip( jpip_dec_param_t *dec);
00255 
00263 OPJ_API OPJ_BOOL OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec);
00264 
00273 OPJ_API void OPJ_CALLCONV output_log( OPJ_BOOL messages, OPJ_BOOL metadata, OPJ_BOOL ihdrbox, jpip_dec_param_t *dec);
00274 
00275 /*
00276  *  test the format of index (cidx) box in JP2 file
00277  */
00278 
00280 typedef index_param_t index_t;
00281 
00288 OPJ_API index_t * OPJ_CALLCONV get_index_from_JP2file( int fd);
00289 
00295 OPJ_API void OPJ_CALLCONV destroy_index( index_t **idx);
00296 
00297 
00303 OPJ_API void OPJ_CALLCONV output_index( index_t *index);
00304 
00305 #endif /*SERVER*/
00306 
00307 #endif /* !OPENJPIP_H_ */