diff --git a/webcam-capture-drivers/driver-ipcam/src/examples/java/JpegDasdingStudioExample.java b/webcam-capture-drivers/driver-ipcam/src/examples/java/JpegDasdingStudioExample.java index 70249f6e..80030760 100644 --- a/webcam-capture-drivers/driver-ipcam/src/examples/java/JpegDasdingStudioExample.java +++ b/webcam-capture-drivers/driver-ipcam/src/examples/java/JpegDasdingStudioExample.java @@ -9,6 +9,7 @@ import com.github.sarxos.webcam.Webcam; import com.github.sarxos.webcam.WebcamPanel; +import com.github.sarxos.webcam.WebcamPanel.DrawMode; import com.github.sarxos.webcam.ds.ipcam.IpCamDriver; import com.github.sarxos.webcam.ds.ipcam.IpCamStorage; @@ -49,7 +50,7 @@ public static void main(String[] args) throws MalformedURLException { for (Webcam webcam : Webcam.getWebcams()) { WebcamPanel panel = new WebcamPanel(webcam, new Dimension(256, 144), false); - panel.setFillArea(true); + panel.setDrawMode(DrawMode.FIT); panel.setFPSLimited(true); panel.setFPSLimit(0.2); // 0.2 FPS = 1 frame per 5 seconds panel.setBorder(BorderFactory.createEmptyBorder()); diff --git a/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java b/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java index 7ca95451..54ff3374 100644 --- a/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java +++ b/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java @@ -23,6 +23,8 @@ import org.apache.http.client.protocol.ClientContext; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpConnectionParams; import org.apache.http.protocol.BasicHttpContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -205,7 +207,7 @@ public void stop() { private Dimension[] sizes = null; private Dimension size = null; - + public IpCamDevice(String name, String url, IpCamMode mode) throws MalformedURLException { this(name, new URL(url), mode, null); } @@ -235,6 +237,10 @@ public IpCamDevice(String name, URL url, IpCamMode mode, IpCamAuth auth) { } } + public IpCamHttpClient getClient() { + return client; + } + protected static final URL toURL(String url) { String base = null; @@ -428,7 +434,7 @@ public boolean isOnline() { } HttpHead head = new HttpHead(uri); - + HttpResponse response = null; try { response = client.execute(head); diff --git a/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/impl/IpCamHttpClient.java b/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/impl/IpCamHttpClient.java index 35ffd690..8381fe63 100644 --- a/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/impl/IpCamHttpClient.java +++ b/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/impl/IpCamHttpClient.java @@ -4,6 +4,7 @@ import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; +import org.apache.http.params.HttpConnectionParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,12 +26,15 @@ public class IpCamHttpClient extends DefaultHttpClient { */ public static final String PROXY_PORT_KEY = "http.proxyPort"; + public static final String SO_TIMEOUT = "http.socket.timeout"; + public static final String CONNECTION_TIMEOUT = "http.connection.timeout"; + private HttpHost proxy = null; public IpCamHttpClient() { super(new PoolingClientConnectionManager()); - + // configure proxy if any String proxyHost = System.getProperty(PROXY_HOST_KEY); @@ -44,6 +48,16 @@ public IpCamHttpClient() { setProxy(proxy); } + + String soTimeout = System.getProperty(SO_TIMEOUT); + if (soTimeout != null) { + HttpConnectionParams.setSoTimeout(getParams(), Integer.parseInt(soTimeout)); + } + + String connectionTimeout = System.getProperty(CONNECTION_TIMEOUT); + if (connectionTimeout != null) { + HttpConnectionParams.setConnectionTimeout(getParams(), Integer.parseInt(connectionTimeout)); + } } public void setProxy(HttpHost proxy) {