Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painter enhancements in WebcamPanel #173

Merged
merged 1 commit into from
Feb 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webcam-capture/src/example/java/WebcamPanelExample.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading