OSDN Git Service

LiveViewを動かすところ。
authorMRSa <mrsa@myad.jp>
Thu, 27 Feb 2020 15:12:17 +0000 (00:12 +0900)
committerMRSa <mrsa@myad.jp>
Thu, 27 Feb 2020 15:12:17 +0000 (00:12 +0900)
AS3.6対応。

app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
build.gradle
gradle.properties
gradle/wrapper/gradle-wrapper.properties

index 2169542..43198be 100644 (file)
@@ -34,7 +34,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
     private float maxPointLimitWidth;
     private float maxPointLimitHeight;
     private RectF preFocusFrameRect = null;
-    private boolean isDumpLog = false;
+    private boolean isDumpLog = true;
 
     public NikonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
     {
@@ -194,11 +194,17 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
     {
         try
         {
-
-
-            if ((rx_body.length > 10)&&((rx_body[8] != (byte) 0x01)||(rx_body[9] != (byte) 0x20)))
+            if (rx_body.length < 10)
+            {
+                Log.v(TAG, " --- BODY LENGTH IS SHORT : FOCUS OPERATION ---");
+                hideFocusFrame();
+                preFocusFrameRect = null;
+                return;
+            }
+            int responseCode = (rx_body[8] & 0xff) + ((rx_body[9] & 0xff) * 256);
+            if (responseCode != 0x2001)
             {
-                Log.v(TAG, " --- RECEIVED NG REPLY. : FOCUS OPERATION ---");
+                Log.v(TAG, String.format(" --- RECEIVED NG REPLY. : FOCUS OPERATION (0x%x) ---", responseCode));
                 hideFocusFrame();
                 preFocusFrameRect = null;
                 return;
index 59119c6..4186ee2 100644 (file)
@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
 import net.osdn.gokigen.a01d.camera.nikon.wrapper.command.messages.specific.NikonLiveViewRequestMessage;
 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpResponseReceiver;
@@ -25,7 +26,7 @@ import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.
 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_START_LIVEVIEW;
 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_STOP_LIVEVIEW;
 
-public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListener, IPtpIpCommunication, IPtpIpLiveViewImageCallback, IPtpIpResponseReceiver
+public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListener, IPtpIpCommunication, IPtpIpLiveViewImageCallback, IPtpIpCommandCallback
 {
     private final String TAG = this.toString();
     private final IPtpIpCommandPublisher commandIssuer;
@@ -60,9 +61,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
         Log.v(TAG, " startLiveView() ");
         try
         {
-            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_START_LIVEVIEW, 20, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
-            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_DEVICE_READY, 20, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
-            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(this), SEQ_AFDRIVE, 20, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
+            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 20, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
         }
         catch (Exception e)
         {
@@ -208,16 +207,78 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
     }
 
     @Override
-    public void response(int id, int responseCode)
+    public void receivedMessage(int id, byte[] rx_body)
     {
-        // 応答OKなら LV開始。
-        if ((id == SEQ_AFDRIVE)&&(responseCode == 0x2001))
+        Log.v(TAG, " NikonLiveViewControl::receivedMessage() : ");
+        try
+        {
+            if (rx_body.length < 10)
+            {
+                retrySendMessage(id);
+                return;
+            }
+            int responseCode = (rx_body[8] & 0xff) + ((rx_body[9] & 0xff) * 256);
+            if (responseCode != 0x2001)
+            {
+                // NG応答を受信...同じコマンドを再送する
+                Log.v(TAG, String.format(" RECEIVED NG REPLY ID : %d, RESPONSE CODE : 0x%04x ", id, responseCode));
+                retrySendMessage(id);
+                return;
+            }
+
+            Log.v(TAG, String.format(" OK REPLY (ID : %d) ", id));
+            if (id == SEQ_START_LIVEVIEW)
+            {
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 20, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
+            }
+            else if (id == SEQ_DEVICE_READY)
+            {
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 20, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
+            }
+            else
+            {
+                // ライブビューの開始。
+                startLiveviewImpl();
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private void retrySendMessage(int id)
+    {
+        try
         {
-            startLiveviewImpl();
+            if (id == SEQ_START_LIVEVIEW)
+            {
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 20, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
+            }
+            else if (id == SEQ_DEVICE_READY)
+            {
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 20, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
+            }
+            else
+            {
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 20, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
+            }
         }
-        else
+        catch (Exception e)
         {
-            Log.v(TAG, String.format(" ===== NikonLiveViewControl::response() ID : %d, RESPONSE CODE : 0x%04x ", id, responseCode));
+            e.printStackTrace();
         }
     }
+
+    @Override
+    public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
+    {
+        //
+    }
+
+    @Override
+    public boolean isReceiveMulti()
+    {
+        return (false);
+    }
 }
index 5b3bdaa..265988f 100644 (file)
@@ -6,7 +6,7 @@ buildscript {
         google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.5.3'
+        classpath 'com.android.tools.build:gradle:3.6.0'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
index aac7c9b..7dac9b8 100644 (file)
@@ -15,3 +15,6 @@ org.gradle.jvmargs=-Xmx1536m
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
+
+android.enableJetifier=true
+android.useAndroidX=true
index 3a480cf..4df5b6f 100644 (file)
@@ -1,6 +1,6 @@
-#Sat Sep 07 00:01:41 JST 2019
+#Wed Feb 26 00:13:03 JST 2020
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip