OSDN Git Service

PanasonicのJPEG区切りを取得する方法が間違っていたので修正する。
authorMRSa <mrsa@myad.jp>
Thu, 14 Oct 2021 14:45:23 +0000 (23:45 +0900)
committerMRSa <mrsa@myad.jp>
Thu, 14 Oct 2021 14:45:23 +0000 (23:45 +0900)
app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/panasonic/liveview/PanasonicLiveViewControl.kt

index 635896e..509455b 100644 (file)
@@ -167,7 +167,8 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
         val dataLength: Int = packet.length
         var searchIndex = 0
         var startPosition = 0
-        val startmarker = intArrayOf(0xff, 0xd8)
+        //val startmarker = intArrayOf(0xff, 0xd8)
+        val startmarker = byteArrayOf(0xff.toByte(), 0xd8.toByte())
         val receivedData: ByteArray = packet.data
         if (receivedData == null)
         {
@@ -175,13 +176,13 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
             Log.v(TAG, "RECEIVED DATA IS NULL...")
             return
         }
-        //Log.v(TAG, "RECEIVED PACKET : " + dataLength);
+        // Log.v(TAG, "RECEIVED PACKET : " + dataLength);
         while (startPosition < dataLength)
         {
             // 先頭のjpegマーカーが出てくるまで読み飛ばす
             try
             {
-                if (receivedData[startPosition++] == startmarker[searchIndex].toByte())
+                if (receivedData[startPosition++] == startmarker[searchIndex])
                 {
                     searchIndex++
                     if (searchIndex >= startmarker.size)
@@ -189,6 +190,10 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
                         break
                     }
                 }
+                else
+                {
+                    searchIndex = 0
+                }
             }
             catch (e: Exception)
             {