Bartosz Firyn (SarXos)

com.github.sarxos.webcam
Class WebcamLock

java.lang.Object
  extended by com.github.sarxos.webcam.WebcamLock

public class WebcamLock
extends Object

This class is used as a global (system) lock preventing other processes from using the same camera while it's open. Whenever webcam is open there is a thread running in background which updates the lock once per 2 seconds. Lock is being released whenever webcam is either closed or completely disposed. Lock will remain for at least 2 seconds in case when JVM has not been gracefully terminated (due to SIGSEGV, SIGTERM, etc).

Author:
Bartosz Firyn (sarxos)

Field Summary
static long INTERVAL
          Update interval (ms).
 
Method Summary
 void disable()
          Completely disable locking mechanism.
 boolean isLocked()
          Check if webcam is locked.
 void lock()
          Lock webcam.
 void unlock()
          Unlock webcam.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERVAL

public static final long INTERVAL
Update interval (ms).

See Also:
Constant Field Values
Method Detail

lock

public void lock()
Lock webcam.


disable

public void disable()
Completely disable locking mechanism. After this method is invoked, the lock will not have any effect on the webcam runtime.


unlock

public void unlock()
Unlock webcam.


isLocked

public boolean isLocked()
Check if webcam is locked.

Returns:
True if webcam is locked, false otherwise

Bartosz Firyn (SarXos)

Copyright © 2012-2013 Bartosz Firyn (SarXos). All Rights Reserved.