home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 114 / macaddict114.cdr / Software / Utilities / macam.0.8.4.dmg / macam sources / component_specific / MyBridge.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-08-15  |  8.4 KB  |  169 lines

  1. /*
  2.     macam - webcam app and QuickTime driver component
  3.     Copyright (C) 2002 Matthias Krauss (macam@matthias-krauss.de)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  $Id: MyBridge.h,v 1.5 2005/08/15 05:27:30 hxr Exp $
  19. */
  20.  
  21. #import <Cocoa/Cocoa.h>
  22. #import <Carbon/Carbon.h>
  23. #import <QuickTime/QuickTime.h>
  24. #include "GlobalDefs.h"
  25.  
  26. #define NUM_BRIDGE_GRAB_BUFFERS 2
  27.  
  28.  
  29. typedef struct BridgeGrabBuffer {
  30.     CameraResolution resolution;
  31.     unsigned char* data;
  32. } BridgeGrabBuffer;
  33.  
  34. typedef enum BridgeClientState {
  35.     ClientFrameInvalid,
  36.     ClientFramePending,
  37.     ClientFrameValid
  38. }BridgeClientState;
  39.  
  40. @class RGB888Scaler,MyCameraCentral,MyCameraDriver;
  41.  
  42. @interface MyBridge : NSObject {
  43.     MyCameraCentral* central;            //A pointer to our camera central
  44.     unsigned long cid;                //Our camera id for the central
  45.     MyCameraDriver* driver;            //Our camera driver
  46.     RGB888Scaler* scaler;            //Our handler for (primitive) scaling of images
  47.     
  48. //The client state
  49.     short clientBufferIdx;            //The buffer in grabBuffers currently outputting
  50.     BOOL clientImagePending;        
  51.  
  52.     BridgeClientState clientState;        //The state as seen from the client
  53.     
  54. //The driver state
  55.     short driverBufferIdx;            //The buffer in grabBuffers currently inputting 
  56.     BOOL driverStarted;                //YES from successful startup until shutdown
  57.     BOOL driverShuttingDown;            //YES for the shutdown sequence (shutDownLock is locked)
  58.     BOOL driverGrabRunning;            //YES if the driver is currently grabbing
  59.     BOOL driverFormatChangePending;        //YES if formatCahngeLock is locked until change is done
  60.     
  61.     NSLock* stateLock;                //General lock to mutex all serious calls
  62.     NSLock* formatChangeLock;            //Prevents a format change call from returning before the change is complete
  63.     NSLock* shutdownLock;            //Prevents shutdown from returning before the shutdown is complete
  64.  
  65.     CameraResolution wantedResolution;        //Value to set in the next driver format update
  66.     short wantedFps;                //Value to set in the next driver format update
  67.     short wantedCompression;            //Value to set in the next driver format update
  68.  
  69.     BridgeGrabBuffer grabBuffers[NUM_BRIDGE_GRAB_BUFFERS];    //The buffers we're grabbing to
  70.  
  71. }
  72.  
  73. //----------------------
  74. //   Startup/shutdown
  75. //----------------------
  76.  
  77. - (id) initWithCentral:(MyCameraCentral*)central cid:(unsigned long)cid;
  78. - (unsigned long) cid;
  79. - (void) dealloc;
  80. - (BOOL) startup;                //Opens the camera driver and starts up bridge (reflect VDOpen)
  81. - (void) shutdown;                //Closes the camera driver shuts down bridge (reflect VDClose)
  82.  
  83. //-----------------
  84. //   Doing grabs
  85. //-----------------
  86.  
  87. - (BOOL) grabOneFrameCompressedAsync;        //Starts grabbing one frame to compressed target
  88. - (BOOL) compressionDoneTo:(unsigned char **)data        //Returns if grabOneFrameCompressedAsync has finished
  89.                       size:(long*)size
  90.                 similarity:(UInt8*)similarity;
  91. - (void) takeBackCompressionBuffer:(Ptr)buf;    //returns a buffer (they are taken out when starting a compressed grab)
  92. - (BOOL) setDestinationWidth:(long)width height:(long)height;        //Set destination image size (we'll scale if necessary)
  93. - (BOOL) getAnImageDescriptionCopy:(ImageDescriptionHandle)outHandle;    //Returns a copy of the image description in the given handle
  94.  
  95. //---------------------
  96. //   Status requests
  97. //---------------------
  98.  
  99. - (BOOL) isStarted;            //Returns if the bridge is currently started (in use) 
  100. - (BOOL) isCameraValid;            //Returns if there currently is a real, valid camera that can deliver real video
  101. - (BOOL) getName:(char*)name;        //Try to get the camera name
  102.  
  103. //-----------------------
  104. //   Camera parameters
  105. //-----------------------
  106.  
  107. - (BOOL)canSetContrast;            //Returns if the camera supports contrast adjustment
  108. - (unsigned short)contrast;        //Returns the contrast in the range [0..65535], if supported
  109. - (void)setContrast:(unsigned short)c;    //sets the contrast in the range [0..65535], if supported
  110. - (BOOL)canSetBrightness;        //Returns if the camera supports brightness adjustment
  111. - (unsigned short)brightness;        //Returns the brightness in the range [0..65535], if supported
  112. - (void)setBrightness:(unsigned short)c;//Sets the brightness in the range [0..65535], if supported
  113. - (BOOL)canSetSaturation;        //Returns if the camera supports saturation adjustment
  114. - (unsigned short)saturation;        //Returns the saturation in the range [0..65535], if supported
  115. - (void)setSaturation:(unsigned short)c;//Sets the saturation in the range [0..65535], if supported
  116. - (BOOL)canSetSharpness;        //Returns if the camera supports sharpness adjustment
  117. - (unsigned short)sharpness;        //Returns the sharpness in the range [0..65535], if supported
  118. - (void)setSharpness:(unsigned short)c; //Sets the sharpness in the range [0..65535], if supported
  119. - (BOOL)canSetGamma;            //Returns if the camera supports gamma adjustment
  120. - (unsigned short)gamma;        //Returns the gamma in the range [0..65535], if supported
  121. - (void)setGamma:(unsigned short)c;    //Sets the gamma in the range [0..65535], if supported
  122. - (BOOL)canSetHFlip;            //Returns if the camera supports horizonal flipping
  123. - (BOOL)hFlip;                //Returns the horizontal flip state
  124. - (void)setHFlip:(BOOL)c;        //Sets the horizontal flip state
  125. - (BOOL)canSetGain;            //Returns if the camera supports gain adjustment
  126. - (void)setGain:(unsigned short)v;    //Sets the gain in the range [0..65535], if supported
  127. - (unsigned short)gain;            //Returns the gain in the range [0..65535], if supported
  128. - (BOOL)canSetShutter;            //Returns if the camera supports shutter/exposure adjustment
  129. - (void)setShutter:(unsigned short)v;    //Sets the shutter/exposure in the range [0..65535], if supported
  130. - (unsigned short)shutter;        //Returns the shutter/exposure in the range [0..65535], if supported
  131. - (BOOL)canSetAutoGain;            //Returns if the camera can be switched between auto/manual gain/shutter
  132. - (void)setAutoGain:(BOOL)v;        //Sets the auto gain/shutter/exposure control state
  133. - (BOOL)isAutoGain;            //Returns the auto gain/shutter/exposure control state
  134. - (short) maxCompression;        //Returns the number of different compression strengths (0=uncompressed only)
  135. - (short) compression;            //Returns the current compression [0 .. maxCompression]
  136. - (void) setCompression:(short)v;    //Sets the current compression [0 .. maxCompression]
  137. - (BOOL) canSetWhiteBalanceMode;    //If camera can adjust white balance at all
  138. - (BOOL) canSetWhiteBalanceModeTo:(WhiteBalanceMode)m;    //If the camera supports a specific whiute balance setting
  139. - (WhiteBalanceMode) whiteBalanceMode;    //The current white balance mode
  140. - (void) setWhiteBalanceMode:(WhiteBalanceMode)m;    //Set the current white balance mode
  141.  
  142. - (BOOL) canBlackWhiteMode;        //If camera can adjust color/greyscale at all
  143. - (BOOL) blackWhiteMode;        //The current color mode
  144. - (void) setBlackWhiteMode:(BOOL)m;    //Set the current color mode
  145.  
  146. - (BOOL) canSetLed;            //Can the camera toggle its LED
  147. - (BOOL) isLedOn;            //The current LED status
  148. - (void) setLed:(BOOL)v;        //Set the LED status
  149.  
  150. - (short) width;            //Returns the current grabbing width in pixels
  151. - (short) height;            //Returns the current grabbing height in pixels
  152. - (void) nativeBounds:(Rect*)r;        //Returns the native grabbing rect ( = <0,0,[width],[height]> )
  153. - (short) fps;                //Returns the current grabbing rate in frames per second (a bit unreliable)
  154. - (CameraResolution)resolution;        //Returns the current grabbing image format
  155. - (BOOL) supportsResolution:(CameraResolution)res fps:(short)fps;    //Returns if the resolution/fps combination is supported
  156. - (void) setResolution:(CameraResolution)res fps:(short)fps;        //Sets the current resolution/fps combi if supported
  157. - (void) saveAsDefaults;        //Takes a snapshot of the camera settings as default values for this camera type    
  158.  
  159. //------------------------
  160. //   Delegate Callbacks
  161. //------------------------
  162.  
  163. - (void) imageReady:(id)cam;
  164. - (void) cameraHasShutDown:(id)cam;
  165. - (void) grabFinished:(id)cam withError:(CameraError)err;
  166.  
  167.  
  168. @end
  169.