support tid request

This commit is contained in:
Kaori Hagihara 2011-08-24 17:07:28 +00:00
parent 9c475467d5
commit 4da816e459
24 changed files with 140 additions and 26 deletions

View File

@ -7,6 +7,7 @@ What's New for OpenJPIP
August 24, 2011
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
+ [kaori] added tid request support
August 16, 2011
* [antonin] fixed cmake support for openjpip

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>

View File

@ -31,7 +31,6 @@
#ifndef BOX_MANAGER_H_
# define BOX_MANAGER_H_
#include <stdio.h>
#include "byte_manager.h"
//! box parameters

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

View File

@ -31,8 +31,6 @@
#ifndef BYTE_MANAGER_H_
# define BYTE_MANAGER_H_
#include <stdio.h>
//! 1Byte parameter type
typedef unsigned char Byte_t;

View File

@ -31,7 +31,6 @@
#ifndef CODESTREAM_MANAGER_H_
# define CODESTREAM_MANAGER_H_
#include <stdio.h>
#include "byte_manager.h"
//! codestream parameters

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
@ -742,31 +743,45 @@ Byte_t * recons_codestream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte
Byte_t *codestream = NULL;
int last_tileID;
int tileID;
bool found;
Byte8_t binOffset;
*codelen = 0;
// main header first
ptr = msgqueue->first;
binOffset = 0;
while(( ptr = search_message( MAINHEADER_MSG, -1, csn, ptr))!=NULL){
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
if( ptr->bin_offset == binOffset){
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
binOffset += ptr->length;
}
ptr = ptr->next;
}
last_tileID = get_last_tileID( msgqueue, csn);
for( tileID=0; tileID <= last_tileID; tileID++){
bool found = false;
found = false;
binOffset = 0;
ptr = msgqueue->first;
while(( ptr = search_message( TILE_MSG, tileID, csn, ptr))!=NULL){
found = true;
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
if( ptr->bin_offset == binOffset){
found = true;
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
binOffset += ptr->length;
}
ptr = ptr->next;
}
ptr = msgqueue->first;
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
if( ptr->aux >= minlev){
found = true;
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
if( ptr->bin_offset == binOffset){
found = true;
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
binOffset += ptr->length;
}
}
ptr = ptr->next;
}

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "placeholder_manager.h"

View File

