package net.osdn.gokigen.pkremote.camera.vendor.nikon.wrapper.playback;
-import android.app.Activity;
import android.util.Log;
import androidx.annotation.NonNull;
{
private static final String TAG = NikonFullImageReceiver.class.getSimpleName();
- private final Activity activity;
private final IPtpIpCommandPublisher publisher;
private IDownloadContentCallback callback = null;
private boolean isReceiveMulti = true;
private int objectId = 0;
-
+ private int delayMs;
private int received_total_bytes = 0;
private int received_remain_bytes = 0;
private int target_image_size = 0;
private boolean receivedFirstData = false;
- NikonFullImageReceiver(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
+ NikonFullImageReceiver(@NonNull IPtpIpCommandPublisher publisher, int delayMs)
{
- this.activity = activity;
this.publisher = publisher;
+ this.delayMs = delayMs;
}
void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback)
this.receivedFirstData = false;
Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x101b, 12, objectId, 0, imageSize, 0)); // GetPartialObject (0x101b)
+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, delayMs, true, 0, 0x101b, 12, objectId, 0, imageSize, 0)); // GetPartialObject (0x101b)
}
@Override
{
private final String TAG = toString();
private final NikonInterfaceProvider provider;
+ private final int delayMs;
private boolean isDumpLog = true;
private ICameraContentListCallback callback = null;
private SparseArray<NikonStorageContentHolder> storageIdList;
- NikonImageObjectReceiver(NikonInterfaceProvider provider)
+ NikonImageObjectReceiver(NikonInterfaceProvider provider, int delayMs)
{
this.provider = provider;
+ this.delayMs = delayMs;
this.storageIdList = new SparseArray<>();
}
((int) rx_body[readPosition + 1] << 8) +
((int) rx_body[readPosition + 2] << 16) +
((int) rx_body[readPosition + 3] << 24);
- storageIdList.append(storageId, new NikonStorageContentHolder(provider, storageId, this));
+ storageIdList.append(storageId, new NikonStorageContentHolder(provider, storageId, this, delayMs));
readPosition = readPosition + 4;
}
Log.v(TAG, " NOF STORAGE IDs : " + storageIdList.size() + " ");
if (publisher != null)
{
// オブジェクト一覧をクリアする
- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, 50, isDumpLog, 0, 0x1004, 0, 0, 0, 0, 0)); // GetStorageIDs
+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, delayMs, isDumpLog, 0, 0x1004, 0, 0, 0, 0, 0)); // GetStorageIDs
this.callback = callback;
}
}
import android.graphics.Color;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import net.osdn.gokigen.pkremote.IInformationReceiver;
import net.osdn.gokigen.pkremote.R;
-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;
private final Activity activity;
private final NikonInterfaceProvider provider;
private final NikonFullImageReceiver fullImageReceiver;
- //private final NikonSmallImageReceiver smallImageReciever;
- // private String raw_suffix = "NEF";
+ private int delayMs = 50;
+ private final NikonSmallImageReceiver smallImageReciever;
private boolean use_screennail_image = false;
private NikonImageObjectReceiver nikonImageObjectReceiver;
public NikonPlaybackControl(Activity activity, NikonInterfaceProvider provider)
{
- this.activity = activity;
- this.provider = provider;
- nikonImageObjectReceiver = new NikonImageObjectReceiver(provider);
- this.fullImageReceiver = new NikonFullImageReceiver(activity, provider.getCommandPublisher());
- //this.smallImageReciever = new NikonSmallImageReceiver(activity, provider.getCommandPublisher());
-
try
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
- //raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
use_screennail_image = preferences.getBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
+
+ try
+ {
+ delayMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT, IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT_DEFAULT_VALUE));
+ }
+ catch (Exception ee)
+ {
+ delayMs = 50;
+ ee.printStackTrace();
+ }
}
catch (Exception e)
{
e.printStackTrace();
}
+
+ this.activity = activity;
+ this.provider = provider;
+ nikonImageObjectReceiver = new NikonImageObjectReceiver(provider, delayMs);
+ this.fullImageReceiver = new NikonFullImageReceiver(provider.getCommandPublisher(), delayMs);
+ this.smallImageReciever = new NikonSmallImageReceiver(provider.getCommandPublisher(), delayMs);
+
}
@Override
public String getRawFileSuffix()
{
- //return (raw_suffix);
return ("NEF");
}
}
// 画像を取得する
- publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, 75, false, 0, 0x90c4, 4, objectId, 0, 0, 0));
+ publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, delayMs, false, 0, 0x90c4, 4, objectId, 0, 0, 0));
}
}
catch (Exception e)
}
// Log.v(TAG, "downloadContentThumbnail() " + indexStr + " [" + objectId + "] (" + storageId + ")");
- publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, 75, false, 0, 0x100a, 4, objectId, 0, 0, 0)); // getThumb
+ publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, delayMs, false, 0, 0x100a, 4, objectId, 0, 0, 0)); // getThumb
}
}
catch (Exception e)
if (isSmallSize)
{
// スモールサイズの画像取得コマンド(シーケンス)を発行する
- //smallImageReciever.issueCommand(content.getObjectId(), callback);
- fullImageReceiver.issueCommand(content.getObjectId(), content.getOriginalSize(), callback);
+ smallImageReciever.issueCommand(content.getObjectId(), callback);
+ //fullImageReceiver.issueCommand(content.getObjectId(), content.getOriginalSize(), callback);
}
else
{
package net.osdn.gokigen.pkremote.camera.vendor.nikon.wrapper.playback;
-import android.app.Activity;
import android.util.Log;
import androidx.annotation.NonNull;
{
private static final String TAG = NikonFullImageReceiver.class.getSimpleName();
- private final Activity activity;
private final IPtpIpCommandPublisher publisher;
private IDownloadContentCallback callback = null;
private int target_image_size = 0;
private boolean receivedFirstData = false;
+ private int delayMs;
- NikonSmallImageReceiver(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
+ NikonSmallImageReceiver(@NonNull IPtpIpCommandPublisher publisher, int delayMs)
{
- this.activity = activity;
this.publisher = publisher;
+ this.delayMs = delayMs;
}
void issueCommand(int objectId, IDownloadContentCallback callback)
this.receivedFirstData = false;
//Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
//publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x101b, 12, objectId, 0, imageSize)); // GetPartialObject 0x101b
- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x90c4, 4, objectId, 0, 0, 0)); // GetLargeThumb
+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, delayMs, true, 0, 0x90c4, 4, objectId, 0, 0, 0)); // GetLargeThumb
}
@Override
private boolean isDumpLog = false;
private int subDirectoryCount = 0;
private int receivedDirectoryCount = 0;
+ private int delayMs;
private boolean isObjectReceived = false;
private SparseArray<NikonImageContentInfo> imageObjectList;
- NikonStorageContentHolder(@NonNull NikonInterfaceProvider provider, int storageId, @NonNull ImageObjectReceivedCallback callback)
+ NikonStorageContentHolder(@NonNull NikonInterfaceProvider provider, int storageId, @NonNull ImageObjectReceivedCallback callback, int delayMs)
{
this.provider = provider;
this.storageId = storageId;
this.callback = callback;
+ this.delayMs = delayMs;
this.imageObjectList = new SparseArray<>();
}
{
isObjectReceived = false;
IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff, 0));
+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff, 0));
imageObjectList.clear();
}
catch (Exception e)
for (int subDirectory : directoriesList)
{
Log.v(TAG, " STORAGE ID : " + storageId + " DIRECTORY ID : " + subDirectory);
- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0)); //
+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0)); //
}
return;
}
public boolean isReceiveMulti() {
return false;
}
- }, GET_STORAGE_HANDLE3, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0));
+ }, GET_STORAGE_HANDLE3, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0));
/*
// ストレージ名称。。。ここでは利用できない
String NIKON_CAMERA_IP_ADDRESS = "nikon_host_ip";
String NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE = "192.168.1.1";
+ String NIKON_RECEIVE_WAIT = "nikon_receive_wait";
+ String NIKON_RECEIVE_WAIT_DEFAULT_VALUE = "50";
+
+
/*
//String GR2_DISPLAY_MODE = "gr2_display_mode";
//String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
if (!items.containsKey(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS)) {
editor.putString(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS, IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT)) {
+ editor.putString(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT, IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT_DEFAULT_VALUE);
+ }
if (!items.containsKey(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL)) {
editor.putBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
}
<string name="pref_wifi_settings">WiFi設定</string>
<string name="pref_summary_wifi_settings"> </string>
+ <string name="pref_nikon_receive_wait">応答受信待ち時間</string>
+ <string name="pref_summary_nikon_receive_wait">カメラからの応答待ち時間(単位:ms)</string>
+
</resources>
<string name="pref_wifi_settings">WIFI Settings</string>
<string name="pref_summary_wifi_settings"> </string>
+ <string name="pref_nikon_receive_wait">Receive reply wait(ms)</string>
+ <string name="pref_summary_nikon_receive_wait"> </string>
+
</resources>
android:title="@string/pref_nikon_host_ip"
android:defaultValue="192.168.1.1"
android:summary="@string/pref_summary_nikon_host_ip" />
+
+ <EditTextPreference
+ android:key="nikon_receive_wait"
+ android:title="@string/pref_nikon_receive_wait"
+ android:defaultValue="50"
+ android:summary="@string/pref_summary_nikon_receive_wait" />
+
<!--
<CheckBoxPreference
android:key="ble_wifi_on"