1 package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper;
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.util.Log;
7 import androidx.annotation.NonNull;
8 import androidx.preference.PreferenceManager;
10 import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
11 import net.osdn.gokigen.gr2control.camera.ICameraConnection;
12 import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
13 import net.osdn.gokigen.gr2control.camera.ICameraInformation;
14 import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
15 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
16 import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
17 import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
18 import net.osdn.gokigen.gr2control.camera.ICaptureControl;
19 import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
20 import net.osdn.gokigen.gr2control.camera.IFocusingControl;
21 import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
22 import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
23 import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
24 import net.osdn.gokigen.gr2control.camera.fuji_x.IFujiXInterfaceProvider;
25 import net.osdn.gokigen.gr2control.camera.fuji_x.operation.FujiXButtonControl;
26 import net.osdn.gokigen.gr2control.camera.fuji_x.operation.FujiXCaptureControl;
27 import net.osdn.gokigen.gr2control.camera.fuji_x.operation.FujiXFocusingControl;
28 import net.osdn.gokigen.gr2control.camera.fuji_x.operation.FujiXHardwareStatus;
29 import net.osdn.gokigen.gr2control.camera.fuji_x.operation.FujiXZoomControl;
30 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.FujiXAsyncResponseReceiver;
31 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.FujiXCommandPublisher;
32 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
33 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
34 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommunication;
35 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.connection.FujiXConnection;
36 import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
37 import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
38 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
39 import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
40 import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
41 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
43 public class FujiXInterfaceProvider implements IFujiXInterfaceProvider, IDisplayInjector
45 private final String TAG = toString();
47 private static final int STREAM_PORT = 55742;
48 private static final int ASYNC_RESPONSE_PORT = 55741;
49 private static final int CONTROL_PORT = 55740;
50 private static final String CAMERA_IP = "192.168.0.1";
52 private final Activity activity;
53 //private final ICameraStatusReceiver provider;
54 private final FujiXCommandPublisher commandPublisher;
55 private final FujiXLiveViewControl liveViewControl;
56 private final FujiXAsyncResponseReceiver asyncReceiver;
57 private final FujiXConnection fujiXConnection;
59 private final FujiXButtonControl buttonControl;
60 private final FujiXStatusChecker statusChecker;
61 private final FujiXPlaybackControl playbackControl;
62 private final FujiXHardwareStatus hardwareStatus;
63 private final FujiXRunMode runMode;
64 private final FujiXZoomControl zoomControl;
66 private FujiXCaptureControl captureControl = null;
67 private FujiXFocusingControl focusControl = null;
73 public FujiXInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
75 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
76 int communicationTimeoutMs = 5000; // デフォルトは 5000ms とする
79 communicationTimeoutMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE)) * 1000;
80 if (communicationTimeoutMs < 5000)
82 communicationTimeoutMs = 5000; // 最小値は 5000msとする。
89 this.activity = context;
90 //this.provider = provider;
91 this.commandPublisher = new FujiXCommandPublisher(CAMERA_IP, CONTROL_PORT);
92 fujiXConnection = new FujiXConnection(context, provider, this);
93 liveViewControl = new FujiXLiveViewControl(context, CAMERA_IP, STREAM_PORT);
94 asyncReceiver = new FujiXAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
95 zoomControl = new FujiXZoomControl();
96 buttonControl = new FujiXButtonControl();
97 statusChecker = new FujiXStatusChecker(context, commandPublisher);
98 playbackControl = new FujiXPlaybackControl(communicationTimeoutMs);
99 hardwareStatus = new FujiXHardwareStatus();
100 runMode = new FujiXRunMode();
103 public void prepare()
105 Log.v(TAG, "prepare()");
109 public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
111 Log.v(TAG, "injectDisplay()");
112 focusControl = new FujiXFocusingControl(activity, commandPublisher, frameDisplayer, indicator);
113 captureControl = new FujiXCaptureControl(commandPublisher, frameDisplayer);
117 public ICameraConnection getCameraConnection()
119 return (fujiXConnection);
123 public ILiveViewControl getLiveViewControl()
125 return (liveViewControl);
129 public ILiveViewListener getLiveViewListener()
131 if (liveViewControl == null)
135 return (liveViewControl.getLiveViewListener());
139 public IFocusingControl getFocusingControl()
141 return (focusControl);
145 public ICameraInformation getCameraInformation()
151 public IZoomLensControl getZoomLensControl()
153 return (zoomControl);
157 public ICaptureControl getCaptureControl()
159 return (captureControl);
163 public IDisplayInjector getDisplayInjector()
169 public ICameraStatus getCameraStatusListHolder()
171 return (statusChecker);
175 public ICameraButtonControl getButtonControl()
177 return (buttonControl);
181 public ICameraStatusWatcher getCameraStatusWatcher()
183 return (statusChecker);
187 public IPlaybackControl getPlaybackControl()
189 return (playbackControl);
193 public ICameraHardwareStatus getHardwareStatus()
195 return (hardwareStatus);
199 public ICameraRunMode getCameraRunMode()
205 public IFujiXCommunication getLiveviewCommunication() {
206 return (liveViewControl);
210 public IFujiXCommunication getAsyncEventCommunication() {
211 return (asyncReceiver);
215 public IFujiXCommunication getCommandCommunication()
217 return (commandPublisher);
221 public ICameraStatusUpdateNotify getStatusListener()
223 return statusChecker.getStatusListener();
227 public IFujiXCommandPublisher getCommandPublisher()
229 return (commandPublisher);
233 public void setAsyncEventReceiver(@NonNull IFujiXCommandCallback receiver)
235 asyncReceiver.setEventSubscriber(receiver);