changed parameter and file names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
This commit is contained in:
parent
a5130aebab
commit
826fda959c
|
@ -5,6 +5,9 @@ What's New for OpenJPIP
|
||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
|
July 5, 2011
|
||||||
|
! [kaori] changed parameter and file names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||||
|
|
||||||
May 26, 2011
|
May 26, 2011
|
||||||
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ void print_binarycode( Byte8_t n, int segmentlen)
|
||||||
Byte_t * parse_bin_id_vbas( Byte_t *streamptr, Byte_t *bb, Byte_t *c, Byte8_t *in_class_id);
|
Byte_t * parse_bin_id_vbas( Byte_t *streamptr, Byte_t *bb, Byte_t *c, Byte8_t *in_class_id);
|
||||||
Byte_t * parse_vbas( Byte_t *streamptr, Byte8_t *elem);
|
Byte_t * parse_vbas( Byte_t *streamptr, Byte8_t *elem);
|
||||||
|
|
||||||
void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_param_t *msgqueue)
|
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
Byte_t *ptr; // stream pointer
|
Byte_t *ptr; // stream pointer
|
||||||
message_param_t *msg;
|
message_param_t *msg;
|
||||||
|
@ -496,8 +496,8 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
|
||||||
|
|
||||||
class_id = -1; // dummy
|
class_id = -1; // dummy
|
||||||
csn = 0;
|
csn = 0;
|
||||||
ptr = stream;
|
ptr = JPIPstream;
|
||||||
while( ptr-stream < jptlen){
|
while( ptr-JPIPstream < streamlen){
|
||||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||||
|
|
||||||
ptr = parse_bin_id_vbas( ptr, &bb, &c, &msg->in_class_id);
|
ptr = parse_bin_id_vbas( ptr, &bb, &c, &msg->in_class_id);
|
||||||
|
@ -522,7 +522,7 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
|
||||||
else
|
else
|
||||||
msg->aux = 0;
|
msg->aux = 0;
|
||||||
|
|
||||||
msg->res_offset = ptr-stream+offset;
|
msg->res_offset = ptr-JPIPstream+offset;
|
||||||
msg->phld = NULL;
|
msg->phld = NULL;
|
||||||
msg->next = NULL;
|
msg->next = NULL;
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
|
||||||
|
|
||||||
void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *stream);
|
void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *stream);
|
||||||
|
|
||||||
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t jptlen, metadatalist_param_t *metadatalist)
|
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist)
|
||||||
{
|
{
|
||||||
message_param_t *msg;
|
message_param_t *msg;
|
||||||
|
|
||||||
|
|
|
@ -119,24 +119,24 @@ void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse JPT-stream to message queue
|
* parse JPT- JPP- stream to message queue
|
||||||
*
|
*
|
||||||
* @param[in] stream JPT-stream data pointer
|
* @param[in] JPIPstream JPT- JPP- stream data pointer
|
||||||
* @param[in] jptlen JPT-stream length
|
* @param[in] streamlen JPIPstream length
|
||||||
* @param[in] offset offset of the JPT-stream from the whole beginning
|
* @param[in] offset offset of the stream from the whole beginning
|
||||||
* @param[in,out] msgqueue adding message queue pointer
|
* @param[in,out] msgqueue adding message queue pointer
|
||||||
*/
|
*/
|
||||||
void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_param_t *msgqueue);
|
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse JPT-stream to message queue
|
* parse JPT- JPP- stream to message queue
|
||||||
*
|
*
|
||||||
* @param[in] msgqueue reference message queue pointer
|
* @param[in] msgqueue reference message queue pointer
|
||||||
* @param[in] stream JPT-stream data pointer
|
* @param[in] stream stream data pointer
|
||||||
* @param[in] jptlen JPT-stream length
|
* @param[in] streamlen stream length
|
||||||
* @param[in] metadatalist adding metadata list pointer
|
* @param[in] metadatalist adding metadata list pointer
|
||||||
*/
|
*/
|
||||||
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t jptlen, metadatalist_param_t *metadatalist);
|
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,7 +8,7 @@ ALL = opj_dec_server
|
||||||
|
|
||||||
all: $(ALL)
|
all: $(ALL)
|
||||||
|
|
||||||
opj_dec_server: opj_dec_server.o jp2k_decoder.o imgsock_manager.o jptstream_manager.o cache_manager.o $(LIBFNAME)
|
opj_dec_server: opj_dec_server.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o $(LIBFNAME)
|
||||||
$(CC) $(CFLAGS) $< jp2k_decoder.o imgsock_manager.o jptstream_manager.o cache_manager.o $(LDFLAGS) -o $@
|
$(CC) $(CFLAGS) $< jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o $(LDFLAGS) -o $@
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALL) *.o *~
|
rm -f $(ALL) *.o *~
|
||||||
|
|
|
@ -94,7 +94,7 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
|
||||||
{
|
{
|
||||||
int receive_size;
|
int receive_size;
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
char *magicid[] = { "JPT-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
|
char *magicid[] = { "JPT-stream", "JPP-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
receive_size = receive_line( connected_socket, buf);
|
receive_size = receive_line( connected_socket, buf);
|
||||||
|
@ -115,9 +115,9 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
|
||||||
return MSGERROR;
|
return MSGERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
|
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
|
||||||
{
|
{
|
||||||
Byte_t *jptstream=NULL, *ptr;
|
Byte_t *jpipstream=NULL, *ptr;
|
||||||
char buf[BUF_LEN], versionstring[] = "version 1.0";
|
char buf[BUF_LEN], versionstring[] = "version 1.0";
|
||||||
int linelen, redlen, remlen;
|
int linelen, redlen, remlen;
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, in
|
||||||
fprintf( stderr, "Receiveing Data length: %d\n", *streamlen);
|
fprintf( stderr, "Receiveing Data length: %d\n", *streamlen);
|
||||||
|
|
||||||
|
|
||||||
jptstream = (unsigned char *)malloc( (*streamlen));
|
jpipstream = (unsigned char *)malloc( (*streamlen));
|
||||||
ptr = jptstream;
|
ptr = jpipstream;
|
||||||
remlen = (*streamlen);
|
remlen = (*streamlen);
|
||||||
while( remlen > 0){
|
while( remlen > 0){
|
||||||
redlen = recv( connected_socket, ptr, remlen, 0);
|
redlen = recv( connected_socket, ptr, remlen, 0);
|
||||||
if( redlen == -1){
|
if( redlen == -1){
|
||||||
fprintf( stderr, "receive jptstream error\n");
|
fprintf( stderr, "receive JPT- JPP- stream error\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
remlen -= redlen;
|
remlen -= redlen;
|
||||||
|
@ -164,7 +164,7 @@ Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, in
|
||||||
}
|
}
|
||||||
fprintf( stderr, " done\n");
|
fprintf( stderr, " done\n");
|
||||||
|
|
||||||
return jptstream;
|
return jpipstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_stream( SOCKET connected_socket, void *stream, int length);
|
void send_stream( SOCKET connected_socket, void *stream, int length);
|
||||||
|
|
|
@ -48,8 +48,8 @@ typedef int SOCKET;
|
||||||
*/
|
*/
|
||||||
SOCKET open_listeningsocket();
|
SOCKET open_listeningsocket();
|
||||||
|
|
||||||
#define NUM_OF_MSGTYPES 7
|
#define NUM_OF_MSGTYPES 8
|
||||||
typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
|
typedef enum eMSGTYPE{ JPTSTREAM, JPPSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* indeitify client message type
|
* indeitify client message type
|
||||||
|
@ -60,15 +60,15 @@ typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT,
|
||||||
msgtype_t identify_clientmsg( SOCKET connected_socket);
|
msgtype_t identify_clientmsg( SOCKET connected_socket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* receive JPT-stream from client
|
* receive a JPT- JPP- stream from client
|
||||||
*
|
*
|
||||||
* @param [in] connected_socket file descriptor of the connected socket
|
* @param [in] connected_socket file descriptor of the connected socket
|
||||||
* @param [out] target received target file name (if not received, null string)
|
* @param [out] target received target file name (if not received, null string)
|
||||||
* @param [out] cid received channel identifier (if not received, null string)
|
* @param [out] cid received channel identifier (if not received, null string)
|
||||||
* @param [out] streamlen length of the received codestream
|
* @param [out] streamlen length of the received codestream
|
||||||
* @return codestream
|
* @return JPT- JPP- codestream
|
||||||
*/
|
*/
|
||||||
Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
|
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send PGM/PPM image stream to the client
|
* send PGM/PPM image stream to the client
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: jptstream_manager.c 44 2011-02-15 12:32:29Z kaori $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
@ -32,45 +32,22 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "jptstream_manager.h"
|
#include "jpipstream_manager.h"
|
||||||
#include "jp2k_decoder.h"
|
#include "jp2k_decoder.h"
|
||||||
#include "imgreg_manager.h"
|
#include "imgreg_manager.h"
|
||||||
|
|
||||||
Byte_t * update_JPTstream( Byte_t *newjptstream, int newjptlen, Byte_t *cache_jptstream, int *jptlen)
|
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen)
|
||||||
{
|
{
|
||||||
Byte_t *jptstream = (Byte_t *)malloc( (*jptlen)+newjptlen);
|
Byte_t *stream = (Byte_t *)malloc( (*streamlen)+newstreamlen);
|
||||||
if( *jptlen > 0)
|
if( *streamlen > 0)
|
||||||
memcpy( jptstream, cache_jptstream, *jptlen);
|
memcpy( stream, cache_stream, *streamlen);
|
||||||
memcpy( jptstream+(*jptlen), newjptstream, newjptlen);
|
memcpy( stream+(*streamlen), newstream, newstreamlen);
|
||||||
*jptlen += newjptlen;
|
*streamlen += newstreamlen;
|
||||||
|
|
||||||
if(cache_jptstream)
|
if(cache_stream)
|
||||||
free( cache_jptstream);
|
free( cache_stream);
|
||||||
|
|
||||||
return jptstream;
|
return stream;
|
||||||
}
|
|
||||||
|
|
||||||
Byte_t * jpt_to_pnm( Byte_t *jptstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
|
||||||
{
|
|
||||||
Byte_t *pnmstream;
|
|
||||||
Byte_t *j2kstream; // j2k or jp2 codestream
|
|
||||||
Byte8_t j2klen;
|
|
||||||
int level = 0;
|
|
||||||
|
|
||||||
if( *ihdrbox){
|
|
||||||
// infinit value is set for maxmum level
|
|
||||||
int fx = fw, fy = fh;
|
|
||||||
int xmin = 0, ymin = 0;
|
|
||||||
int xmax = (*ihdrbox)->width, ymax = (*ihdrbox)->height;
|
|
||||||
find_level( 1000, &level, &fx, &fy, &xmin, &ymin, &xmax, &ymax);
|
|
||||||
}
|
|
||||||
|
|
||||||
j2kstream = recons_j2k( msgqueue, jptstream, csn, level+1, &j2klen);
|
|
||||||
|
|
||||||
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
|
|
||||||
free( j2kstream);
|
|
||||||
|
|
||||||
return pnmstream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
||||||
|
@ -89,3 +66,27 @@ void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
||||||
fwrite( codestream, streamlen, 1, fp);
|
fwrite( codestream, streamlen, 1, fp);
|
||||||
fclose( fp);
|
fclose( fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
||||||
|
{
|
||||||
|
Byte_t *pnmstream;
|
||||||
|
Byte_t *j2kstream; // j2k or jp2 codestream
|
||||||
|
Byte8_t j2klen;
|
||||||
|
int level = 0;
|
||||||
|
|
||||||
|
if( *ihdrbox){
|
||||||
|
// infinit value is set for maxmum level
|
||||||
|
int fx = fw, fy = fh;
|
||||||
|
int xmin = 0, ymin = 0;
|
||||||
|
int xmax = (*ihdrbox)->width, ymax = (*ihdrbox)->height;
|
||||||
|
find_level( 1000, &level, &fx, &fy, &xmin, &ymin, &xmax, &ymax);
|
||||||
|
}
|
||||||
|
|
||||||
|
j2kstream = recons_j2k( msgqueue, jpipstream, csn, level+1, &j2klen);
|
||||||
|
|
||||||
|
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
|
||||||
|
free( j2kstream);
|
||||||
|
|
||||||
|
return pnmstream;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: jptstream_manager.h 44 2011-02-15 12:32:29Z kaori $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
#include "msgqueue_manager.h"
|
#include "msgqueue_manager.h"
|
||||||
#include "ihdrbox_manager.h"
|
#include "ihdrbox_manager.h"
|
||||||
|
|
||||||
Byte_t * update_JPTstream( Byte_t *newjptstream, int newjptlen, Byte_t *cache_jptstream, int *jptlen);
|
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen);
|
||||||
|
|
||||||
Byte_t * jpt_to_pnm( Byte_t *jptstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
|
|
||||||
|
|
||||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt);
|
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt);
|
||||||
|
|
||||||
|
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
|
|
@ -52,7 +52,7 @@
|
||||||
#include "msgqueue_manager.h"
|
#include "msgqueue_manager.h"
|
||||||
#include "ihdrbox_manager.h"
|
#include "ihdrbox_manager.h"
|
||||||
#include "imgsock_manager.h"
|
#include "imgsock_manager.h"
|
||||||
#include "jptstream_manager.h"
|
#include "jpipstream_manager.h"
|
||||||
#include "cache_manager.h"
|
#include "cache_manager.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -70,34 +70,34 @@ WSADATA initialisation_win32;
|
||||||
#define MAX_LENOFCID 30
|
#define MAX_LENOFCID 30
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle JPTstream message
|
* handle JPT- JPP- stream message
|
||||||
*
|
*
|
||||||
* @param[in] connected_socket socket descriptor
|
* @param[in] connected_socket socket descriptor
|
||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
* @param[in,out] jptstream address of jptstream pointer
|
* @param[in,out] jpipstream address of JPT- JPP- stream pointer
|
||||||
* @param[in,out] jptlen address of jptstream length
|
* @param[in,out] streamlen address of stream length
|
||||||
* @param[in,out] msgqueue message queue pointer
|
* @param[in,out] msgqueue message queue pointer
|
||||||
*/
|
*/
|
||||||
void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue);
|
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle PNM request message
|
* handle PNM request message
|
||||||
*
|
*
|
||||||
* @param[in] connected_socket socket descriptor
|
* @param[in] connected_socket socket descriptor
|
||||||
* @param[in] jptstream jptstream pointer
|
* @param[in] jpipstream jpipstream pointer
|
||||||
* @param[in] msgqueue message queue pointer
|
* @param[in] msgqueue message queue pointer
|
||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
*/
|
*/
|
||||||
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
|
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle XML request message
|
* handle XML request message
|
||||||
*
|
*
|
||||||
* @param[in] connected_socket socket descriptor
|
* @param[in] connected_socket socket descriptor
|
||||||
* @param[in] jptstream address of caching jptstream pointer
|
* @param[in] jpipstream address of caching jpipstream pointer
|
||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
*/
|
*/
|
||||||
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist);
|
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle ChannelID request message
|
* handle ChannelID request message
|
||||||
|
@ -121,16 +121,16 @@ void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||||
* @param[in] connected_socket socket descriptor
|
* @param[in] connected_socket socket descriptor
|
||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
* @param[in] msgqueue message queue pointer
|
* @param[in] msgqueue message queue pointer
|
||||||
* @param[in] jptstream address of caching jptstream pointer
|
* @param[in] jpipstream address of caching jpipstream pointer
|
||||||
*/
|
*/
|
||||||
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream);
|
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream);
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
SOCKET connected_socket;
|
SOCKET connected_socket;
|
||||||
struct sockaddr_in peer_sin;
|
struct sockaddr_in peer_sin;
|
||||||
Byte_t *jptstream = NULL;
|
Byte_t *jpipstream = NULL;
|
||||||
int jptlen = 0;
|
int jpipstreamlen = 0;
|
||||||
msgqueue_param_t *msgqueue = gene_msgqueue( true, NULL);
|
msgqueue_param_t *msgqueue = gene_msgqueue( true, NULL);
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
|
|
||||||
|
@ -153,15 +153,16 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
switch( msgtype){
|
switch( msgtype){
|
||||||
case JPTSTREAM:
|
case JPTSTREAM:
|
||||||
handle_JPTstreamMSG( connected_socket, cachelist, &jptstream, &jptlen, msgqueue);
|
case JPPSTREAM:
|
||||||
|
handle_JPIPstreamMSG( connected_socket, cachelist, &jpipstream, &jpipstreamlen, msgqueue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNMREQ:
|
case PNMREQ:
|
||||||
handle_PNMreqMSG( connected_socket, jptstream, msgqueue, cachelist);
|
handle_PNMreqMSG( connected_socket, jpipstream, msgqueue, cachelist);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XMLREQ:
|
case XMLREQ:
|
||||||
handle_XMLreqMSG( connected_socket, jptstream, cachelist);
|
handle_XMLreqMSG( connected_socket, jpipstream, cachelist);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CIDREQ:
|
case CIDREQ:
|
||||||
|
@ -173,7 +174,7 @@ int main(int argc, char *argv[]){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JP2SAVE:
|
case JP2SAVE:
|
||||||
handle_JP2saveMSG( connected_socket, cachelist, msgqueue, jptstream);
|
handle_JP2saveMSG( connected_socket, cachelist, msgqueue, jpipstream);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QUIT:
|
case QUIT:
|
||||||
|
@ -201,8 +202,8 @@ int main(int argc, char *argv[]){
|
||||||
if( msgqueue)
|
if( msgqueue)
|
||||||
delete_msgqueue( &msgqueue);
|
delete_msgqueue( &msgqueue);
|
||||||
|
|
||||||
save_codestream( jptstream, jptlen, "jpt");
|
// save_codestream( jpipstream, jpipstreamlen, "jpt");
|
||||||
free( jptstream);
|
free( jpipstream);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if( WSACleanup() != 0){
|
if( WSACleanup() != 0){
|
||||||
|
@ -215,24 +216,24 @@ int main(int argc, char *argv[]){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
|
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
|
||||||
Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue)
|
Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
|
||||||
{
|
{
|
||||||
Byte_t *newjptstream;
|
Byte_t *newjpipstream;
|
||||||
int newjptlen = 0;
|
int newstreamlen = 0;
|
||||||
cache_param_t *cache;
|
cache_param_t *cache;
|
||||||
char target[MAX_LENOFTARGET], cid[MAX_LENOFCID];
|
char target[MAX_LENOFTARGET], cid[MAX_LENOFCID];
|
||||||
metadatalist_param_t *metadatalist;
|
metadatalist_param_t *metadatalist;
|
||||||
|
|
||||||
newjptstream = receive_JPTstream( connected_socket, target, cid, &newjptlen);
|
newjpipstream = receive_JPIPstream( connected_socket, target, cid, &newstreamlen);
|
||||||
|
|
||||||
parse_stream( newjptstream, newjptlen, *jptlen, msgqueue);
|
parse_JPIPstream( newjpipstream, newstreamlen, *streamlen, msgqueue);
|
||||||
|
|
||||||
*jptstream = update_JPTstream( newjptstream, newjptlen, *jptstream, jptlen);
|
*jpipstream = update_JPIPstream( newjpipstream, newstreamlen, *jpipstream, streamlen);
|
||||||
free( newjptstream);
|
free( newjpipstream);
|
||||||
|
|
||||||
metadatalist = gene_metadatalist();
|
metadatalist = gene_metadatalist();
|
||||||
parse_metamsg( msgqueue, *jptstream, *jptlen, metadatalist);
|
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
|
||||||
|
|
||||||
// cid registration
|
// cid registration
|
||||||
if( target[0] != 0 && cid[0] != 0){
|
if( target[0] != 0 && cid[0] != 0){
|
||||||
|
@ -253,7 +254,7 @@ void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
|
||||||
response_signal( connected_socket, true);
|
response_signal( connected_socket, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
|
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
|
||||||
{
|
{
|
||||||
Byte_t *pnmstream;
|
Byte_t *pnmstream;
|
||||||
ihdrbox_param_t *ihdrbox;
|
ihdrbox_param_t *ihdrbox;
|
||||||
|
@ -271,14 +272,14 @@ void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_para
|
||||||
receive_line( connected_socket, tmp);
|
receive_line( connected_socket, tmp);
|
||||||
fh = atoi( tmp);
|
fh = atoi( tmp);
|
||||||
|
|
||||||
pnmstream = jpt_to_pnm( jptstream, msgqueue, cache->csn, fw, fh, &cache->ihdrbox);
|
pnmstream = jpipstream_to_pnm( jpipstream, msgqueue, cache->csn, fw, fh, &cache->ihdrbox);
|
||||||
ihdrbox = cache->ihdrbox;
|
ihdrbox = cache->ihdrbox;
|
||||||
send_PNMstream( connected_socket, pnmstream, ihdrbox->width, ihdrbox->height, ihdrbox->nc, ihdrbox->bpc > 8 ? 255 : (1 << ihdrbox->bpc) - 1);
|
send_PNMstream( connected_socket, pnmstream, ihdrbox->width, ihdrbox->height, ihdrbox->nc, ihdrbox->bpc > 8 ? 255 : (1 << ihdrbox->bpc) - 1);
|
||||||
|
|
||||||
free( pnmstream);
|
free( pnmstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist)
|
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist)
|
||||||
{
|
{
|
||||||
char cid[MAX_LENOFCID];
|
char cid[MAX_LENOFCID];
|
||||||
cache_param_t *cache;
|
cache_param_t *cache;
|
||||||
|
@ -289,7 +290,7 @@ void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_par
|
||||||
|
|
||||||
boxcontents_param_t *boxcontents = cache->metadatalist->last->boxcontents;
|
boxcontents_param_t *boxcontents = cache->metadatalist->last->boxcontents;
|
||||||
Byte_t *xmlstream = (Byte_t *)malloc( boxcontents->length);
|
Byte_t *xmlstream = (Byte_t *)malloc( boxcontents->length);
|
||||||
memcpy( xmlstream, jptstream+boxcontents->offset, boxcontents->length);
|
memcpy( xmlstream, jpipstream+boxcontents->offset, boxcontents->length);
|
||||||
send_XMLstream( connected_socket, xmlstream, boxcontents->length);
|
send_XMLstream( connected_socket, xmlstream, boxcontents->length);
|
||||||
free( xmlstream);
|
free( xmlstream);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +322,7 @@ void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||||
response_signal( connected_socket, true);
|
response_signal( connected_socket, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream)
|
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream)
|
||||||
{
|
{
|
||||||
char cid[MAX_LENOFCID];
|
char cid[MAX_LENOFCID];
|
||||||
cache_param_t *cache;
|
cache_param_t *cache;
|
||||||
|
@ -332,7 +333,7 @@ void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, m
|
||||||
if(!(cache = search_cacheBycid( cid, cachelist)))
|
if(!(cache = search_cacheBycid( cid, cachelist)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jp2stream = recons_jp2( msgqueue, jptstream, cache->csn, &jp2len);
|
jp2stream = recons_jp2( msgqueue, jpipstream, cache->csn, &jp2len);
|
||||||
|
|
||||||
if( jp2stream){
|
if( jp2stream){
|
||||||
save_codestream( jp2stream, jp2len, "jp2");
|
save_codestream( jp2stream, jp2len, "jp2");
|
||||||
|
|
Loading…
Reference in New Issue