added cachemodel_manager, which had been managed in target_manager previously
This commit is contained in:
parent
ef258914b2
commit
0310cbad0a
|
@ -5,6 +5,9 @@ What's New for OpenJPIP
|
||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
|
August 24, 2011
|
||||||
|
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||||
|
|
||||||
August 16, 2011
|
August 16, 2011
|
||||||
* [antonin] fixed cmake support for openjpip
|
* [antonin] fixed cmake support for openjpip
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "cachemodel_manager.h"
|
||||||
|
#include "faixbox_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif //SERVER
|
||||||
|
|
||||||
|
|
||||||
|
cachemodellist_param_t * gene_cachemodellist()
|
||||||
|
{
|
||||||
|
cachemodellist_param_t *cachemodellist;
|
||||||
|
|
||||||
|
cachemodellist = (cachemodellist_param_t *)malloc( sizeof(cachemodellist_param_t));
|
||||||
|
|
||||||
|
cachemodellist->first = NULL;
|
||||||
|
cachemodellist->last = NULL;
|
||||||
|
|
||||||
|
return cachemodellist;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
|
faixbox_param_t *tilepart;
|
||||||
|
size_t numOfelem;
|
||||||
|
|
||||||
|
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
|
||||||
|
|
||||||
|
refer_target( target, &cachemodel->target);
|
||||||
|
cachemodel->mhead_model = false;
|
||||||
|
|
||||||
|
tilepart = target->codeidx->tilepart;
|
||||||
|
numOfelem = get_nmax( tilepart)*get_m( tilepart);
|
||||||
|
cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
|
||||||
|
|
||||||
|
cachemodel->next = NULL;
|
||||||
|
|
||||||
|
if( cachemodellist){
|
||||||
|
if( cachemodellist->first) // there are one or more entries
|
||||||
|
cachemodellist->last->next = cachemodel;
|
||||||
|
else // first entry
|
||||||
|
cachemodellist->first = cachemodel;
|
||||||
|
cachemodellist->last = cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel generated\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||||
|
{
|
||||||
|
Byte8_t TPnum; // num of tile parts in each tile
|
||||||
|
int i, j, k, n;
|
||||||
|
|
||||||
|
fprintf( logstream, "target: %s\n", cachemodel.target->filename);
|
||||||
|
fprintf( logstream, "\t main header model: %d\n", cachemodel.mhead_model);
|
||||||
|
|
||||||
|
fprintf( logstream, "\t tile part model:\n");
|
||||||
|
|
||||||
|
TPnum = get_nmax( cachemodel.target->codeidx->tilepart);
|
||||||
|
|
||||||
|
for( i=0, n=0; i<cachemodel.target->codeidx->YTnum; i++){
|
||||||
|
for( j=0; j<cachemodel.target->codeidx->XTnum; j++){
|
||||||
|
for( k=0; k<TPnum; k++)
|
||||||
|
fprintf( logstream, "%d", cachemodel.tp_model[n++]);
|
||||||
|
fprintf( logstream, " ");
|
||||||
|
}
|
||||||
|
fprintf( logstream, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = cachemodellist->first;
|
||||||
|
|
||||||
|
while( foundcachemodel != NULL){
|
||||||
|
|
||||||
|
if( foundcachemodel->target == target)
|
||||||
|
return foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = foundcachemodel->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodellist( cachemodellist_param_t **cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodelPtr, *cachemodelNext;
|
||||||
|
|
||||||
|
cachemodelPtr = (*cachemodellist)->first;
|
||||||
|
while( cachemodelPtr != NULL){
|
||||||
|
cachemodelNext=cachemodelPtr->next;
|
||||||
|
delete_cachemodel( &cachemodelPtr);
|
||||||
|
cachemodelPtr=cachemodelNext;
|
||||||
|
}
|
||||||
|
free(*cachemodellist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||||
|
{
|
||||||
|
unrefer_target( (*cachemodel)->target);
|
||||||
|
|
||||||
|
free( (*cachemodel)->tp_model);
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel deleted\n");
|
||||||
|
#endif
|
||||||
|
free( *cachemodel);
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CACHEMODEL_MANAGER_H_
|
||||||
|
# define CACHEMODEL_MANAGER_H_
|
||||||
|
|
||||||
|
#include "bool.h"
|
||||||
|
#include "target_manager.h"
|
||||||
|
|
||||||
|
//! Cache model parameters
|
||||||
|
typedef struct cachemodel_param{
|
||||||
|
target_param_t *target; //!< reference pointer to the target
|
||||||
|
bool mhead_model; //!< main header model, if sent, 1, else 0
|
||||||
|
bool *tp_model; //!< dynamic array pointer of tile part model, if sent, 1, else 0
|
||||||
|
struct cachemodel_param *next; //!< pointer to the next cache model
|
||||||
|
} cachemodel_param_t;
|
||||||
|
|
||||||
|
//! Cache model list parameters
|
||||||
|
typedef struct cachemodellist_param{
|
||||||
|
cachemodel_param_t *first; //!< first cache model pointer of the list
|
||||||
|
cachemodel_param_t *last; //!< last cache model pointer of the list
|
||||||
|
} cachemodellist_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a cache model list
|
||||||
|
*
|
||||||
|
* @return pointer to the generated cache model list
|
||||||
|
*/
|
||||||
|
cachemodellist_param_t * gene_cachemodellist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a session under the sesion list
|
||||||
|
*
|
||||||
|
* @param[in] cachemodellist cachemodel list to insert the generated cache model
|
||||||
|
* @param[in] target pointer the reference target
|
||||||
|
* @return pointer to the generated cache model
|
||||||
|
*/
|
||||||
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print cache model
|
||||||
|
*
|
||||||
|
* @param[in] cachemodel cache model
|
||||||
|
*/
|
||||||
|
void print_cachemodel( cachemodel_param_t cachemodel);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache model of a target
|
||||||
|
*
|
||||||
|
* @param[in] target refering target
|
||||||
|
* @param[in] cachemodellist cache model list
|
||||||
|
* @return found cache model pointer
|
||||||
|
*/
|
||||||
|
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a cache model
|
||||||
|
*
|
||||||
|
* @param[in] cachemodel address of the cachemodel pointer
|
||||||
|
*/
|
||||||
|
void delete_cachemodel( cachemodel_param_t **cachemodel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete cachemodel list
|
||||||
|
*
|
||||||
|
* @param[in,out] cachemodellist address of the cachemodel list pointer
|
||||||
|
*/
|
||||||
|
void delete_cachemodellist( cachemodellist_param_t **cachemodellist);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !CACHEMODEL_MANAGER_H_ */
|
|
@ -10,7 +10,7 @@ all: $(LIBNAME)
|
||||||
|
|
||||||
$(LIBNAME): target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
$(LIBNAME): target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
||||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
||||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o
|
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o cachemodel_manager.o
|
||||||
ar r $@ $^
|
ar r $@ $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "bool.h"
|
||||||
#include "index_manager.h"
|
#include "index_manager.h"
|
||||||
#include "box_manager.h"
|
#include "box_manager.h"
|
||||||
#include "manfbox_manager.h"
|
#include "manfbox_manager.h"
|
||||||
|
@ -145,31 +146,10 @@ void print_index( index_param_t index)
|
||||||
print_allmetadata( index.metadatalist);
|
print_allmetadata( index.metadatalist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_cachemodel( index_param_t index)
|
|
||||||
{
|
|
||||||
Byte8_t TPnum; // num of tile parts in each tile
|
|
||||||
int i, j, k, n;
|
|
||||||
|
|
||||||
TPnum = get_nmax( index.tilepart);
|
|
||||||
|
|
||||||
fprintf( logstream, "\t main header model: %d\n", index.mhead_model);
|
|
||||||
|
|
||||||
fprintf( logstream, "\t tile part model:\n");
|
|
||||||
for( i=0, n=0; i<index.YTnum; i++){
|
|
||||||
for( j=0; j<index.XTnum; j++){
|
|
||||||
for( k=0; k<TPnum; k++)
|
|
||||||
fprintf( logstream, "%d", index.tp_model[n++]);
|
|
||||||
fprintf( logstream, " ");
|
|
||||||
}
|
|
||||||
fprintf( logstream, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void delete_index( index_param_t **index)
|
void delete_index( index_param_t **index)
|
||||||
{
|
{
|
||||||
delete_metadatalist( &((*index)->metadatalist));
|
delete_metadatalist( &((*index)->metadatalist));
|
||||||
delete_faixbox( &((*index)->tilepart));
|
delete_faixbox( &((*index)->tilepart));
|
||||||
free( (*index)->tp_model);
|
|
||||||
free(*index);
|
free(*index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +345,6 @@ bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, ind
|
||||||
if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix")))
|
if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
jp2idx->mhead_model = 0;
|
|
||||||
jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0);
|
jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0);
|
||||||
|
|
||||||
mhix = gene_mhixbox( mhix_box);
|
mhix = gene_mhixbox( mhix_box);
|
||||||
|
@ -383,8 +362,6 @@ bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||||
{
|
{
|
||||||
box_param_t *tpix_box; //!< tpix box
|
box_param_t *tpix_box; //!< tpix box
|
||||||
box_param_t *faix_box; //!< faix box
|
box_param_t *faix_box; //!< faix box
|
||||||
faixbox_param_t *faix; //!< faix
|
|
||||||
size_t numOfelem;
|
|
||||||
|
|
||||||
if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix")))
|
if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix")))
|
||||||
return false;
|
return false;
|
||||||
|
@ -392,14 +369,8 @@ bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||||
if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix")))
|
if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
faix = gene_faixbox( faix_box);
|
jp2idx->tilepart = gene_faixbox( faix_box);
|
||||||
jp2idx->tilepart = faix;
|
|
||||||
numOfelem = get_nmax( faix)*get_m( faix);
|
|
||||||
|
|
||||||
jp2idx->tp_model = (bool *)malloc( numOfelem*sizeof(bool));
|
|
||||||
memset( jp2idx->tp_model, 0, numOfelem*sizeof(bool));
|
|
||||||
|
|
||||||
//delete_faixbox( &faix); // currently the jp2idx element
|
|
||||||
free( tpix_box);
|
free( tpix_box);
|
||||||
free( faix_box);
|
free( faix_box);
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#ifndef INDEX_MANAGER_H_
|
#ifndef INDEX_MANAGER_H_
|
||||||
# define INDEX_MANAGER_H_
|
# define INDEX_MANAGER_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "bool.h"
|
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
#include "faixbox_manager.h"
|
#include "faixbox_manager.h"
|
||||||
#include "metadata_manager.h"
|
#include "metadata_manager.h"
|
||||||
|
@ -72,9 +70,6 @@ typedef struct index_param{
|
||||||
Byte_t YRsiz[3]; //!< vertical separation of a sample of
|
Byte_t YRsiz[3]; //!< vertical separation of a sample of
|
||||||
//!component with respect to the reference grid
|
//!component with respect to the reference grid
|
||||||
faixbox_param_t *tilepart; //!< tile part information from tpix box
|
faixbox_param_t *tilepart; //!< tile part information from tpix box
|
||||||
bool mhead_model; //!< main header model, if sent, 1, else 0
|
|
||||||
bool *tp_model; //!< dynamic array pointer of tile part
|
|
||||||
//!model, if sent, 1, else 0
|
|
||||||
} index_param_t;
|
} index_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,13 +89,6 @@ index_param_t * parse_jp2file( int fd);
|
||||||
*/
|
*/
|
||||||
void print_index( index_param_t index);
|
void print_index( index_param_t index);
|
||||||
|
|
||||||
/**
|
|
||||||
* print cache model
|
|
||||||
*
|
|
||||||
* @param[in] index index parameters
|
|
||||||
*/
|
|
||||||
void print_cachemodel( index_param_t index);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete index
|
* delete index
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
#define MAINHEADER_MSG 6
|
#define MAINHEADER_MSG 6
|
||||||
#define METADATA_MSG 8
|
#define METADATA_MSG 8
|
||||||
|
|
||||||
msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target)
|
msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel)
|
||||||
{
|
{
|
||||||
msgqueue_param_t *msgqueue;
|
msgqueue_param_t *msgqueue;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target)
|
||||||
msgqueue->last = NULL;
|
msgqueue->last = NULL;
|
||||||
|
|
||||||
msgqueue->stateless = stateless;
|
msgqueue->stateless = stateless;
|
||||||
msgqueue->target = target;
|
msgqueue->cachemodel = cachemodel;
|
||||||
|
|
||||||
return msgqueue;
|
return msgqueue;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ void delete_msgqueue( msgqueue_param_t **msgqueue)
|
||||||
free( ptr);
|
free( ptr);
|
||||||
ptr = next;
|
ptr = next;
|
||||||
}
|
}
|
||||||
if( (*msgqueue)->stateless && (*msgqueue)->target)
|
if( (*msgqueue)->stateless && (*msgqueue)->cachemodel)
|
||||||
delete_target( &((*msgqueue)->target));
|
delete_cachemodel( &((*msgqueue)->cachemodel));
|
||||||
|
|
||||||
free(*msgqueue);
|
free(*msgqueue);
|
||||||
}
|
}
|
||||||
|
@ -124,10 +124,12 @@ void enqueue_message( message_param_t *msg, msgqueue_param_t *msgqueue);
|
||||||
|
|
||||||
void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
target_param_t *target;
|
target_param_t *target;
|
||||||
message_param_t *msg;
|
message_param_t *msg;
|
||||||
|
|
||||||
target = msgqueue->target;
|
cachemodel = msgqueue->cachemodel;
|
||||||
|
target = cachemodel->target;
|
||||||
|
|
||||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||||
|
|
||||||
|
@ -144,11 +146,12 @@ void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
||||||
|
|
||||||
enqueue_message( msg, msgqueue);
|
enqueue_message( msg, msgqueue);
|
||||||
|
|
||||||
target->codeidx->mhead_model = true;
|
cachemodel->mhead_model = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
target_param_t *target;
|
target_param_t *target;
|
||||||
bool *tp_model;
|
bool *tp_model;
|
||||||
Byte8_t numOftparts; // num of tile parts par tile
|
Byte8_t numOftparts; // num of tile parts par tile
|
||||||
|
@ -159,7 +162,8 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||||
Byte8_t binOffset, binLength;
|
Byte8_t binOffset, binLength;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
target = msgqueue->target;
|
cachemodel = msgqueue->cachemodel;
|
||||||
|
target = cachemodel->target;
|
||||||
codeidx = target->codeidx;
|
codeidx = target->codeidx;
|
||||||
tilepart = codeidx->tilepart;
|
tilepart = codeidx->tilepart;
|
||||||
|
|
||||||
|
@ -171,7 +175,7 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp_model = &codeidx->tp_model[ tile_id*numOftparts];
|
tp_model = &cachemodel->tp_model[ tile_id*numOftparts];
|
||||||
|
|
||||||
binOffset=0;
|
binOffset=0;
|
||||||
for( i=0; i<numOftparts-level; i++){
|
for( i=0; i<numOftparts-level; i++){
|
||||||
|
@ -213,7 +217,7 @@ void enqueue_metadata( int meta_id, msgqueue_param_t *msgqueue)
|
||||||
metadata_param_t *metadata;
|
metadata_param_t *metadata;
|
||||||
Byte8_t binOffset;
|
Byte8_t binOffset;
|
||||||
|
|
||||||
metadatalist = msgqueue->target->codeidx->metadatalist;
|
metadatalist = msgqueue->cachemodel->target->codeidx->metadatalist;
|
||||||
metadata = search_metadata( meta_id, metadatalist);
|
metadata = search_metadata( meta_id, metadatalist);
|
||||||
|
|
||||||
if( !metadata){
|
if( !metadata){
|
||||||
|
@ -243,7 +247,7 @@ void enqueue_box( int meta_id, boxlist_param_t *boxlist, msgqueue_param_t *msgqu
|
||||||
|
|
||||||
box = boxlist->first;
|
box = boxlist->first;
|
||||||
while( box){
|
while( box){
|
||||||
msg = gene_metamsg( meta_id, *binOffset, box->length, box->offset, NULL, msgqueue->target->csn);
|
msg = gene_metamsg( meta_id, *binOffset, box->length, box->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||||
enqueue_message( msg, msgqueue);
|
enqueue_message( msg, msgqueue);
|
||||||
|
|
||||||
*binOffset += box->length;
|
*binOffset += box->length;
|
||||||
|
@ -258,7 +262,7 @@ void enqueue_phld( int meta_id, placeholderlist_param_t *phldlist, msgqueue_para
|
||||||
|
|
||||||
phld = phldlist->first;
|
phld = phldlist->first;
|
||||||
while( phld){
|
while( phld){
|
||||||
msg = gene_metamsg( meta_id, *binOffset, phld->LBox, 0, phld, msgqueue->target->csn);
|
msg = gene_metamsg( meta_id, *binOffset, phld->LBox, 0, phld, msgqueue->cachemodel->target->csn);
|
||||||
enqueue_message( msg, msgqueue);
|
enqueue_message( msg, msgqueue);
|
||||||
|
|
||||||
*binOffset += phld->LBox;
|
*binOffset += phld->LBox;
|
||||||
|
@ -270,7 +274,7 @@ void enqueue_boxcontents( int meta_id, boxcontents_param_t *boxcontents, msgqueu
|
||||||
{
|
{
|
||||||
message_param_t *msg;
|
message_param_t *msg;
|
||||||
|
|
||||||
msg = gene_metamsg( meta_id, *binOffset, boxcontents->length, boxcontents->offset, NULL, msgqueue->target->csn);
|
msg = gene_metamsg( meta_id, *binOffset, boxcontents->length, boxcontents->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||||
enqueue_message( msg, msgqueue);
|
enqueue_message( msg, msgqueue);
|
||||||
|
|
||||||
*binOffset += boxcontents->length;
|
*binOffset += boxcontents->length;
|
||||||
|
@ -357,7 +361,7 @@ void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue)
|
||||||
if( msg->phld)
|
if( msg->phld)
|
||||||
emit_placeholder( msg->phld);
|
emit_placeholder( msg->phld);
|
||||||
else
|
else
|
||||||
emit_body( msg, msgqueue->target->fd);
|
emit_body( msg, msgqueue->cachemodel->target->fd);
|
||||||
|
|
||||||
msg = msg->next;
|
msg = msg->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,9 @@
|
||||||
#ifndef MSGQUEUE_MANAGER_H_
|
#ifndef MSGQUEUE_MANAGER_H_
|
||||||
# define MSGQUEUE_MANAGER_H_
|
# define MSGQUEUE_MANAGER_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "bool.h"
|
#include "bool.h"
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
#include "target_manager.h"
|
#include "cachemodel_manager.h"
|
||||||
#include "placeholder_manager.h"
|
#include "placeholder_manager.h"
|
||||||
|
|
||||||
//! message parameters
|
//! message parameters
|
||||||
|
@ -56,17 +55,17 @@ typedef struct msgqueue_param{
|
||||||
message_param_t *first; //!< first message pointer of the list
|
message_param_t *first; //!< first message pointer of the list
|
||||||
message_param_t *last; //!< last message pointer of the list
|
message_param_t *last; //!< last message pointer of the list
|
||||||
bool stateless; //!< if this is a stateless message queue
|
bool stateless; //!< if this is a stateless message queue
|
||||||
target_param_t *target; //!< reference target pointer
|
cachemodel_param_t *cachemodel; //!< reference cachemodel pointer
|
||||||
} msgqueue_param_t;
|
} msgqueue_param_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate message queue
|
* generate message queue
|
||||||
*
|
*
|
||||||
* @param[in] stateless if this is a stateless message queue
|
* @param[in] stateless if this is a stateless message queue
|
||||||
* @param[in] target reference target pointer
|
* @param[in] cachemodel cachemodel pointer
|
||||||
* @return generated message queue pointer
|
* @return generated message queue pointer
|
||||||
*/
|
*/
|
||||||
msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target);
|
msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete message queue
|
* delete message queue
|
||||||
|
|
|
@ -68,14 +68,13 @@ targetlist_param_t * gene_targetlist()
|
||||||
*/
|
*/
|
||||||
int open_jp2file( char filename[]);
|
int open_jp2file( char filename[]);
|
||||||
|
|
||||||
target_param_t * gene_target( char *targetname)
|
target_param_t * gene_target( targetlist_param_t *targetlist, char *targetname)
|
||||||
{
|
{
|
||||||
target_param_t *target;
|
target_param_t *target;
|
||||||
int fd;
|
int fd;
|
||||||
index_param_t *jp2idx;
|
index_param_t *jp2idx;
|
||||||
static int last_csn = 0;
|
static int last_csn = 0;
|
||||||
|
|
||||||
|
|
||||||
if( targetname[0]=='\0'){
|
if( targetname[0]=='\0'){
|
||||||
fprintf( FCGI_stderr, "Error: exception, no targetname in gene_target()\n");
|
fprintf( FCGI_stderr, "Error: exception, no targetname in gene_target()\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -96,12 +95,34 @@ target_param_t * gene_target( char *targetname)
|
||||||
target->fd = fd;
|
target->fd = fd;
|
||||||
target->csn = last_csn++;
|
target->csn = last_csn++;
|
||||||
target->codeidx = jp2idx;
|
target->codeidx = jp2idx;
|
||||||
|
target->num_of_use = 0;
|
||||||
|
|
||||||
target->next=NULL;
|
target->next=NULL;
|
||||||
|
|
||||||
|
if( targetlist->first) // there are one or more entries
|
||||||
|
targetlist->last->next = target;
|
||||||
|
else // first entry
|
||||||
|
targetlist->first = target;
|
||||||
|
targetlist->last = target;
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: target %s generated\n", targetname);
|
||||||
|
#endif
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void refer_target( target_param_t *reftarget, target_param_t **ptr)
|
||||||
|
{
|
||||||
|
*ptr = reftarget;
|
||||||
|
reftarget->num_of_use++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unrefer_target( target_param_t *target)
|
||||||
|
{
|
||||||
|
target->num_of_use--;
|
||||||
|
}
|
||||||
|
|
||||||
void delete_target( target_param_t **target)
|
void delete_target( target_param_t **target)
|
||||||
{
|
{
|
||||||
close( (*target)->fd);
|
close( (*target)->fd);
|
||||||
|
@ -146,14 +167,20 @@ void delete_targetlist(targetlist_param_t **targetlist)
|
||||||
free( *targetlist);
|
free( *targetlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_target( target_param_t *target)
|
||||||
|
{
|
||||||
|
fprintf( logstream, "target:\n");
|
||||||
|
fprintf( logstream, "\t csn=%d\n", target->csn);
|
||||||
|
fprintf( logstream, "\t target=%s\n\n", target->filename);
|
||||||
|
}
|
||||||
|
|
||||||
void print_alltarget( targetlist_param_t *targetlist)
|
void print_alltarget( targetlist_param_t *targetlist)
|
||||||
{
|
{
|
||||||
target_param_t *ptr;
|
target_param_t *ptr;
|
||||||
|
|
||||||
ptr = targetlist->first;
|
ptr = targetlist->first;
|
||||||
while( ptr != NULL){
|
while( ptr != NULL){
|
||||||
fprintf( logstream,"csn=%d\n", ptr->csn);
|
print_target( ptr);
|
||||||
fprintf( logstream,"target=%s\n", ptr->filename);
|
|
||||||
ptr=ptr->next;
|
ptr=ptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ typedef struct target_param{
|
||||||
int fd; //!< file descriptor
|
int fd; //!< file descriptor
|
||||||
int csn; //!< codestream number
|
int csn; //!< codestream number
|
||||||
index_param_t *codeidx; //!< index information of codestream
|
index_param_t *codeidx; //!< index information of codestream
|
||||||
|
int num_of_use; //!< numbers of sessions refering to this target
|
||||||
struct target_param *next; //!< pointer to the next target
|
struct target_param *next; //!< pointer to the next target
|
||||||
} target_param_t;
|
} target_param_t;
|
||||||
|
|
||||||
|
@ -65,12 +66,29 @@ targetlist_param_t * gene_targetlist();
|
||||||
/**
|
/**
|
||||||
* generate a target
|
* generate a target
|
||||||
*
|
*
|
||||||
|
* @param[in] targetlist target list to insert the generated target
|
||||||
* @param[in] targetname target file name
|
* @param[in] targetname target file name
|
||||||
* @return pointer to the generated target
|
* @return pointer to the generated target
|
||||||
*/
|
*/
|
||||||
target_param_t * gene_target( char *targetname);
|
target_param_t * gene_target( targetlist_param_t *targetlist, char *targetname);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refer a target, used to make a new cache model
|
||||||
|
*
|
||||||
|
* @param[in] reftarget reference target pointer
|
||||||
|
* @param[out] ptr address of feeding target pointer
|
||||||
|
*/
|
||||||
|
void refer_target( target_param_t *reftarget, target_param_t **ptr);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refer a target, used to make a new cache model
|
||||||
|
*
|
||||||
|
* @param[in] target reference pointer to the target
|
||||||
|
*/
|
||||||
|
void unrefer_target( target_param_t *target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a target
|
* delete a target
|
||||||
*
|
*
|
||||||
|
@ -95,6 +113,14 @@ void delete_target_in_list( target_param_t **target, targetlist_param_t *targetl
|
||||||
*/
|
*/
|
||||||
void delete_targetlist(targetlist_param_t **targetlist);
|
void delete_targetlist(targetlist_param_t **targetlist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print target parameters
|
||||||
|
*
|
||||||
|
* @param[in] target target pointer
|
||||||
|
*/
|
||||||
|
void print_target( target_param_t *target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print all target parameters
|
* print all target parameters
|
||||||
*
|
*
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class JPIPHttpClient
|
||||||
urlconn.setRequestMethod("GET");
|
urlconn.setRequestMethod("GET");
|
||||||
urlconn.setInstanceFollowRedirects(false);
|
urlconn.setInstanceFollowRedirects(false);
|
||||||
urlconn.connect();
|
urlconn.connect();
|
||||||
|
|
||||||
Map<String,java.util.List<String>> headers = urlconn.getHeaderFields();
|
Map<String,java.util.List<String>> headers = urlconn.getHeaderFields();
|
||||||
java.util.List<String> hvaluelist;
|
java.util.List<String> hvaluelist;
|
||||||
|
|
||||||
|
@ -177,10 +177,10 @@ public class JPIPHttpClient
|
||||||
cid = hvalueline.substring( hvalueline.indexOf('=')+1, hvalueline.indexOf(','));
|
cid = hvalueline.substring( hvalueline.indexOf('=')+1, hvalueline.indexOf(','));
|
||||||
System.err.println("cid: " + cid);
|
System.err.println("cid: " + cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream input = urlconn.getInputStream();
|
InputStream input = urlconn.getInputStream();
|
||||||
buflen = input.available();
|
buflen = input.available();
|
||||||
|
|
||||||
if( buflen > 0){
|
if( buflen > 0){
|
||||||
ByteArrayOutputStream tmpstream = new ByteArrayOutputStream();
|
ByteArrayOutputStream tmpstream = new ByteArrayOutputStream();
|
||||||
byte[] buf = new byte[ 1024];
|
byte[] buf = new byte[ 1024];
|
||||||
|
@ -230,7 +230,7 @@ public class JPIPHttpClient
|
||||||
}
|
}
|
||||||
|
|
||||||
urlconn.disconnect();
|
urlconn.disconnect();
|
||||||
|
|
||||||
return jpipstream;
|
return jpipstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
LIBDIR = ../libopenjpip
|
LIBDIR = ../libopenjpip
|
||||||
|
|
||||||
LIBFNAME = $(LIBDIR)/libopenjpip_server.a
|
LIBFNAME = $(LIBDIR)/libopenjpip_server.a
|
||||||
CFLAGS = -O3 -Wall -m32 -DSERVER -I$(LIBDIR)
|
CFLAGS = -O3 -Wall -m32 -DSERVER -I$(LIBDIR)
|
||||||
LDFLAGS = -L$(LIBDIR) -lm -lfcgi -lopenjpip_server
|
LDFLAGS = -L$(LIBDIR) -lm -lfcgi -lopenjpip_server
|
||||||
|
|
|
@ -54,20 +54,18 @@ channellist_param_t * gene_channellist()
|
||||||
return channellist;
|
return channellist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel_param_t * gene_channel( query_param_t query_param, cachemodel_param_t *cachemodel, channellist_param_t *channellist)
|
||||||
channel_param_t * gene_channel( query_param_t query_param, target_param_t *target, channellist_param_t *channellist)
|
|
||||||
{
|
{
|
||||||
channel_param_t *channel;
|
channel_param_t *channel;
|
||||||
|
|
||||||
// set the target
|
if( !cachemodel){
|
||||||
if( !target){
|
|
||||||
fprintf( FCGI_stdout, "Status: 404\r\n");
|
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||||
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
|
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||||
channel->target = target;
|
channel->cachemodel = cachemodel;
|
||||||
|
|
||||||
// set channel ID and get present time
|
// set channel ID and get present time
|
||||||
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());;
|
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());;
|
||||||
|
@ -141,7 +139,7 @@ void print_allchannel( channellist_param_t *channellist)
|
||||||
|
|
||||||
ptr = channellist->first;
|
ptr = channellist->first;
|
||||||
while( ptr != NULL){
|
while( ptr != NULL){
|
||||||
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->target->filename);
|
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->cachemodel->target->filename);
|
||||||
ptr=ptr->next;
|
ptr=ptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,16 +33,15 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "query_parser.h"
|
#include "query_parser.h"
|
||||||
#include "target_manager.h"
|
#include "cachemodel_manager.h"
|
||||||
|
|
||||||
//! Channel parameters
|
//! Channel parameters
|
||||||
typedef struct channel_param{
|
typedef struct channel_param{
|
||||||
target_param_t *target; //!< reference pointer to the target
|
cachemodel_param_t *cachemodel; //!< reference pointer to the cache model
|
||||||
char cid[MAX_LENOFCID]; //!< channel identifier
|
char cid[MAX_LENOFCID]; //!< channel identifier
|
||||||
// - a record of the client's capabilities and preferences
|
// - a record of the client's capabilities and preferences to the extent that the server queues requests
|
||||||
// - to the extent that the server queues requests
|
time_t start_tm; //!< starting time
|
||||||
time_t start_tm; //!< starting time
|
struct channel_param *next; //!< pointer to the next channel
|
||||||
struct channel_param *next; //!< pointer to the next channel
|
|
||||||
} channel_param_t;
|
} channel_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,11 +64,11 @@ channellist_param_t * gene_channellist();
|
||||||
* generate a channel under the channel list
|
* generate a channel under the channel list
|
||||||
*
|
*
|
||||||
* @param[in] query_param query parameters
|
* @param[in] query_param query parameters
|
||||||
* @param[in] target reference target
|
* @param[in] cachemodel reference cachemodel
|
||||||
* @param[in] channellist channel list pointer
|
* @param[in] channellist channel list pointer
|
||||||
* @return pointer to the generated channel
|
* @return pointer to the generated channel
|
||||||
*/
|
*/
|
||||||
channel_param_t * gene_channel( query_param_t query_param, target_param_t *target, channellist_param_t *channellist);
|
channel_param_t * gene_channel( query_param_t query_param, cachemodel_param_t *cachemodel, channellist_param_t *channellist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set channel variable parameters
|
* set channel variable parameters
|
||||||
|
|
|
@ -70,11 +70,13 @@
|
||||||
*
|
*
|
||||||
* @param[in] query_param structured query
|
* @param[in] query_param structured query
|
||||||
* @param[in] sessionlist session list pointer
|
* @param[in] sessionlist session list pointer
|
||||||
|
* @param[in] targetlist target list pointer
|
||||||
* @param[in,out] msgqueue address of the message queue pointer
|
* @param[in,out] msgqueue address of the message queue pointer
|
||||||
* @return if succeeded (true) or failed (false)
|
* @return if succeeded (true) or failed (false)
|
||||||
*/
|
*/
|
||||||
bool parse_JPIPrequest( query_param_t query_param,
|
bool parse_JPIPrequest( query_param_t query_param,
|
||||||
sessionlist_param_t *sessionlist,
|
sessionlist_param_t *sessionlist,
|
||||||
|
targetlist_param_t *targetlist,
|
||||||
msgqueue_param_t **msgqueue);
|
msgqueue_param_t **msgqueue);
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,12 +99,14 @@ bool associate_channel( query_param_t query_param,
|
||||||
*
|
*
|
||||||
* @param[in] query_param structured query
|
* @param[in] query_param structured query
|
||||||
* @param[in] sessionlist session list pointer
|
* @param[in] sessionlist session list pointer
|
||||||
|
* @param[in] target requested target pointer
|
||||||
* @param[in,out] cursession address of the associated/opened session pointer
|
* @param[in,out] cursession address of the associated/opened session pointer
|
||||||
* @param[in,out] curchannel address of the associated/opened channel pointer
|
* @param[in,out] curchannel address of the associated/opened channel pointer
|
||||||
* @return if succeeded (true) or failed (false)
|
* @return if succeeded (true) or failed (false)
|
||||||
*/
|
*/
|
||||||
bool open_channel( query_param_t query_param,
|
bool open_channel( query_param_t query_param,
|
||||||
sessionlist_param_t *sessionlist,
|
sessionlist_param_t *sessionlist,
|
||||||
|
target_param_t *target,
|
||||||
session_param_t **cursession,
|
session_param_t **cursession,
|
||||||
channel_param_t **curchannel);
|
channel_param_t **curchannel);
|
||||||
|
|
||||||
|
@ -124,12 +128,14 @@ bool close_channel( query_param_t query_param,
|
||||||
* REQUEST: view-window (fsiz)
|
* REQUEST: view-window (fsiz)
|
||||||
*
|
*
|
||||||
* @param[in] query_param structured query
|
* @param[in] query_param structured query
|
||||||
|
* @param[in] target requested target pointer
|
||||||
* @param[in,out] cursession associated session pointer
|
* @param[in,out] cursession associated session pointer
|
||||||
* @param[in,out] curchannel associated channel pointer
|
* @param[in,out] curchannel associated channel pointer
|
||||||
* @param[in,out] msgqueue address of the message queue pointer
|
* @param[in,out] msgqueue address of the message queue pointer
|
||||||
* @return if succeeded (true) or failed (false)
|
* @return if succeeded (true) or failed (false)
|
||||||
*/
|
*/
|
||||||
bool gene_JPTstream( query_param_t query_param,
|
bool gene_JPTstream( query_param_t query_param,
|
||||||
|
target_param_t *target,
|
||||||
session_param_t *cursession,
|
session_param_t *cursession,
|
||||||
channel_param_t *curchannel,
|
channel_param_t *curchannel,
|
||||||
msgqueue_param_t **msgqueue);
|
msgqueue_param_t **msgqueue);
|
||||||
|
@ -137,10 +143,12 @@ bool gene_JPTstream( query_param_t query_param,
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
sessionlist_param_t *sessionlist;
|
sessionlist_param_t *sessionlist;
|
||||||
|
targetlist_param_t *targetlist;
|
||||||
bool parse_status;
|
bool parse_status;
|
||||||
|
|
||||||
sessionlist = gene_sessionlist();
|
sessionlist = gene_sessionlist();
|
||||||
|
targetlist = gene_targetlist();
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
|
|
||||||
char *query_string;
|
char *query_string;
|
||||||
|
@ -168,8 +176,7 @@ int main(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
msgqueue = NULL;
|
msgqueue = NULL;
|
||||||
parse_status = parse_JPIPrequest( query_param, sessionlist, &msgqueue);
|
parse_status = parse_JPIPrequest( query_param, sessionlist, targetlist, &msgqueue);
|
||||||
|
|
||||||
|
|
||||||
fprintf( FCGI_stdout, "\r\n");
|
fprintf( FCGI_stdout, "\r\n");
|
||||||
|
|
||||||
|
@ -178,28 +185,38 @@ int main(void)
|
||||||
// print_allsession( sessionlist);
|
// print_allsession( sessionlist);
|
||||||
print_msgqueue( msgqueue);
|
print_msgqueue( msgqueue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
emit_stream_from_msgqueue( msgqueue);
|
emit_stream_from_msgqueue( msgqueue);
|
||||||
|
|
||||||
delete_msgqueue( &msgqueue);
|
delete_msgqueue( &msgqueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_sessionlist( &sessionlist);
|
delete_sessionlist( &sessionlist);
|
||||||
|
delete_targetlist( &targetlist);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse_JPIPrequest( query_param_t query_param,
|
bool parse_JPIPrequest( query_param_t query_param,
|
||||||
sessionlist_param_t *sessionlist,
|
sessionlist_param_t *sessionlist,
|
||||||
|
targetlist_param_t *targetlist,
|
||||||
msgqueue_param_t **msgqueue)
|
msgqueue_param_t **msgqueue)
|
||||||
{
|
{
|
||||||
|
target_param_t *target = NULL;
|
||||||
session_param_t *cursession = NULL;
|
session_param_t *cursession = NULL;
|
||||||
channel_param_t *curchannel = NULL;
|
channel_param_t *curchannel = NULL;
|
||||||
|
|
||||||
|
if( query_param.target[0] !='\0')
|
||||||
|
if( !( target = search_target( query_param.target, targetlist)))
|
||||||
|
if(!( target = gene_target( targetlist, query_param.target)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if( query_param.cid[0] != '\0')
|
if( query_param.cid[0] != '\0')
|
||||||
if( !associate_channel( query_param, sessionlist, &cursession, &curchannel))
|
if( !associate_channel( query_param, sessionlist, &cursession, &curchannel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( query_param.cnew){
|
if( query_param.cnew){
|
||||||
if( !open_channel( query_param, sessionlist, &cursession, &curchannel))
|
if( !open_channel( query_param, sessionlist, target, &cursession, &curchannel))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( query_param.cclose[0][0] != '\0')
|
if( query_param.cclose[0][0] != '\0')
|
||||||
|
@ -207,7 +224,7 @@ bool parse_JPIPrequest( query_param_t query_param,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( (query_param.fx > 0 && query_param.fy > 0) || query_param.box_type[0][0] != 0)
|
if( (query_param.fx > 0 && query_param.fy > 0) || query_param.box_type[0][0] != 0)
|
||||||
if( !gene_JPTstream( query_param, cursession, curchannel, msgqueue))
|
if( !gene_JPTstream( query_param, target, cursession, curchannel, msgqueue))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -232,36 +249,24 @@ bool associate_channel( query_param_t query_param,
|
||||||
|
|
||||||
bool open_channel( query_param_t query_param,
|
bool open_channel( query_param_t query_param,
|
||||||
sessionlist_param_t *sessionlist,
|
sessionlist_param_t *sessionlist,
|
||||||
|
target_param_t *target,
|
||||||
session_param_t **cursession,
|
session_param_t **cursession,
|
||||||
channel_param_t **curchannel)
|
channel_param_t **curchannel)
|
||||||
{
|
{
|
||||||
target_param_t *target=NULL;
|
cachemodel_param_t *cachemodel = NULL;
|
||||||
|
|
||||||
if( query_param.target[0] !='\0'){ // target query specified
|
if( target){
|
||||||
if( *cursession){
|
if( !(*cursession))
|
||||||
if( !( target = search_target( query_param.target, (*cursession)->targetlist))){
|
*cursession = gene_session( sessionlist);
|
||||||
if((target = gene_target( query_param.target)))
|
if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist)))
|
||||||
insert_target_into_session( *cursession, target);
|
if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target)))
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if((target = gene_target( query_param.target))){
|
|
||||||
// new session
|
|
||||||
*cursession = gene_session( sessionlist);
|
|
||||||
insert_target_into_session( *cursession, target);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
if( *cursession)
|
if( *curchannel)
|
||||||
target = (*curchannel)->target;
|
cachemodel = (*curchannel)->cachemodel;
|
||||||
}
|
|
||||||
|
*curchannel = gene_channel( query_param, cachemodel, (*cursession)->channellist);
|
||||||
*curchannel = gene_channel( query_param, target, (*cursession)->channellist);
|
|
||||||
if( *curchannel == NULL)
|
if( *curchannel == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -335,22 +340,25 @@ void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadata
|
||||||
|
|
||||||
|
|
||||||
bool gene_JPTstream( query_param_t query_param,
|
bool gene_JPTstream( query_param_t query_param,
|
||||||
|
target_param_t *target,
|
||||||
session_param_t *cursession,
|
session_param_t *cursession,
|
||||||
channel_param_t *curchannel,
|
channel_param_t *curchannel,
|
||||||
msgqueue_param_t **msgqueue)
|
msgqueue_param_t **msgqueue)
|
||||||
{
|
{
|
||||||
target_param_t *target;
|
|
||||||
index_param_t *codeidx;
|
index_param_t *codeidx;
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
|
|
||||||
if( !cursession || !curchannel){ // stateless
|
if( !cursession || !curchannel){ // stateless
|
||||||
if((target = gene_target( query_param.target)))
|
if( !target)
|
||||||
*msgqueue = gene_msgqueue( true, target);
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
if( !(cachemodel = gene_cachemodel( NULL, target)))
|
||||||
|
return false;
|
||||||
|
*msgqueue = gene_msgqueue( true, cachemodel);
|
||||||
}
|
}
|
||||||
else{ // session
|
else{ // session
|
||||||
target = curchannel->target;
|
cachemodel = curchannel->cachemodel;
|
||||||
*msgqueue = gene_msgqueue( false, target);
|
target = cachemodel->target;
|
||||||
|
*msgqueue = gene_msgqueue( false, cachemodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
codeidx = target->codeidx;
|
codeidx = target->codeidx;
|
||||||
|
@ -359,13 +367,12 @@ bool gene_JPTstream( query_param_t query_param,
|
||||||
if( query_param.box_type[0][0] != 0)
|
if( query_param.box_type[0][0] != 0)
|
||||||
enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue);
|
enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue);
|
||||||
|
|
||||||
// image code
|
// image codestream
|
||||||
if( query_param.fx > 0 && query_param.fy > 0){
|
if( query_param.fx > 0 && query_param.fy > 0){
|
||||||
if( !codeidx->mhead_model)
|
if( !cachemodel->mhead_model)
|
||||||
enqueue_mainheader( *msgqueue);
|
enqueue_mainheader( *msgqueue);
|
||||||
enqueue_tiles( query_param, codeidx, *msgqueue);
|
enqueue_tiles( query_param, codeidx, *msgqueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
#include "target_manager.h"
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
#include "fcgi_stdio.h"
|
#include "fcgi_stdio.h"
|
||||||
|
@ -62,7 +63,7 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist)
|
||||||
session = (session_param_t *)malloc( sizeof(session_param_t));
|
session = (session_param_t *)malloc( sizeof(session_param_t));
|
||||||
|
|
||||||
session->channellist = gene_channellist();
|
session->channellist = gene_channellist();
|
||||||
session->targetlist = gene_targetlist();
|
session->cachemodellist = gene_cachemodellist();
|
||||||
|
|
||||||
session->next = NULL;
|
session->next = NULL;
|
||||||
|
|
||||||
|
@ -102,19 +103,19 @@ bool search_session_and_channel( char cid[],
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_target_into_session( session_param_t *session, target_param_t *target)
|
void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_t *cachemodel)
|
||||||
{
|
{
|
||||||
if(!target)
|
if(!cachemodel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
fprintf( logstream, "local log: insert target into session %p\n", (void *)session);
|
fprintf( logstream, "local log: insert cachemodel into session\n");
|
||||||
#endif
|
#endif
|
||||||
if( session->targetlist->first != NULL)
|
if( session->cachemodellist->first != NULL)
|
||||||
session->targetlist->last->next = target;
|
session->cachemodellist->last->next = cachemodel;
|
||||||
else
|
else
|
||||||
session->targetlist->first = target;
|
session->cachemodellist->first = cachemodel;
|
||||||
session->targetlist->last = target;
|
session->cachemodellist->last = cachemodel;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist)
|
bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist)
|
||||||
|
@ -138,7 +139,7 @@ bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_channellist( &((*session)->channellist));
|
delete_channellist( &((*session)->channellist));
|
||||||
delete_targetlist ( &((*session)->targetlist));
|
delete_cachemodellist( &((*session)->cachemodellist));
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
fprintf( logstream, "local log: session: %p deleted!\n", (void *)(*session));
|
fprintf( logstream, "local log: session: %p deleted!\n", (void *)(*session));
|
||||||
|
@ -157,7 +158,7 @@ void delete_sessionlist( sessionlist_param_t **sessionlist)
|
||||||
sessionNext=sessionPtr->next;
|
sessionNext=sessionPtr->next;
|
||||||
|
|
||||||
delete_channellist( &(sessionPtr->channellist));
|
delete_channellist( &(sessionPtr->channellist));
|
||||||
delete_targetlist ( &(sessionPtr->targetlist));
|
delete_cachemodellist( &(sessionPtr->cachemodellist));
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
fprintf( logstream, "local log: session: %p deleted!\n", (void *)sessionPtr);
|
fprintf( logstream, "local log: session: %p deleted!\n", (void *)sessionPtr);
|
||||||
|
@ -176,6 +177,7 @@ void delete_sessionlist( sessionlist_param_t **sessionlist)
|
||||||
void print_allsession( sessionlist_param_t *sessionlist)
|
void print_allsession( sessionlist_param_t *sessionlist)
|
||||||
{
|
{
|
||||||
session_param_t *ptr;
|
session_param_t *ptr;
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
fprintf( logstream, "SESSIONS info:\n");
|
fprintf( logstream, "SESSIONS info:\n");
|
||||||
|
@ -184,7 +186,11 @@ void print_allsession( sessionlist_param_t *sessionlist)
|
||||||
while( ptr != NULL){
|
while( ptr != NULL){
|
||||||
fprintf( logstream, "session No.%d\n", i++);
|
fprintf( logstream, "session No.%d\n", i++);
|
||||||
print_allchannel( ptr->channellist);
|
print_allchannel( ptr->channellist);
|
||||||
print_alltarget( ptr->targetlist);
|
cachemodel = ptr->cachemodellist->first;
|
||||||
|
while( cachemodel){
|
||||||
|
print_target( cachemodel->target);
|
||||||
|
cachemodel = cachemodel->next;
|
||||||
|
}
|
||||||
ptr=ptr->next;
|
ptr=ptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
|
|
||||||
#include "bool.h"
|
#include "bool.h"
|
||||||
#include "channel_manager.h"
|
#include "channel_manager.h"
|
||||||
#include "target_manager.h"
|
#include "cachemodel_manager.h"
|
||||||
|
|
||||||
//! Session parameters
|
//! Session parameters
|
||||||
typedef struct session_param{
|
typedef struct session_param{
|
||||||
channellist_param_t *channellist; //!< channel list pointer
|
channellist_param_t *channellist; //!< channel list pointer
|
||||||
targetlist_param_t *targetlist; //!< target list pointer
|
cachemodellist_param_t *cachemodellist; //!< cache list pointer
|
||||||
struct session_param *next; //!< pointer to the next session
|
struct session_param *next; //!< pointer to the next session
|
||||||
} session_param_t;
|
} session_param_t;
|
||||||
|
|
||||||
//! Session list parameters
|
//! Session list parameters
|
||||||
|
@ -80,12 +80,12 @@ bool search_session_and_channel( char cid[],
|
||||||
channel_param_t **foundchannel);
|
channel_param_t **foundchannel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert a target into a session
|
* insert a cache model into a session
|
||||||
*
|
*
|
||||||
* @param[in] session session pointer
|
* @param[in] session session pointer
|
||||||
* @param[in] target target pointer
|
* @param[in] cachemodel cachemodel pointer
|
||||||
*/
|
*/
|
||||||
void insert_target_into_session( session_param_t *session, target_param_t *target);
|
void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_t *cachemodel);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue