+
+ private static boolean haveAddedDumpToAcra = false;
+
+ private static final String TAG = NikonGetLiveViewImageCommand.class.getSimpleName();
+ private static byte[] tmpStorage = new byte[0x4000];
+ private final Options options;
+ private LiveViewData data;
+
+ public NikonGetLiveViewImageCommand(NikonCamera camera, LiveViewData data) {
+ super(camera);
+ this.data = data;
+ if (data == null) {
+ this.data = new LiveViewData();
+ //this.data.histogram = ByteBuffer.allocate(1024 * 4);
+ //this.data.histogram.order(ByteOrder.LITTLE_ENDIAN);
+ } else {
+ this.data = data;
+ }
+ options = new BitmapFactory.Options();
+ options.inBitmap = this.data.bitmap;
+ options.inSampleSize = 1;
+ options.inTempStorage = tmpStorage;
+ this.data.bitmap = null;
+ }
+
+ @Override
+ public void exec(IO io) {
+ if (!camera.isLiveViewOpen()) {
+ return;
+ }
+ io.handleCommand(this);
+ if (responseCode == Response.DeviceBusy) {
+ camera.onDeviceBusy(this, true);
+ return;
+ }
+ data.hasHistogram = false;
+ if (this.data.bitmap != null && responseCode == Response.Ok) {
+ camera.onLiveViewReceived(data);
+ } else {
+ camera.onLiveViewReceived(null);
+ }
+ }
+
+ @Override
+ public void encodeCommand(ByteBuffer b) {
+ encodeCommand(b, Operation.NikonGetLiveViewImage);
+ }
+
+ @Override
+ protected void decodeData(ByteBuffer b, int length) {
+ if (length <= 128) {
+ return;
+ }
+
+ data.hasAfFrame = false;
+
+ int productId = camera.getProductId();
+ int start = b.position();
+ int pictureOffset;
+
+ switch (productId) {
+ case Product.NikonD5000:
+ case Product.NikonD3S:
+ case Product.NikonD90:
+ pictureOffset = 128;
+ break;
+ case Product.NikonD3X:
+ case Product.NikonD300S:
+ case Product.NikonD3:
+ case Product.NikonD300:
+ case Product.NikonD700:
+ pictureOffset = 64;
+ break;
+ case Product.NikonD7000:
+ case Product.NikonD5100:
+ pictureOffset = 384;
+ break;
+ default:
+ return;
+ }
+
+ b.order(ByteOrder.BIG_ENDIAN);
+
+ // read af frame
+ {
+ data.hasAfFrame = true;
+
+ int jpegImageWidth = b.getShort() & 0xFFFF;
+ int jpegImageHeight = b.getShort() & 0xFFFF;
+ int wholeWidth = b.getShort() & 0xFFFF;
+ int wholeHeight = b.getShort() & 0xFFFF;
+
+ float multX = jpegImageWidth / (float) wholeWidth;
+ float multY = jpegImageHeight / (float) wholeHeight;
+
+ b.position(start + 16);
+ data.nikonWholeWidth = wholeWidth;
+ data.nikonWholeHeight = wholeHeight;
+ data.nikonAfFrameWidth = (int) ((b.getShort() & 0xFFFF) * multX);
+ data.nikonAfFrameHeight = (int) ((b.getShort() & 0xFFFF) * multY);
+ data.nikonAfFrameCenterX = (int) ((b.getShort() & 0xFFFF) * multX);
+ data.nikonAfFrameCenterY = (int) ((b.getShort() & 0xFFFF) * multY);
+ }
+
+ b.order(ByteOrder.LITTLE_ENDIAN);
+
+ b.position(start + pictureOffset);
+
+ if (b.remaining() <= 128) {
+ data.bitmap = null;
+ return;
+ }
+
+ try {
+ data.bitmap = BitmapFactory.decodeByteArray(b.array(), b.position(), length - b.position(), options);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "decoding failed " + e.toString());
+ Log.e(TAG, e.getLocalizedMessage());
+ if (AppConfig.LOG) {
+ PacketUtil.logHexdump(TAG, b.array(), start, 512);
+ }
+ }
+ }
+}
@@ -0,0 +1,51 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.commands.nikon; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+ |
|
20 |
+import com.remoteyourcam.usb.ptp.NikonCamera; |
|
21 |
+import com.remoteyourcam.usb.ptp.PacketUtil; |
|
22 |
+import com.remoteyourcam.usb.ptp.PtpCamera.IO; |
|
23 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Operation; |
|
24 |
+ |
|
25 |
+public class NikonGetVendorPropCodesCommand extends NikonCommand { |
|
26 |
+ |
|
27 |
+ private int[] propertyCodes = new int[0]; |
|
28 |
+ |
|
29 |
+ public NikonGetVendorPropCodesCommand(NikonCamera camera) { |
|
30 |
+ super(camera); |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ public int[] getPropertyCodes() { |
|
34 |
+ return propertyCodes; |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ @Override |
|
38 |
+ public void exec(IO io) { |
|
39 |
+ throw new UnsupportedOperationException(); |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ @Override |
|
43 |
+ public void encodeCommand(ByteBuffer b) { |
|
44 |
+ encodeCommand(b, Operation.NikonGetVendorPropCodes); |
|
45 |
+ } |
|
46 |
+ |
|
47 |
+ @Override |
|
48 |
+ protected void decodeData(ByteBuffer b, int length) { |
|
49 |
+ propertyCodes = PacketUtil.readU16Array(b); |
|
50 |
+ } |
|
51 |
+} |
@@ -0,0 +1,69 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.commands.nikon; |
|
17 |
+ |
|
18 |
+import com.remoteyourcam.usb.ptp.NikonCamera; |
|
19 |
+import com.remoteyourcam.usb.ptp.PtpAction; |
|
20 |
+import com.remoteyourcam.usb.ptp.PtpCamera.IO; |
|
21 |
+import com.remoteyourcam.usb.ptp.PtpConstants; |
|
22 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Datatype; |
|
23 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Operation; |
|
24 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Property; |
|
25 |
+import com.remoteyourcam.usb.ptp.commands.OpenSessionCommand; |
|
26 |
+import com.remoteyourcam.usb.ptp.commands.SetDevicePropValueCommand; |
|
27 |
+ |
|
28 |
+public class NikonOpenSessionAction implements PtpAction { |
|
29 |
+ |
|
30 |
+ private final NikonCamera camera; |
|
31 |
+ |
|
32 |
+ public NikonOpenSessionAction(NikonCamera camera) { |
|
33 |
+ this.camera = camera; |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ @Override |
|
37 |
+ public void exec(IO io) { |
|
38 |
+ OpenSessionCommand openSession = new OpenSessionCommand(camera); |
|
39 |
+ io.handleCommand(openSession); |
|
40 |
+ if (openSession.getResponseCode() == PtpConstants.Response.Ok) { |
|
41 |
+ if (camera.hasSupportForOperation(Operation.NikonGetVendorPropCodes)) { |
|
42 |
+ NikonGetVendorPropCodesCommand getPropCodes = new NikonGetVendorPropCodesCommand(camera); |
|
43 |
+ io.handleCommand(getPropCodes); |
|
44 |
+ SetDevicePropValueCommand c = new SetDevicePropValueCommand(camera, Property.NikonRecordingMedia, 1, |
|
45 |
+ Datatype.uint8); |
|
46 |
+ io.handleCommand(c); |
|
47 |
+ if (getPropCodes.getResponseCode() == PtpConstants.Response.Ok |
|
48 |
+ && c.getResponseCode() == PtpConstants.Response.Ok) { |
|
49 |
+ camera.setVendorPropCodes(getPropCodes.getPropertyCodes()); |
|
50 |
+ camera.onSessionOpened(); |
|
51 |
+ } else { |
|
52 |
+ camera.onPtpError(String.format( |
|
53 |
+ "Couldn't read device property codes! Open session command failed with error code \"%s\"", |
|
54 |
+ PtpConstants.responseToString(getPropCodes.getResponseCode()))); |
|
55 |
+ } |
|
56 |
+ } else { |
|
57 |
+ camera.onSessionOpened(); |
|
58 |
+ } |
|
59 |
+ } else { |
|
60 |
+ camera.onPtpError(String.format( |
|
61 |
+ "Couldn't open session! Open session command failed with error code \"%s\"", |
|
62 |
+ PtpConstants.responseToString(openSession.getResponseCode()))); |
|
63 |
+ } |
|
64 |
+ } |
|
65 |
+ |
|
66 |
+ @Override |
|
67 |
+ public void reset() { |
|
68 |
+ } |
|
69 |
+} |
@@ -0,0 +1,66 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.commands.nikon; |
|
17 |
+ |
|
18 |
+import com.remoteyourcam.usb.ptp.NikonCamera; |
|
19 |
+import com.remoteyourcam.usb.ptp.PtpAction; |
|
20 |
+import com.remoteyourcam.usb.ptp.PtpCamera.IO; |
|
21 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Operation; |
|
22 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Response; |
|
23 |
+import com.remoteyourcam.usb.ptp.commands.SimpleCommand; |
|
24 |
+ |
|
25 |
+public class NikonStartLiveViewAction implements PtpAction { |
|
26 |
+ |
|
27 |
+ private final NikonCamera camera; |
|
28 |
+ |
|
29 |
+ public NikonStartLiveViewAction(NikonCamera camera) { |
|
30 |
+ this.camera = camera; |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ @Override |
|
34 |
+ public void exec(IO io) { |
|
35 |
+ SimpleCommand simpleCmd = new SimpleCommand(camera, Operation.NikonStartLiveView); |
|
36 |
+ io.handleCommand(simpleCmd); |
|
37 |
+ |
|
38 |
+ if (simpleCmd.getResponseCode() != Response.Ok) { |
|
39 |
+ return; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ SimpleCommand deviceReady = new SimpleCommand(camera, Operation.NikonDeviceReady); |
|
43 |
+ for (int i = 0; i < 10; ++i) { |
|
44 |
+ try { |
|
45 |
+ Thread.sleep(300); |
|
46 |
+ } catch (InterruptedException e) { |
|
47 |
+ // nop |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ deviceReady.reset(); |
|
51 |
+ io.handleCommand(deviceReady); |
|
52 |
+ if (deviceReady.getResponseCode() == Response.DeviceBusy) { |
|
53 |
+ // still waiting |
|
54 |
+ } else if (deviceReady.getResponseCode() == Response.Ok) { |
|
55 |
+ camera.onLiveViewStarted(); |
|
56 |
+ return; |
|
57 |
+ } else { |
|
58 |
+ return; |
|
59 |
+ } |
|
60 |
+ } |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ @Override |
|
64 |
+ public void reset() { |
|
65 |
+ } |
|
66 |
+} |
@@ -0,0 +1,54 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.commands.nikon; |
|
17 |
+ |
|
18 |
+import com.remoteyourcam.usb.ptp.NikonCamera; |
|
19 |
+import com.remoteyourcam.usb.ptp.PtpAction; |
|
20 |
+import com.remoteyourcam.usb.ptp.PtpCamera.IO; |
|
21 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Operation; |
|
22 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Response; |
|
23 |
+import com.remoteyourcam.usb.ptp.commands.SimpleCommand; |
|
24 |
+ |
|
25 |
+public class NikonStopLiveViewAction implements PtpAction { |
|
26 |
+ |
|
27 |
+ private final NikonCamera camera; |
|
28 |
+ private final boolean notifyUser; |
|
29 |
+ |
|
30 |
+ public NikonStopLiveViewAction(NikonCamera camera, boolean notifyUser) { |
|
31 |
+ this.camera = camera; |
|
32 |
+ this.notifyUser = notifyUser; |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ @Override |
|
36 |
+ public void exec(IO io) { |
|
37 |
+ SimpleCommand simpleCmd = new SimpleCommand(camera, Operation.NikonEndLiveView); |
|
38 |
+ io.handleCommand(simpleCmd); |
|
39 |
+ |
|
40 |
+ if (simpleCmd.getResponseCode() == Response.DeviceBusy) { |
|
41 |
+ camera.onDeviceBusy(this, true); |
|
42 |
+ } else { |
|
43 |
+ if (notifyUser) { |
|
44 |
+ camera.onLiveViewStopped(); |
|
45 |
+ } else { |
|
46 |
+ camera.onLiveViewStoppedInternal(); |
|
47 |
+ } |
|
48 |
+ } |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ @Override |
|
52 |
+ public void reset() { |
|
53 |
+ } |
|
54 |
+} |
@@ -0,0 +1,113 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.model; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+import java.util.Arrays; |
|
20 |
+ |
|
21 |
+import com.remoteyourcam.usb.ptp.PacketUtil; |
|
22 |
+import com.remoteyourcam.usb.ptp.PtpConstants; |
|
23 |
+ |
|
24 |
+/** |
|
25 |
+ * Device info data set as defined by PTP standard. |
|
26 |
+ */ |
|
27 |
+public class DeviceInfo { |
|
28 |
+ |
|
29 |
+ public short standardVersion; |
|
30 |
+ public int vendorExtensionId; |
|
31 |
+ public short vendorExtensionVersion; |
|
32 |
+ public String vendorExtensionDesc; |
|
33 |
+ public short functionalMode; |
|
34 |
+ public int[] operationsSupported; |
|
35 |
+ public int[] eventsSupported; |
|
36 |
+ public int[] devicePropertiesSupported; |
|
37 |
+ public int[] captureFormats; |
|
38 |
+ public int[] imageFormats; |
|
39 |
+ public String manufacture; |
|
40 |
+ public String model; |
|
41 |
+ public String deviceVersion; |
|
42 |
+ public String serialNumber; |
|
43 |
+ |
|
44 |
+ public DeviceInfo(ByteBuffer b, int length) { |
|
45 |
+ decode(b, length); |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ public DeviceInfo() { |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ public void decode(ByteBuffer b, int length) { |
|
52 |
+ standardVersion = b.getShort(); |
|
53 |
+ vendorExtensionId = b.getInt(); |
|
54 |
+ vendorExtensionVersion = b.getShort(); |
|
55 |
+ vendorExtensionDesc = PacketUtil.readString(b); |
|
56 |
+ functionalMode = b.getShort(); |
|
57 |
+ operationsSupported = PacketUtil.readU16Array(b); |
|
58 |
+ eventsSupported = PacketUtil.readU16Array(b); |
|
59 |
+ devicePropertiesSupported = PacketUtil.readU16Array(b); |
|
60 |
+ captureFormats = PacketUtil.readU16Array(b); |
|
61 |
+ imageFormats = PacketUtil.readU16Array(b); |
|
62 |
+ manufacture = PacketUtil.readString(b); |
|
63 |
+ model = PacketUtil.readString(b); |
|
64 |
+ deviceVersion = PacketUtil.readString(b); |
|
65 |
+ serialNumber = PacketUtil.readString(b); |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ public void encode(ByteBuffer b) { |
|
69 |
+ b.putShort(standardVersion); |
|
70 |
+ b.putInt(vendorExtensionId); |
|
71 |
+ b.putInt(vendorExtensionVersion); |
|
72 |
+ PacketUtil.writeString(b, ""); |
|
73 |
+ b.putShort(functionalMode); |
|
74 |
+ PacketUtil.writeU16Array(b, new int[0]); |
|
75 |
+ PacketUtil.writeU16Array(b, new int[0]); |
|
76 |
+ PacketUtil.writeU16Array(b, new int[0]); |
|
77 |
+ PacketUtil.writeU16Array(b, new int[0]); |
|
78 |
+ PacketUtil.writeU16Array(b, new int[0]); |
|
79 |
+ PacketUtil.writeString(b, ""); |
|
80 |
+ PacketUtil.writeString(b, ""); |
|
81 |
+ PacketUtil.writeString(b, ""); |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ @Override |
|
85 |
+ public String toString() { |
|
86 |
+ // Changes here have to reflect changes in PtpConstants.main() |
|
87 |
+ StringBuilder b = new StringBuilder(); |
|
88 |
+ b.append("DeviceInfo\n"); |
|
89 |
+ b.append("StandardVersion: ").append(standardVersion).append('\n'); |
|
90 |
+ b.append("VendorExtensionId: ").append(vendorExtensionId).append('\n'); |
|
91 |
+ b.append("VendorExtensionVersion: ").append(vendorExtensionVersion).append('\n'); |
|
92 |
+ b.append("VendorExtensionDesc: ").append(vendorExtensionDesc).append('\n'); |
|
93 |
+ b.append("FunctionalMode: ").append(functionalMode).append('\n'); |
|
94 |
+ appendU16Array(b, "OperationsSupported", PtpConstants.Operation.class, operationsSupported); |
|
95 |
+ appendU16Array(b, "EventsSupported", PtpConstants.Event.class, eventsSupported); |
|
96 |
+ appendU16Array(b, "DevicePropertiesSupported", PtpConstants.Property.class, devicePropertiesSupported); |
|
97 |
+ appendU16Array(b, "CaptureFormats", PtpConstants.ObjectFormat.class, captureFormats); |
|
98 |
+ appendU16Array(b, "ImageFormats", PtpConstants.ObjectFormat.class, imageFormats); |
|
99 |
+ b.append("Manufacture: ").append(manufacture).append('\n'); |
|
100 |
+ b.append("Model: ").append(model).append('\n'); |
|
101 |
+ b.append("DeviceVersion: ").append(deviceVersion).append('\n'); |
|
102 |
+ b.append("SerialNumber: ").append(serialNumber).append('\n'); |
|
103 |
+ return b.toString(); |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ private static void appendU16Array(StringBuilder b, String name, Class<?> cl, int[] a) { |
|
107 |
+ Arrays.sort(a); |
|
108 |
+ b.append(name).append(":\n"); |
|
109 |
+ for (int i = 0; i < a.length; ++i) { |
|
110 |
+ b.append(" ").append(PtpConstants.constantToString(cl, a[i])).append('\n'); |
|
111 |
+ } |
|
112 |
+ } |
|
113 |
+} |
@@ -0,0 +1,102 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.model; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+ |
|
20 |
+import com.remoteyourcam.usb.ptp.PacketUtil; |
|
21 |
+import com.remoteyourcam.usb.ptp.PtpConstants.Datatype; |
|
22 |
+ |
|
23 |
+public class DevicePropDesc { |
|
24 |
+ |
|
25 |
+ public int code; |
|
26 |
+ public int datatype; |
|
27 |
+ public boolean readOnly; |
|
28 |
+ public int factoryDefault; |
|
29 |
+ public int currentValue; |
|
30 |
+ public int[] description; |
|
31 |
+ |
|
32 |
+ public DevicePropDesc() { |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ public DevicePropDesc(ByteBuffer b, int length) { |
|
36 |
+ decode(b, length); |
|
37 |
+ } |
|
38 |
+ |
|
39 |
+ public void decode(ByteBuffer b, int length) { |
|
40 |
+ code = b.getShort() & 0xFFFF; |
|
41 |
+ datatype = b.getShort() & 0xFFFF; |
|
42 |
+ readOnly = b.get() == 0; |
|
43 |
+ |
|
44 |
+ if (datatype == Datatype.int8 || datatype == Datatype.uint8) { |
|
45 |
+ factoryDefault = b.get() & 0xFF; |
|
46 |
+ currentValue = b.get() & 0xFF; |
|
47 |
+ int form = b.get(); |
|
48 |
+ if (form == 2) { |
|
49 |
+ description = PacketUtil.readU8Enumeration(b); |
|
50 |
+ } else if (form == 1) { |
|
51 |
+ int mini = b.get(); |
|
52 |
+ int maxi = b.get(); |
|
53 |
+ int step = b.get(); |
|
54 |
+ description = new int[(maxi - mini) / step + 1]; |
|
55 |
+ for (int i = 0; i < description.length; ++i) { |
|
56 |
+ description[i] = mini + step * i; |
|
57 |
+ } |
|
58 |
+ } |
|
59 |
+ } else if (datatype == Datatype.uint16) { |
|
60 |
+ factoryDefault = b.getShort() & 0xFFFF; |
|
61 |
+ currentValue = b.getShort() & 0xFFFF; |
|
62 |
+ int form = b.get(); |
|
63 |
+ if (form == 2) { |
|
64 |
+ description = PacketUtil.readU16Enumeration(b); |
|
65 |
+ } else if (form == 1) { |
|
66 |
+ int mini = b.getShort() & 0xFFFF; |
|
67 |
+ int maxi = b.getShort() & 0xFFFF; |
|
68 |
+ int step = b.getShort() & 0xFFFF; |
|
69 |
+ description = new int[(maxi - mini) / step + 1]; |
|
70 |
+ for (int i = 0; i < description.length; ++i) { |
|
71 |
+ description[i] = mini + step * i; |
|
72 |
+ } |
|
73 |
+ } |
|
74 |
+ } else if (datatype == Datatype.int16) { |
|
75 |
+ factoryDefault = b.getShort(); |
|
76 |
+ currentValue = b.getShort(); |
|
77 |
+ int form = b.get(); |
|
78 |
+ if (form == 2) { |
|
79 |
+ description = PacketUtil.readS16Enumeration(b); |
|
80 |
+ } else if (form == 1) { |
|
81 |
+ int mini = b.getShort(); |
|
82 |
+ int maxi = b.getShort(); |
|
83 |
+ int step = b.getShort(); |
|
84 |
+ description = new int[(maxi - mini) / step + 1]; |
|
85 |
+ for (int i = 0; i < description.length; ++i) { |
|
86 |
+ description[i] = mini + step * i; |
|
87 |
+ } |
|
88 |
+ } |
|
89 |
+ } else if (datatype == Datatype.int32 || datatype == Datatype.uint32) { |
|
90 |
+ factoryDefault = b.getInt(); |
|
91 |
+ currentValue = b.getInt(); |
|
92 |
+ int form = b.get(); |
|
93 |
+ if (form == 2) { |
|
94 |
+ description = PacketUtil.readU32Enumeration(b); |
|
95 |
+ } |
|
96 |
+ } |
|
97 |
+ |
|
98 |
+ if (description == null) { |
|
99 |
+ description = new int[0]; |
|
100 |
+ } |
|
101 |
+ } |
|
102 |
+} |
@@ -0,0 +1,44 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.model; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+ |
|
20 |
+import android.graphics.Bitmap; |
|
21 |
+ |
|
22 |
+public class LiveViewData { |
|
23 |
+ |
|
24 |
+ public Bitmap bitmap; |
|
25 |
+ |
|
26 |
+ public int zoomFactor; |
|
27 |
+ public int zoomRectLeft; |
|
28 |
+ public int zoomRectTop; |
|
29 |
+ public int zoomRectRight; |
|
30 |
+ public int zoomRectBottom; |
|
31 |
+ |
|
32 |
+ public boolean hasHistogram; |
|
33 |
+ public ByteBuffer histogram; |
|
34 |
+ |
|
35 |
+ // dimensions are in bitmap size |
|
36 |
+ public boolean hasAfFrame; |
|
37 |
+ public int nikonAfFrameCenterX; |
|
38 |
+ public int nikonAfFrameCenterY; |
|
39 |
+ public int nikonAfFrameWidth; |
|
40 |
+ public int nikonAfFrameHeight; |
|
41 |
+ |
|
42 |
+ public int nikonWholeWidth; |
|
43 |
+ public int nikonWholeHeight; |
|
44 |
+} |
@@ -0,0 +1,101 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.model; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+ |
|
20 |
+import com.remoteyourcam.usb.ptp.PacketUtil; |
|
21 |
+import com.remoteyourcam.usb.ptp.PtpConstants; |
|
22 |
+ |
|
23 |
+/** |
|
24 |
+ * Object info data set as defined by the PTP standard. |
|
25 |
+ */ |
|
26 |
+public class ObjectInfo { |
|
27 |
+ |
|
28 |
+ public int storageId; |
|
29 |
+ public int objectFormat; |
|
30 |
+ public int protectionStatus; |
|
31 |
+ public int objectCompressedSize; |
|
32 |
+ public int thumbFormat; |
|
33 |
+ public int thumbCompressedSize; |
|
34 |
+ public int thumbPixWidth; |
|
35 |
+ public int thumbPixHeight; |
|
36 |
+ public int imagePixWidth; |
|
37 |
+ public int imagePixHeight; |
|
38 |
+ public int imageBitDepth; |
|
39 |
+ public int parentObject; |
|
40 |
+ public int associationType; |
|
41 |
+ public int associationDesc; |
|
42 |
+ public int sequenceNumber; |
|
43 |
+ public String filename; |
|
44 |
+ public String captureDate; |
|
45 |
+ public String modificationDate; |
|
46 |
+ public int keywords; |
|
47 |
+ |
|
48 |
+ public ObjectInfo() { |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ public ObjectInfo(ByteBuffer b, int length) { |
|
52 |
+ decode(b, length); |
|
53 |
+ } |
|
54 |
+ |
|
55 |
+ public void decode(ByteBuffer b, int length) { |
|
56 |
+ storageId = b.getInt(); |
|
57 |
+ objectFormat = b.getShort(); |
|
58 |
+ protectionStatus = b.getShort(); |
|
59 |
+ objectCompressedSize = b.getInt(); |
|
60 |
+ thumbFormat = b.getShort(); |
|
61 |
+ thumbCompressedSize = b.getInt(); |
|
62 |
+ thumbPixWidth = b.getInt(); |
|
63 |
+ thumbPixHeight = b.getInt(); |
|
64 |
+ imagePixWidth = b.getInt(); |
|
65 |
+ imagePixHeight = b.getInt(); |
|
66 |
+ imageBitDepth = b.getInt(); |
|
67 |
+ parentObject = b.getInt(); |
|
68 |
+ associationType = b.getShort(); |
|
69 |
+ associationDesc = b.getInt(); |
|
70 |
+ sequenceNumber = b.getInt(); |
|
71 |
+ filename = PacketUtil.readString(b); |
|
72 |
+ captureDate = PacketUtil.readString(b); |
|
73 |
+ modificationDate = PacketUtil.readString(b); |
|
74 |
+ keywords = b.get(); // string, not used on camera? |
|
75 |
+ } |
|
76 |
+ |
|
77 |
+ @Override |
|
78 |
+ public String toString() { |
|
79 |
+ StringBuilder b = new StringBuilder(); |
|
80 |
+ b.append("ObjectInfo\n"); |
|
81 |
+ b.append("StorageId: ").append(String.format("0x%08x\n", storageId)); |
|
82 |
+ b.append("ObjectFormat: ").append(PtpConstants.objectFormatToString(objectFormat)).append('\n'); |
|
83 |
+ b.append("ProtectionStatus: ").append(protectionStatus).append('\n'); |
|
84 |
+ b.append("ObjectCompressedSize: ").append(objectCompressedSize).append('\n'); |
|
85 |
+ b.append("ThumbFormat: ").append(PtpConstants.objectFormatToString(thumbFormat)).append('\n'); |
|
86 |
+ b.append("ThumbCompressedSize: ").append(thumbCompressedSize).append('\n'); |
|
87 |
+ b.append("ThumbPixWdith: ").append(thumbPixWidth).append('\n'); |
|
88 |
+ b.append("ThumbPixHeight: ").append(thumbPixHeight).append('\n'); |
|
89 |
+ b.append("ImagePixWidth: ").append(imagePixWidth).append('\n'); |
|
90 |
+ b.append("ImagePixHeight: ").append(imagePixHeight).append('\n'); |
|
91 |
+ b.append("ImageBitDepth: ").append(imageBitDepth).append('\n'); |
|
92 |
+ b.append("ParentObject: ").append(String.format("0x%08x", parentObject)).append('\n'); |
|
93 |
+ b.append("AssociationType: ").append(associationType).append('\n'); |
|
94 |
+ b.append("AssociatonDesc: ").append(associationDesc).append('\n'); |
|
95 |
+ b.append("Filename: ").append(filename).append('\n'); |
|
96 |
+ b.append("CaptureDate: ").append(captureDate).append('\n'); |
|
97 |
+ b.append("ModificationDate: ").append(modificationDate).append('\n'); |
|
98 |
+ b.append("Keywords: ").append(keywords).append('\n'); |
|
99 |
+ return b.toString(); |
|
100 |
+ } |
|
101 |
+} |
@@ -0,0 +1,47 @@ |
||
1 |
+/** |
|
2 |
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech |
|
3 |
+ * |
|
4 |
+ * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
+ * you may not use this file except in compliance with the License. |
|
6 |
+ * You may obtain a copy of the License at |
|
7 |
+ * |
|
8 |
+ * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
+ * |
|
10 |
+ * Unless required by applicable law or agreed to in writing, software |
|
11 |
+ * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
+ * See the License for the specific language governing permissions and |
|
14 |
+ * limitations under the License. |
|
15 |
+ */ |
|
16 |
+package com.remoteyourcam.usb.ptp.model; |
|
17 |
+ |
|
18 |
+import java.nio.ByteBuffer; |
|
19 |
+ |
|
20 |
+import com.remoteyourcam.usb.ptp.PacketUtil; |
|
21 |
+ |
|
22 |
+public class StorageInfo { |
|
23 |
+ |
|
24 |
+ public int storageType; |
|
25 |
+ public int filesystemType; |
|
26 |
+ public int accessCapability; |
|
27 |
+ public long maxCapacity; |
|
28 |
+ public long freeSpaceInBytes; |
|
29 |
+ public int freeSpaceInImages; |
|
30 |
+ public String storageDescription; |
|
31 |
+ public String volumeLabel; |
|
32 |
+ |
|
33 |
+ public StorageInfo(ByteBuffer b, int length) { |
|
34 |
+ decode(b, length); |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ private void decode(ByteBuffer b, int length) { |
|
38 |
+ storageType = b.getShort() & 0xffff; |
|
39 |
+ filesystemType = b.getShort() & 0xffff; |
|
40 |
+ accessCapability = b.getShort() & 0xff; |
|
41 |
+ maxCapacity = b.getLong(); |
|
42 |
+ freeSpaceInBytes = b.getLong(); |
|
43 |
+ freeSpaceInImages = b.getInt(); |
|
44 |
+ storageDescription = PacketUtil.readString(b); |
|
45 |
+ volumeLabel = PacketUtil.readString(b); |
|
46 |
+ } |
|
47 |
+} |
@@ -0,0 +1,3 @@ |
||
1 |
+<resources> |
|
2 |
+ <string name="app_name">ryc</string> |
|
3 |
+</resources> |
@@ -1 +1 @@ |
||
1 |
-include ':app', ':common', ':views' |
|
1 |
+include ':app', ':common', ':views', ':ryc' |