OSDN Git Service

すこし余裕を持たせる。
authorMRSa <mrsa@myad.jp>
Tue, 3 Nov 2020 04:10:28 +0000 (13:10 +0900)
committerMRSa <mrsa@myad.jp>
Tue, 3 Nov 2020 04:10:28 +0000 (13:10 +0900)
app/build.gradle
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonCaptureControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/command/messages/specific/NikonLiveViewRequestMessage.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/PtpIpCommandPublisher.kt

index 15e82f5..e36a883 100644 (file)
@@ -21,10 +21,10 @@ android {
 dependencies {
     api fileTree(dir: 'libs', include: ['*.jar'])
     implementation 'androidx.appcompat:appcompat:1.2.0'
-    implementation 'androidx.exifinterface:exifinterface:1.3.0'
+    implementation 'androidx.exifinterface:exifinterface:1.3.1'
     implementation 'androidx.preference:preference-ktx:1.1.1'
     implementation 'com.google.android.material:material:1.2.1'
-    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
+    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
     implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
 
     api files('libs/olycamerakit.jar')
index 4ce51fd..f239c10 100644 (file)
@@ -37,9 +37,9 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
             Log.v(TAG, " doCapture() ");
 
             // シャッターを切る
-            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, REQUEST_SHUTTER_ON, 50, 300, false, isDumpLog, 0, 0x9207, 8, 0xffffffff, 0x00, 0, 0));
-            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_DEVICE_READY, 50, 300, false, isDumpLog, 0, 0x90c8, 0, 0, 0, 0, 0));
-            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_GET_EVENT, 50, 300, false, isDumpLog, 0, 0x90c7, 0, 0, 0, 0, 0));
+            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, REQUEST_SHUTTER_ON, 30, 200, false, isDumpLog, 0, 0x9207, 8, 0xffffffff, 0x00, 0, 0));
+            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_DEVICE_READY, 30, 200, false, isDumpLog, 0, 0x90c8, 0, 0, 0, 0, 0));
+            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_GET_EVENT, 30, 200, false, isDumpLog, 0, 0x90c7, 0, 0, 0, 0, 0));
         }
         catch (Exception e)
         {
index 440b670..f682a44 100644 (file)
@@ -117,7 +117,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
         try
         {
             Log.v(TAG, " Unlock AF ");
-            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_UNLOCK, 30, 100, false, isDumpLog, 0, 0x9206, 0, 0, 0, 0, 0));
+            commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_UNLOCK, 30, 200, false, isDumpLog, 0, 0x9206, 0, 0, 0, 0, 0));
         }
         catch (Exception e)
         {
@@ -129,7 +129,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
     public void halfPressShutter(boolean isPressed)
     {
         //unlockAutoFocus();
-        commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 250, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
+        commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 200, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
         //lockAutoFocus(new PointF(0.5f, 0.5f));
     }
 
@@ -141,9 +141,9 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
             int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1));
             Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
             if (!not_support_focus_lock) {
-                commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_LOCK, 30, 250, false, isDumpLog, 0, 0x9205, 8, x, y, 0, 0));
+                commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_LOCK, 30, 200, false, isDumpLog, 0, 0x9205, 8, x, y, 0, 0));
             } else {
-                commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 250, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
+                commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 200, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
             }
         }
         catch (Exception e)
index ec52de6..f283a66 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, 30);
+        liveViewControl = new NikonLiveViewControl(context, this, 50, 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 084ff73..d927f34 100644 (file)
@@ -13,7 +13,7 @@ import net.osdn.gokigen.a01d.liveview.liveviewlistener.IImageDataReceiver
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener
 import java.util.*
 
-class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProvider: IPtpIpInterfaceProvider, private val delayMs: Int) : ILiveViewControl, ILiveViewListener, IPtpIpCommunication, IPtpIpLiveViewImageCallback, IPtpIpCommandCallback
+class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProvider: IPtpIpInterfaceProvider, private val delayMs: Int, private val delayScale: Int) : ILiveViewControl, ILiveViewListener, IPtpIpCommunication, IPtpIpLiveViewImageCallback, IPtpIpCommandCallback
 {
     private val isDumpLog = false
     private val commandIssuer = interfaceProvider.commandPublisher
@@ -121,11 +121,12 @@ class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProv
 
     private fun sendNextMessage()
     {
+        Log.v(TAG, "sendNextMessage(), sleep : ${delayMs.toLong() * delayScale} ms ")
         try
         {
             //Thread.sleep(delayMs.toLong())
             //commandIssuer.enqueueCommand(NikonStatusRequestMessage(statusReceiver, delayMs, isDumpLog))
-            Thread.sleep(delayMs.toLong())
+            Thread.sleep(delayMs.toLong() * delayScale)
             commandIssuer.enqueueCommand(NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog))
         }
         catch (e: Exception)
@@ -196,6 +197,7 @@ class NikonLiveViewControl(private val context: AppCompatActivity, interfaceProv
             }
 
             Log.v(TAG, String.format(" NikonLiveViewControl: ----- OK REPLY (ID : %d) ----- ", id))
+            waitSleep()
 
             when (id)
             {
index 31942a8..fcf6d8e 100644 (file)
@@ -45,7 +45,7 @@ class PtpIpCommandPublisher(private val ipAddress : String, private val portNumb
             socket?.tcpNoDelay = tcpNoDelay
             if (tcpNoDelay)
             {
-                socket?.tcpNoDelay = true
+                //socket?.tcpNoDelay = true
                 //socket?.keepAlive = false
                 socket?.keepAlive = false
                 //socket?.setPerformancePreferences(0, 1, 2)
@@ -56,11 +56,11 @@ class PtpIpCommandPublisher(private val ipAddress : String, private val portNumb
                 socket?.oobInline = true
                 //socket?.reuseAddress = false
                 socket?.trafficClass = 0x80 // 0x80
-                //socket?.soTimeout = 800
                 socket?.soTimeout = 0
+                //socket?.soTimeout = 0
                 //socket?.receiveBufferSize = 8192  // 10240 // 16384 // 6144// 8192 // 49152 // 65536 // 32768
-                //socket?.sendBufferSize = 8192 // 4096 // 2048 // 10248
-                socket?.setSoLinger(true, 3000);
+                //socket?.sendBufferSize = 1024 // 8192 // 4096 // 2048 // 10240
+                socket?.setSoLinger(true, 500);
                 //socket?.setReceiveBufferSize(2097152);
                 //socket?.setSendBufferSize(524288);
 
@@ -198,7 +198,7 @@ class PtpIpCommandPublisher(private val ipAddress : String, private val portNumb
                 isHold = true
                 holdId = command.holdId
             }
-            //Log.v(TAG, "Enqueue : "  + command.getId());
+            Log.v(TAG, "Enqueue [ID: " + command.getId() + "] size: " + commandQueue.size);
             return (commandQueue.offer(command))
         }
         catch (e: Exception)
@@ -713,6 +713,6 @@ class PtpIpCommandPublisher(private val ipAddress : String, private val portNumb
         private const val BUFFER_SIZE = 1024 * 1024 + 16 // 受信バッファは 1MB
         private const val COMMAND_SEND_RECEIVE_DURATION_MS = 5
         private const val COMMAND_SEND_RECEIVE_DURATION_MAX = 3000
-        private const val COMMAND_POLL_QUEUE_MS = 5
+        private const val COMMAND_POLL_QUEUE_MS = 5 // 5
     }
 }