[1.5] backport r909, r922-925 to branch 1.5 (terminating status of opj_server in...
authorAntonin Descampe <antonin@gmail.com>
Mon, 10 Oct 2011 07:03:28 +0000 (07:03 +0000)
committerAntonin Descampe <antonin@gmail.com>
Mon, 10 Oct 2011 07:03:28 +0000 (07:03 +0000)
19 files changed:
applications/jpip/CHANGES
applications/jpip/README
applications/jpip/opj_client/opj_dec_server/cache_manager.c
applications/jpip/opj_client/opj_dec_server/cache_manager.h
applications/jpip/opj_client/opj_dec_server/imgsock_manager.c
applications/jpip/opj_client/opj_dec_server/imgsock_manager.h
applications/jpip/opj_client/opj_dec_server/opj_dec_server.c
applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110825.jar [deleted file]
applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110916.jar [new file with mode: 0644]
applications/jpip/opj_client/opj_viewer/dist/opj_viewer.jar
applications/jpip/opj_client/opj_viewer/src/ImageManager.java
applications/jpip/opj_client/opj_viewer/src/ImageViewer.java
applications/jpip/opj_client/opj_viewer/src/ImageWindow.java
applications/jpip/opj_client/opj_viewer/src/ImgdecClient.java
applications/jpip/opj_client/opj_viewer/src/JPIPHttpClient.java
applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110825.jar [deleted file]
applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110916.jar [new file with mode: 0644]
applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces.jar
applications/jpip/opj_server/opj_server.c

index 4ed52aa5d57c704919513d03d3a8f330b661f1db..3e4141eeab87d059a1fb60bfe6237ef08cdf6dbd 100644 (file)
@@ -5,6 +5,12 @@ What's New for OpenJPIP
 ! : 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
 
index 0f053189f7084db93c91d69d986483fb7042de78..c35557f11a9fe324ff22547752cf5ffc91367858 100644 (file)
@@ -106,10 +106,11 @@ Client:
     % ../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
index 6a7b92c914ae3094c4d3167064d4f640f89be649..597a589633b9a559e1c279ed41744bbe0484c5a8 100644 (file)
@@ -154,6 +154,20 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
   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;
index ad35de80e2b694c400591d312541d3b3ec024796..61c1381569ee982e826bfc80ca086f2a493ee2fe 100644 (file)
@@ -121,7 +121,7 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
 
 
 /**
- * search codestream number (csn) by cid
+ * search a cache by cid
  *
  * @param[in] cid        channel identifer
  * @param[in] cachelist  cache list pointer
@@ -129,6 +129,16 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
  */
 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
  *
index 19599a9a724ca1c4528ec52075d700dda4eb0b0e..4e6652aceb1f1ef027277c22b7dbf2d1bc046c4d 100644 (file)
@@ -123,6 +123,7 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *tid, c
   
   target[0] = 0;
   cid[0] = 0;
+  tid[0] = 0;
   
   if((linelen = receive_line( connected_socket, buf)) == 0)
     return NULL;
@@ -140,11 +141,13 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *tid, c
     
     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;
index 7a76d619bfc51c52d1ed1217b0271502a95cd868..713c099ecb0fd7e26063324ec7e8b4ddfdfc2d8f 100644 (file)
@@ -141,7 +141,7 @@ int receive_line(SOCKET connected_socket, char *buf);
  *\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
index c8c3c6958d7da6afa8df19eda96b25c781ef2ac7..a2fe2143ebfc646078e49be691d3eb6ccc1d0244 100644 (file)
@@ -247,10 +247,12 @@ void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist
   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);
@@ -277,7 +279,8 @@ void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_par
   
   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);
diff --git a/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110825.jar b/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110825.jar
deleted file mode 100644 (file)
index 67b68b6..0000000
Binary files a/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110825.jar and /dev/null differ
diff --git a/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110916.jar b/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110916.jar
new file mode 100644 (file)
index 0000000..a492a2c
Binary files /dev/null and b/applications/jpip/opj_client/opj_viewer/dist/opj_viewer-20110916.jar differ
index ce826b27f1d1f1d0c5dff55dab9f1dda8483de52..1553f3e0e6805fe1a10c4852d41b24a8c2ae1b6d 120000 (symlink)
@@ -1 +1 @@
-opj_viewer-20110825.jar
\ No newline at end of file
+opj_viewer-20110916.jar
\ No newline at end of file
index 62166f8a106790c2c0fed5836362eca979eb2185..f9e124419e8b62037191fe5d4f2e642447c849dc 100644 (file)
@@ -43,22 +43,25 @@ public class ImageManager extends JPIPHttpClient
     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);
@@ -70,11 +73,11 @@ public class ImageManager extends JPIPHttpClient
     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);
@@ -96,7 +99,9 @@ public class ImageManager extends JPIPHttpClient
     }
     public void closeChannel()
     {
-       ImgdecClient.destroy_cid( cid);
-       super.closeChannel();
+       if( cid != null){
+           ImgdecClient.destroy_cid( cid);
+           super.closeChannel();
+       }
     }
 }
\ No newline at end of file
index fe6f7eb4876ddd057f063cf1657c03e2273d3d55..8e0abe4a27382b0020dc39ad3cc7f568c478e7e7 100644 (file)
@@ -55,7 +55,7 @@ public class ImageViewer extends JPanel
     private Rectangle roirect[] = null;
     private String roiname[] = null;
       
-    public ImageViewer( String j2kfilename, ImageManager manager)
+    public ImageViewer( String j2kfilename, ImageManager manager, boolean session)
     {
        String str;
 
@@ -70,7 +70,7 @@ public class ImageViewer extends JPanel
        myRL = new ResizeListener(this);
 
        imgmanager = manager;
-       img = imgmanager.getImage( j2kfilename, vw, vh);
+       img = imgmanager.getImage( j2kfilename, vw, vh, session);
 
        addMouseListener(myMML);
        addMouseMotionListener(myMML);
index f6fc98ee75ddc4b0e508f3d9878f08e2c5c85cfa..5ffe9a5e65687d7e2f843448a9c0814bb4513fa6 100644 (file)
@@ -38,13 +38,13 @@ public class ImageWindow extends JFrame
     //    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);
@@ -71,16 +71,21 @@ public class ImageWindow extends JFrame
     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);
    
index 85fba6127b9955f797d925a844376f75bbd3bda7..6f1b3c303b6ea87e5b902cbec2f76036d96a4332 100644 (file)
@@ -33,17 +33,17 @@ import java.net.*;
 
 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)
@@ -91,10 +91,13 @@ public class ImgdecClient{
                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)
@@ -106,7 +109,7 @@ public class ImgdecClient{
        }
     }
 
-    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 {
@@ -116,7 +119,13 @@ public class ImgdecClient{
            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");
 
index cfd3db4cc897bbf6c5e123750ec874e7d441d015..93d4ad5cdf4bbaf6d0844215b1749eab9515b967 100644 (file)
@@ -72,7 +72,11 @@ public class JPIPHttpClient
        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)
diff --git a/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110825.jar b/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110825.jar
deleted file mode 100644 (file)
index 4028b66..0000000
Binary files a/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110825.jar and /dev/null differ
diff --git a/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110916.jar b/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110916.jar
new file mode 100644 (file)
index 0000000..e3eb2d6
Binary files /dev/null and b/applications/jpip/opj_client/opj_viewer_xerces/dist/opj_viewer_xerces-20110916.jar differ
index 0f5d3dc99413bb5458fb9abcf915928b0f86a11d..4036811e4ac3f3b7329139599b4bbae676af0ad0 120000 (symlink)
@@ -1 +1 @@
-opj_viewer_xerces-20110825.jar
\ No newline at end of file
+opj_viewer_xerces-20110916.jar
\ No newline at end of file
index 936b54ce71e730ea7f2bb5d4286e4cbd4de2e400..deaaae3d18be7b6f8855bc1b7e0e2eedd6b1d72d 100644 (file)
@@ -98,7 +98,7 @@ int main(void)
 #else
 
   char query_string[128];
-  while((fgets( query_string, 128, stdin))[0] != '\n' )
+  while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
 #endif
     {