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.fuji_x.wrapper.playback.FujiXPlaybackControl;
37 import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
38 import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
39 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
40 import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
41 import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
42 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
44 public class FujiXInterfaceProvider implements IFujiXInterfaceProvider, IDisplayInjector
46 private final String TAG = toString();
48 private static final int STREAM_PORT = 55742;
49 private static final int ASYNC_RESPONSE_PORT = 55741;
50 private static final int CONTROL_PORT = 55740;
51 private static final String CAMERA_IP = "192.168.0.1";
53 private final Activity activity;
54 //private final ICameraStatusReceiver provider;
55 private final FujiXCommandPublisher commandPublisher;
56 private final FujiXLiveViewControl liveViewControl;
57 private final FujiXAsyncResponseReceiver asyncReceiver;
58 private final FujiXConnection fujiXConnection;
60 private final FujiXButtonControl buttonControl;
61 private final FujiXStatusChecker statusChecker;
62 private final FujiXPlaybackControl playbackControl;
63 private final FujiXHardwareStatus hardwareStatus;
64 private final FujiXRunMode runMode;
65 private final FujiXZoomControl zoomControl;
67 private FujiXCaptureControl captureControl = null;
68 private FujiXFocusingControl focusControl = null;
74 public FujiXInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
76 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
77 int communicationTimeoutMs;
80 communicationTimeoutMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE)) * 1000;
81 if (communicationTimeoutMs < 5000)
83 communicationTimeoutMs = 5000; // 最小値は 5000msとする。
90 this.activity = context;
91 //this.provider = provider;
92 this.commandPublisher = new FujiXCommandPublisher(CAMERA_IP, CONTROL_PORT);
93 fujiXConnection = new FujiXConnection(context, provider, this);
94 liveViewControl = new FujiXLiveViewControl(context, CAMERA_IP, STREAM_PORT);
95 asyncReceiver = new FujiXAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
96 zoomControl = new FujiXZoomControl();
97 buttonControl = new FujiXButtonControl();
98 statusChecker = new FujiXStatusChecker(context, commandPublisher);
99 playbackControl = new FujiXPlaybackControl(context, this);
100 hardwareStatus = new FujiXHardwareStatus();
101 runMode = new FujiXRunMode(this, statusChecker);
104 public void prepare()
106 Log.v(TAG, "prepare()");
110 public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
112 Log.v(TAG, "injectDisplay()");
113 focusControl = new FujiXFocusingControl(activity, commandPublisher, frameDisplayer, indicator);
114 captureControl = new FujiXCaptureControl(commandPublisher, frameDisplayer);
118 public ICameraConnection getCameraConnection()
120 return (fujiXConnection);
124 public ILiveViewControl getLiveViewControl()
126 return (liveViewControl);
130 public ILiveViewListener getLiveViewListener()
132 if (liveViewControl == null)
136 return (liveViewControl.getLiveViewListener());
140 public IFocusingControl getFocusingControl()
142 return (focusControl);
146 public ICameraInformation getCameraInformation()
152 public IZoomLensControl getZoomLensControl()
154 return (zoomControl);
158 public ICaptureControl getCaptureControl()
160 return (captureControl);
164 public IDisplayInjector getDisplayInjector()
170 public ICameraStatus getCameraStatusListHolder()
172 return (statusChecker);
176 public ICameraButtonControl getButtonControl()
178 return (buttonControl);
182 public ICameraStatusWatcher getCameraStatusWatcher()
184 return (statusChecker);
188 public IPlaybackControl getPlaybackControl()
190 return (playbackControl);
194 public ICameraHardwareStatus getHardwareStatus()
196 return (hardwareStatus);
200 public ICameraRunMode getCameraRunMode()
206 public IFujiXCommunication getLiveviewCommunication() {
207 return (liveViewControl);
211 public IFujiXCommunication getAsyncEventCommunication() {
212 return (asyncReceiver);
216 public IFujiXCommunication getCommandCommunication()
218 return (commandPublisher);
222 public ICameraStatusUpdateNotify getStatusListener()
224 return statusChecker.getStatusListener();
228 public IFujiXCommandPublisher getCommandPublisher()
230 return (commandPublisher);
234 public void setAsyncEventReceiver(@NonNull IFujiXCommandCallback receiver)
236 asyncReceiver.setEventSubscriber(receiver);