added tid request support to JPIP client and JPIP server quit request
This commit is contained in:
parent
4da816e459
commit
40fe9e6d67
|
@ -5,9 +5,13 @@ What's New for OpenJPIP
|
|||
! : changed
|
||||
+ : added
|
||||
|
||||
August 25, 2011
|
||||
+ [kaori] added tid request support to JPIP client
|
||||
+ [kaori] added quit JPIP server request
|
||||
|
||||
August 24, 2011
|
||||
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||
+ [kaori] added tid request support
|
||||
+ [kaori] added tid request support to JPIP server
|
||||
|
||||
August 16, 2011
|
||||
* [antonin] fixed cmake support for openjpip
|
||||
|
|
|
@ -90,6 +90,11 @@ Server:
|
|||
|
||||
2. Launch opj_server from the server terminal:
|
||||
% spawn-fcgi -f ./opj_server -p 3000 -n
|
||||
|
||||
For shutting down JPIP server:
|
||||
%GET http://hostname/myFCGI?quitJPIP
|
||||
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
|
||||
|
||||
Client:
|
||||
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||
|
|
|
@ -101,8 +101,6 @@ target_param_t * gene_target( targetlist_param_t *targetlist, char *targetname)
|
|||
|
||||
target->next=NULL;
|
||||
|
||||
fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", target->tid);
|
||||
|
||||
if( targetlist->first) // there are one or more entries
|
||||
targetlist->last->next = target;
|
||||
else // first entry
|
||||
|
@ -220,9 +218,6 @@ target_param_t * search_targetBytid( char tid[], targetlist_param_t *targetlist)
|
|||
foundtarget = foundtarget->next;
|
||||
}
|
||||
|
||||
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: tid %s not found\r\n", tid);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,12 +61,13 @@ void delete_cachelist(cachelist_param_t **cachelist)
|
|||
free( *cachelist);
|
||||
}
|
||||
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *cid)
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
|
||||
{
|
||||
cache_param_t *cache;
|
||||
|
||||
cache = (cache_param_t *)malloc( sizeof(cache_param_t));
|
||||
strcpy( cache->filename, targetname);
|
||||
strcpy( cache->tid, tid);
|
||||
cache->csn = csn;
|
||||
cache->cid = (char **)malloc( sizeof(char *));
|
||||
*cache->cid = (char *)malloc( MAX_LENOFCID);
|
||||
|
@ -175,6 +176,14 @@ void add_cachecid( char *cid, cache_param_t *cache)
|
|||
cache->numOfcid ++;
|
||||
}
|
||||
|
||||
void update_cachetid( char *tid, cache_param_t *cache)
|
||||
{
|
||||
if( tid[0] != '0' && strcmp( tid, cache->tid) !=0){
|
||||
fprintf( stderr, "tid is updated to %s for %s\n", tid, cache->filename);
|
||||
strcpy( cache->tid, tid);
|
||||
}
|
||||
}
|
||||
|
||||
void remove_cidInCache( char *cid, cache_param_t *cache);
|
||||
|
||||
void remove_cachecid( char *cid, cachelist_param_t *cachelist)
|
||||
|
@ -225,6 +234,7 @@ void print_cache( cache_param_t *cache)
|
|||
|
||||
fprintf( stdout,"cache\n");
|
||||
fprintf( stdout,"\t filename: %s\n", cache->filename);
|
||||
fprintf( stdout,"\t tid: %s\n", cache->tid);
|
||||
fprintf( stdout,"\t csn: %d\n", cache->csn);
|
||||
fprintf( stdout,"\t cid:");
|
||||
|
||||
|
|
|
@ -37,9 +37,13 @@
|
|||
//! maximum length of target name
|
||||
#define MAX_LENOFTARGET 128
|
||||
|
||||
//! maximum length of target identifier
|
||||
#define MAX_LENOFTID 30
|
||||
|
||||
//! cache parameters
|
||||
typedef struct cache_param{
|
||||
char filename[MAX_LENOFTARGET]; //!< file name
|
||||
char tid[MAX_LENOFTID]; //!< taregt identifier
|
||||
int csn; //!< codestream number
|
||||
char **cid; //!< dynamic array of channel identifiers
|
||||
int numOfcid; //!< number of cids
|
||||
|
@ -74,10 +78,11 @@ void delete_cachelist(cachelist_param_t **cachelist);
|
|||
*
|
||||
* @param[in] targetname target file name
|
||||
* @param[in] csn codestream number
|
||||
* @param[in] tid target identifier
|
||||
* @param[in] cid channel identifier
|
||||
* @return pointer to the generated cache
|
||||
*/
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *cid);
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
|
||||
|
||||
/**
|
||||
* delete a cache
|
||||
|
@ -132,6 +137,16 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
|
|||
*/
|
||||
void add_cachecid( char *cid, cache_param_t *cache);
|
||||
|
||||
|
||||
/**
|
||||
* update tid of a cache
|
||||
*
|
||||
* @param[in] tid target identifier
|
||||
* @param[in] cache cache pointer
|
||||
*/
|
||||
void update_cachetid( char *tid, cache_param_t *cache);
|
||||
|
||||
|
||||
/**
|
||||
* remove cid in cache
|
||||
*
|
||||
|
|
|
@ -94,7 +94,7 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
|
|||
{
|
||||
int receive_size;
|
||||
char buf[BUF_LEN];
|
||||
char *magicid[] = { "JPIP-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
|
||||
char *magicid[] = { "JPIP-stream", "PNM request", "XML request", "TID request", "CID request", "CID destroy", "JP2 save", "QUIT"};
|
||||
int i;
|
||||
|
||||
receive_size = receive_line( connected_socket, buf);
|
||||
|
@ -106,7 +106,7 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
|
|||
|
||||
for( i=0; i<NUM_OF_MSGTYPES; i++){
|
||||
if( strncasecmp( magicid[i], buf, strlen(magicid[i])) == 0){
|
||||
printf("Client message: %s\n", magicid[i]);
|
||||
printf("%s\n", magicid[i]);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +115,10 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
|
|||
return MSGERROR;
|
||||
}
|
||||
|
||||
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
|
||||
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *tid, char *cid, int *streamlen)
|
||||
{
|
||||
Byte_t *jpipstream=NULL, *ptr;
|
||||
char buf[BUF_LEN], versionstring[] = "version 1.1";
|
||||
char buf[BUF_LEN], versionstring[] = "version 1.2";
|
||||
int linelen, redlen, remlen;
|
||||
|
||||
target[0] = 0;
|
||||
|
@ -137,6 +137,10 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, i
|
|||
if( strstr( buf, "jp2")){
|
||||
// register cid option
|
||||
strcpy( target, buf);
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
strcpy( tid, buf);
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
|
@ -147,9 +151,8 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, i
|
|||
}
|
||||
|
||||
*streamlen = atoi( buf);
|
||||
fprintf( stderr, "Receiveing Data length: %d\n", *streamlen);
|
||||
fprintf( stderr, "Receive Data: %d Bytes\n", *streamlen);
|
||||
|
||||
|
||||
jpipstream = (unsigned char *)malloc( (*streamlen));
|
||||
ptr = jpipstream;
|
||||
remlen = (*streamlen);
|
||||
|
@ -162,7 +165,6 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, i
|
|||
remlen -= redlen;
|
||||
ptr = ptr + redlen;
|
||||
}
|
||||
fprintf( stderr, " done\n");
|
||||
|
||||
return jpipstream;
|
||||
}
|
||||
|
@ -183,17 +185,29 @@ void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
|
|||
send_stream( connected_socket, xmlstream, length);
|
||||
}
|
||||
|
||||
void send_IDstream( SOCKET connected_socket, char *id, int idlen, char *label);
|
||||
|
||||
void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen)
|
||||
{
|
||||
send_IDstream( connected_socket, cid, cidlen, "CID");
|
||||
}
|
||||
|
||||
void send_TIDstream( SOCKET connected_socket, char *tid, int tidlen)
|
||||
{
|
||||
send_IDstream( connected_socket, tid, tidlen, "TID");
|
||||
}
|
||||
|
||||
void send_IDstream( SOCKET connected_socket, char *id, int idlen, char *label)
|
||||
{
|
||||
Byte_t header[4];
|
||||
|
||||
header[0] = 'C';
|
||||
header[1] = 'I';
|
||||
header[2] = 'D';
|
||||
header[3] = cidlen & 0xff;
|
||||
header[0] = label[0];
|
||||
header[1] = label[1];
|
||||
header[2] = label[2];
|
||||
header[3] = idlen & 0xff;
|
||||
|
||||
send_stream( connected_socket, header, 4);
|
||||
send_stream( connected_socket, cid, cidlen);
|
||||
send_stream( connected_socket, id, idlen);
|
||||
}
|
||||
|
||||
void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
|
||||
|
|
|
@ -48,8 +48,8 @@ typedef int SOCKET;
|
|||
*/
|
||||
SOCKET open_listeningsocket();
|
||||
|
||||
#define NUM_OF_MSGTYPES 7
|
||||
typedef enum eMSGTYPE{ JPIPSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
|
||||
#define NUM_OF_MSGTYPES 8
|
||||
typedef enum eMSGTYPE{ JPIPSTREAM, PNMREQ, XMLREQ, TIDREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
|
||||
|
||||
/**
|
||||
* indeitify client message type
|
||||
|
@ -64,11 +64,12 @@ msgtype_t identify_clientmsg( SOCKET connected_socket);
|
|||
*
|
||||
* @param [in] connected_socket file descriptor of the connected socket
|
||||
* @param [out] target received target file name (if not received, null string)
|
||||
* @param [out] tid received target identifier (if not received, null string)
|
||||
* @param [out] cid received channel identifier (if not received, null string)
|
||||
* @param [out] streamlen length of the received codestream
|
||||
* @return JPT- JPP- codestream
|
||||
*/
|
||||
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
|
||||
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *tid, char *cid, int *streamlen);
|
||||
|
||||
/**
|
||||
* send PGM/PPM image stream to the client
|
||||
|
@ -91,6 +92,15 @@ void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int wi
|
|||
*/
|
||||
void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
|
||||
|
||||
/**
|
||||
* send TID data stream to the client
|
||||
*
|
||||
* @param [in] connected_socket file descriptor of the connected socket
|
||||
* @param [in] tid tid string
|
||||
* @param [in] tidlen legnth of the tid string
|
||||
*/
|
||||
void send_TIDstream( SOCKET connected_socket, char *tid, int tidlen);
|
||||
|
||||
/**
|
||||
* send CID data stream to the client
|
||||
*
|
||||
|
@ -125,7 +135,7 @@ int receive_line(SOCKET connected_socket, char *buf);
|
|||
*\section sec1 JPIP-stream
|
||||
* Cache JPT- JPP- stream in server
|
||||
*
|
||||
* client -> server: JPIP-stream\\n version 1.1\\n (optional for cid registration: targetnamestring\\n cidstring\\n) bytelengthvalue\\n data \n
|
||||
* client -> server: JPIP-stream\\n version 1.1\\n (optional for cid registration: targetnamestring\\n tidstring\\n cidstring\\n) bytelengthvalue\\n data \n
|
||||
* server -> client: 1 or 0 (of 1Byte response signal)
|
||||
*
|
||||
*\section sec2 PNM request
|
||||
|
@ -140,25 +150,31 @@ int receive_line(SOCKET connected_socket, char *buf);
|
|||
* client -> server: XML request\\n \n
|
||||
* server -> client: XML (3Byte) length (2Byte Big endian) data
|
||||
*
|
||||
*\section sec4 CID request
|
||||
*\section sec4 TID request
|
||||
* Get target ID of target image
|
||||
*
|
||||
* client -> server: TID request\\n targetname\\n \n
|
||||
* server -> client: TID (3Byte) length (1Byte) tiddata
|
||||
*
|
||||
*\section sec5 CID request
|
||||
* Get Channel ID of identical target image
|
||||
*
|
||||
* client -> server: CID request\\n targetname\\n \n
|
||||
* server -> client: CID (3Byte) length (1Byte) ciddata
|
||||
*
|
||||
*\section sec5 CID destroy
|
||||
*\section sec6 CID destroy
|
||||
* Close Channel ID
|
||||
*
|
||||
* client -> server: CID destroy\\n ciddata \n
|
||||
* server -> client: 1 or 0 (of 1Byte response signal)
|
||||
*
|
||||
*\section sec6 JP2 save
|
||||
*\section sec7 JP2 save
|
||||
* Save in JP2 file format
|
||||
*
|
||||
* client -> server: JP2 save\\n ciddata \n
|
||||
* server -> client: 1 or 0 (of 1Byte response signal)
|
||||
*
|
||||
*\section sec7 QUIT
|
||||
*\section sec8 QUIT
|
||||
* Quit the opj_dec_server program
|
||||
*
|
||||
* client -> server: quit or QUIT
|
||||
|
|
|
@ -99,6 +99,14 @@ void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_par
|
|||
*/
|
||||
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
|
||||
|
||||
/**
|
||||
* handle TargetID request message
|
||||
*
|
||||
* @param[in] connected_socket socket descriptor
|
||||
* @param[in] cachelist cache list pointer
|
||||
*/
|
||||
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
|
||||
|
||||
/**
|
||||
* handle ChannelID request message
|
||||
*
|
||||
|
@ -163,6 +171,10 @@ int main(int argc, char *argv[]){
|
|||
case XMLREQ:
|
||||
handle_XMLreqMSG( connected_socket, jpipstream, cachelist);
|
||||
break;
|
||||
|
||||
case TIDREQ:
|
||||
handle_TIDreqMSG( connected_socket, cachelist);
|
||||
break;
|
||||
|
||||
case CIDREQ:
|
||||
handle_CIDreqMSG( connected_socket, cachelist);
|
||||
|
@ -183,7 +195,7 @@ int main(int argc, char *argv[]){
|
|||
break;
|
||||
}
|
||||
|
||||
printf("cut the connection. listening to port\n");
|
||||
printf("\t end of the connection\n\n");
|
||||
if( closesocket(connected_socket) != 0){
|
||||
perror("close");
|
||||
return -1;
|
||||
|
@ -221,10 +233,10 @@ void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist
|
|||
Byte_t *newjpipstream;
|
||||
int newstreamlen = 0;
|
||||
cache_param_t *cache;
|
||||
char target[MAX_LENOFTARGET], cid[MAX_LENOFCID];
|
||||
char target[MAX_LENOFTARGET], tid[MAX_LENOFTID], cid[MAX_LENOFCID];
|
||||
metadatalist_param_t *metadatalist;
|
||||
|
||||
newjpipstream = receive_JPIPstream( connected_socket, target, cid, &newstreamlen);
|
||||
newjpipstream = receive_JPIPstream( connected_socket, target, tid, cid, &newstreamlen);
|
||||
|
||||
parse_JPIPstream( newjpipstream, newstreamlen, *streamlen, msgqueue);
|
||||
|
||||
|
@ -235,11 +247,13 @@ void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist
|
|||
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
|
||||
|
||||
// cid registration
|
||||
if( target[0] != 0 && cid[0] != 0){
|
||||
if((cache = search_cache( target, cachelist)))
|
||||
if( target[0] != 0 && tid[0] != 0 && cid[0] != 0){
|
||||
if((cache = search_cache( target, cachelist))){
|
||||
add_cachecid( cid, cache);
|
||||
update_cachetid( tid, cache);
|
||||
}
|
||||
else{
|
||||
cache = gene_cache( target, msgqueue->last->csn, cid);
|
||||
cache = gene_cache( target, msgqueue->last->csn, tid, cid);
|
||||
insert_cache_into_list( cache, cachelist);
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +308,22 @@ void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_pa
|
|||
free( xmlstream);
|
||||
}
|
||||
|
||||
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||
{
|
||||
char target[MAX_LENOFTARGET], *tid = NULL;
|
||||
cache_param_t *cache;
|
||||
int tidlen = 0;
|
||||
|
||||
receive_line( connected_socket, target);
|
||||
cache = search_cache( target, cachelist);
|
||||
|
||||
if( cache){
|
||||
tid = cache->tid;
|
||||
tidlen = strlen(tid);
|
||||
}
|
||||
send_TIDstream( connected_socket, tid, tidlen);
|
||||
}
|
||||
|
||||
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||
{
|
||||
char target[MAX_LENOFTARGET], *cid = NULL;
|
||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
opj_viewer-20110824.jar
|
||||
opj_viewer-20110825.jar
|
|
@ -50,16 +50,19 @@ public class ImageManager extends JPIPHttpClient
|
|||
String refcid = ImgdecClient.query_cid( j2kfilename);
|
||||
byte[] jpipstream;
|
||||
|
||||
if( refcid == null)
|
||||
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, true);
|
||||
if( refcid == null){
|
||||
String reftid = ImgdecClient.query_tid( j2kfilename);
|
||||
if( reftid == null)
|
||||
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, true);
|
||||
else
|
||||
jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, true);
|
||||
}
|
||||
else
|
||||
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, true);
|
||||
|
||||
System.err.println( "decoding to PNM image");
|
||||
pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, cid, fw, fh);
|
||||
pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh);
|
||||
System.err.println( " done");
|
||||
|
||||
// System.out.println( "fw: " + fw + " fh: " + fh + "pnm w: ");
|
||||
|
||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ public class ImgdecClient{
|
|||
return get_PNMstream( cid, fw, fh);
|
||||
}
|
||||
|
||||
public static PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String cid, int fw, int fh)
|
||||
public static PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
|
||||
{
|
||||
send_JPIPstream( jpipstream, j2kfilename, cid);
|
||||
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
||||
return get_PNMstream( cid, fw, fh);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class ImgdecClient{
|
|||
System.err.println("Sending " + jpipstream.length + "Data Bytes to decodingServer");
|
||||
|
||||
os.writeBytes("JPIP-stream\n");
|
||||
os.writeBytes("version 1.1\n");
|
||||
os.writeBytes("version 1.2\n");
|
||||
os.writeBytes( jpipstream.length + "\n");
|
||||
os.write( jpipstream, 0, jpipstream.length);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class ImgdecClient{
|
|||
}
|
||||
}
|
||||
|
||||
public static void send_JPIPstream( byte[] jpipstream, String j2kfilename, String cid)
|
||||
public static void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
||||
{
|
||||
try{
|
||||
Socket imgdecSocket = new Socket( "localhost", 5000);
|
||||
|
@ -85,8 +85,12 @@ public class ImgdecClient{
|
|||
System.err.println("Sending " + length + "Data Bytes to decodingServer");
|
||||
|
||||
os.writeBytes("JPIP-stream\n");
|
||||
os.writeBytes("version 1.1\n");
|
||||
os.writeBytes("version 1.2\n");
|
||||
os.writeBytes( j2kfilename + "\n");
|
||||
if( tid == null)
|
||||
os.writeBytes( "0\n");
|
||||
else
|
||||
os.writeBytes( tid + "\n");
|
||||
os.writeBytes( cid + "\n");
|
||||
os.writeBytes( length + "\n");
|
||||
os.write( jpipstream, 0, length);
|
||||
|
@ -189,7 +193,27 @@ public class ImgdecClient{
|
|||
|
||||
public static String query_cid( String j2kfilename)
|
||||
{
|
||||
String cid = null;
|
||||
int []retmsglabel = new int[3];
|
||||
retmsglabel[0] = 67;
|
||||
retmsglabel[1] = 73;
|
||||
retmsglabel[2] = 68;
|
||||
|
||||
return query_id( "CID request", j2kfilename, retmsglabel);
|
||||
}
|
||||
|
||||
public static String query_tid( String j2kfilename)
|
||||
{
|
||||
int []retmsglabel = new int[3];
|
||||
retmsglabel[0] = 84;
|
||||
retmsglabel[1] = 73;
|
||||
retmsglabel[2] = 68;
|
||||
|
||||
return query_id( "TID request", j2kfilename, retmsglabel);
|
||||
}
|
||||
|
||||
public static String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
||||
{
|
||||
String id = null;
|
||||
|
||||
try{
|
||||
Socket imgdecSocket = new Socket( "localhost", 5000);
|
||||
|
@ -197,23 +221,23 @@ public class ImgdecClient{
|
|||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||
byte []header = new byte[4];
|
||||
|
||||
os.writeBytes("CID request\n");
|
||||
os.writeBytes( reqmsghead + "\n");
|
||||
os.writeBytes( j2kfilename + "\n");
|
||||
|
||||
read_stream( is, header, 4);
|
||||
|
||||
if( header[0] == 67 && header[1] == 73 && header[2] == 68){
|
||||
if( header[0] == retmsglabel[0] && header[1] == retmsglabel[1] && header[2] == retmsglabel[2]){
|
||||
int length = header[3]&0xff;
|
||||
|
||||
if( length > 0){
|
||||
|
||||
byte []ciddata = new byte[ length];
|
||||
read_stream( is, ciddata, length);
|
||||
cid = new String( ciddata);
|
||||
byte []iddata = new byte[ length];
|
||||
read_stream( is, iddata, length);
|
||||
id = new String( iddata);
|
||||
}
|
||||
}
|
||||
else
|
||||
System.err.println("Error in query_cid(), not starting with CID");
|
||||
System.err.println("Error in query_id("+ reqmsghead + "), wrong to start with " + header);
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
System.err.println("Trying to connect to unknown host: " + e);
|
||||
|
@ -221,7 +245,7 @@ public class ImgdecClient{
|
|||
System.err.println("IOException: " + e);
|
||||
}
|
||||
|
||||
return cid;
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void read_stream( DataInputStream is, byte []stream, int length)
|
||||
|
|
|
@ -77,45 +77,57 @@ public class JPIPHttpClient
|
|||
|
||||
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid)
|
||||
{
|
||||
return requestViewWindow( null, reqfw, reqfh, -1, -1, -1, -1, reqcid, false);
|
||||
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, false);
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh, String reqcid)
|
||||
{
|
||||
return requestViewWindow( null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, false);
|
||||
return requestViewWindow( null, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, false);
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( String target, int reqfw, int reqfh)
|
||||
{
|
||||
return requestViewWindow( target, reqfw, reqfh, -1, -1, -1, -1, null, false);
|
||||
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, false);
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( String target, int reqfw, int reqfh, boolean reqcnew)
|
||||
{
|
||||
if( cid == null) // 1 channel allocation only
|
||||
return requestViewWindow( target, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew);
|
||||
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( String target, String reqtid, int reqfw, int reqfh, boolean reqcnew)
|
||||
{
|
||||
if( cid == null) // 1 channel allocation only
|
||||
return requestViewWindow( target, reqtid, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( String target, int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
|
||||
{
|
||||
return requestViewWindow( target, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false);
|
||||
return requestViewWindow( target, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false);
|
||||
}
|
||||
|
||||
|
||||
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid, boolean reqcnew)
|
||||
{
|
||||
return requestViewWindow( null, reqfw, reqfh, -1, -1, -1, -1, reqcid, reqcnew);
|
||||
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, reqcnew);
|
||||
}
|
||||
|
||||
public byte[] requestViewWindow( String target,
|
||||
int reqfw, int reqfh,
|
||||
int reqrx, int reqry,
|
||||
int reqrw, int reqrh,
|
||||
String reqcid, boolean reqcnew)
|
||||
public byte[] requestViewWindow( String target,
|
||||
String reqtid,
|
||||
int reqfw, int reqfh,
|
||||
int reqrx, int reqry,
|
||||
int reqrw, int reqrh,
|
||||
String reqcid, boolean reqcnew)
|
||||
{
|
||||
String urlstring = const_urlstring( target, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, reqcnew);
|
||||
if( reqtid != null)
|
||||
tid = reqtid;
|
||||
|
||||
String urlstring = const_urlstring( target, reqtid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, reqcnew);
|
||||
return GETrequest( urlstring);
|
||||
}
|
||||
|
||||
|
@ -151,7 +163,14 @@ public class JPIPHttpClient
|
|||
|
||||
Map<String,java.util.List<String>> headers = urlconn.getHeaderFields();
|
||||
java.util.List<String> hvaluelist;
|
||||
|
||||
|
||||
String status = headers.get(null).get(0);
|
||||
|
||||
System.err.println( status);
|
||||
if( !status.contains("OK"))
|
||||
System.err.println( headers.get("Reason"));
|
||||
System.err.println( headers.get("Content-type"));
|
||||
|
||||
if(( hvaluelist = headers.get("JPIP-fsiz")) != null){
|
||||
String hvalueline = hvaluelist.get(0);
|
||||
fw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
|
||||
|
@ -242,7 +261,8 @@ public class JPIPHttpClient
|
|||
return jpipstream;
|
||||
}
|
||||
|
||||
private String const_urlstring( String target,
|
||||
private String const_urlstring( String target,
|
||||
String reqtid,
|
||||
int reqfw, int reqfh,
|
||||
int reqrx, int reqry,
|
||||
int reqrw, int reqrh,
|
||||
|
@ -258,6 +278,11 @@ public class JPIPHttpClient
|
|||
urlstring = urlstring.concat( "&");
|
||||
urlstring = urlstring.concat( "target=" + target);
|
||||
}
|
||||
if( reqtid != null){
|
||||
if( !urlstring.endsWith("?"))
|
||||
urlstring = urlstring.concat( "&");
|
||||
urlstring = urlstring.concat( "tid=" + reqtid);
|
||||
}
|
||||
if( reqfw != -1 && reqfh != -1){
|
||||
if( !urlstring.endsWith("?"))
|
||||
urlstring = urlstring.concat( "&");
|
||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
opj_viewer_xerces-20110824.jar
|
||||
opj_viewer_xerces-20110825.jar
|
|
@ -9,7 +9,8 @@ opj_server_CPPFLAGS = \
|
|||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
@FCGI_CFLAGS@ \
|
||||
-DSERVER
|
||||
-DSERVER \
|
||||
-DQUIT_SIGNAL=\"quitJPIP\"
|
||||
opj_server_CFLAGS =
|
||||
opj_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_server.la @FCGI_LIBS@ -lm
|
||||
opj_server_SOURCES = \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
LIBDIR = ../libopenjpip
|
||||
|
||||
LIBFNAME = $(LIBDIR)/libopenjpip_server.a
|
||||
CFLAGS = -O3 -Wall -m32 -DSERVER -I$(LIBDIR)
|
||||
CFLAGS = -O3 -Wall -m32 -DSERVER -DQUIT_SIGNAL=\"quitJPIP\" -I$(LIBDIR)
|
||||
LDFLAGS = -L$(LIBDIR) -lm -lfcgi -lopenjpip_server
|
||||
|
||||
ALL = opj_server
|
||||
|
|
|
@ -55,6 +55,9 @@
|
|||
#include "imgreg_manager.h"
|
||||
#include "msgqueue_manager.h"
|
||||
|
||||
#ifndef QUIT_SIGNAL
|
||||
#define QUIT_SIGNAL "quitJPIP"
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
|
@ -102,6 +105,9 @@ int main(void)
|
|||
#ifdef SERVER
|
||||
query_string = getenv("QUERY_STRING");
|
||||
#endif //SERVER
|
||||
|
||||
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
||||
break;
|
||||
|
||||
fprintf( FCGI_stdout, "Content-type: image/jpt-stream\r\n");
|
||||
|
||||
|
@ -130,6 +136,8 @@ int main(void)
|
|||
|
||||
delete_msgqueue( &msgqueue);
|
||||
}
|
||||
|
||||
fprintf( FCGI_stderr, "JPIP server terminated by a client request\n");
|
||||
|
||||
delete_sessionlist( &sessionlist);
|
||||
delete_targetlist( &targetlist);
|
||||
|
@ -216,9 +224,11 @@ bool parse_JPIPrequest( query_param_t query_param,
|
|||
session_param_t *cursession = NULL;
|
||||
channel_param_t *curchannel = NULL;
|
||||
|
||||
if( !identify_target( query_param, targetlist, &target))
|
||||
return false;
|
||||
|
||||
if( query_param.target[0] != '\0' || query_param.tid[0] != '\0'){
|
||||
if( !identify_target( query_param, targetlist, &target))
|
||||
return false;
|
||||
}
|
||||
|
||||
if( query_param.cid[0] != '\0'){
|
||||
if( !associate_channel( query_param, sessionlist, &cursession, &curchannel))
|
||||
return false;
|
||||
|
@ -241,32 +251,30 @@ bool parse_JPIPrequest( query_param_t query_param,
|
|||
|
||||
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
|
||||
{
|
||||
if( query_param.tid[0] !='\0' && strcmp( query_param.tid, "0") != 0 ){
|
||||
if( query_param.cid[0] != '\0'){
|
||||
fprintf( FCGI_stdout, "Reason: Target can not be specified both through tid and cid\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
if( ( *target = search_targetBytid( query_param.tid, targetlist)))
|
||||
return true;
|
||||
}
|
||||
|
||||
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.tid[0] !='\0'){
|
||||
if( strcmp( query_param.tid, "0") != 0 ){
|
||||
if( query_param.cid[0] != '\0'){
|
||||
fprintf( FCGI_stdout, "Reason: Target can not be specified both through tid and cid\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
if( !( *target = search_targetBytid( query_param.tid, targetlist)))
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
if( *target)
|
||||
fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", (*target)->tid);
|
||||
else{
|
||||
fprintf( FCGI_stdout, "Reason: target not specified\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if( *target){
|
||||
fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", (*target)->tid);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stdout, "Reason: target not found\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool associate_channel( query_param_t query_param,
|
||||
|
|
Loading…
Reference in New Issue