From 0a42a8bc46806cb60df56fff3809206b5adffc8d Mon Sep 17 00:00:00 2001 From: Kaori Hagihara Date: Fri, 16 Sep 2011 14:20:00 +0000 Subject: [PATCH] opj_dec_server enabled stateless requests --- .../jpip/opj_client/opj_dec_server/cache_manager.c | 14 ++++++++++++++ .../jpip/opj_client/opj_dec_server/cache_manager.h | 12 +++++++++++- .../opj_client/opj_dec_server/imgsock_manager.c | 7 +++++-- .../opj_client/opj_dec_server/imgsock_manager.h | 2 +- .../opj_client/opj_dec_server/opj_dec_server.c | 11 +++++++---- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/applications/jpip/opj_client/opj_dec_server/cache_manager.c b/applications/jpip/opj_client/opj_dec_server/cache_manager.c index 6a7b92c9..597a5896 100644 --- a/applications/jpip/opj_client/opj_dec_server/cache_manager.c +++ b/applications/jpip/opj_client/opj_dec_server/cache_manager.c @@ -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; diff --git a/applications/jpip/opj_client/opj_dec_server/cache_manager.h b/applications/jpip/opj_client/opj_dec_server/cache_manager.h index ad35de80..61c13815 100644 --- a/applications/jpip/opj_client/opj_dec_server/cache_manager.h +++ b/applications/jpip/opj_client/opj_dec_server/cache_manager.h @@ -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 * diff --git a/applications/jpip/opj_client/opj_dec_server/imgsock_manager.c b/applications/jpip/opj_client/opj_dec_server/imgsock_manager.c index 19599a9a..4e6652ac 100644 --- a/applications/jpip/opj_client/opj_dec_server/imgsock_manager.c +++ b/applications/jpip/opj_client/opj_dec_server/imgsock_manager.c @@ -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; diff --git a/applications/jpip/opj_client/opj_dec_server/imgsock_manager.h b/applications/jpip/opj_client/opj_dec_server/imgsock_manager.h index 7a76d619..713c099e 100644 --- a/applications/jpip/opj_client/opj_dec_server/imgsock_manager.h +++ b/applications/jpip/opj_client/opj_dec_server/imgsock_manager.h @@ -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 diff --git a/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c b/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c index c8c3c695..a2fe2143 100644 --- a/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c +++ b/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c @@ -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);