Pentax DSLR Remote Control app.
Revision | d913d79e10c5df3ea017e3c2d6542ea6886988d3 (tree) |
---|---|
Zeit | 2021-01-03 12:17:18 |
Autor | MRSa <mrsa@myad...> |
Commiter | MRSa |
PowerShotZoomでスモール画像が取得できないので、標準画像を取得するような設定を用意。(スモール画像取得シーケンス TYPE2対応)
@@ -107,7 +107,7 @@ public class PtpIpInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay | ||
107 | 107 | liveViewControl = new PtpIpLiveViewControl(context, ipAddress, STREAM_PORT); |
108 | 108 | asyncReceiver = new PtpIpAsyncResponseReceiver(ipAddress, ASYNC_RESPONSE_PORT); |
109 | 109 | statusChecker = new PtpIpStatusChecker(context, commandPublisher, ipAddress, EVENT_PORT); |
110 | - canonConnection = new CanonConnection(context, provider, this, statusChecker, sequenceType); | |
110 | + canonConnection = new CanonConnection(context, provider, this, statusChecker, ipAddress, sequenceType); | |
111 | 111 | zoomControl = new PtpIpZoomControl(); |
112 | 112 | this.statusListener = statusListener; |
113 | 113 | this.runmode = new PtpIpRunMode(); |
@@ -33,16 +33,18 @@ public class CanonConnection implements ICameraConnection | ||
33 | 33 | private final BroadcastReceiver connectionReceiver; |
34 | 34 | private final Executor cameraExecutor = Executors.newFixedThreadPool(1); |
35 | 35 | private final PtpIpStatusChecker statusChecker; |
36 | + private final String ipAddress; | |
36 | 37 | private final int sequenceType; |
37 | 38 | private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN; |
38 | 39 | |
39 | - public CanonConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull PtpIpStatusChecker statusChecker, int sequenceType) | |
40 | + public CanonConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull PtpIpStatusChecker statusChecker, @NonNull String ipAddress, int sequenceType) | |
40 | 41 | { |
41 | 42 | Log.v(TAG, "CanonConnection()"); |
42 | 43 | this.context = context; |
43 | 44 | this.statusReceiver = statusReceiver; |
44 | 45 | this.interfaceProvider = interfaceProvider; |
45 | 46 | this.statusChecker = statusChecker; |
47 | + this.ipAddress = ipAddress; | |
46 | 48 | this.sequenceType = sequenceType; |
47 | 49 | connectionReceiver = new BroadcastReceiver() |
48 | 50 | { |
@@ -60,10 +62,10 @@ public class CanonConnection implements ICameraConnection | ||
60 | 62 | */ |
61 | 63 | private void onReceiveBroadcastOfConnection(Context context, Intent intent) |
62 | 64 | { |
63 | - interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_check_wifi), false, false, 0); | |
64 | - statusReceiver.onStatusNotify(context.getString(R.string.connect_check_wifi)); | |
65 | + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_check_wifi) + " : " + ipAddress, false, false, 0); | |
66 | + statusReceiver.onStatusNotify(context.getString(R.string.connect_check_wifi) + " " + ipAddress); | |
65 | 67 | |
66 | - Log.v(TAG, context.getString(R.string.connect_check_wifi)); | |
68 | + Log.v(TAG, context.getString(R.string.connect_check_wifi) + " : " + ipAddress); | |
67 | 69 | |
68 | 70 | String action = intent.getAction(); |
69 | 71 | if (action == null) |
@@ -135,7 +137,7 @@ public class CanonConnection implements ICameraConnection | ||
135 | 137 | @Override |
136 | 138 | public void connect() |
137 | 139 | { |
138 | - Log.v(TAG, "connect()"); | |
140 | + Log.v(TAG, "connect() seq : " + sequenceType); | |
139 | 141 | connectToCamera(); |
140 | 142 | } |
141 | 143 |
@@ -222,7 +224,7 @@ public class CanonConnection implements ICameraConnection | ||
222 | 224 | */ |
223 | 225 | private void connectToCamera() |
224 | 226 | { |
225 | - Log.v(TAG, " connectToCamera()"); | |
227 | + Log.v(TAG, " connectToCamera() sequence Type : " + sequenceType); | |
226 | 228 | connectionStatus = CameraConnectionStatus.CONNECTING; |
227 | 229 | try |
228 | 230 | { |
@@ -14,7 +14,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.Pt | ||
14 | 14 | |
15 | 15 | import java.io.ByteArrayOutputStream; |
16 | 16 | |
17 | -public class CanonFullImageReceiver implements IPtpIpCommandCallback | |
17 | +public class CanonFullImageReceiver implements IPtpIpCommandCallback, ICanonImageReceiver | |
18 | 18 | { |
19 | 19 | private static final String TAG = CanonFullImageReceiver.class.getSimpleName(); |
20 | 20 |
@@ -37,7 +37,8 @@ public class CanonFullImageReceiver implements IPtpIpCommandCallback | ||
37 | 37 | this.publisher = publisher; |
38 | 38 | } |
39 | 39 | |
40 | - void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback) | |
40 | + @Override | |
41 | + public void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback) | |
41 | 42 | { |
42 | 43 | if (this.objectId != 0) |
43 | 44 | { |
@@ -25,17 +25,20 @@ public class CanonImageContentInfo implements ICameraContent | ||
25 | 25 | try |
26 | 26 | { |
27 | 27 | // 撮影日時を解析 |
28 | - long objectDate = (rx_body[0x30] & 0xff) + ((rx_body[0x31] & 0xff) << 8); | |
29 | - objectDate = objectDate + ((rx_body[0x32] & 0xff) << 16) + ((rx_body[0x33] & 0xff) << 24); | |
30 | - | |
31 | - // UTC から 端末のタイムゾーンに変換する(オフセット時間をとる) | |
32 | - TimeZone tz = TimeZone.getDefault(); | |
33 | - Date now = new Date(); | |
34 | - long offsetFromUtc = tz.getOffset(now.getTime()); | |
35 | - | |
36 | - date = new Date(objectDate * 1000 - offsetFromUtc); | |
37 | - isDateValid = true; | |
38 | - return; | |
28 | + if (rx_body.length >= 0x33) | |
29 | + { | |
30 | + long objectDate = (rx_body[0x30] & 0xff) + ((rx_body[0x31] & 0xff) << 8); | |
31 | + objectDate = objectDate + ((rx_body[0x32] & 0xff) << 16) + ((rx_body[0x33] & 0xff) << 24); | |
32 | + | |
33 | + // UTC から 端末のタイムゾーンに変換する(オフセット時間をとる) | |
34 | + TimeZone tz = TimeZone.getDefault(); | |
35 | + Date now = new Date(); | |
36 | + long offsetFromUtc = tz.getOffset(now.getTime()); | |
37 | + | |
38 | + date = new Date(objectDate * 1000 - offsetFromUtc); | |
39 | + isDateValid = true; | |
40 | + return; | |
41 | + } | |
39 | 42 | } |
40 | 43 | catch (Exception e) |
41 | 44 | { |
@@ -69,8 +72,12 @@ public class CanonImageContentInfo implements ICameraContent | ||
69 | 72 | { |
70 | 73 | try |
71 | 74 | { |
72 | - byte[] fileNameArray = Arrays.copyOfRange(rx_body, 0x20, 0x20 + 8 + 1 + 3); | |
73 | - return (new String(fileNameArray)); | |
75 | + if (rx_body.length > 0x20) | |
76 | + { | |
77 | + int copySize = (rx_body.length < (0x20 + 8 + 3)) ? rx_body.length : (0x20 + 8 + 1 + 3); | |
78 | + byte[] fileNameArray = Arrays.copyOfRange(rx_body, 0x20, copySize); | |
79 | + return (new String(fileNameArray)); | |
80 | + } | |
74 | 81 | } |
75 | 82 | catch (Exception e) |
76 | 83 | { |
@@ -14,7 +14,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.sp | ||
14 | 14 | import java.io.ByteArrayOutputStream |
15 | 15 | import java.util.* |
16 | 16 | |
17 | -class CanonSmallImageReceiver(private val activity: Activity, private val publisher: IPtpIpCommandPublisher, private val sequenceType : Int) : IPtpIpCommandCallback, ICanonSmallImageReceiver | |
17 | +class CanonImageReceiver(private val activity: Activity, private val publisher: IPtpIpCommandPublisher, private val sequenceType : Int) : IPtpIpCommandCallback, ICanonImageReceiver | |
18 | 18 | { |
19 | 19 | private val mine = this |
20 | 20 | private val isDumpLog = false |
@@ -26,9 +26,9 @@ class CanonSmallImageReceiver(private val activity: Activity, private val publis | ||
26 | 26 | private var receivedTotalBytes = 0 |
27 | 27 | private var receivedRemainBytes = 0 |
28 | 28 | |
29 | - override fun issueCommand(objectId: Int, callback: IDownloadContentCallback?) | |
29 | + override fun issueCommand(objectId: Int, imageSize: Int, callback: IDownloadContentCallback?) | |
30 | 30 | { |
31 | - Log.v(TAG, " issueCommand() : $objectId") | |
31 | + Log.v(TAG, " issueCommand() : $objectId (size:$imageSize)") | |
32 | 32 | if (this.objectId != 0) |
33 | 33 | { |
34 | 34 | // already issued |
@@ -233,6 +233,6 @@ class CanonSmallImageReceiver(private val activity: Activity, private val publis | ||
233 | 233 | |
234 | 234 | companion object |
235 | 235 | { |
236 | - private val TAG = CanonSmallImageReceiver::class.java.simpleName | |
236 | + private val TAG = CanonImageReceiver::class.java.simpleName | |
237 | 237 | } |
238 | 238 | } |
@@ -18,9 +18,9 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.sp | ||
18 | 18 | import java.io.ByteArrayOutputStream; |
19 | 19 | |
20 | 20 | |
21 | -public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICanonSmallImageReceiver | |
21 | +public class CanonImageReceiverPrev implements IPtpIpCommandCallback, ICanonImageReceiver | |
22 | 22 | { |
23 | - private static final String TAG = CanonSmallImageReceiver.class.getSimpleName(); | |
23 | + private static final String TAG = CanonImageReceiver.class.getSimpleName(); | |
24 | 24 | |
25 | 25 | private final Activity activity; |
26 | 26 | private final IPtpIpCommandPublisher publisher; |
@@ -33,7 +33,7 @@ public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICano | ||
33 | 33 | private int received_total_bytes = 0; |
34 | 34 | private int received_remain_bytes = 0; |
35 | 35 | |
36 | - public CanonSmallImageReceiverPrev(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher) | |
36 | + public CanonImageReceiverPrev(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher) | |
37 | 37 | { |
38 | 38 | this.activity = activity; |
39 | 39 | this.publisher = publisher; |
@@ -41,7 +41,7 @@ public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICano | ||
41 | 41 | } |
42 | 42 | |
43 | 43 | @Override |
44 | - public void issueCommand(final int objectId, IDownloadContentCallback callback) | |
44 | + public void issueCommand(final int objectId, int imageSize, IDownloadContentCallback callback) | |
45 | 45 | { |
46 | 46 | if (this.objectId != 0) |
47 | 47 | { |
@@ -32,7 +32,7 @@ public class CanonPlaybackControl implements IPlaybackControl | ||
32 | 32 | private final Activity activity; |
33 | 33 | private final PtpIpInterfaceProvider provider; |
34 | 34 | private final CanonFullImageReceiver fullImageReceiver; |
35 | - private final ICanonSmallImageReceiver smallImageReciever; | |
35 | + private final ICanonImageReceiver smallImageReciever; | |
36 | 36 | private String raw_suffix = "CR2"; |
37 | 37 | private boolean useScreennailImage = false; |
38 | 38 | private final CanonImageObjectReceiver canonImageObjectReceiver; |
@@ -76,11 +76,15 @@ public class CanonPlaybackControl implements IPlaybackControl | ||
76 | 76 | this.fullImageReceiver = new CanonFullImageReceiver(activity, provider.getCommandPublisher()); |
77 | 77 | if (smallImageSequence == 2) |
78 | 78 | { |
79 | - this.smallImageReciever = new CanonReducedImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence); | |
79 | + this.smallImageReciever = new CanonFullImageReceiver(activity, provider.getCommandPublisher()); | |
80 | + } | |
81 | + else if (smallImageSequence == 3) | |
82 | + { | |
83 | + this.smallImageReciever = new CanonImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence); | |
80 | 84 | } |
81 | 85 | else |
82 | 86 | { |
83 | - this.smallImageReciever = new CanonSmallImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence); | |
87 | + this.smallImageReciever = new CanonImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence); | |
84 | 88 | } |
85 | 89 | canonImageObjectReceiver = new CanonImageObjectReceiver(provider, delayMs); |
86 | 90 | } |
@@ -206,7 +210,7 @@ public class CanonPlaybackControl implements IPlaybackControl | ||
206 | 210 | if (isSmallSize) |
207 | 211 | { |
208 | 212 | // スモールサイズの画像取得コマンド(シーケンス)を発行する |
209 | - smallImageReciever.issueCommand(content.getId(), callback); | |
213 | + smallImageReciever.issueCommand(content.getId(), content.getOriginalSize(), callback); | |
210 | 214 | } |
211 | 215 | else |
212 | 216 | { |
@@ -10,11 +10,10 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpComma | ||
10 | 10 | import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandCanonGetPartialObject |
11 | 11 | import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric |
12 | 12 | import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRequestInnerDevelopEnd |
13 | -import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRequestInnerDevelopStart | |
14 | 13 | import java.io.ByteArrayOutputStream |
15 | 14 | import java.util.* |
16 | 15 | |
17 | -class CanonReducedImageReceiver(private val activity: Activity, private val publisher: IPtpIpCommandPublisher, private val sequenceType : Int) : IPtpIpCommandCallback, ICanonSmallImageReceiver | |
16 | +class CanonReducedImageReceiver(private val activity: Activity, private val publisher: IPtpIpCommandPublisher, private val sequenceType : Int) : IPtpIpCommandCallback, ICanonImageReceiver | |
18 | 17 | { |
19 | 18 | private val mine = this |
20 | 19 |
@@ -27,9 +26,9 @@ class CanonReducedImageReceiver(private val activity: Activity, private val publ | ||
27 | 26 | private var receivedRemainBytes = 0 |
28 | 27 | |
29 | 28 | |
30 | - override fun issueCommand(objectId: Int, callback: IDownloadContentCallback?) | |
29 | + override fun issueCommand(objectId: Int, imageSize: Int, callback: IDownloadContentCallback?) | |
31 | 30 | { |
32 | - Log.v(TAG, " issueCommand() : ${objectId}") | |
31 | + Log.v(TAG, " issueCommand() : $objectId (size: $imageSize)") | |
33 | 32 | if (this.objectId != 0) |
34 | 33 | { |
35 | 34 | // already issued |
@@ -172,13 +171,9 @@ class CanonReducedImageReceiver(private val activity: Activity, private val publ | ||
172 | 171 | if (bodySize <= 12) |
173 | 172 | { |
174 | 173 | Log.v(TAG, " BODY SIZE IS SMALL : " + dataPosition + " (" + bodySize + ") [" + receivedRemainBytes + "] " + rx_body.size + " ") |
175 | - //int startpos = (data_position > 48) ? (data_position - 48) : 0; | |
176 | - //SimpleLogDumper.dump_bytes("[xxx]", Arrays.copyOfRange(rx_body, startpos, (data_position + 48))); | |
177 | 174 | break |
178 | 175 | } |
179 | 176 | |
180 | - // Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")"); | |
181 | - //SimpleLogDumper.dump_bytes("[yyy] " + data_position + ": ", Arrays.copyOfRange(rx_body, data_position, (data_position + 64))); | |
182 | 177 | if (dataPosition + bodySize > length) |
183 | 178 | { |
184 | 179 | // データがすべてバッファ内になかったときは、バッファすべてコピーして残ったサイズを記憶しておく。 |
@@ -2,7 +2,7 @@ package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.playback; | ||
2 | 2 | |
3 | 3 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback; |
4 | 4 | |
5 | -public interface ICanonSmallImageReceiver | |
5 | +public interface ICanonImageReceiver | |
6 | 6 | { |
7 | - void issueCommand(final int objectId, IDownloadContentCallback callback); | |
7 | + void issueCommand(final int objectId, int imageSize, IDownloadContentCallback callback); | |
8 | 8 | } |
@@ -120,12 +120,14 @@ | ||
120 | 120 | <item>TYPE0</item> |
121 | 121 | <item>TYPE1</item> |
122 | 122 | <item>TYPE2</item> |
123 | + <item>TYPE3</item> | |
123 | 124 | </string-array> |
124 | 125 | |
125 | 126 | <string-array name="canon_small_picture_type_value"> |
126 | 127 | <item>0</item> |
127 | 128 | <item>1</item> |
128 | 129 | <item>2</item> |
130 | + <item>3</item> | |
129 | 131 | </string-array> |
130 | 132 | |
131 | 133 | </resources> |