OSDN Git Service

NIKON対応ひととおり。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / camera / nikon / wrapper / liveview / NikonLiveViewImageReceiver.java
index 0527953..10fb5dd 100644 (file)
@@ -5,10 +5,8 @@ import android.util.Log;
 import androidx.annotation.NonNull;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
-import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
 
 import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
 
 public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
 {
@@ -60,7 +58,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
     @Override
     public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] rx_body)
     {
-        Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
+        //Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
 
         // 受信したデータから、通信のヘッダ部分を削除する
         cutHeader(rx_body);
@@ -72,7 +70,6 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
         {
             return;
         }
-        int first_offset = 416;
         int length = rx_body.length;
         int data_position = 0;
         if (!receivedFirstData)
@@ -80,7 +77,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
             // データを最初に読んだとき。ヘッダ部分を読み飛ばす
             receivedFirstData = true;
             data_position = (int) rx_body[0] & (0xff);
-            Log.v(TAG, " FIRST DATA POS. : " + data_position);
+            //Log.v(TAG, " FIRST DATA POS. : " + data_position);
             //SimpleLogDumper.dump_bytes(" [sssXXXsss]", Arrays.copyOfRange(rx_body, first_offset, (first_offset + 64)));
         }
         else if (received_remain_bytes > 0)
@@ -113,30 +110,8 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 break;
             }
 
-            int forward_length = data_position;
-
             // 受信データ(のヘッダ部分)をダンプする
-            Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
-            try
-            {
-                while (forward_length < rx_body.length)
-                {
-
-                    if ((rx_body[forward_length] == (byte) 0xff)&&(rx_body[forward_length + 1] == (byte) 0xd8))
-                    {
-                        break;
-                    }
-                    forward_length++;
-                }
-                if (forward_length >= rx_body.length)
-                {
-                    forward_length = data_position + 12;
-                }
-            }
-            catch (Exception e)
-            {
-                e.printStackTrace();
-            }
+            //Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
 
             if ((data_position + body_size) > length)
             {
@@ -145,7 +120,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + (12)), copysize);
                 received_remain_bytes = body_size - copysize - (12);  // マイナス12は、ヘッダ分
                 received_total_bytes = received_total_bytes + copysize;
-                Log.v(TAG, " ----- copy : " + (data_position + (12)) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
+                //Log.v(TAG, " ----- copy : " + (data_position + (12)) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
                 break;
             }
             try
@@ -153,7 +128,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + (12)), (body_size - (12)));
                 data_position = data_position + body_size;
                 received_total_bytes = received_total_bytes + (12);
-                Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - (12)) + " remain : " + received_remain_bytes);
+                //Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - (12)) + " remain : " + received_remain_bytes);
             }
             catch (Exception e)
             {