imgsock_manager.h File Reference
`#include "byte_manager.h"`
`#include "sock_manager.h"`
`#include "opj_includes.h"`

Go to the source code of this file.

## Macros

#define | NUM_OF_MSGTYPES 9

## Typedefs

typedef enum eMSGTYPE | msgtype_t

## Enumerations

enum | eMSGTYPE { JPIPSTREAM , PNMREQ , XMLREQ , TIDREQ , CIDREQ , CIDDST , SIZREQ , JP2SAVE , QUIT , MSGERROR }

## Functions

msgtype_t | identify_clientmsg (SOCKET connected_socket)
| indeitify client message type
Byte_t * | receive_JPIPstream (SOCKET connected_socket, char **target, char **tid, char **cid, OPJ_SIZE_T *streamlen)
| receive a JPT- JPP- stream from client
void | send_PNMstream (SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
| send PGM/PPM image stream to the client
void | send_XMLstream (SOCKET connected_socket, Byte_t *xmlstream, OPJ_SIZE_T length)
| send XML data stream to the client
void | send_TIDstream (SOCKET connected_socket, const char *tid, OPJ_SIZE_T tidlen)
| send TID data stream to the client
void | send_CIDstream (SOCKET connected_socket, const char *cid, OPJ_SIZE_T cidlen)
| send CID data stream to the client
void | send_SIZstream (SOCKET connected_socket, unsigned int width, unsigned int height)
| send SIZ data stream to the client
void | response_signal (SOCKET connected_socket, OPJ_BOOL succeed)
| send response signal to the client

## Detailed Description

PROTOCOL specification to communicate with opj_dec_server

# JPIP-stream

Cache JPT- JPP- stream in server

client -> server: JPIP-stream\n version 1.1\n (optional for cid registration: targetnamestring\n tidstring\n cidstring\n) bytelengthvalue\n data
server -> client: 1 or 0 (of 1Byte response signal)

# PNM request

Get decoded PGM/PPM image

client -> server: PNM request\n [cid/tid]string\n fw\n fh\n
server -> client: P6 or P5 (2Byte) width (2Byte Big endian) height (2Byte Big endian) maxval (1Byte) data

# XML request

Get XML data

client -> server: XML request\n
server -> client: XML (3Byte) length (2Byte Big endian) data

# TID request

Get target ID of target image

client -> server: TID request\n targetname\n
server -> client: TID (3Byte) length (1Byte) tiddata

# CID request

Get Channel ID of identical target image

client -> server: CID request\n targetname\n
server -> client: CID (3Byte) length (1Byte) ciddata

# CID destroy

Close Channel ID

client -> server: CID destroy\n ciddata
server -> client: 1 or 0 (of 1Byte response signal)

# SIZ request

Get original size of image

client -> server: SIZ request\n tidstring\n cidstring\n
server -> client: SIZ (3Byte) width (3Byte Big endian) height (3Byte Big endian)

# JP2 save

Save in JP2 file format

client -> server: JP2 save\n ciddata
server -> client: 1 or 0 (of 1Byte response signal)

# QUIT

Quit the opj_dec_server program

client -> server: quit or QUIT

## Macro Definition Documentation

## NUM_OF_MSGTYPES

#define NUM_OF_MSGTYPES 9

## Typedef Documentation

## msgtype_t

typedef enum eMSGTYPE msgtype_t

## Enumeration Type Documentation

## eMSGTYPE

enum eMSGTYPE

Enumerator
JPIPSTREAM |
PNMREQ |
XMLREQ |
TIDREQ |
CIDREQ |
CIDDST |
SIZREQ |
JP2SAVE |
QUIT |
MSGERROR |

## Function Documentation

## identify_clientmsg()

msgtype_t identify_clientmsg | ( | SOCKET | connected_socket | ) |

indeitify client message type

Parameters

  [in] | connected_socket | file descriptor of the connected socket

Returns
  message type

References BUF_LEN, MSGERROR, NUM_OF_MSGTYPES, and receive_line().

Referenced by handle_clientreq().

## receive_JPIPstream()

Byte_t * receive_JPIPstream | ( | SOCKET | connected_socket,
|  | char ** | target,
|  | char ** | tid,
|  | char ** | cid,
|  | OPJ_SIZE_T * | streamlen
| ) |  |

receive a JPT- JPP- stream from client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [out] | target | address of received target file name string pointer ( malloced, if not received, NULL)
  [out] | tid | address of received target identifier string pointer ( malloced, if not received, null string)
  [out] | cid | address of received channel identifier string pointer ( malloced, if not received, null string)
  [out] | streamlen | length of the received codestream

Returns
  JPT- JPP- codestream

References BUF_LEN, receive_line(), and receive_stream().

Referenced by handle_JPIPstreamMSG().

## response_signal()

void response_signal | ( | SOCKET | connected_socket,
|  | OPJ_BOOL | succeed
| ) |  |

send response signal to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | succeed | whether if the requested process succeeded

References send_stream().

Referenced by handle_dstCIDreqMSG(), and handle_JPIPstreamMSG().

## send_CIDstream()

void send_CIDstream | ( | SOCKET | connected_socket,
|  | const char * | cid,
|  | OPJ_SIZE_T | cidlen
| ) |  |

send CID data stream to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | cid | cid string
  [in] | cidlen | length of the cid string

References send_IDstream().

Referenced by handle_CIDreqMSG().

## send_PNMstream()

void send_PNMstream | ( | SOCKET | connected_socket,
|  | Byte_t * | pnmstream,
|  | unsigned int | width,
|  | unsigned int | height,
|  | unsigned int | numofcomp,
|  | Byte_t | maxval
| ) |  |

send PGM/PPM image stream to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | pnmstream | PGM/PPM image codestream
  [in] | width | width of the PGM/PPM image (different from the original image)
  [in] | height | height of the PGM/PPM image
  [in] | numofcomp | number of components of the image
  [in] | maxval | maximum value of the image (only 255 supported)

References send_stream().

Referenced by handle_PNMreqMSG().

## send_SIZstream()

void send_SIZstream | ( | SOCKET | connected_socket,
|  | unsigned int | width,
|  | unsigned int | height
| ) |  |

send SIZ data stream to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | width | original width of the image
  [in] | height | original height of the image

References send_stream().

Referenced by handle_SIZreqMSG().

## send_TIDstream()

void send_TIDstream | ( | SOCKET | connected_socket,
|  | const char * | tid,
|  | OPJ_SIZE_T | tidlen
| ) |  |

send TID data stream to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | tid | tid string
  [in] | tidlen | length of the tid string

References send_IDstream().

Referenced by handle_TIDreqMSG().

## send_XMLstream()

void send_XMLstream | ( | SOCKET | connected_socket,
|  | Byte_t * | xmlstream,
|  | OPJ_SIZE_T | length
| ) |  |

send XML data stream to the client

Parameters

  [in] | connected_socket | file descriptor of the connected socket
  [in] | xmlstream | xml data stream
  [in] | length | length of the xml data stream

References send_stream().

Referenced by handle_XMLreqMSG().