]> granicus.if.org Git - openjpeg/commitdiff
opj_dec_server enabled stateless requests
authorKaori Hagihara <khagihara@users.noreply.github.com>
Fri, 16 Sep 2011 14:20:00 +0000 (14:20 +0000)
committerKaori Hagihara <khagihara@users.noreply.github.com>
Fri, 16 Sep 2011 14:20:00 +0000 (14:20 +0000)
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

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);