import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproCameraInformation;
import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproRunMode;
import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproStatusChecker;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT;
import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE;
{
String ipAddress;
String controlPortStr;
+ int communicationTimeoutMs;
try
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
ipAddress = preferences.getString(PIXPRO_HOST_IP, PIXPRO_HOST_IP_DEFAULT_VALUE);
controlPortStr = preferences.getString(PIXPRO_COMMAND_PORT, PIXPRO_COMMAND_PORT_DEFAULT_VALUE);
+ communicationTimeoutMs = parseInt(preferences.getString(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE), 30) * 1000;
+ if (communicationTimeoutMs < 3000)
+ {
+ communicationTimeoutMs = 3000; // 最小値は 3000msとする。
+ }
}
catch (Exception e)
{
e.printStackTrace();
ipAddress = "172.16.0.254";
controlPortStr = "9175";
+ communicationTimeoutMs = 30000; // エラー時は 30000msとする。
}
int controlPort = parseInt(controlPortStr, 9175);
this.commandCommunicator = new PixproCommandCommunicator(this, ipAddress, controlPort, true, false);
this.pixproConnection = new PixproConnection(activity, provider, this, statusChecker);
this.hardwarestatus = new PixproCameraHardwareStatus();
this.runMode = new PixproRunMode();
- this.playbackControl = new PixproPlaybackControl(this);
+ this.playbackControl = new PixproPlaybackControl(ipAddress, communicationTimeoutMs,this);
}
private int parseInt(@NonNull String key, int defaultValue)
import androidx.annotation.NonNull;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentListCallback;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.IConnectionKeyProvider;
+import java.util.ArrayList;
+import java.util.List;
+
public class PixproPlaybackControl implements IPlaybackControl
{
private final String TAG = toString();
+ private static final int DEFAULT_TIMEOUT = 3000;
+ private final String ipAddress;
private final IConnectionKeyProvider keyProvider;
+ private final int timeoutValue;
+
+ private List<ICameraContent> cameraContentList;
- public PixproPlaybackControl(@NonNull IConnectionKeyProvider keyProvider)
+ public PixproPlaybackControl(@NonNull String ipAddress, int timeoutMs, @NonNull IConnectionKeyProvider keyProvider)
{
+ this.ipAddress = ipAddress;
this.keyProvider = keyProvider;
+ this.timeoutValue = Math.max(timeoutMs, DEFAULT_TIMEOUT);
+ cameraContentList = new ArrayList<>();
}
@Override
public void getCameraContentList(ICameraContentListCallback callback)
{
+ try
+ {
+ String imageListurl = "http://" + ipAddress + "/?custom=1&" + getConnectionString();
+ String receivedMessage = SimpleHttpClient.httpGet(imageListurl, timeoutValue);
+ if (receivedMessage == null)
+ {
+ // ぬるぽ発行
+ callback.onErrorOccurred(new NullPointerException());
+ cameraContentList.clear();
+ return;
+ }
+ // 応答を受信した場合...
+ Log.v(TAG, " RECEIVED CONTENT REPLY : " + receivedMessage.length());
+ parseContentList(receivedMessage);
+ callback.onCompleted(cameraContentList);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ // 例外時にはぬるぽを発行する
+ callback.onErrorOccurred(new NullPointerException());
+ }
+ }
+
+ private void parseContentList(@NonNull String receivedMessage)
+ {
+ // 受信したボディを解析して、画像一覧を cameraContentList に入れる
+
}
+
@Override
public void showPictureStarted()
{
String PIXPRO_COMMAND_PORT = "pixpro_command_port";
String PIXPRO_COMMAND_PORT_DEFAULT_VALUE = "9175";
+ String PIXPRO_GET_PICS_LIST_TIMEOUT = "pixpro_get_pics_list_timeout";
+ String PIXPRO_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE = "30";
+
/*
//String GR2_DISPLAY_MODE = "gr2_display_mode";
//String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
{
editor.putString(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT, IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT))
+ {
+ editor.putString(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
+ }
editor.apply();
}
catch (Exception e)
<string name="pixpro_command_line_disconnected">カメラへのコマンド送信回線が切断されました。再試行してください。</string>
<string name="dialog_title_connect_failed_pixpro">接続失敗(PIXPRO)</string>
+ <string name="pref_pixpro_get_pics_list_timeout">撮影画像一覧取得時のタイムアウト(単位:秒)</string>
+ <string name="pref_summary_pixpro_get_pics_list_timeout">通常、変更は不要です (初期値:30)</string>
+
</resources>
<string name="pixpro_command_line_disconnected">The command communication line is disconnected. (RETRY please.)</string>
<string name="dialog_title_connect_failed_pixpro">Connect failed (PIXPRO)</string>
+ <string name="pref_pixpro_get_pics_list_timeout">Get Pics List Timeout(unit: sec.)</string>
+ <string name="pref_summary_pixpro_get_pics_list_timeout">If the camera has many number of Pics, increase number.</string>
+
</resources>
android:title="@string/pref_pixpro_control_port"
android:defaultValue="9175"
android:summary="@string/pref_summary_pixpro_control_port" />
+
+ <EditTextPreference
+ android:key="pixpro_get_pics_list_timeout"
+ android:title="@string/pref_pixpro_get_pics_list_timeout"
+ android:defaultValue="30"
+ android:inputType="number"
+ android:summary="@string/pref_summary_pixpro_get_pics_list_timeout" />
+
<!--
<CheckBoxPreference
android:key="capture_both_camera_and_live_view"