Getting linux webcam state via command line or API

view full story

http://serverfault.com – I would, preferably, like to know of a command I can run that will let me know whether a webcam is on/off or recording/not recording, etc. Maybe a way to see if any programs are currently accessing it would work as well. If there is no command line option, I'm not opposed to writing a small c or c++ program to do this, but I haven't been able to find a way to do that either. (HowTos)