import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpMessages;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRegistrationMessage;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.status.IPtpIpRunModeHolder;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.status.PtpIpStatusChecker;
-
public class CanonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCommandCallback, IPtpIpMessages
{
private final String TAG = this.toString();
private final IPtpIpInterfaceProvider interfaceProvider;
private final IPtpIpCommandPublisher commandIssuer;
private final PtpIpStatusChecker statusChecker;
- private boolean isBothLiveView = false;
CanonCameraConnectSequenceForPlayback(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull PtpIpStatusChecker statusChecker)
{
{
try
{
-/*
- try
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- isBothLiveView = preferences.getBoolean(IPreferencePropertyAccessor.FUJIX_DISPLAY_CAMERA_VIEW, false);
- }
- catch (Exception e)
- {
- //isBothLiveView = false;
- e.printStackTrace();
- }
-*/
// カメラとTCP接続
IPtpIpCommandPublisher issuer = interfaceProvider.getCommandPublisher();
if (!issuer.isConnected())
@Override
public void receivedMessage(int id, byte[] rx_body)
{
- //Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
- //int bodyLength = 0;
- IPtpIpRunModeHolder runModeHolder;
switch (id)
{
-/**/
case SEQ_REGISTRATION:
if (checkRegistrationMessage(rx_body))
{
case SEQ_SET_EVENT_MODE:
interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting5), false, false, 0);
- break;
-/*
- case SEQ_START_2ND_READ:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting2), false, false, 0);
- cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connecting));
- if (rx_body.length == (int)rx_body[0])
- {
- // なぜかもうちょっとデータが飛んでくるので待つ
- //commandIssuer.enqueueCommand(new ReceiveOnly(this));
-
- commandIssuer.enqueueCommand(new StartMessage3rd(this));
- }
- else
- {
- commandIssuer.enqueueCommand(new StartMessage3rd(this));
- }
- break;
-
- case SEQ_START_2ND_RECEIVE:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting3), false, false, 0);
- commandIssuer.enqueueCommand(new StartMessage3rd(this));
- break;
-
- case SEQ_START_3RD:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting4), false, false, 0);
- commandIssuer.enqueueCommand(new StartMessage4th(this));
- break;
-
- case SEQ_START_4TH:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting5), false, false, 0);
- if (isBothLiveView)
- {
- // カメラのLCDと遠隔のライブビューを同時に表示する場合...
- commandIssuer.enqueueCommand(new CameraRemoteMessage(this));
- }
- else
- {
- commandIssuer.enqueueCommand(new StartMessage5th(this));
- }
- break;
-
- case SEQ_START_5TH:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting6), false, false, 0);
- commandIssuer.enqueueCommand(new QueryCameraCapabilities(this));
- //commandIssuer.enqueueCommand(new StatusRequestMessage(this));
- break;
-
- case SEQ_QUERY_CAMERA_CAPABILITIES:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting7), false, false, 0);
- commandIssuer.enqueueCommand(new CameraRemoteMessage(this));
- break;
-
- case SEQ_CAMERA_REMOTE:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting8), false, false, 0);
- commandIssuer.enqueueCommand(new ChangeToPlayback1st(this));
- runModeHolder = interfaceProvider.getRunModeHolder();
- if (runModeHolder != null)
- {
- runModeHolder.transitToPlaybackMode(false);
- }
- //connectFinished();
- break;
-
- case SEQ_CHANGE_TO_PLAYBACK_1ST:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting9), false, false, 0);
- commandIssuer.enqueueCommand(new ChangeToPlayback2nd(this));
- break;
-
- case SEQ_CHANGE_TO_PLAYBACK_2ND:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting10), false, false, 0);
- commandIssuer.enqueueCommand(new ChangeToPlayback3rd(this));
- break;
-
- case SEQ_CHANGE_TO_PLAYBACK_3RD:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting11), false, false, 0);
- commandIssuer.enqueueCommand(new ChangeToPlayback4th(this));
- break;
-
- case SEQ_CHANGE_TO_PLAYBACK_4TH:
- interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connecting12), false, false, 0);
- commandIssuer.enqueueCommand(new StatusRequestMessage(this));
- break;
-
- case SEQ_STATUS_REQUEST:
interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connect_finished), false, false, 0);
- IPtpIpCommandCallback callback = interfaceProvider.getStatusHolder();
- if (callback != null)
- {
- callback.receivedMessage(id, rx_body);
- }
- runModeHolder = interfaceProvider.getRunModeHolder();
- if (runModeHolder != null)
- {
- runModeHolder.transitToPlaybackMode(true);
- }
connectFinished();
Log.v(TAG, "CHANGED PLAYBACK MODE : DONE.");
break;
-*/
+
default:
Log.v(TAG, "RECEIVED UNKNOWN ID : " + id);
onConnectError(context.getString(R.string.connect_receive_unknown_message));
{
e.printStackTrace();
}
- //commandIssuer.enqueueCommand(new CanonInitEventRequest(this, connectionNumber));
- //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, 0x1002, 4, 0x41));
}
private boolean checkRegistrationMessage(byte[] receiveData)
{
// データ(Connection Number)がないときにはエラーと判断する
- if ((receiveData == null)||(receiveData.length < 12))
- {
- return (false);
- }
- return (true);
+ return (!((receiveData == null)||(receiveData.length < 12)));
}
private boolean checkEventInitialize(byte[] receiveData)
{
Log.v(TAG, "checkEventInitialize() ");
- if (receiveData == null)
- {
- return (false);
- }
- return (true);
+ return (!(receiveData == null));
}
-
private void connectFinished()
{
try
// ちょっと待つ
Thread.sleep(1000);
- interfaceProvider.getAsyncEventCommunication().connect();
+ //interfaceProvider.getAsyncEventCommunication().connect();
//interfaceProvider.getCameraStatusWatcher().startStatusWatch(interfaceProvider.getStatusListener()); ステータスの定期確認は実施しない
// 接続成功!のメッセージを出す
// カメラとの接続確立を通知する
cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connected));
cameraStatusReceiver.onCameraConnected();
- Log.v(TAG, "onConnectNotify()");
+ Log.v(TAG, " onConnectNotify()");
}
});
thread.start();
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandPublisher;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpMessages;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonInitEventRequest;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.StatusRequestMessage;
import java.io.BufferedReader;
import java.io.DataOutputStream;
this.statusHolder = new PtpIpStatusHolder();
this.ipAddress = ip;
this.portNumber = portNumber;
-
-/*
- try
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
- String pollingWait = preferences.getString(IPreferencePropertyAccessor.FUJIX_COMMAND_POLLING_WAIT, IPreferencePropertyAccessor.FUJIX_COMMAND_POLLING_WAIT_DEFAULT_VALUE);
- this.sleepMs = Integer.parseInt(pollingWait);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- this.sleepMs = 400;
- }
-*/
Log.v(TAG, "POLLING WAIT : " + sleepMs);
}
private void receive_from_camera(boolean isDumpReceiveLog, int id, IPtpIpCommandCallback callback, boolean receiveAgain, int delayMs) {
try {
sleep(delayMs);
- Log.v(TAG, " ----- receive_from_camera() ----- : " + isDumpReceiveLog + " " + receiveAgain);
+
boolean isFirstTime = true;
int totalReadBytes;
int receive_message_buffer_size = BUFFER_SIZE;
}
if (isDumpReceiveLog) {
// ログに受信メッセージを出力する
- Log.v(TAG, " receive_from_camera() : " + read_bytes + " bytes. [" + receive_message_buffer_size + "]");
+ Log.v(TAG, " receive_from_camera() : " + read_bytes + " bytes.");
dump_bytes("RECV[" + receive_body.length + "] ", receive_body);
}
if (callback != null) {