@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include "target_manager.h"
#ifdef SERVER
@ -91,6 +92,7 @@ target_param_t * gene_target( targetlist_param_t *targetlist, char *targetname)
}
target = (target_param_t *)malloc( sizeof(target_param_t));
snprintf( target->tid, MAX_LENOFTID, "%x-%x", (unsigned int)time(NULL), (unsigned int)rand());
strcpy( target->filename, targetname);
target->fd = fd;
target->csn = last_csn++;
@ -99,6 +101,8 @@ 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
@ -170,6 +174,7 @@ void delete_targetlist(targetlist_param_t **targetlist)
void print_target( target_param_t *target)
{
fprintf( logstream, "target:\n");
fprintf( logstream, "\t tid=%s\n", target->tid);
fprintf( logstream, "\t csn=%d\n", target->csn);
fprintf( logstream, "\t target=%s\n\n", target->filename);
}
@ -201,6 +206,26 @@ target_param_t * search_target( char targetname[], targetlist_param_t *targetlis
return NULL;
}
target_param_t * search_targetBytid( char tid[], targetlist_param_t *targetlist)
{
target_param_t *foundtarget;
foundtarget = targetlist->first;
while( foundtarget != NULL){
if( strcmp( tid, foundtarget->tid) == 0)
return foundtarget;
foundtarget = foundtarget->next;
}
fprintf( FCGI_stdout, "Status: 404\r\n");
fprintf( FCGI_stdout, "Reason: tid %s not found\r\n", tid);
return NULL;
}
int open_jp2file( char filename[])
{
int fd;

View File

@ -33,11 +33,15 @@
#include "index_manager.h"
//! maximum length of target identifier
#define MAX_LENOFTID 30
//! maximum length of target name
#define MAX_LENOFTARGET 128
//! target parameters
typedef struct target_param{
char tid[MAX_LENOFTID]; //!< taregt identifier
char filename[MAX_LENOFTARGET]; //!< file name
int fd; //!< file descriptor
int csn; //!< codestream number
@ -138,5 +142,15 @@ void print_alltarget( targetlist_param_t *targetlist);
*/
target_param_t * search_target( char targetname[], targetlist_param_t *targetlist);
/**
* search a target by tid
*
* @param[in] tid target identifier
* @param[in] targetlist target list pointer
* @return found target pointer
*/
target_param_t * search_targetBytid( char tid[], targetlist_param_t *targetlist);
#endif /* !TARGET_MANAGER_H_ */

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "jp2k_decoder.h"

View File

@ -201,7 +201,7 @@ int main(int argc, char *argv[]){
if( msgqueue)
delete_msgqueue( &msgqueue);
// save_codestream( jpipstream, jpipstreamlen, "jpt");
//save_codestream( jpipstream, jpipstreamlen, "jpt");
free( jpipstream);
#ifdef _WIN32

View File

@ -1 +1 @@
opj_viewer-20110711.jar
opj_viewer-20110824.jar

View File

@ -40,6 +40,7 @@ public class JPIPHttpClient
protected int rx, ry;
protected int rw, rh;
protected String cid;
protected String tid;
public JPIPHttpClient( String URI)
{
@ -48,6 +49,7 @@ public class JPIPHttpClient
rx = ry = -1;
rw = rh = -1;
cid = null;
tid = null;
}
public int getFw(){ return fw;}
@ -178,6 +180,12 @@ public class JPIPHttpClient
System.err.println("cid: " + cid);
}
if(( hvaluelist = headers.get("JPIP-tid")) != null){
String hvalueline = hvaluelist.get(0);
tid = hvalueline.substring( hvalueline.indexOf('=')+1);
System.err.println("tid: " + tid);
}
InputStream input = urlconn.getInputStream();
buflen = input.available();

View File

@ -1 +1 @@
opj_viewer_xerces-20110711.jar
opj_viewer_xerces-20110824.jar

View File

@ -68,7 +68,7 @@ channel_param_t * gene_channel( query_param_t query_param, cachemodel_param_t *c
channel->cachemodel = cachemodel;
// 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());
channel->next=NULL;

View File

@ -115,7 +115,8 @@ int main(void)
#endif
msgqueue = NULL;
parse_status = parse_JPIPrequest( query_param, sessionlist, targetlist, &msgqueue);
if( !(parse_status = parse_JPIPrequest( query_param, sessionlist, targetlist, &msgqueue)))
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
fprintf( FCGI_stdout, "\r\n");
@ -136,6 +137,15 @@ int main(void)
return 0;
}
/**
* REQUEST: target identification by target or tid request
*
* @param[in] query_param structured query
* @param[in] targetlist target list pointer
* @param[out] target address of target pointer
* @return if succeeded (true) or failed (false)
*/
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target);
/**
* REQUEST: channel association
@ -206,14 +216,13 @@ bool parse_JPIPrequest( query_param_t query_param,
session_param_t *cursession = 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( !identify_target( query_param, targetlist, &target))
return false;
if( query_param.cid[0] != '\0')
if( query_param.cid[0] != '\0'){
if( !associate_channel( query_param, sessionlist, &cursession, &curchannel))
return false;
}
if( query_param.cnew){
if( !open_channel( query_param, sessionlist, target, &cursession, &curchannel))
@ -230,6 +239,36 @@ bool parse_JPIPrequest( query_param_t query_param,
return true;
}
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
{
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;
}
}
}
return true;
}
bool associate_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
session_param_t **cursession,

View File

@ -99,6 +99,9 @@ void parse_query( char *query_string, query_param_t *query_param)
if( strcasecmp( fieldname, "target") == 0)
strcpy( query_param->target,fieldval);
else if( strcasecmp( fieldname, "tid") == 0)
strcpy( query_param->tid, fieldval);
else if( strcasecmp( fieldname, "fsiz") == 0)
sscanf( fieldval, "%d,%d", &query_param->fx, &query_param->fy);
@ -128,6 +131,7 @@ void init_queryparam( query_param_t *query_param)
int i;
query_param->target[0]='\0';
query_param->tid[0]='\0';
query_param->fx=-1;
query_param->fy=-1;
query_param->rx=-1;
@ -183,6 +187,7 @@ void print_queryparam( query_param_t query_param)
fprintf( logstream, "query parameters:\n");
fprintf( logstream, "\t target: %s\n", query_param.target);
fprintf( logstream, "\t tid: %s\n", query_param.tid);
fprintf( logstream, "\t fx,fy: %d, %d\n", query_param.fx, query_param.fy);
fprintf( logstream, "\t rx,ry: %d, %d \t rw,rh: %d, %d\n", query_param.rx, query_param.ry, query_param.rw, query_param.rh);
fprintf( logstream, "\t cnew: %d\n", query_param.cnew);

View File

@ -36,6 +36,9 @@
//! maximum length of target name
#define MAX_LENOFTARGET 128
//! maximum length of target identifier
#define MAX_LENOFTID 30
//! maximum length of channel identifier
#define MAX_LENOFCID 30
@ -48,6 +51,7 @@
//! Query parameters
typedef struct query_param{
char target[MAX_LENOFTARGET]; //!< target name
char tid[MAX_LENOFTID]; //!< target identifier
int fx, fy; //!< frame size (fx,fy)
int rx, ry, rw, rh; //!< roi region
char cid[MAX_LENOFCID]; //!< channel identifier