! : changed
+ : added
+September 16, 2011
++ [kaori] enabled stateless requests from the opj_viewers
+
+Septempber 1, 2011
+* [kaori] changed terminating status of opj_server in debug/non-server mode
+
August 27, 2011
* [antonin] fixed missing include directory in opj_client/opj_dec_server/CMakeLists.txt
% ../opj_dec_server
2. Open image viewers (as many as needed)
- % java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2
+ % java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2 [stateless]
( The arguments
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
- - JP2_filename.jp2 is the name of a JP2 file available on the server.)
+ - JP2_filename.jp2 is the name of a JP2 file available on the server.
+ - stateless if stateless request is desired, otherwise session request is implemented
Image viewer GUI instructions:
Scale up request: Enlarge the window
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
return NULL;
}
+cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist)
+{
+ cache_param_t *foundcache;
+
+ foundcache = cachelist->first;
+
+ while( foundcache != NULL){
+ if( strcmp( tid, foundcache->tid) == 0)
+ return foundcache;
+ foundcache = foundcache->next;
+ }
+ return NULL;
+}
+
void add_cachecid( char *cid, cache_param_t *cache)
{
char **tmp;
/**
- * search codestream number (csn) by cid
+ * search a cache by cid
*
* @param[in] cid channel identifer
* @param[in] cachelist cache list pointer
*/
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
+
+/**
+ * search a cache by tid
+ *
+ * @param[in] tid target identifer
+ * @param[in] cachelist cache list pointer
+ * @return found cache pointer
+ */
+cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist);
+
/**
* add cid into a cache
*
target[0] = 0;
cid[0] = 0;
+ tid[0] = 0;
if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL;
if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL;
- strcpy( tid, buf);
+ if( strcmp( buf, "0") != 0)
+ strcpy( tid, buf);
if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL;
- strcpy( cid, buf);
+ if( strcmp( buf, "0") != 0)
+ strcpy( cid, buf);
if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL;
*\section sec2 PNM request
* Get decoded PGM/PPM image
*
- * client -> server: PNM request\\n cidstring\\n fw\\n fh\\n \n
+ * client -> server: PNM request\\n [cid/tid]string\\n fw\\n fh\\n \n
* server -> client: P6 or P5 (2Byte) width (2Byte Big endian) height (2Byte Big endian) maxval (1Byte) data
*
*\section sec3 XML request
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
// cid registration
- if( target[0] != 0 && tid[0] != 0 && cid[0] != 0){
+ if( target[0] != 0){
if((cache = search_cache( target, cachelist))){
- add_cachecid( cid, cache);
- update_cachetid( tid, cache);
+ if( tid[0] != 0)
+ update_cachetid( tid, cache);
+ if( cid[0] != 0)
+ add_cachecid( cid, cache);
}
else{
cache = gene_cache( target, msgqueue->last->csn, tid, cid);
receive_line( connected_socket, cid);
if(!(cache = search_cacheBycid( cid, cachelist)))
- return;
+ if(!(cache = search_cacheBytid( cid, cachelist)))
+ return;
receive_line( connected_socket, tmp);
fw = atoi( tmp);
-opj_viewer-20110825.jar
\ No newline at end of file
+opj_viewer-20110916.jar
\ No newline at end of file
public int getOrigWidth(){ return pnmimage.width;}
public int getOrigHeight(){ return pnmimage.height;}
- public Image getImage( String j2kfilename, int reqfw, int reqfh)
+ public Image getImage( String j2kfilename, int reqfw, int reqfh, boolean reqcnew)
{
System.err.println();
- String refcid = ImgdecClient.query_cid( j2kfilename);
+ String refcid = null;
byte[] jpipstream;
+ if( reqcnew)
+ refcid = ImgdecClient.query_cid( j2kfilename);
+
if( refcid == null){
String reftid = ImgdecClient.query_tid( j2kfilename);
if( reftid == null)
- jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, true);
+ jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew);
else
- jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, true);
+ jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, reqcnew);
}
else
- jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, true);
+ jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew);
System.err.println( "decoding to PNM image");
pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh);
public Image getImage( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
{
System.err.println();
-
+
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
System.err.println( "decoding to PNM image");
- pnmimage = ImgdecClient.decode_jpipstream( jpipstream, cid, fw, fh);
+ pnmimage = ImgdecClient.decode_jpipstream( jpipstream, tid, cid, fw, fh);
System.err.println( " done");
return pnmimage.createROIImage( rx, ry, rw, rh);
}
public void closeChannel()
{
- ImgdecClient.destroy_cid( cid);
- super.closeChannel();
+ if( cid != null){
+ ImgdecClient.destroy_cid( cid);
+ super.closeChannel();
+ }
}
}
\ No newline at end of file
private Rectangle roirect[] = null;
private String roiname[] = null;
- public ImageViewer( String j2kfilename, ImageManager manager)
+ public ImageViewer( String j2kfilename, ImageManager manager, boolean session)
{
String str;
myRL = new ResizeListener(this);
imgmanager = manager;
- img = imgmanager.getImage( j2kfilename, vw, vh);
+ img = imgmanager.getImage( j2kfilename, vw, vh, session);
addMouseListener(myMML);
addMouseMotionListener(myMML);
// private OptionPanel optpanel;
private ImageManager imgmanager;
- public ImageWindow( String uri, String j2kfilename)
+ public ImageWindow( String uri, String j2kfilename, boolean session)
{
super( j2kfilename);
imgmanager = new ImageManager( uri);
- imgviewer = new ImageViewer( j2kfilename, imgmanager);
+ imgviewer = new ImageViewer( j2kfilename, imgmanager, session);
imgviewer.setOpaque(true); //content panes must be opaque
// optpanel = new OptionPanel( imgmanager, imgviewer);
public static void main(String s[])
{
String j2kfilename, uri;
+ boolean session;
if(s.length > 0){
uri = s[0];
j2kfilename = s[1];
+ if( s.length > 2)
+ session = !s[2].equalsIgnoreCase( "stateless");
+ else
+ session = true;
}
else{
- System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2");
+ System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session]");
return;
}
- ImageWindow frame = new ImageWindow( uri, j2kfilename);
+ ImageWindow frame = new ImageWindow( uri, j2kfilename, session);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public class ImgdecClient{
- public static PnmImage decode_jpipstream( byte[] jpipstream, String cid, int fw, int fh)
+ public static PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
{
if( jpipstream != null)
send_JPIPstream( jpipstream);
- return get_PNMstream( cid, fw, fh);
+ return get_PNMstream( cid, tid, fw, fh);
}
public static PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
{
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
- return get_PNMstream( cid, fw, fh);
+ return get_PNMstream( cid, tid, fw, fh);
}
public static void send_JPIPstream( byte[] jpipstream)
os.writeBytes( "0\n");
else
os.writeBytes( tid + "\n");
- os.writeBytes( cid + "\n");
+ if( cid == null)
+ os.writeBytes( "0\n");
+ else
+ os.writeBytes( cid + "\n");
os.writeBytes( length + "\n");
os.write( jpipstream, 0, length);
-
+
byte signal = is.readByte();
if( signal == 0)
}
}
- public static PnmImage get_PNMstream( String cid, int fw, int fh)
+ public static PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
{
PnmImage pnmstream = new PnmImage();
try {
byte []header = new byte[7];
os.writeBytes("PNM request\n");
- os.writeBytes( cid + "\n");
+ if( cid != null)
+ os.writeBytes( cid + "\n");
+ else
+ if( tid != null)
+ os.writeBytes( tid + "\n");
+ else
+ os.writeBytes( "0\n");
os.writeBytes( fw + "\n");
os.writeBytes( fh + "\n");
if( cid != null)
return requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh, cid);
else
- return null;
+ // return null;
+ if( tid != null)
+ return requestViewWindow( null, tid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false);
+ else
+ return null;
}
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid)
-opj_viewer_xerces-20110825.jar
\ No newline at end of file
+opj_viewer_xerces-20110916.jar
\ No newline at end of file
#else
char query_string[128];
- while((fgets( query_string, 128, stdin))[0] != '\n' )
+ while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
#endif
{