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
{
@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);
{
return;
}
- int first_offset = 416;
int length = rx_body.length;
int data_position = 0;
if (!receivedFirstData)
// データを最初に読んだとき。ヘッダ部分を読み飛ばす
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)
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)
{
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
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)
{