{
try
{
- byte x = (byte) (0x000000ff & ((int)(Math.round(point.x) * maxPointLimitWidth) + 1));
- byte y = (byte) (0x000000ff & ((int)(Math.round(point.y) * maxPointLimitHeight) + 1));
+ byte x = (byte) (0x000000ff & (Math.round(point.x * maxPointLimitWidth) + 1));
+ byte y = (byte) (0x000000ff & (Math.round(point.y * maxPointLimitHeight) + 1));
Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
issuer.enqueueCommand(new FocusLock(x, y, this));
}
// message_header.type : focus_unlock (0x9027)
(byte)0x27, (byte)0x90,
- // message_id (0~1づつ繰り上がる...
+ // sequence number
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
});
}
import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.IFujiXCommandCallback;
import net.osdn.gokigen.a01d.camera.fujix.wrapper.connection.FujiXCameraConnectSequence;
-public class StartReceiveOnly extends FujiXCommandBase
+public class ReceiveOnly extends FujiXCommandBase
{
private final IFujiXCommandCallback callback;
- public StartReceiveOnly(@NonNull IFujiXCommandCallback callback)
+ public ReceiveOnly(@NonNull IFujiXCommandCallback callback)
{
this.callback = callback;
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.command.messages;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.IFujiXCommandCallback;
+import net.osdn.gokigen.a01d.camera.fujix.wrapper.connection.FujiXCameraConnectSequence;
+
+public class SetPropertyValue extends FujiXCommandBase
+{
+ private final IFujiXCommandCallback callback;
+ private final boolean isShortMessage;
+ private final byte id0;
+ private final byte id1;
+ private final byte data0;
+ private final byte data1;
+ private final byte data2;
+ private final byte data3;
+
+ public SetPropertyValue(@NonNull IFujiXCommandCallback callback, int id, int value, boolean isShort)
+ {
+ this.callback = callback;
+ this.isShortMessage = isShort;
+
+ id0 = ((byte) (0x000000ff & id));
+ id1 = ((byte)((0x0000ff00 & id) >> 8));
+
+ data0 = ((byte) (0x000000ff & value));
+ data1 = ((byte)((0x0000ff00 & value) >> 8));
+ data2 = ((byte)((0x00ff0000 & value) >> 16));
+ data3 = ((byte)((0xff000000 & value) >> 24));
+ }
+
+ @Override
+ public IFujiXCommandCallback responseCallback()
+ {
+ return (callback);
+ }
+
+ @Override
+ public int getId()
+ {
+ return (FujiXCameraConnectSequence.SEQ_STATUS_REQUEST);
+ }
+
+ @Override
+ public byte[] commandBody()
+ {
+ return (new byte[] {
+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
+ (byte)0x01, (byte)0x00,
+
+ // message_header.type : two_part (0x1016)
+ (byte)0x16, (byte)0x10,
+
+ // message_id (0~1づつ繰り上がる)
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+
+ // command code
+ id0, id1, (byte)0x00, (byte)0x00,
+ });
+ }
+
+ @Override
+ public byte[] commandBody2()
+ {
+ if (isShortMessage) {
+ return (new byte[]{
+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
+ (byte) 0x02, (byte) 0x00,
+
+ // message_header.type : two_part (0x1016)
+ (byte) 0x16, (byte) 0x10,
+
+ // sequence number
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+
+ // ...data...
+ data0, data1,
+ });
+ } else {
+ return (new byte[]{
+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
+ (byte) 0x02, (byte) 0x00,
+
+ // message_header.type : two_part (0x1016)
+ (byte) 0x16, (byte) 0x10,
+
+ // sequence number
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+
+ // ...data...
+ data0, data1, data2, data3,
+ });
+ }
+ }
+
+ @Override
+ public boolean dumpLog()
+ {
+ return (false);
+ }
+}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.fujix.wrapper.command.messages;
-
-import androidx.annotation.NonNull;
-
-import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.IFujiXCommandCallback;
-import net.osdn.gokigen.a01d.camera.fujix.wrapper.connection.FujiXCameraConnectSequence;
-
-public class StartReceiveOnly2 extends FujiXCommandBase
-{
- private final IFujiXCommandCallback callback;
-
- public StartReceiveOnly2(@NonNull IFujiXCommandCallback callback)
- {
- this.callback = callback;
- }
-
- @Override
- public IFujiXCommandCallback responseCallback()
- {
- return (callback);
- }
-
- @Override
- public int getId()
- {
- return (FujiXCameraConnectSequence.SEQ_START_RECEIVE2);
- }
-
- @Override
- public byte[] commandBody()
- {
- return (null);
- }
-}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.fujix.wrapper.command.messages;
-
-import androidx.annotation.NonNull;
-
-import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.IFujiXCommandCallback;
-import net.osdn.gokigen.a01d.camera.fujix.wrapper.connection.FujiXCameraConnectSequence;
-
-public class StatusRequestReceive extends FujiXCommandBase
-{
- private final IFujiXCommandCallback callback;
-
- public StatusRequestReceive(@NonNull IFujiXCommandCallback callback)
- {
- this.callback = callback;
- }
-
- @Override
- public IFujiXCommandCallback responseCallback()
- {
- return (callback);
- }
-
- @Override
- public int getId()
- {
- return (FujiXCameraConnectSequence.SEQ_STATUS_REQUEST_RECEIVE);
- }
-
- @Override
- public byte[] commandBody()
- {
- return (null);
- }
-}
public static final int SEQ_CAMERA_REMOTE = 7;
public static final int SEQ_START_5TH = 8;
public static final int SEQ_STATUS_REQUEST = 9;
- public static final int SEQ_STATUS_REQUEST_RECEIVE = 10;
public static final int SEQ_QUERY_CAMERA_CAPABILITIES = 11;
- public static final int SEQ_START_RECEIVE2 = 12;
private final Activity context;
private final ICameraConnection cameraConnection;
if (rx_body.length == (int)rx_body[0])
{
// なぜかもうちょっとデータが飛んでくるので待つ
- //commandIssuer.enqueueCommand(new StartReceiveOnly(this));
+ //commandIssuer.enqueueCommand(new ReceiveOnly(this));
commandIssuer.enqueueCommand(new StartMessage3rd(this));
}
commandIssuer.enqueueCommand(new QueryCameraCapabilities(this));
break;
- case SEQ_STATUS_REQUEST_RECEIVE:
- commandIssuer.enqueueCommand(new QueryCameraCapabilities(this));
- break;
-
case SEQ_QUERY_CAMERA_CAPABILITIES:
commandIssuer.enqueueCommand(new CameraRemoteMessage(this));
break;
- case SEQ_START_RECEIVE2:
- commandIssuer.enqueueCommand(new CameraRemoteMessage(this));
- break;
case SEQ_CAMERA_REMOTE:
connectFinished();
break;
private final CameraLiveViewListenerImpl liveViewListener;
private int waitMs = 0;
private static final int DATA_HEADER_OFFSET = 18;
- private static final int BUFFER_SIZE = 1920 * 1024 + 8;
+ private static final int BUFFER_SIZE = 2048 * 1280 + 8;
private static final int ERROR_LIMIT = 30;
private boolean isStart = false;
{
try
{
+ boolean findJpeg = false;
+ int length_bytes;
int read_bytes = isr.read(byteArray, 0, BUFFER_SIZE);
- Log.v(TAG, "READ BYTES : " + read_bytes + " (" + waitMs + "ms)");
- liveViewListener.onUpdateLiveView(Arrays.copyOfRange(byteArray, DATA_HEADER_OFFSET, read_bytes - DATA_HEADER_OFFSET), null);
- //liveViewListener.onUpdateLiveView(Arrays.copyOfRange(byteArray, 0, read_bytes), null);
+ if (read_bytes > DATA_HEADER_OFFSET)
+ {
+ // メッセージボディの先頭にあるメッセージ長分は読み込む
+ length_bytes = ((((int) byteArray[3]) & 0xff) << 24) + ((((int) byteArray[2]) & 0xff) << 16) + ((((int) byteArray[1]) & 0xff) << 8) + (((int) byteArray[0]) & 0xff);
+ if ((byteArray[18] == (byte)0xff)&&(byteArray[19] == (byte)0xd8))
+ {
+ findJpeg = true;
+ while ((read_bytes < length_bytes) && (read_bytes < BUFFER_SIZE) && (length_bytes <= BUFFER_SIZE))
+ {
+ int append_bytes = isr.read(byteArray, read_bytes, length_bytes - read_bytes);
+ Log.v(TAG, "READ AGAIN : " + append_bytes + " [" + read_bytes + "]");
+ if (append_bytes < 0)
+ {
+ break;
+ }
+ read_bytes = read_bytes + append_bytes;
+ }
+ Log.v(TAG, "READ BYTES : " + read_bytes + " (" + length_bytes + " bytes, " + waitMs + "ms)");
+ }
+ else
+ {
+ // ウェイトを短めに入れてマーカーを拾うまで待つ
+ Thread.sleep(waitMs/4);
+ continue;
+ }
+ }
+
+ // お試し: 先頭データ(24バイト分)をダンプしてみる。
+ //dump_bytes("[LV]", byteArray, 24);
+
+ if (findJpeg)
+ {
+ liveViewListener.onUpdateLiveView(Arrays.copyOfRange(byteArray, DATA_HEADER_OFFSET, read_bytes - DATA_HEADER_OFFSET), null);
+ errorCount = 0;
+ }
Thread.sleep(waitMs);
- errorCount = 0;
}
catch (Exception e)
{
{
isStart = false;
}
+
+ /**
+ * デバッグ用:ログにバイト列を出力する
+ *
+ */
+ private void dump_bytes(String header, byte[] data, int dumpBytes)
+ {
+ int index = 0;
+ StringBuffer message;
+ if (dumpBytes <= 0)
+ {
+ dumpBytes = 24;
+ }
+ message = new StringBuffer();
+ for (int point = 0; point < dumpBytes; point++)
+ {
+ byte item = data[point];
+ index++;
+ message.append(String.format("%02x ", item));
+ if (index >= 8)
+ {
+ Log.v(TAG, header + " " + message);
+ index = 0;
+ message = new StringBuffer();
+ }
+ }
+ if (index != 0)
+ {
+ Log.v(TAG, header + " " + message);
+ }
+ System.gc();
+ }
+
+
}
import android.util.SparseIntArray;
import androidx.annotation.NonNull;
+import androidx.collection.SparseArrayCompat;
import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
import java.util.ArrayList;
import java.util.List;
-class FujiXStatusHolder
+class FujiXStatusHolder implements IFujiXCameraProperties
{
private final String TAG = toString();
private SparseIntArray statusHolder;
+ private SparseArrayCompat<String> statusNameArray;
FujiXStatusHolder()
{
statusHolder = new SparseIntArray();
statusHolder.clear();
+
+ statusNameArray = new SparseArrayCompat<>();
+ prepareStatusNameArray();
}
+ private void prepareStatusNameArray()
+ {
+ statusNameArray.clear();
+ statusNameArray.append(BATTERY_LEVEL, "Battery");
+ statusNameArray.append(WHITE_BALANCE, "WhiteBalance");
+ statusNameArray.append(APERTURE, "Aperture");
+ statusNameArray.append(FOCUS_MODE, "FocusMode");
+ statusNameArray.append(SHOOTING_MODE, "ShootingMode");
+ statusNameArray.append(FLASH, "FlashMode");
+ statusNameArray.append(EXPOSURE_COMPENSATION, "ExposureCompensation");
+ statusNameArray.append(SELF_TIMER, "SelfTimer");
+ statusNameArray.append(FILM_SIMULATION, "FilmSimulation");
+ statusNameArray.append(IMAGE_FORMAT, "ImageFormat");
+ statusNameArray.append(RECMODE_ENABLE, "RecModeEnable");
+ statusNameArray.append(F_SS_CONTROL, "F_SS_Control");
+ statusNameArray.append(ISO, "Iso");
+ statusNameArray.append(MOVIE_ISO, "MovieIso");
+ statusNameArray.append(FOCUS_POINT, "FocusPoint");
+ statusNameArray.append(DEVICE_ERROR, "DeviceError");
+ statusNameArray.append(SDCARD_REMAIN_SIZE, "ImageRemainCount");
+ statusNameArray.append(FOCUS_LOCK, "FocusLock");
+ statusNameArray.append(MOVIE_REMAINING_TIME, "MovieRemainTime");
+ statusNameArray.append(SHUTTER_SPEED, "ShutterSpeed");
+ statusNameArray.append(IMAGE_ASPECT, "ImageAspect");
+ statusNameArray.append(BATTERY_LEVEL_2, "BattLevel");
+ }
+
+
void updateValue(ICameraStatusUpdateNotify notifier, int id, byte data0, byte data1, byte data2, byte data3)
{
try
if (currentValue != value)
{
Log.v(TAG, "STATUS ID: " + id + " value : " + currentValue + " -> " + value);
- updateDetected(notifier, id, currentValue, value);
+ if (notifier != null)
+ {
+ updateDetected(notifier, id, currentValue, value);
+ }
}
}
catch (Exception e)
{
e.printStackTrace();
}
-
}
- private void updateDetected(ICameraStatusUpdateNotify notifier, int id, int previous, int current)
+ private void updateDetected(@NonNull ICameraStatusUpdateNotify notifier, int id, int previous, int current)
{
- Log.v(TAG, "updateDetected(" + id + " " + previous + " -> " + current + " )");
+ try
+ {
+ String idName = statusNameArray.get(id, "Unknown");
+ Log.v(TAG, "updateDetected(" + id + " [" + idName + "] " + previous + " -> " + current + " )");
+
+ if (id == FOCUS_LOCK)
+ {
+ if (current == 1)
+ {
+ // focus Lock
+ notifier.updateFocusedStatus(true, true);
+ }
+ else
+ {
+ // focus unlock
+ notifier.updateFocusedStatus(false, false);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
+
List<String> getAvailableItemList(String listKey)
{
- return (new ArrayList<>());
+ ArrayList<String> selection = new ArrayList<>();
+
+ // これ違う...これだと認識したステータスの一覧だ...
+ try
+ {
+ for (int index = 0; index < statusHolder.size(); index++)
+ {
+ int key = statusHolder.keyAt(index);
+ selection.add(statusNameArray.get(key));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (selection);
}
String getItemStatus(String key)
{
- return ("");
+ try
+ {
+ for (int index = 0; index < statusNameArray.size(); index++)
+ {
+ int id = statusNameArray.keyAt(index);
+ String strKey = statusNameArray.valueAt(index);
+ if (key.contentEquals(strKey))
+ {
+ return (statusHolder.get(id) + "");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return ("?");
}
-
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status;
+
+public interface IFujiXCameraProperties
+{
+ int BATTERY_LEVEL = 0x5001;
+ int WHITE_BALANCE = 0x5005;
+ int APERTURE = 0x5007;
+ int FOCUS_MODE = 0x500a;
+ int SHOOTING_MODE = 0x500e;
+ int FLASH = 0x500c;
+ int EXPOSURE_COMPENSATION = 0x5010;
+ int SELF_TIMER = 0x5012;
+ int FILM_SIMULATION = 0xd001;
+ int IMAGE_FORMAT = 0xd018;
+ int RECMODE_ENABLE = 0xd019;
+ int F_SS_CONTROL = 0xd028;
+ int ISO = 0xd02a;
+ int MOVIE_ISO = 0xd02b;
+ int FOCUS_POINT = 0xd17c;
+ int FOCUS_LOCK = 0xd209;
+ int DEVICE_ERROR = 0xd21b;
+ int SDCARD_REMAIN_SIZE = 0xd229;
+ int MOVIE_REMAINING_TIME = 0xd22a;
+ int SHUTTER_SPEED = 0xd240;
+ int IMAGE_ASPECT = 0xd241;
+ int BATTERY_LEVEL_2 = 0xd242;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXBatteryMode
+{
+ int BATTERY_CRITICAL =1;
+ int BATTERY_ONE_BAR =2;
+ int BATTERY_TWO_BAR =3;
+ int BATTERY_FULL =4;
+ int BATTERY_126S_CRITICAL =6;
+ int BATTERY_126S_ONE_BAR =7;
+ int BATTERY_126S_TWO_BAR =8;
+ int BATTERY_126S_THREE_BAR =9;
+ int BATTERY_126S_FOUR_BAR =10;
+ int BATTERY_126S_FULL =11;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXFSSControl
+{
+ int F_SS_CTRL_BOTH = 0;
+ int F_SS_CTRL_F = 1;
+ int F_SS_CTRL_SS = 2;
+ int F_SS_CTRL_NONE = 3;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXFilmSimulation
+{
+ int FILM_SIMULATION_MIN = 1;
+ int FILM_SIMULATION_PROVIA =1;
+ int FILM_SIMULATION_VELVIA =2;
+ int FILM_SIMULATION_ASTIA =3;
+ int FILM_SIMULATION_MONOCHROME =4;
+ int FILM_SIMULATION_SEPIA =5;
+ int FILM_SIMULATION_PRO_NEG_HI =6;
+ int FILM_SIMULATION_PRO_NEG_STD =7;
+ int FILM_SIMULATION_MONOCHROME_Y_FILTER =8;
+ int FILM_SIMULATION_MONOCHROME_R_FILTER =9;
+ int FILM_SIMULATION_MONOCHROME_G_FILTER =10;
+ int FILM_SIMULATION_CLASSIC_CHROME =11;
+ int FILM_SIMULATION_ACROS =12;
+ int FILM_SIMULATION_ACROS_Y =13;
+ int FILM_SIMULATION_ACROS_R =14;
+ int FILM_SIMULATION_ACROS_G =15;
+ int FILM_SIMULATION_ETERNA =16;
+ int FILM_SIMULATION_MAX = 17;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXFlashMode
+{
+ int FLASH_AUTO =1;
+ int FLASH_OFF =2;
+ int FLASH_FILL =3;
+ int FLASH_REDEYE_AUTO =4;
+ int FLASH_REDEYE_FILL =5;
+ int FLASH_EXTERNAL_SYNC =6;
+ int FLASH_ON =0x8001;
+ int FLASH_REDEYE =0x8002;
+ int FLASH_REDEYE_ON =0x8003;
+ int FLASH_REDEYE_SYNC =0x8004;
+ int FLASH_REDEYE_REAR =0x8005;
+ int FLASH_SLOW_SYNC =0x8006;
+ int FLASH_REAR_SYNC =0x8007;
+ int FLASH_COMMANDER =0x8008;
+ int FLASH_DISABLE =0x8009;
+ int FLASH_ENABLE =0x800a;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXFocusingMode
+{
+ int FOCUS_MANUAL = 1;
+ int FOCUS_SINGLE_AUTO = 0x8001;
+ int FOCUS_CONTINUOUS_AUTO = 0x8002;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXImageAspectMode
+{
+ int IMAGE_ASPECT_MIN = 2;
+ int IMAGE_ASPECT_S_3x2 = 2;
+ int IMAGE_ASPECT_S_16x9 = 3;
+ int IMAGE_ASPECT_S_1x1 = 4;
+ int IMAGE_ASPECT_M_3x2 = 6;
+ int IMAGE_ASPECT_M_16x9 = 7;
+ int IMAGE_ASPECT_M_1x1 = 8;
+ int IMAGE_ASPECT_L_3x2 = 10;
+ int IMAGE_ASPECT_L_16x9 = 11;
+ int IMAGE_ASPECT_L_1x1 = 12;
+ int IMAGE_ASPECT_MAX = 12;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXImageFormatMode
+{
+ int IMAGE_FORMAT_FINE = 2;
+ int IMAGE_FORMAT_NORMAL = 3;
+ int IMAGE_FORMAT_FINE_RAW = 4;
+ int IMAGE_FORMAT_NORMAL_RAW = 5;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXShootingMode
+{
+ int SHOOTING_MANUAL = 1;
+ int SHOOTING_PROGRAM = 2;
+ int SHOOTING_APERTURE = 3;
+ int SHOOTING_SHUTTER = 4;
+ int SHOOTING_CUSTOM = 5;
+ int SHOOTING_AUTO = 6;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXTimerMode
+{
+ int TIMER_OFF =0;
+ int TIMER_1SEC =1;
+ int TIMER_2SEC =2;
+ int TIMER_5SEC =3;
+ int TIMER_10SEC =4;
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.fujix.wrapper.status.values;
+
+public interface IFujiXWhiteBalanceMode
+{
+ int WHITE_BALANCE_AUTO = 2;
+ int WHITE_BALANCE_FINE = 4;
+ int WHITE_BALANCE_INCANDESCENT = 6;
+ int WHITE_BALANCE_FLUORESCENT_1 = 0x8001;
+ int WHITE_BALANCE_FLUORESCENT_2 = 0x8002;
+ int WHITE_BALANCE_FLUORESCENT_3 = 0x8003;
+ int WHITE_BALANCE_SHADE = 0x8006;
+ int WHITE_BALANCE_UNDERWATER = 0x800a;
+ int WHITE_BALANCE_TEMPERATURE = 0x800b;
+ int WHITE_BALANCE_CUSTOM =0X800c;
+}
import java.io.EOFException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.net.Socket;
import java.net.URL;
public class SimpleLiveviewSlicer
private HttpURLConnection mHttpConn;
private InputStream mInputStream;
+ public void open(InputStream inputStream)
+ {
+ mInputStream = inputStream;
+ }
+
public void open(String liveviewUrl)
{
try