• R/O
  • HTTP
  • SSH
  • HTTPS

PKRemote: Commit

Pentax DSLR Remote Control app.


Commit MetaInfo

Revisiond913d79e10c5df3ea017e3c2d6542ea6886988d3 (tree)
Zeit2021-01-03 12:17:18
AutorMRSa <mrsa@myad...>
CommiterMRSa

Log Message

PowerShotZoomでスモール画像が取得できないので、標準画像を取得するような設定を用意。(スモール画像取得シーケンス TYPE2対応)

Ändern Zusammenfassung

Diff

--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/PtpIpInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/PtpIpInterfaceProvider.java
@@ -107,7 +107,7 @@ public class PtpIpInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
107107 liveViewControl = new PtpIpLiveViewControl(context, ipAddress, STREAM_PORT);
108108 asyncReceiver = new PtpIpAsyncResponseReceiver(ipAddress, ASYNC_RESPONSE_PORT);
109109 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);
111111 zoomControl = new PtpIpZoomControl();
112112 this.statusListener = statusListener;
113113 this.runmode = new PtpIpRunMode();
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/connection/CanonConnection.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/connection/CanonConnection.java
@@ -33,16 +33,18 @@ public class CanonConnection implements ICameraConnection
3333 private final BroadcastReceiver connectionReceiver;
3434 private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
3535 private final PtpIpStatusChecker statusChecker;
36+ private final String ipAddress;
3637 private final int sequenceType;
3738 private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN;
3839
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)
4041 {
4142 Log.v(TAG, "CanonConnection()");
4243 this.context = context;
4344 this.statusReceiver = statusReceiver;
4445 this.interfaceProvider = interfaceProvider;
4546 this.statusChecker = statusChecker;
47+ this.ipAddress = ipAddress;
4648 this.sequenceType = sequenceType;
4749 connectionReceiver = new BroadcastReceiver()
4850 {
@@ -60,10 +62,10 @@ public class CanonConnection implements ICameraConnection
6062 */
6163 private void onReceiveBroadcastOfConnection(Context context, Intent intent)
6264 {
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);
6567
66- Log.v(TAG, context.getString(R.string.connect_check_wifi));
68+ Log.v(TAG, context.getString(R.string.connect_check_wifi) + " : " + ipAddress);
6769
6870 String action = intent.getAction();
6971 if (action == null)
@@ -135,7 +137,7 @@ public class CanonConnection implements ICameraConnection
135137 @Override
136138 public void connect()
137139 {
138- Log.v(TAG, "connect()");
140+ Log.v(TAG, "connect() seq : " + sequenceType);
139141 connectToCamera();
140142 }
141143
@@ -222,7 +224,7 @@ public class CanonConnection implements ICameraConnection
222224 */
223225 private void connectToCamera()
224226 {
225- Log.v(TAG, " connectToCamera()");
227+ Log.v(TAG, " connectToCamera() sequence Type : " + sequenceType);
226228 connectionStatus = CameraConnectionStatus.CONNECTING;
227229 try
228230 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonFullImageReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonFullImageReceiver.java
@@ -14,7 +14,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.Pt
1414
1515 import java.io.ByteArrayOutputStream;
1616
17-public class CanonFullImageReceiver implements IPtpIpCommandCallback
17+public class CanonFullImageReceiver implements IPtpIpCommandCallback, ICanonImageReceiver
1818 {
1919 private static final String TAG = CanonFullImageReceiver.class.getSimpleName();
2020
@@ -37,7 +37,8 @@ public class CanonFullImageReceiver implements IPtpIpCommandCallback
3737 this.publisher = publisher;
3838 }
3939
40- void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback)
40+ @Override
41+ public void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback)
4142 {
4243 if (this.objectId != 0)
4344 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageContentInfo.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageContentInfo.java
@@ -25,17 +25,20 @@ public class CanonImageContentInfo implements ICameraContent
2525 try
2626 {
2727 // 撮影日時を解析
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+ }
3942 }
4043 catch (Exception e)
4144 {
@@ -69,8 +72,12 @@ public class CanonImageContentInfo implements ICameraContent
6972 {
7073 try
7174 {
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+ }
7481 }
7582 catch (Exception e)
7683 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonSmallImageReceiver.kt
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageReceiver.kt
@@ -14,7 +14,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.sp
1414 import java.io.ByteArrayOutputStream
1515 import java.util.*
1616
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
1818 {
1919 private val mine = this
2020 private val isDumpLog = false
@@ -26,9 +26,9 @@ class CanonSmallImageReceiver(private val activity: Activity, private val publis
2626 private var receivedTotalBytes = 0
2727 private var receivedRemainBytes = 0
2828
29- override fun issueCommand(objectId: Int, callback: IDownloadContentCallback?)
29+ override fun issueCommand(objectId: Int, imageSize: Int, callback: IDownloadContentCallback?)
3030 {
31- Log.v(TAG, " issueCommand() : $objectId")
31+ Log.v(TAG, " issueCommand() : $objectId (size:$imageSize)")
3232 if (this.objectId != 0)
3333 {
3434 // already issued
@@ -233,6 +233,6 @@ class CanonSmallImageReceiver(private val activity: Activity, private val publis
233233
234234 companion object
235235 {
236- private val TAG = CanonSmallImageReceiver::class.java.simpleName
236+ private val TAG = CanonImageReceiver::class.java.simpleName
237237 }
238238 }
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonSmallImageReceiverPrev.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageReceiverPrev.java
@@ -18,9 +18,9 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.sp
1818 import java.io.ByteArrayOutputStream;
1919
2020
21-public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICanonSmallImageReceiver
21+public class CanonImageReceiverPrev implements IPtpIpCommandCallback, ICanonImageReceiver
2222 {
23- private static final String TAG = CanonSmallImageReceiver.class.getSimpleName();
23+ private static final String TAG = CanonImageReceiver.class.getSimpleName();
2424
2525 private final Activity activity;
2626 private final IPtpIpCommandPublisher publisher;
@@ -33,7 +33,7 @@ public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICano
3333 private int received_total_bytes = 0;
3434 private int received_remain_bytes = 0;
3535
36- public CanonSmallImageReceiverPrev(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
36+ public CanonImageReceiverPrev(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
3737 {
3838 this.activity = activity;
3939 this.publisher = publisher;
@@ -41,7 +41,7 @@ public class CanonSmallImageReceiverPrev implements IPtpIpCommandCallback, ICano
4141 }
4242
4343 @Override
44- public void issueCommand(final int objectId, IDownloadContentCallback callback)
44+ public void issueCommand(final int objectId, int imageSize, IDownloadContentCallback callback)
4545 {
4646 if (this.objectId != 0)
4747 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonPlaybackControl.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonPlaybackControl.java
@@ -32,7 +32,7 @@ public class CanonPlaybackControl implements IPlaybackControl
3232 private final Activity activity;
3333 private final PtpIpInterfaceProvider provider;
3434 private final CanonFullImageReceiver fullImageReceiver;
35- private final ICanonSmallImageReceiver smallImageReciever;
35+ private final ICanonImageReceiver smallImageReciever;
3636 private String raw_suffix = "CR2";
3737 private boolean useScreennailImage = false;
3838 private final CanonImageObjectReceiver canonImageObjectReceiver;
@@ -76,11 +76,15 @@ public class CanonPlaybackControl implements IPlaybackControl
7676 this.fullImageReceiver = new CanonFullImageReceiver(activity, provider.getCommandPublisher());
7777 if (smallImageSequence == 2)
7878 {
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);
8084 }
8185 else
8286 {
83- this.smallImageReciever = new CanonSmallImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence);
87+ this.smallImageReciever = new CanonImageReceiver(activity, provider.getCommandPublisher(), smallImageSequence);
8488 }
8589 canonImageObjectReceiver = new CanonImageObjectReceiver(provider, delayMs);
8690 }
@@ -206,7 +210,7 @@ public class CanonPlaybackControl implements IPlaybackControl
206210 if (isSmallSize)
207211 {
208212 // スモールサイズの画像取得コマンド(シーケンス)を発行する
209- smallImageReciever.issueCommand(content.getId(), callback);
213+ smallImageReciever.issueCommand(content.getId(), content.getOriginalSize(), callback);
210214 }
211215 else
212216 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonReducedImageReceiver.kt
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonReducedImageReceiver.kt
@@ -10,11 +10,10 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpComma
1010 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandCanonGetPartialObject
1111 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric
1212 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
1413 import java.io.ByteArrayOutputStream
1514 import java.util.*
1615
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
1817 {
1918 private val mine = this
2019
@@ -27,9 +26,9 @@ class CanonReducedImageReceiver(private val activity: Activity, private val publ
2726 private var receivedRemainBytes = 0
2827
2928
30- override fun issueCommand(objectId: Int, callback: IDownloadContentCallback?)
29+ override fun issueCommand(objectId: Int, imageSize: Int, callback: IDownloadContentCallback?)
3130 {
32- Log.v(TAG, " issueCommand() : ${objectId}")
31+ Log.v(TAG, " issueCommand() : $objectId (size: $imageSize)")
3332 if (this.objectId != 0)
3433 {
3534 // already issued
@@ -172,13 +171,9 @@ class CanonReducedImageReceiver(private val activity: Activity, private val publ
172171 if (bodySize <= 12)
173172 {
174173 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)));
177174 break
178175 }
179176
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)));
182177 if (dataPosition + bodySize > length)
183178 {
184179 // データがすべてバッファ内になかったときは、バッファすべてコピーして残ったサイズを記憶しておく。
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/ICanonSmallImageReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/ICanonImageReceiver.java
@@ -2,7 +2,7 @@ package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.playback;
22
33 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback;
44
5-public interface ICanonSmallImageReceiver
5+public interface ICanonImageReceiver
66 {
7- void issueCommand(final int objectId, IDownloadContentCallback callback);
7+ void issueCommand(final int objectId, int imageSize, IDownloadContentCallback callback);
88 }
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -120,12 +120,14 @@
120120 <item>TYPE0</item>
121121 <item>TYPE1</item>
122122 <item>TYPE2</item>
123+ <item>TYPE3</item>
123124 </string-array>
124125
125126 <string-array name="canon_small_picture_type_value">
126127 <item>0</item>
127128 <item>1</item>
128129 <item>2</item>
130+ <item>3</item>
129131 </string-array>
130132
131133 </resources>
Show on old repository browser