68
     {
67 69
 	for (int i = 0; i < supported.length; i++) {

+ 2 - 2
app/src/main/java/com/ptplib/usbcamera/NameFactory.java

@@ -27,10 +27,10 @@ package com.ptplib.usbcamera;
27 27
 public class NameFactory
28 28
 {
29 29
     // package private
30
-    protected NameFactory () { }
30
+    public NameFactory () { }
31 31
 
32 32
     // package private
33
-    protected NameFactory updateFactory (int vendorExtensionId)
33
+    public NameFactory updateFactory (int vendorExtensionId)
34 34
     {
35 35
 	switch (vendorExtensionId) {
36 36
 	    case 0:	return this;

+ 3 - 3
app/src/main/java/com/ptplib/usbcamera/Session.java

@@ -24,7 +24,7 @@ package com.ptplib.usbcamera;
24 24
  * @version $Id: Session.java,v 1.3 2001/04/12 23:13:00 dbrownell Exp $
25 25
  * @author David Brownell
26 26
  */
27
-class Session
27
+public class Session
28 28
 {
29 29
     private int		sessionId;
30 30
     private int		xid;
@@ -47,13 +47,13 @@ class Session
47 47
 	throw new IllegalStateException ("already active");
48 48
     }
49 49
 
50
-    boolean isActive ()
50
+  public   boolean isActive ()
51 51
 	{ return active; }
52 52
 
53 53
     void open ()
54 54
 	{ xid = 1; active = true; }
55 55
 
56
-    void close ()
56
+    public void close ()
57 57
 	{ active = false; }
58 58
     
59 59
     int getSessionId ()

+ 69 - 71
app/src/main/java/com/ptplib/usbcamera/USBCameraTest.java

@@ -1,4 +1,4 @@
1
-package com.ptplib.usbcamera;
1
+package com.ptplib.usbcamera.test;
2 2
 
3 3
 
4 4
 
@@ -36,35 +36,16 @@ package com.ptplib.usbcamera;
36 36
  */
37 37
 
38 38
 
39
-
40
-import android.annotation.SuppressLint;
41 39
 import android.app.Activity;
42
-import android.os.Bundle;
43
-import android.os.Handler;
44
-import android.os.Message;
45
-///http://www.koders.com/info.aspx?c=ProjectInfo&pid=UCBHEX8BYMVVNMXBWVSEQ1BH8A
46
-import java.io.IOException;
47
-import java.nio.ByteBuffer;
48
-import java.util.Timer;
49
-import java.util.TimerTask;
50
-
51
-import com.ptplib.usbcamera.eos.EosEventConstants;
52
-import com.ptplib.usbcamera.eos.EosInitiator;
53
-import com.ptplib.usbcamera.nikon.NikonEventConstants;
54
-import com.ptplib.usbcamera.nikon.NikonInitiator;
55
-import com.strickling.usbcamera.R;
56
-
57 40
 import android.content.BroadcastReceiver;
58 41
 import android.content.Context;
59 42
 import android.content.Intent;
60 43
 import android.content.IntentFilter;
61
-import android.hardware.usb.UsbConstants;
62 44
 import android.hardware.usb.UsbDevice;
63
-import android.hardware.usb.UsbDeviceConnection;
64
-import android.hardware.usb.UsbEndpoint;
65
-import android.hardware.usb.UsbInterface;
66 45
 import android.hardware.usb.UsbManager;
67
-import android.hardware.usb.UsbRequest;
46
+import android.os.Bundle;
47
+import android.os.Handler;
48
+import android.os.Message;
68 49
 import android.util.Log;
69 50
 import android.view.View;
70 51
 import android.widget.ArrayAdapter;
@@ -74,6 +55,23 @@ import android.widget.Spinner;
74 55
 import android.widget.TextView;
75 56
 import android.widget.Toast;
76 57
 
58
+import com.ptplib.usbcamera.BaselineInitiator;
59
+import com.ptplib.usbcamera.DeviceInfo;
60
+import com.ptplib.usbcamera.DevicePropDesc;
61
+import com.ptplib.usbcamera.NameFactory;
62
+import com.ptplib.usbcamera.PTPException;
63
+import com.ptplib.usbcamera.Response;
64
+import com.ptplib.usbcamera.Session;
65
+import com.ptplib.usbcamera.eos.EosEventConstants;
66
+import com.ptplib.usbcamera.eos.EosInitiator;
67
+import com.ptplib.usbcamera.nikon.NikonEventConstants;
68
+import com.ptplib.usbcamera.nikon.NikonInitiator;
69
+import com.strickling.usbcamera.R;
70
+
71
+import java.util.Timer;
72
+
73
+///http://www.koders.com/info.aspx?c=ProjectInfo&pid=UCBHEX8BYMVVNMXBWVSEQ1BH8A
74
+
77 75
 public class USBCameraTest extends Activity { //implements Runnable {
78 76
 
79 77
 	private USBCameraTest mainActivity = this;
@@ -236,7 +234,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
236 234
 				}
237 235
 				//tv3.setText(testInfo.toString());
238 236
 				//changeSpinnerToCanon();
239
-				if (bi== null || bi.info == null){
237
+				if (bi== null || bi.getInfo() == null){
240 238
 					tv2.setText ("Error, not connected");
241 239
 					initDevice (searchDevice());
242 240
 					return;
@@ -259,16 +257,16 @@ public class USBCameraTest extends Activity { //implements Runnable {
259 257
 				clearTV();
260 258
 				//changeSpinnerToNikon();
261 259
 				
262
-				if (bi== null || bi.info == null){
260
+				if (bi== null || bi.getInfo() == null){
263 261
 					tv2.setText ("Error, not connected");
264 262
 					return;
265 263
 				}
266
-				DeviceInfo	info = bi.info;
267
-				if (info.vendorExtensionId != 0) {
268
-					factory = factory.updateFactory (info.vendorExtensionId);
269
-					info.factory = factory;
264
+				DeviceInfo info = bi.getInfo();
265
+				if (info.getVendorExtensionId() != 0) {
266
+					factory = factory.updateFactory (info.getVendorExtensionId());
267
+					info.setFactory(factory);
270 268
 				}
271
-				tv2.setText(bi.info.toString());
269
+				tv2.setText(bi.getInfo().toString());
272 270
 			}
273 271
 		});
274 272
 
@@ -1219,7 +1217,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1219 1217
 				//Old code bi =  new EosInitiator (device, mUsbManager.openDevice(device));	
1220 1218
 				bi = new BaselineInitiator (device, mUsbManager.openDevice(device));
1221 1219
 				// Select appropriate deviceInitiator, VIDs see http://www.linux-usb.org/usb.ids
1222
-				if (bi.device.getVendorId() == EosInitiator.CANON_VID) {
1220
+				if (bi.getDevice().getVendorId() == EosInitiator.CANON_VID) {
1223 1221
 				    try {
1224 1222
 				        bi.getClearStatus();
1225 1223
 				        bi.close();
@@ -1258,7 +1256,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1258 1256
 
1259 1257
 	public void detachDevice () {
1260 1258
 		if (bi != null /*&& mDevice.equals(device)*/) {			
1261
-			if (bi.device != null) Log.d(TAG, "detachDevice: " +bi.device.getDeviceName());
1259
+			if (bi.getDevice() != null) Log.d(TAG, "detachDevice: " +bi.getDevice().getDeviceName());
1262 1260
 			try {
1263 1261
 				bi.close();
1264 1262
 			} catch (PTPException e) {
@@ -1292,7 +1290,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1292 1290
 				initDevice (device);
1293 1291
 			} else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
1294 1292
 				tv1.setText("USB_DEVICE_DETACHED");
1295
-				if (bi != null && bi.session != null) bi.session.close();
1293
+				if (bi != null && bi.getSession() != null) bi.getSession().close();
1296 1294
 				detachDevice ();
1297 1295
 			}	    			        
1298 1296
 		}
@@ -1335,7 +1333,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1335 1333
 	public boolean releaseShutter (Session session){
1336 1334
 		Log.d(TAG, "Starting releaseShutter");
1337 1335
 		boolean result = session.isActive();
1338
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1336
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1339 1337
 		if (!bi.isSessionActive())
1340 1338
 			try {
1341 1339
 				bi.openSession();
@@ -1360,7 +1358,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1360 1358
 	public boolean setAppreture (Session session){
1361 1359
 		Log.d(TAG, "Starting releaseShutter");
1362 1360
 		boolean result = session.isActive();
1363
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1361
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1364 1362
 		if (!bi.isSessionActive())
1365 1363
 			try {
1366 1364
 				bi.openSession();
@@ -1391,7 +1389,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1391 1389
 
1392 1390
 	public boolean setISO (Session session){
1393 1391
 		Log.d(TAG, "Starting Test: setISO");
1394
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1392
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1395 1393
 		boolean result = session.isActive();
1396 1394
 		
1397 1395
 		if (!bi.isSessionActive())
@@ -1405,7 +1403,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1405 1403
 	        int ret = 0;
1406 1404
 	        Response resp = null;
1407 1405
 	        
1408
-	        synchronized (bi.session) {
1406
+	        synchronized (bi.getSession()) {
1409 1407
 
1410 1408
 	        	try {
1411 1409
 	        		resp = bi.transact1(Command.EosSetRemoteMode, null, 1);
@@ -1446,7 +1444,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1446 1444
 	public boolean setShutter (Session session, int shutter){
1447 1445
 		Log.d(TAG, "Set Shutter");
1448 1446
 		boolean result = session.isActive();
1449
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1447
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1450 1448
 		if (!bi.isSessionActive())
1451 1449
 			try {
1452 1450
 				bi.openSession();
@@ -1474,7 +1472,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1474 1472
 	public boolean setISO (Session session, int isoValue){
1475 1473
 		Log.d(TAG, "Set ISO");
1476 1474
 		boolean result = session.isActive();
1477
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1475
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1478 1476
 		if (!bi.isSessionActive())
1479 1477
 			try {
1480 1478
 				bi.openSession();
@@ -1502,7 +1500,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1502 1500
 	public boolean setAperture (Session session, int apertureValue){
1503 1501
 		Log.d(TAG, "Set Aperture");
1504 1502
 		boolean result = session.isActive();
1505
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1503
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1506 1504
 		if (!bi.isSessionActive())
1507 1505
 			try {
1508 1506
 				bi.openSession();
@@ -1530,7 +1528,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1530 1528
 	public boolean moveFocusForward (Session session){
1531 1529
 		Log.d(TAG, "Starting moveFocusForward");
1532 1530
 		boolean result = session.isActive();
1533
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1531
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1534 1532
 		if (!bi.isSessionActive())
1535 1533
 			try {
1536 1534
 				bi.openSession();
@@ -1559,7 +1557,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1559 1557
 	public boolean moveFocusBackward (Session session){
1560 1558
 		Log.d(TAG, "Starting moveFocusBackward");
1561 1559
 		boolean result = session.isActive();
1562
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1560
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1563 1561
 		if (!bi.isSessionActive())
1564 1562
 			try {
1565 1563
 				bi.openSession();
@@ -1588,7 +1586,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1588 1586
 	public boolean setPictureSyle (Session session, int pictureValue){
1589 1587
 		Log.d(TAG, "Set setPictureSyle");
1590 1588
 		boolean result = session.isActive();
1591
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1589
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1592 1590
 		if (!bi.isSessionActive())
1593 1591
 			try {
1594 1592
 				bi.openSession();
@@ -1616,7 +1614,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1616 1614
 	public boolean setWhiteBalance (Session session, int whitebalanceValue){
1617 1615
 		Log.d(TAG, "Set setWhiteBalance");
1618 1616
 		boolean result = session.isActive();
1619
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1617
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1620 1618
 		if (!bi.isSessionActive())
1621 1619
 			try {
1622 1620
 				bi.openSession();
@@ -1644,7 +1642,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1644 1642
 	public boolean setImageQuality (Session session, int imagequalityValue){
1645 1643
 		Log.d(TAG, "Set ImageQuality");
1646 1644
 		boolean result = session.isActive();
1647
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1645
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1648 1646
 		if (!bi.isSessionActive())
1649 1647
 			try {
1650 1648
 				bi.openSession();
@@ -1671,7 +1669,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1671 1669
 	public boolean setExposure (Session session, int exposureValue){
1672 1670
 		Log.d(TAG, "Set setExposure");
1673 1671
 		boolean result = session.isActive();
1674
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1672
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1675 1673
 		if (!bi.isSessionActive())
1676 1674
 			try {
1677 1675
 				bi.openSession();
@@ -1698,7 +1696,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1698 1696
 	public boolean setDriveMode (Session session, int drivemodeValue){
1699 1697
 		Log.d(TAG, "Set setDriveMode");
1700 1698
 		boolean result = session.isActive();
1701
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1699
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1702 1700
 		if (!bi.isSessionActive())
1703 1701
 			try {
1704 1702
 				bi.openSession();
@@ -1725,7 +1723,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1725 1723
 	public boolean setMetering (Session session, int meteringValue){
1726 1724
 		Log.d(TAG, "Set setMetering");
1727 1725
 		boolean result = session.isActive();
1728
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1726
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1729 1727
 		if (!bi.isSessionActive())
1730 1728
 			try {
1731 1729
 				bi.openSession();
@@ -1752,7 +1750,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1752 1750
 	public boolean startBulb (Session session){
1753 1751
 		Log.d(TAG, "Starting releaseShutter");
1754 1752
 		boolean result = session.isActive();
1755
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1753
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1756 1754
 		if (!bi.isSessionActive())
1757 1755
 			try {
1758 1756
 				bi.openSession();
@@ -1783,7 +1781,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1783 1781
 	public boolean stopBulb (Session session){
1784 1782
 		Log.d(TAG, "Starting stopBulb");
1785 1783
 		boolean result = session.isActive();
1786
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1784
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1787 1785
 		if (!bi.isSessionActive())
1788 1786
 			try {
1789 1787
 				bi.openSession();
@@ -1813,7 +1811,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1813 1811
 	public boolean getShutterSpeed (Session session){
1814 1812
 		Log.d(TAG, "getShutterSpeed");
1815 1813
 		boolean result = session.isActive();
1816
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1814
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1817 1815
 		if (!bi.isSessionActive())
1818 1816
 			try {
1819 1817
 				bi.openSession();
@@ -1841,7 +1839,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1841 1839
 	public boolean setShutterSpeed (Session session, int speed){
1842 1840
 		Log.d(TAG, "Starting stopBulb");
1843 1841
 		boolean result = session.isActive();
1844
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1842
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1845 1843
 		if (!bi.isSessionActive())
1846 1844
 			try {
1847 1845
 				bi.openSession();
@@ -1868,7 +1866,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1868 1866
 	public boolean initLiveview (Session session){
1869 1867
 		Log.d(TAG, "Set setMetering");
1870 1868
 		boolean result = session.isActive();
1871
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1869
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1872 1870
 		if (!bi.isSessionActive())
1873 1871
 			try {
1874 1872
 				bi.openSession();
@@ -1895,7 +1893,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1895 1893
 	public boolean startLiveview (Session session){
1896 1894
 		Log.d(TAG, "Set setMetering");
1897 1895
 		boolean result = session.isActive();
1898
-		if (bi.device == null) {log("NO DEVICE OPENED"); return false;}
1896
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return false;}
1899 1897
 		if (!bi.isSessionActive())
1900 1898
 			try {
1901 1899
 				bi.openSession();
@@ -1918,7 +1916,7 @@ public class USBCameraTest extends Activity { //implements Runnable {
1918 1916
 
1919 1917
 		Log.d(TAG, "Starting releaseShutter");
1920 1918
 		boolean result = session.isActive();
1921
-		if (bi.device == null) {log("NO DEVICE OPENED"); return result;}
1919
+		if (bi.getDevice() == null) {log("NO DEVICE OPENED"); return result;}
1922 1920
 		if (!bi.isSessionActive())
1923 1921
 			try {
1924 1922
 				bi.openSession();
@@ -2042,58 +2040,58 @@ public class USBCameraTest extends Activity { //implements Runnable {
2042 2040
 		public void run() {
2043 2041
 //			Log.d(TAG, "running thread " +thread.getName());
2044 2042
 			if (thread.getName().equals(THREAD_SHUTTER)) { 
2045
-				releaseShutter (bi.session);
2043
+				releaseShutter (bi.getSession());
2046 2044
 			}; 		
2047 2045
 			if (thread.getName().equals(THREAD_TEST)) { 
2048
-				testFunction(bi.session);
2046
+				testFunction(bi.getSession());
2049 2047
 			};
2050 2048
 			if (thread.getName().equals(THREAD_STARTBULB)) { 
2051
-				startBulb(bi.session);
2049
+				startBulb(bi.getSession());
2052 2050
 			};
2053 2051
 			if (thread.getName().equals(THREAD_STOPBULB)) { 
2054
-				stopBulb(bi.session);
2052
+				stopBulb(bi.getSession());
2055 2053
 			};
2056 2054
 			if (thread.getName().equals(THREAD_SETSHUTTER)) { 
2057
-				setShutter(bi.session, shutter_value);
2055
+				setShutter(bi.getSession(), shutter_value);
2058 2056
 			};		
2059 2057
 			if (thread.getName().equals(THREAD_SETISO)) { 
2060
-				setISO(bi.session, iso_value);
2058
+				setISO(bi.getSession(), iso_value);
2061 2059
 			};
2062 2060
 			if (thread.getName().equals(THREAD_SETAPERTURE)) { 
2063
-				setAperture(bi.session, aperture_value);
2061
+				setAperture(bi.getSession(), aperture_value);
2064 2062
 			};
2065 2063
 			if (thread.getName().equals(THREAD_FOCUSFORWARD)) { 
2066
-				moveFocusForward(bi.session);
2064
+				moveFocusForward(bi.getSession());
2067 2065
 			};
2068 2066
 			if (thread.getName().equals(THREAD_FOCUSBACKWARD)) { 
2069
-				moveFocusBackward(bi.session);
2067
+				moveFocusBackward(bi.getSession());
2070 2068
 			};
2071 2069
 			if (thread.getName().equals(THREAD_SETPICTURESTYLE)) { 
2072
-				setPictureSyle(bi.session, picturestyle_value);
2070
+				setPictureSyle(bi.getSession(), picturestyle_value);
2073 2071
 			};
2074 2072
 			if (thread.getName().equals(THREAD_SETWHITEBALANCE)) { 
2075
-				setWhiteBalance(bi.session,whitebalance_value);
2073
+				setWhiteBalance(bi.getSession(),whitebalance_value);
2076 2074
 			};
2077 2075
 			if (thread.getName().equals(THREAD_SETEXPOSURE)) { 
2078
-				setExposure(bi.session, exposure_value);
2076
+				setExposure(bi.getSession(), exposure_value);
2079 2077
 			};
2080 2078
 			if (thread.getName().equals(THREAD_SETDRIVEMODE)) { 
2081
-				setDriveMode(bi.session, drivemode_value);
2079
+				setDriveMode(bi.getSession(), drivemode_value);
2082 2080
 			};		
2083 2081
 			
2084 2082
 			if (thread.getName().equals(THREAD_SETMETERING)) { 
2085
-				setMetering(bi.session, metering_value);
2083
+				setMetering(bi.getSession(), metering_value);
2086 2084
 			};
2087 2085
 			
2088 2086
 			if (thread.getName().equals(THREAD_INITLIVEVIEW)) { 
2089
-				initLiveview(bi.session);
2087
+				initLiveview(bi.getSession());
2090 2088
 				liveViewTurnedOn = true;
2091 2089
 			};
2092 2090
 			
2093 2091
 			if (thread.getName().equals(THREAD_STARTLIVEVIEW)) { 
2094 2092
 				while(liveViewTurnedOn)
2095 2093
 				{
2096
-					startLiveview(bi.session);
2094
+					startLiveview(bi.getSession());
2097 2095
 				}
2098 2096
 			};
2099 2097
 			

kodo - Gogs: Go Git Service

Nav apraksta

views.py 129B

    # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render # Create your views here.