Skip to content

Commit

Permalink
Merge pull request #173 from syliks/master
Browse files Browse the repository at this point in the history
Painter enhancements in WebcamPanel
  • Loading branch information
sarxos committed Feb 4, 2014
2 parents 9f60aa2 + d36900b commit 2671302
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 42 deletions.
2 changes: 1 addition & 1 deletion webcam-capture/src/example/java/WebcamPanelExample.java
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) throws InterruptedException {

JFrame window = new JFrame("Test webcam panel");
window.add(panel);
window.setResizable(false);
window.setResizable(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
Expand Down
Expand Up @@ -51,6 +51,7 @@ public Thread newThread(Runnable r) {
private volatile List<Webcam> webcams = null;

private AtomicBoolean running = new AtomicBoolean(false);
private AtomicBoolean enabled = new AtomicBoolean(false);

private Thread runner = null;

Expand Down Expand Up @@ -322,10 +323,17 @@ public void stop() {
*/
public void start() {

// if configured to not start, then simply return

if (!enabled.get()) {
LOG.info("Discovery service has been disabled and thus it will not be started");
return;
}

// capture driver does not support discovery - nothing to do

if (support == null) {
LOG.debug("Discovery will not run - driver {} does not support this feature", driver.getClass().getSimpleName());
LOG.info("Discovery will not run - driver {} does not support this feature", driver.getClass().getSimpleName());
return;
}

Expand All @@ -352,6 +360,17 @@ public boolean isRunning() {
return running.get();
}

/**
* Webcam discovery service will be automatically started if it's enabled,
* otherwise, when set to disabled, it will never start, even when user try
* to run it.
*
* @param enabled the parameter controlling if discovery shall be started
*/
public void setEnabled(boolean enabled) {
this.enabled.set(enabled);
}

/**
* Cleanup.
*/
Expand Down

0 comments on commit 2671302

Please sign in to comment.