/* ------------------------------------------------------------------------ */ 
/* VideoMessages : Messages and Format for a video capture frame            */ 
/* ------------------------------------------------------------------------ */ 
/*                                                                          */ 
/* (c) Copyright 2003  EdgeTech,                                            */ 
/*                                                                          */ 
/* This file contains proprietary information, and trade secrets of         */ 
/* EdgeTech, and may not be disclosed or reproduced without the prior       */ 
/* written consent of EdgeTech.                                             */ 
/*                                                                          */ 
/* EdgeTech is not responsible for the consequences of the use or misuse    */ 
/* of this software, even if they result from defects in it.                */ 
/*                                                                          */ 
/* ------------------------------------------------------------------------ */ 

#ifndef __VIDEOMESSAGES_H__
#define __VIDEOMESSAGES_H__

#include "MessageOffsets.h"
#include "Subsystem.h"
#include "Timestamp.h"

/* Subsystem for video messages                                              */ 
#define SUBSYSTEM_VIDEO SUBSYSTEM_OFFSET_VIDEO


/* ------------------------------------------------------------------------- */ 
/* Video message numbers                                                     */ 
/* ------------------------------------------------------------------------- */ 

typedef enum
{

  /* Video data from a camera (VideoCaptureDataType)                         */ 
  DEV_VIDEO_DATA = MESSAGE_OFFSET_VIDEO,

  /* Video data parameters (VideoParametersType)                             */ 
  DEV_VIDEO_PARAMETERS,

} VideoMessagesType;


/* ------------------------------------------------------------------------- */ 
/* Parameters for video processing                                           */ 
/* ------------------------------------------------------------------------- */ 

typedef struct
{
  /* Flags                                                                   */ 
  /* Bit 0: Enable Video Capture                                             */ 
  /* Bit 1: Save in color (not monochrome) : Only for Directshow Video       */ 
  /* Bit 2: Disable JPEG Compression       : Only for Directshow Video       */ 
  int flags;

  /* Update counter.  Incremented each time new parameters are received      */ 
  /* This item cannot be written with a SONAR_COMMAND_SET.                   */ 
  int updateCounter;

  /* ----------------------------------------------------------------------- */ 
  /* Direct show camera only parameters                                      */ 
  /* ----------------------------------------------------------------------- */ 

  /* Quality factor if JPEG compression used (0 to 100 where 100 is best     */ 
  /* quality and lowest compression.                                         */ 
  int JPegQuality;

  /* Image decimation (Minimum of 1)                                         */ 
  int frameDecimationFactor;

  /* ----------------------------------------------------------------------- */ 
  /* Canon only parameters                                                   */ 
  /* ----------------------------------------------------------------------- */ 

  /* Zoom factor                                                             */ 
  int zoomFactor;

  /* Incremented to cause camera to refocus                                  */ 
  int refocusCounter;

  /* Reserved for future use                                                 */ 
  int reserved[28];
} VideoParametersType;


/* ------------------------------------------------------------------------- */ 
/* Video data message structure                                              */ 
/* ------------------------------------------------------------------------- */ 

/* Valid formats for video data                                              */ 
typedef enum
{
  VIDCAPFORMAT_JPEGRGB, /* JPEG Compressed RGB  */ 
  VIDCAPFORMAT_JPEG_M,  /* JPEG Compressed Mono */ 
  VIDCAPFORMAT_PCMRGB,  /* Pulse Code RGB       */ 
  VIDCAPFORMAT_PCM_M,   /* Pulse Code Mono      */ 
} VideoFormatEnumType;

/* Latest data                                                              */ 
typedef struct
{
  /* Time of sample                                                         */ 
  TimestampType time;
  /* Bytes in data part                                                     */ 
  int bytesToFollow;
  /* Reserved for future use                                                */ 
  int reserved0;
  /* Bitmap dimensions                                                      */ 
  short int width;
  short int height;
  /* Format of data JPEG or PCM                                             */ 
  unsigned char format;
  /* Reserved for future use                                                */ 
  unsigned char reserved1[3];
  /* Multiping support : incremented frame counter.                         */ 
  int frameCounter;
  /* The packet number starts at 0 and goes to numPackets - 1.  If there is */ 
  /* more than one packet then the byte data should be concatenated to make */ 
  /* a complete frame.  In this case the bytesToFollow IS STILL the total   */ 
  /* bytes in the full image and the bytes in this message is determined via*/ 
  /* the remainder in a standard message header (byteCount field)           */ 
  short packetNum;
  short numPackets;
  /* Reserved for future use                                                */ 
  int reserved[4];
  /* Data for bitmap or JPEG image follows                                  */ 
  /* In the case of a bit map, there are 1 (monochrome) or 3 (color) bytes  */ 
  /* per pixel.  For JPeg, the data if written to a file will be a valid    */ 
  /* JPEG image.                                                            */ 
} VideoCaptureDataType;

#endif

/* ---------------------------------------------------------------------- */ 
/* End VideoMessages.h                                                    */ 
/* ---------------------------------------------------------------------- */ 
