OSDN Git Service

このへんで...。
authorMRSa <mrsa@myad.jp>
Tue, 3 Nov 2020 05:06:35 +0000 (14:06 +0900)
committerMRSa <mrsa@myad.jp>
Tue, 3 Nov 2020 05:06:35 +0000 (14:06 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.kt
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpCommandPublisher.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.kt
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisherLegacy.java

index f283a66..d9249db 100644 (file)
@@ -65,7 +65,7 @@ public class NikonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
     {
         this.activity = context;
         commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, true, false);
-        liveViewControl = new NikonLiveViewControl(context, this, 50, 1);
+        liveViewControl = new NikonLiveViewControl(context, this, 35, 1);
         asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
         statusChecker = new NikonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
         nikonConnection = new NikonConnection(context, provider, this, statusChecker);
index d927f34..2d3247d 100644 (file)
@@ -4,9 +4,11 @@ import android.util.Log
 import androidx.appcompat.app.AppCompatActivity
 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.nikon.wrapper.command.messages.specific.NikonStatusRequestMessage
 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider
-import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.*
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpResponseReceiver
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.IImageDataReceiver
@@ -127,7 +129,10 @@ class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProv
             //Thread.sleep(delayMs.toLong())
             //commandIssuer.enqueueCommand(NikonStatusRequestMessage(statusReceiver, delayMs, isDumpLog))
             Thread.sleep(delayMs.toLong() * delayScale)
-            commandIssuer.enqueueCommand(NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog))
+            if (commandIssuer.isExistCommandMessageQueue(IPtpIpMessages.SEQ_GET_VIEWFRAME) < 2)
+            {
+                commandIssuer.enqueueCommand(NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog))
+            }
         }
         catch (e: Exception)
         {
@@ -198,7 +203,6 @@ class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProv
 
             Log.v(TAG, String.format(" NikonLiveViewControl: ----- OK REPLY (ID : %d) ----- ", id))
             waitSleep()
-
             when (id)
             {
                 IPtpIpMessages.SEQ_START_LIVEVIEW -> commandIssuer.enqueueCommand(PtpIpCommandGeneric(this, IPtpIpMessages.SEQ_DEVICE_READY, delayMs, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00))
index 21ad693..bcdb127 100644 (file)
@@ -9,6 +9,10 @@ public interface IPtpIpCommandPublisher
 
     boolean flushHoldQueue();
 
+    int isExistCommandMessageQueue(int id);
+
+    int getCurrentQueueSize();
+
     void start();
     void stop();
 }
index fcf6d8e..7cbe43a 100644 (file)
@@ -208,6 +208,24 @@ class PtpIpCommandPublisher(private val ipAddress : String, private val portNumb
         return (false)
     }
 
+    override fun getCurrentQueueSize(): Int
+    {
+        return commandQueue.size
+    }
+
+    override fun isExistCommandMessageQueue(id: Int): Int
+    {
+        var count = 0
+        for (cmd in commandQueue)
+        {
+            if (cmd.id == id)
+            {
+                count++
+            }
+        }
+       return count
+    }
+
     override fun flushHoldQueue(): Boolean
     {
         Log.v(TAG, "  flushHoldQueue()")
index b2ff547..ca5959e 100644 (file)
@@ -249,6 +249,27 @@ public class PtpIpCommandPublisherLegacy implements IPtpIpCommandPublisher, IPtp
     }
 
     @Override
+    public int getCurrentQueueSize()
+    {
+        return (commandQueue.size());
+    }
+
+
+    @Override
+    public int isExistCommandMessageQueue(int id)
+    {
+        int count = 0;
+        for (IPtpIpCommand cmd : commandQueue)
+        {
+            if (cmd.getId() == id)
+            {
+                count++;
+            }
+        }
+        return (count);
+    }
+
+    @Override
     public boolean flushHoldQueue()
     {
         Log.v(TAG, "  flushHoldQueue()");