Log.v(TAG, "--- RECEIVE AGAIN --- [" + length + "(" + read_bytes + ") " + byte_array[4]+ "] ");
}
sleep(delayMs);
+ int availableReadBytes = is.available();
+ if (availableReadBytes <= 0)
+ {
+ // 読めるデータ数がない...よみだし終了にする。
+ Log.v(TAG, " is.availableReadBytes() : " + availableReadBytes);
+ break;
+ }
int read_bytes2 = is.read(byte_array, read_bytes, receive_message_buffer_size - read_bytes);
if (read_bytes2 > 0)
{
Log.v(TAG, "receive_from_camera() : " + read_bytes + " bytes.");
dump_bytes("RECV[" + receive_body.length + "] ", receive_body);
}
- if (callback != null)
+ if (callback != null)
{
if (callback.isReceiveMulti())
{
package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.playback;
import android.app.Activity;
-import android.graphics.BitmapFactory;
-import android.util.Log;
+import android.content.SharedPreferences;
+
+import androidx.preference.PreferenceManager;
-import net.osdn.gokigen.pkremote.R;
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.IDownloadThumbnailImageCallback;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.PtpIpInterfaceProvider;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandPublisher;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
/**
*
private final String TAG = toString();
private final Activity activity;
private final PtpIpInterfaceProvider provider;
- //private List<ICameraContent> imageInfo;
- //private SparseArray<PtpIpImageContentInfo> imageContentInfo;
- //private int indexNumber = 0;
- //private ICameraContentListCallback finishedCallback = null;
+ private String raw_suffix = "CR2";
private CanonImageObjectReceiver canonImageObjectReceiver;
public PtpIpPlaybackControl(Activity activity, PtpIpInterfaceProvider provider)
this.activity = activity;
this.provider = provider;
canonImageObjectReceiver = new CanonImageObjectReceiver(provider);
- //this.imageContentInfo = new SparseArray<>();
+
+ try
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+ raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
@Override
public String getRawFileSuffix()
{
- return (null);
+ return (raw_suffix);
}
@Override
// Log.v(TAG, "downloadContentThumbnail() " + indexStr + " [" + objectId + "] (" + storageId + ")");
publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), false, objectId, 0x910a, 8, objectId, 0x00032000));
}
-/*
- int index = Integer.parseInt(indexStr);
- if ((index > 0)&&(index <= imageContentInfo.size()))
- {
- IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
- PtpIpImageContentInfo contentInfo = imageContentInfo.get(index);
- if (!contentInfo.isReceived())
- {
- publisher.enqueueCommand(new GetImageInfo(index, index, contentInfo));
- }
- publisher.enqueueCommand(new GetThumbNail(index, new PtpIpThumbnailImageReceiver(activity, callback)));
- }
- */
}
catch (Exception e)
{
import androidx.annotation.NonNull;
-import net.osdn.gokigen.pkremote.R;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
-import net.osdn.gokigen.pkremote.camera.utils.SimpleLogDumper;
import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
-import java.io.ByteArrayInputStream;
import java.util.Arrays;
public class PtpIpThumbnailImageReceiver implements IPtpIpCommandCallback
{
try
{
- /////// 受信データから、先頭(0xff 0xd8)を検索 /////
//Log.v(TAG, " RECV THUMBNAIL START : " + id + " [" + rx_body.length + "] ");
//SimpleLogDumper.dump_bytes("[THUMB]", rx_body);
//Log.v(TAG, " RECV THUMBNAIL END : " + id + " [" + rx_body.length + "] ");
+ /////// 受信データから、サムネイルの先頭(0xff 0xd8)を検索する /////
int offset = rx_body.length - 22;
//byte[] thumbnail0 = Arrays.copyOfRange(rx_body, 0, rx_body.length);
while (offset > 32)
}
offset--;
}
- if (rx_body.length > offset)
- {
- byte[] thumbnail = Arrays.copyOfRange(rx_body, offset, rx_body.length - 22);
- callback.onCompleted(BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length), null);
-
- //callback.onCompleted(BitmapFactory.decodeByteArray(rx_body, 0, rx_body.length), null);
- //callback.onCompleted(BitmapFactory.decodeByteArray(rx_body, offset, rx_body.length - offset - 22), null);
- //callback.onCompleted(BitmapFactory.decodeStream(new ByteArrayInputStream(rx_body, offset, rx_body.length)), null);
- //callback.onCompleted(BitmapFactory.decodeStream(new ByteArrayInputStream(rx_body, 0, rx_body.length)), null);
- }
- else
- {
- Log.v(TAG, "BITMAP IS NONE... : " + rx_body.length);
- callback.onCompleted(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_broken_image_black_24dp), null);
- }
+ byte[] thumbnail = Arrays.copyOfRange(rx_body, offset, rx_body.length - 22);
+ callback.onCompleted(BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length), null);
}
catch (Exception e)
{
String USE_SMARTPHONE_TRANSFER_MODE = "use_smartphone_transfer_mode";
+ String CANON_RAW_SUFFIX = "canon_raw_suffix";
+ String CANON_RAW_SUFFIX_DEFAULT_VALUE = "CR2";
+
/*
//String GR2_DISPLAY_MODE = "gr2_display_mode";
//String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
package net.osdn.gokigen.pkremote.preference.canon;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.util.Map;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.FragmentActivity;
-import androidx.preference.CheckBoxPreference;
-import androidx.preference.ListPreference;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceFragmentCompat;
-import androidx.preference.PreferenceManager;
-
-import net.osdn.gokigen.pkremote.R;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.operation.PtpIpCameraPowerOff;
-import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
-import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
-import net.osdn.gokigen.pkremote.scene.IChangeScene;
+ import android.content.Context;
+ import android.content.SharedPreferences;
+ import android.os.Bundle;
+ import android.util.Log;
+
+ import java.util.Map;
+
+ import androidx.annotation.NonNull;
+ import androidx.appcompat.app.AppCompatActivity;
+ import androidx.fragment.app.FragmentActivity;
+ import androidx.preference.CheckBoxPreference;
+ import androidx.preference.ListPreference;
+ import androidx.preference.Preference;
+ import androidx.preference.PreferenceFragmentCompat;
+ import androidx.preference.PreferenceManager;
+
+ import net.osdn.gokigen.pkremote.R;
+ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.operation.PtpIpCameraPowerOff;
+ import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
+ import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
+ import net.osdn.gokigen.pkremote.scene.IChangeScene;
/**
*
if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.CANON_RAW_SUFFIX)) {
+ editor.putString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
+ }
editor.apply();
}
catch (Exception e)
try
{
//super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences_fuji_x);
+ addPreferencesFromResource(R.xml.preferences_canon);
ListPreference connectionMethod = (ListPreference) findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
- }
+ }
catch (Exception e)
{
e.printStackTrace();
<string name="pref_sony_use_smartphone_transfer">スマートフォン転送モードを使う</string>
<string name="pref_summary_sony_use_smartphone_transfer">うまく通信できない場合にチェックを入れてください。</string>
+ <string name="pref_canon_raw_suffix">RAW拡張子</string>
+ <string name="pref_summary_canon_raw_suffix">カメラのRAW拡張子を設定してください。</string>
+
<string name="connect_start_2">準備中…</string>
<string name="canon_connect_connecting1">接続中…(1/5)</string>
<string name="canon_connect_connecting2">接続中…(2/5)</string>
<string name="pref_sony_use_smartphone_transfer">Do use SmartPhone transfer mode.</string>
<string name="pref_summary_sony_use_smartphone_transfer">If you cannot communicate, please check this.</string>
+ <string name="pref_canon_raw_suffix">RAW Suffix</string>
+ <string name="pref_summary_canon_raw_suffix">Please set your camera RAW suffix.</string>
+
<string name="connect_start_2">Preparing…</string>
<string name="canon_connect_connecting1">Connecting…(1/5)</string>
<string name="canon_connect_connecting2">Connecting…(2/5)</string>
<PreferenceCategory
android:title="@string/pref_cat_camera">
+
+ <EditTextPreference
+ android:key="canon_raw_suffix"
+ android:title="@string/pref_canon_raw_suffix"
+ android:defaultValue="CR2"
+ android:inputType="number"
+ android:summary="@string/pref_summary_canon_raw_suffix" />
+
<!--
<PreferenceScreen