libuvcc  0.41a
simple uvc implementation for os x
 All Data Structures Functions Variables Typedefs Enumerations Groups Pages
Libuvcc description

Intro

Libuvcc in no way implements all of the uvc-standard. It's main purpose is help people control some of the basic functions available in their webcams.
This is very much an alpha-release, return values and function arguments may very well change in future releases.

Bug reports are always welcome at slugg.nosp@m.o@dm.nosp@m.9.se

Usage

uvccInit() (normally when your program starts).

Get a hold of your cam using one of the uvccGetCam... functions.

Make sure your cam supports the request you want to send by calling uvccCamSupportsRequest(). You can also use uvccSendInfoRequest() with the appropiet params and & the result with Info flags, this however is much slower as it includes sending a request to the cam which in turn means you have to open it first.

Open the cam using uvccOpenCam() when you want to send requests to it. Don't keep it open if you don't need it, opening it means you have exclusive access to the default control pipe on the video control interface.

If you're setting a numerical value (not on/off) get the min/max/res values and make sure your value is usable by valuen = n * (max - min) / res where min ≤ valuen ≤ max.

Send your requests using one of the Request Wrappers, uvccSendRequest() or uvccSendRawRequest().

uvccCloseCam() when you're done sending requests. You can open/close a cam as many times as you want.

When you're done with your cam release it using uvccReleaseCam().

uvccExit() (normally when your program exits).

Camera specific issues

iSight (at least the one in the early 2013 models) does not support opening the default control pipe while streaming video.

MS LifeCam Studio uses a log2-based exposure time scale, use uvccMSLifeCamExposureTimeSpan() and uvccExposureTimeToMsLifeCamValue() to handle it.

TODO

  • make sure all functions set last_error(_fn)
  • fix return values
  • as always.. more error handeling
  • fix handling of not responding devices
  • error-request, UVC spec p.79 (92)
  • more PU-requests
  • listener to reset values if changed or kext to block such reqs
  • rewrite uvcc_err -> log(int lvl, char *s, IOReturn r) then switch lvl if !logger
  • option to only use external devices (ref: BusProper.m:251)
  • get dims @ fps
  • [see source]

Additional notes

Using IOUSBDeviceInterface320 means IOUSBFamily v3.2.0 or above is required, that is os x >= 10.5.4. If anyone wants it's most certainly possible to rewrite for earlier versions.
The code looks a bit incoherent, think of it as everything that is directly callable by a user is ObjC-formatted and the other stuff is more c. Just wanted to point out that i'm not a big fan of oop. not a big fan at all..
Look at "Mac OS X 10.6 Core Library > Drivers, Kernel & Hardware > User-Space Device Access > USB Device Inteface Guide" (especially the SampleUSBMIDIDriver and Deva_Example projects), USBProberV2 ( http://opensource.apple.com/source/IOUSBFamily/IOUSBFamily-540.4.1/USBProberV2 ), Dominic Szablewski's uvc camera control ( http://www.phoboslab.org/log/2009/07/uvc-camera-control-for-mac-os-x ) and the libusb project ( http://libusb.org ) to see where this code came from..