public CanonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
{
this.activity = context;
- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false, false);
liveViewControl = new CanonLiveViewControl(context, this, 10); //
asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT);
private float maxPointLimitWidth;
private float maxPointLimitHeight;
private RectF preFocusFrameRect = null;
- private boolean isDumpLog = false;
+ private boolean not_support_focus_lock = false;
+ private boolean isDumpLog = true;
public NikonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
{
maxPointLimitWidth = 6000.0f;
maxPointLimitHeight = 4000.0f;
}
- Log.v(TAG, "FOCUS RESOLUTION : " + maxPointLimitWidth + "," + maxPointLimitHeight);
+ not_support_focus_lock = preferences.getBoolean(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
+ Log.v(TAG, "FOCUS RESOLUTION : " + maxPointLimitWidth + "," + maxPointLimitHeight + " FOCUS LOCK : " + not_support_focus_lock);
}
catch (Exception e)
{
int x = (0x0000ffff & (Math.round(point.x * maxPointLimitWidth) + 1));
int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1));
Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
- //commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
+ if (!not_support_focus_lock) {
+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
+ } else {
+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
+ }
}
catch (Exception e)
{
public NikonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
{
this.activity = context;
- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, true, false);
liveViewControl = new NikonLiveViewControl(context, this, 20);
asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
statusChecker = new NikonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
{
e.printStackTrace();
}
- //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
commandIssued = false;
+ sendNextMessage();
}
+ private void sendNextMessage()
+ {
+ try
+ {
+ Thread.sleep(delayMs);
+ //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
+ //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
private int searchJpegHeader(byte[] data)
{
try
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
+import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayDeque;
import java.util.Arrays;
private boolean isStart = false;
private boolean isHold = false;
private boolean tcpNoDelay;
+ private boolean waitForever;
private int holdId = 0;
private Socket socket = null;
private DataOutputStream dos = null;
private Queue<IPtpIpCommand> commandQueue;
private Queue<IPtpIpCommand> holdCommandQueue;
- public PtpIpCommandPublisher(@NonNull String ip, int portNumber, boolean tcpNoDelay)
+ public PtpIpCommandPublisher(@NonNull String ip, int portNumber, boolean tcpNoDelay, boolean waitForever)
{
this.ipAddress = ip;
this.portNumber = portNumber;
this.tcpNoDelay = tcpNoDelay;
+ this.waitForever = waitForever;
this.commandQueue = new ArrayDeque<>();
this.holdCommandQueue = new ArrayDeque<>();
commandQueue.clear();
try
{
Log.v(TAG, " connect()");
- socket = new Socket(ipAddress, portNumber);
+ //socket = new Socket(ipAddress, portNumber);
+ socket = new Socket();
socket.setTcpNoDelay(tcpNoDelay);
- socket.setKeepAlive(true);
- //socket.setReceiveBufferSize(32768);
- //socket.setTrafficClass(0x10);
+ if (tcpNoDelay)
+ {
+ socket.setKeepAlive(false);
+ socket.setPerformancePreferences(0, 1, 0);
+ //socket.setSoLinger(true, 3000);
+ socket.setOOBInline(true);
+ socket.setReuseAddress(false);
+ //socket.setReceiveBufferSize(2097152);
+ //socket.setSendBufferSize(524288);
+ socket.setTrafficClass(0x80);
+ }
+ socket.connect(new InetSocketAddress(ipAddress, portNumber), 0);
return (true);
}
catch (Exception e)
{
if (!command.isRetrySend())
{
- // コマンドを再送信しない場合はここで抜ける
+ while (retry_over)
+ {
+ // コマンドを再送信しない場合はここで応答を待つ...
+ retry_over = receive_from_camera(command);
+ }
break;
}
if (!command.isIncrementSequenceNumberToRetry())
{
delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
}
+
+ try
+ {
+ if (socket != null)
+ {
+ Log.v(TAG, " SOCKET : send " + socket.getSendBufferSize() + " recv " + socket.getReceiveBufferSize() + " " + socket.getTcpNoDelay() + " " + socket.getOOBInline() + " " + socket.getKeepAlive() + " " + socket.getReuseAddress() + " " + socket.getSoLinger() + " " + socket.getSoTimeout() + " " + socket.getTrafficClass());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
if ((callback != null)&&(callback.isReceiveMulti()))
{
// 受信したら逐次「受信したよ」と応答するパターン
isLogOutput = false;
}
retry_count--;
- if (retry_count < 0)
+ if ((!waitForever)&&(retry_count < 0))
{
return (-1);
}
String NIKON_FOCUS_XY = "nikon_focus_xy";
String NIKON_FOCUS_XY_DEFAULT_VALUE = "6000,4000";
+ String NIKON_NOT_SUPPORT_FOCUS_LOCK = "nikon_not_support_focus_lock";
+
/*
int CHOICE_SPLASH_SCREEN = 10;
if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_FOCUS_XY)) {
+ editor.putString(IPreferencePropertyAccessor.NIKON_FOCUS_XY, IPreferencePropertyAccessor.NIKON_FOCUS_XY_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK)) {
+ editor.putBoolean(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
+ }
editor.apply();
}
catch (Exception e)
Log.v(TAG, " " + key + " , " + value);
break;
+ case IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK:
+ value = preferences.getBoolean(key, false);
+ Log.v(TAG, " " + key + " , " + value);
+ break;
+
default:
String strValue = preferences.getString(key, "");
setListPreference(key, key, strValue);
try
{
//super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences_olympuspen);
+ addPreferencesFromResource(R.xml.preferences_nikon);
ListPreference connectionMethod = findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
// Preferenceの画面に反映させる
setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
+ setBooleanPreference(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
}
catch (Exception e)
{
<string name="pref_canon_zoom_resolution">ズームステップ</string>
<string name="pref_summary_canon_zoom_resolution">ズームを何段階にするか指定します (標準: 25)</string>
+ <string name="pref_nikon_not_support_focus_lock">フォーカスロック未対応機</string>
+ <string name="pref_summary_nikon_not_support_focus_lock">フォーカスロックでライブビューが止まる場合にチェックを入れてください。</string>
</resources>
<string name="pref_canon_zoom_resolution">Zoom Step</string>
<string name="pref_summary_canon_zoom_resolution"> </string>
+ <string name="pref_nikon_not_support_focus_lock">Not support Focus-Lock</string>
+ <string name="pref_summary_nikon_not_support_focus_lock"> </string>
+
</resources>
android:summary="@string/pref_summary_nikon_focus_xy" />
<CheckBoxPreference
+ android:key="nikon_not_support_focus_lock"
+ android:title="@string/pref_nikon_not_support_focus_lock"
+ android:summary="@string/pref_summary_nikon_not_support_focus_lock" />
+
+ <CheckBoxPreference
android:key="capture_both_camera_and_live_view"
android:title="@string/pref_capture_both_camera_and_live_view" />
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.6.0'
+ classpath 'com.android.tools.build:gradle:3.6.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files