[1.5][JPIP] added execution argument to set port number for opj_dec_server, opj_viewer*
This commit is contained in:
parent
699f172e6c
commit
7b6ae8810d
|
@ -7,6 +7,7 @@ What's New for OpenJPIP
|
||||||
|
|
||||||
February 9, 2012
|
February 9, 2012
|
||||||
* [kaori] fixed Doxygen configuration file to document the utilities
|
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||||
|
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||||
|
|
||||||
January 26, 2012
|
January 26, 2012
|
||||||
! [kaori] unapplied auxtrans_manager to the local mode
|
! [kaori] unapplied auxtrans_manager to the local mode
|
||||||
|
|
|
@ -96,7 +96,7 @@ Server:
|
||||||
|
|
||||||
Client:
|
Client:
|
||||||
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||||
% ./opj_dec_server
|
% ./opj_dec_server [portnumber (50000 by default)]
|
||||||
|
|
||||||
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||||
% mkdir cache
|
% mkdir cache
|
||||||
|
@ -104,10 +104,12 @@ Client:
|
||||||
% ../opj_dec_server
|
% ../opj_dec_server
|
||||||
|
|
||||||
2. Open image viewers (as many as needed)
|
2. Open image viewers (as many as needed)
|
||||||
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [stateless/session] [jptstream/jppstream] [tcp/udp]
|
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||||
( The arguments
|
( The arguments
|
||||||
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
- path/filename.jp2 is the server local path or URL of a JP2 file
|
- path/filename.jp2 is the server local path or URL of a JP2 file
|
||||||
|
- host name of opj_dec_server, localhost by default
|
||||||
|
- portnumber of opj_dec_server, 50000 by default
|
||||||
- request type stateless for no caching, session (default) for caching
|
- request type stateless for no caching, session (default) for caching
|
||||||
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
||||||
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
||||||
|
|
|
@ -33,11 +33,12 @@
|
||||||
*
|
*
|
||||||
* \section impinst Implementing instructions
|
* \section impinst Implementing instructions
|
||||||
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
||||||
* % ./opj_dec_server \n
|
* % ./opj_dec_server [portnumber]\n
|
||||||
|
* ( portnumber=50000 by default)\n
|
||||||
* Keep it alive as long as image viewers are open.\n
|
* Keep it alive as long as image viewers are open.\n
|
||||||
*
|
*
|
||||||
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
||||||
* % telnet localhost 5000\n
|
* % telnet localhost 50000\n
|
||||||
* quit\n
|
* quit\n
|
||||||
* Be sure all image viewers are closed.\n
|
* Be sure all image viewers are closed.\n
|
||||||
* Cache file in JPT format is stored in the working directly before it quites.
|
* Cache file in JPT format is stored in the working directly before it quites.
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "openjpip.h"
|
#include "openjpip.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -55,6 +57,10 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
dec_server_record_t *server_record;
|
dec_server_record_t *server_record;
|
||||||
client_t client;
|
client_t client;
|
||||||
|
int port = 50000;
|
||||||
|
|
||||||
|
if( argc > 1)
|
||||||
|
port = atoi( argv[1]);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||||
|
@ -64,7 +70,7 @@ int main(int argc, char *argv[]){
|
||||||
printf( "Initialisation Winsock\n");
|
printf( "Initialisation Winsock\n");
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
server_record = init_dec_server( 50000);
|
server_record = init_dec_server( port);
|
||||||
|
|
||||||
while(( client = accept_connection( server_record)) != -1 )
|
while(( client = accept_connection( server_record)) != -1 )
|
||||||
if(!handle_clientreq( client, server_record))
|
if(!handle_clientreq( client, server_record))
|
||||||
|
|
|
@ -35,10 +35,12 @@ public class ImageManager extends JPIPHttpClient
|
||||||
private PnmImage pnmimage;
|
private PnmImage pnmimage;
|
||||||
private int origwidth;
|
private int origwidth;
|
||||||
private int origheight;
|
private int origheight;
|
||||||
|
private ImgdecClient imgdecoder;
|
||||||
|
|
||||||
public ImageManager( String uri)
|
public ImageManager( String uri, String host, int port)
|
||||||
{
|
{
|
||||||
super( uri);
|
super( uri);
|
||||||
|
imgdecoder = new ImgdecClient( host, port);
|
||||||
pnmimage = null;
|
pnmimage = null;
|
||||||
origwidth = 0;
|
origwidth = 0;
|
||||||
origheight = 0;
|
origheight = 0;
|
||||||
|
@ -47,7 +49,7 @@ public class ImageManager extends JPIPHttpClient
|
||||||
public int getOrigWidth(){
|
public int getOrigWidth(){
|
||||||
if( origwidth == 0){
|
if( origwidth == 0){
|
||||||
if( cid != null || tid != null){
|
if( cid != null || tid != null){
|
||||||
java.awt.Dimension dim = ImgdecClient.query_imagesize( cid, tid);
|
java.awt.Dimension dim = imgdecoder.query_imagesize( cid, tid);
|
||||||
if( dim != null){
|
if( dim != null){
|
||||||
origwidth = dim.width;
|
origwidth = dim.width;
|
||||||
origheight = dim.height;
|
origheight = dim.height;
|
||||||
|
@ -69,10 +71,10 @@ public class ImageManager extends JPIPHttpClient
|
||||||
|
|
||||||
// Todo: check if the cid is for the same stream type
|
// Todo: check if the cid is for the same stream type
|
||||||
if( reqcnew)
|
if( reqcnew)
|
||||||
refcid = ImgdecClient.query_cid( j2kfilename);
|
refcid = imgdecoder.query_cid( j2kfilename);
|
||||||
|
|
||||||
if( refcid == null){
|
if( refcid == null){
|
||||||
String reftid = ImgdecClient.query_tid( j2kfilename);
|
String reftid = imgdecoder.query_tid( j2kfilename);
|
||||||
if( reftid == null)
|
if( reftid == null)
|
||||||
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
else
|
else
|
||||||
|
@ -82,7 +84,7 @@ public class ImageManager extends JPIPHttpClient
|
||||||
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
|
||||||
System.err.println( "decoding to PNM image");
|
System.err.println( "decoding to PNM image");
|
||||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
||||||
System.err.println( " done");
|
System.err.println( " done");
|
||||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +101,7 @@ public class ImageManager extends JPIPHttpClient
|
||||||
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
||||||
|
|
||||||
System.err.println( "decoding to PNM image");
|
System.err.println( "decoding to PNM image");
|
||||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
||||||
System.err.println( " done");
|
System.err.println( " done");
|
||||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
}
|
}
|
||||||
|
@ -117,9 +119,9 @@ public class ImageManager extends JPIPHttpClient
|
||||||
byte[] jpipstream = super.requestXML();
|
byte[] jpipstream = super.requestXML();
|
||||||
|
|
||||||
if( jpipstream != null){
|
if( jpipstream != null){
|
||||||
ImgdecClient.send_JPIPstream( jpipstream);
|
imgdecoder.send_JPIPstream( jpipstream);
|
||||||
|
|
||||||
xmldata = ImgdecClient.get_XMLstream( cid);
|
xmldata = imgdecoder.get_XMLstream( cid);
|
||||||
}
|
}
|
||||||
return xmldata;
|
return xmldata;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +129,7 @@ public class ImageManager extends JPIPHttpClient
|
||||||
public void closeChannel()
|
public void closeChannel()
|
||||||
{
|
{
|
||||||
if( cid != null){
|
if( cid != null){
|
||||||
ImgdecClient.destroy_cid( cid);
|
imgdecoder.destroy_cid( cid);
|
||||||
super.closeChannel();
|
super.closeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ public class ImageWindow extends JFrame
|
||||||
private ImageViewer imgviewer;
|
private ImageViewer imgviewer;
|
||||||
private ImageManager imgmanager;
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream, int aux)
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
{
|
{
|
||||||
super( j2kfilename);
|
super( j2kfilename);
|
||||||
|
|
||||||
imgmanager = new ImageManager( uri);
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
imgviewer.setOpaque(true); //content panes must be opaque
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
|
@ -66,25 +66,36 @@ public class ImageWindow extends JFrame
|
||||||
|
|
||||||
public static void main(String s[])
|
public static void main(String s[])
|
||||||
{
|
{
|
||||||
String j2kfilename, uri;
|
String j2kfilename, uri, host;
|
||||||
boolean session, jppstream;
|
boolean session, jppstream;
|
||||||
int aux; // 0: none, 1: tcp, 2: udp
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
if(s.length >= 2){
|
if(s.length >= 2){
|
||||||
uri = s[0];
|
uri = s[0];
|
||||||
j2kfilename = s[1];
|
j2kfilename = s[1];
|
||||||
|
|
||||||
if( s.length > 2)
|
if( s.length > 2)
|
||||||
session = !s[2].equalsIgnoreCase( "stateless");
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
else
|
else
|
||||||
session = true;
|
session = true;
|
||||||
|
|
||||||
if( s.length > 3)
|
if( s.length > 5)
|
||||||
jppstream = !s[3].equalsIgnoreCase( "JPT");
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
else
|
else
|
||||||
jppstream = true;
|
jppstream = true;
|
||||||
|
|
||||||
if( s.length > 4){
|
if( s.length > 6){
|
||||||
if( s[4].equalsIgnoreCase("udp"))
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
aux = 2;
|
aux = 2;
|
||||||
else
|
else
|
||||||
aux = 1;
|
aux = 1;
|
||||||
|
@ -93,10 +104,10 @@ public class ImageWindow extends JFrame
|
||||||
aux = 0;
|
aux = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP] [tcp/udp]");
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream, aux);
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
|
|
@ -32,24 +32,33 @@ import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
public class ImgdecClient{
|
public class ImgdecClient{
|
||||||
|
|
||||||
|
private String hostname;
|
||||||
|
private int portNo;
|
||||||
|
|
||||||
public static PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
|
public ImgdecClient( String host, int port)
|
||||||
|
{
|
||||||
|
hostname = host;
|
||||||
|
portNo = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
|
||||||
{
|
{
|
||||||
if( jpipstream != null)
|
if( jpipstream != null)
|
||||||
send_JPIPstream( jpipstream);
|
send_JPIPstream( jpipstream);
|
||||||
return get_PNMstream( cid, tid, 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)
|
public PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
|
||||||
{
|
{
|
||||||
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
||||||
return get_PNMstream( cid, tid, fw, fh);
|
return get_PNMstream( cid, tid, fw, fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send_JPIPstream( byte[] jpipstream)
|
public void send_JPIPstream( byte[] jpipstream)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
|
@ -71,10 +80,10 @@ public class ImgdecClient{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
public void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
@ -109,12 +118,12 @@ public class ImgdecClient{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
|
public PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
|
||||||
{
|
{
|
||||||
PnmImage pnmstream = null;
|
PnmImage pnmstream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[7];
|
byte []header = new byte[7];
|
||||||
|
@ -166,12 +175,12 @@ public class ImgdecClient{
|
||||||
return pnmstream;
|
return pnmstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte [] get_XMLstream( String cid)
|
public byte [] get_XMLstream( String cid)
|
||||||
{
|
{
|
||||||
byte []xmldata = null;
|
byte []xmldata = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[5];
|
byte []header = new byte[5];
|
||||||
|
@ -197,7 +206,7 @@ public class ImgdecClient{
|
||||||
return xmldata;
|
return xmldata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_cid( String j2kfilename)
|
public String query_cid( String j2kfilename)
|
||||||
{
|
{
|
||||||
int []retmsglabel = new int[3];
|
int []retmsglabel = new int[3];
|
||||||
retmsglabel[0] = 67;
|
retmsglabel[0] = 67;
|
||||||
|
@ -207,7 +216,7 @@ public class ImgdecClient{
|
||||||
return query_id( "CID request", j2kfilename, retmsglabel);
|
return query_id( "CID request", j2kfilename, retmsglabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_tid( String j2kfilename)
|
public String query_tid( String j2kfilename)
|
||||||
{
|
{
|
||||||
int []retmsglabel = new int[3];
|
int []retmsglabel = new int[3];
|
||||||
retmsglabel[0] = 84;
|
retmsglabel[0] = 84;
|
||||||
|
@ -217,12 +226,12 @@ public class ImgdecClient{
|
||||||
return query_id( "TID request", j2kfilename, retmsglabel);
|
return query_id( "TID request", j2kfilename, retmsglabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
public String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
||||||
{
|
{
|
||||||
String id = null;
|
String id = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[4];
|
byte []header = new byte[4];
|
||||||
|
@ -254,12 +263,12 @@ public class ImgdecClient{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static java.awt.Dimension query_imagesize( String cid, String tid)
|
public java.awt.Dimension query_imagesize( String cid, String tid)
|
||||||
{
|
{
|
||||||
java.awt.Dimension dim = null;
|
java.awt.Dimension dim = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
byte []header = new byte[3];
|
byte []header = new byte[3];
|
||||||
|
@ -297,7 +306,7 @@ public class ImgdecClient{
|
||||||
return dim;
|
return dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void read_stream( DataInputStream is, byte []stream, int length)
|
private static void read_stream( DataInputStream is, byte []stream, int length)
|
||||||
{
|
{
|
||||||
int remlen = length;
|
int remlen = length;
|
||||||
int off = 0;
|
int off = 0;
|
||||||
|
@ -318,10 +327,10 @@ public class ImgdecClient{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroy_cid( String cid)
|
public void destroy_cid( String cid)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Socket imgdecSocket = new Socket( "localhost", 50000);
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ public class ImageWindow extends JFrame
|
||||||
private OptionPanel optpanel;
|
private OptionPanel optpanel;
|
||||||
private ImageManager imgmanager;
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream, int aux)
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
{
|
{
|
||||||
super( j2kfilename);
|
super( j2kfilename);
|
||||||
|
|
||||||
imgmanager = new ImageManager( uri);
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
imgviewer.setOpaque(true); //content panes must be opaque
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
|
@ -70,25 +70,36 @@ public class ImageWindow extends JFrame
|
||||||
|
|
||||||
public static void main(String s[])
|
public static void main(String s[])
|
||||||
{
|
{
|
||||||
String j2kfilename, uri;
|
String j2kfilename, uri, host;
|
||||||
boolean session, jppstream;
|
boolean session, jppstream;
|
||||||
int aux; // 0: none, 1: tcp, 2: udp
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
if(s.length >= 2){
|
if(s.length >= 2){
|
||||||
uri = s[0];
|
uri = s[0];
|
||||||
j2kfilename = s[1];
|
j2kfilename = s[1];
|
||||||
|
|
||||||
if( s.length > 2)
|
if( s.length > 2)
|
||||||
session = !s[2].equalsIgnoreCase( "stateless");
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
else
|
else
|
||||||
session = true;
|
session = true;
|
||||||
|
|
||||||
if( s.length > 3)
|
if( s.length > 5)
|
||||||
jppstream = !s[3].equalsIgnoreCase( "JPT");
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
else
|
else
|
||||||
jppstream = true;
|
jppstream = true;
|
||||||
|
|
||||||
if( s.length > 4){
|
if( s.length > 6){
|
||||||
if( s[4].equalsIgnoreCase("udp"))
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
aux = 2;
|
aux = 2;
|
||||||
else
|
else
|
||||||
aux = 1;
|
aux = 1;
|
||||||
|
@ -97,10 +108,10 @@ public class ImageWindow extends JFrame
|
||||||
aux = 0;
|
aux = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP] [tcp/udp]");
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream, aux);
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
@ -110,4 +121,4 @@ public class ImageWindow extends JFrame
|
||||||
frame.setLocation( 0, 50);
|
frame.setLocation( 0, 50);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue