001package com.github.sarxos.webcam.ds.ipcam.device.mobotix; 002 003import java.awt.Dimension; 004import java.net.MalformedURLException; 005import java.net.URL; 006 007import javax.swing.JFrame; 008 009import com.github.sarxos.webcam.Webcam; 010import com.github.sarxos.webcam.WebcamException; 011import com.github.sarxos.webcam.WebcamPanel; 012import com.github.sarxos.webcam.WebcamResolution; 013import com.github.sarxos.webcam.ds.ipcam.IpCamDevice; 014import com.github.sarxos.webcam.ds.ipcam.IpCamDeviceRegistry; 015import com.github.sarxos.webcam.ds.ipcam.IpCamDriver; 016import com.github.sarxos.webcam.ds.ipcam.IpCamMode; 017 018 019/** 020 * Speed Dome X104S IP Camera by XVision. 021 * 022 * @author Bartosz Firyn (SarXos) 023 */ 024public class M10 extends IpCamDevice { 025 026 private static final Dimension[] SIZES = new Dimension[] { 027 WebcamResolution.VGA.getSize(), 028 }; 029 030 private URL base = null; 031 032 public M10(String name, String urlBase) { 033 this(name, toURL(urlBase)); 034 } 035 036 public M10(String name, URL base) { 037 super(name, (URL) null, IpCamMode.PUSH); 038 this.base = base; 039 } 040 041 @Override 042 public Dimension[] getResolutions() { 043 return SIZES; 044 } 045 046 @Override 047 public Dimension getResolution() { 048 return SIZES[0]; 049 } 050 051 @Override 052 public URL getURL() { 053 054 // http://80.122.26.250:7000/cgi-bin/faststream.jpg?stream=full&fps=1&rand=142755 055 056 String url = String.format("%s/cgi-bin/faststream.jpg?stream=full&fps=1&rand=%d", base, System.currentTimeMillis()); 057 058 try { 059 return new URL(url); 060 } catch (MalformedURLException e) { 061 throw new WebcamException(String.format("Incorrect URL %s", url), e); 062 } 063 } 064 065 public static void main(String[] args) throws MalformedURLException { 066 067 // System.setProperty(IpCamHttpClient.PROXY_HOST_KEY, 068 // "global.proxy.lucent.com"); 069 // System.setProperty(IpCamHttpClient.PROXY_PORT_KEY, "8000"); 070 071 IpCamDeviceRegistry.register(new M10("MOBOTIX AG M10", "http://80.122.26.250:7000")); 072 Webcam.setDriver(new IpCamDriver()); 073 074 WebcamPanel panel = new WebcamPanel(Webcam.getDefault(), false); 075 076 JFrame f = new JFrame("Mobotix Demo"); 077 f.add(panel); 078 f.pack(); 079 f.setVisible(true); 080 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 081 082 panel.start(); 083 084 } 085}