1 package net.osdn.gokigen.a01d.camera.canon.wrapper.liveview;
3 import android.util.Log;
5 import androidx.annotation.NonNull;
6 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
8 import java.util.Arrays;
15 public class CanonLiveViewImageReceiver implements IPtpIpCommandCallback
17 private final String TAG = toString();
18 private final ICanonLiveViewImageCallback callback;
20 CanonLiveViewImageReceiver(@NonNull ICanonLiveViewImageCallback callback)
22 this.callback = callback;
26 public void receivedMessage(int id, byte[] rx_body)
32 Log.v(TAG, " BITMAP IS NONE...");
33 callback.onCompleted(null, null);
37 /////// 受信データから、サムネイルの先頭(0xff 0xd8)を検索する /////
38 int offset = rx_body.length - 22;
39 //byte[] thumbnail0 = Arrays.copyOfRange(rx_body, 0, rx_body.length);
42 if ((rx_body[offset] == (byte) 0xff)&&((rx_body[offset + 1] == (byte) 0xd8)))
48 byte[] thumbnail = Arrays.copyOfRange(rx_body, offset, rx_body.length);
49 callback.onCompleted(thumbnail, null);
55 callback.onErrorOccurred(e);
61 public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
63 Log.v(TAG, " " + currentBytes + "/" + totalBytes);
67 public boolean isReceiveMulti()