1 package net.osdn.gokigen.a01d.camera.nikon.wrapper;
3 import android.app.Activity;
4 import android.util.Log;
6 import androidx.annotation.NonNull;
8 import net.osdn.gokigen.a01d.IInformationReceiver;
9 import net.osdn.gokigen.a01d.camera.ICameraConnection;
10 import net.osdn.gokigen.a01d.camera.ICameraInformation;
11 import net.osdn.gokigen.a01d.camera.ICameraStatus;
12 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
13 import net.osdn.gokigen.a01d.camera.ICameraStatusWatcher;
14 import net.osdn.gokigen.a01d.camera.ICaptureControl;
15 import net.osdn.gokigen.a01d.camera.IDisplayInjector;
16 import net.osdn.gokigen.a01d.camera.IFocusingControl;
17 import net.osdn.gokigen.a01d.camera.IFocusingModeNotify;
18 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
19 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
20 import net.osdn.gokigen.a01d.camera.nikon.operation.NikonCaptureControl;
21 import net.osdn.gokigen.a01d.camera.nikon.operation.NikonFocusingControl;
22 import net.osdn.gokigen.a01d.camera.nikon.operation.NikonZoomLensControl;
23 import net.osdn.gokigen.a01d.camera.nikon.wrapper.connection.NikonConnection;
24 import net.osdn.gokigen.a01d.camera.nikon.wrapper.hardware.NikonCameraInformation;
25 import net.osdn.gokigen.a01d.camera.nikon.wrapper.liveview.NikonLiveViewControl;
26 import net.osdn.gokigen.a01d.camera.nikon.wrapper.status.NikonStatusChecker;
27 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
28 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
29 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
30 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
31 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpAsyncResponseReceiver;
32 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
33 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.IPtpIpRunModeHolder;
34 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpRunMode;
35 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
36 import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
37 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
38 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
40 public class NikonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplayInjector
42 private final String TAG = toString();
44 private static final int ASYNC_RESPONSE_PORT = 15741;
45 private static final int CONTROL_PORT = 15740;
46 private static final int EVENT_PORT = 15740;
47 private static final String CAMERA_IP = "192.168.1.1";
49 private final Activity activity;
50 private final PtpIpRunMode runmode;
51 private final NikonCameraInformation cameraInformation;
52 private NikonCaptureControl captureControl;
53 private NikonFocusingControl focusingControl;
54 private NikonConnection canonConnection;
55 private PtpIpCommandPublisher commandPublisher;
56 private NikonLiveViewControl liveViewControl;
57 private PtpIpAsyncResponseReceiver asyncReceiver;
58 private NikonZoomLensControl zoomControl;
59 private NikonStatusChecker statusChecker;
60 private ICameraStatusUpdateNotify statusListener;
61 private IInformationReceiver informationReceiver;
63 public NikonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
65 this.activity = context;
66 commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
67 liveViewControl = new NikonLiveViewControl(context, this, 20);
68 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
69 statusChecker = new NikonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
70 canonConnection = new NikonConnection(context, provider, this, statusChecker);
71 cameraInformation = new NikonCameraInformation();
72 zoomControl = new NikonZoomLensControl();
73 this.statusListener = statusListener;
74 this.runmode = new PtpIpRunMode();
75 this.informationReceiver = informationReceiver;
79 public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
81 Log.v(TAG, "injectDisplay()");
82 captureControl = new NikonCaptureControl(commandPublisher, frameDisplayer);
83 focusingControl = new NikonFocusingControl(activity, commandPublisher, frameDisplayer, indicator);
87 public ICameraConnection getCameraConnection()
89 return (canonConnection);
93 public ILiveViewControl getLiveViewControl()
95 return (liveViewControl);
99 public ILiveViewListener getLiveViewListener()
101 return (liveViewControl.getLiveViewListener());
105 public IFocusingControl getFocusingControl()
107 return (focusingControl);
111 public ICameraInformation getCameraInformation()
113 return (cameraInformation);
117 public IZoomLensControl getZoomLensControl()
119 return (zoomControl);
123 public ICaptureControl getCaptureControl()
125 return (captureControl);
129 public IDisplayInjector getDisplayInjector()
135 public IPtpIpRunModeHolder getRunModeHolder()
141 public IPtpIpCommandCallback getStatusHolder() {
142 return (statusChecker);
146 public IPtpIpCommandPublisher getCommandPublisher()
148 return (commandPublisher);
152 public IPtpIpCommunication getLiveviewCommunication()
154 return (liveViewControl);
158 public IPtpIpCommunication getAsyncEventCommunication()
160 return (asyncReceiver);
164 public IPtpIpCommunication getCommandCommunication()
166 return (commandPublisher);
170 public ICameraStatusWatcher getCameraStatusWatcher()
172 return (statusChecker);
176 public ICameraStatusUpdateNotify getStatusListener()
178 return (statusListener);
182 public ICameraStatus getCameraStatusListHolder()
184 return (statusChecker);
188 public IInformationReceiver getInformationReceiver()
190 // ちょっとこの引き回しは気持ちがよくない...
191 return (informationReceiver);
195 public ICameraStatusWatcher getStatusWatcher()
197 return (statusChecker);
201 public void setAsyncEventReceiver(@NonNull IPtpIpCommandCallback receiver)
203 asyncReceiver.setEventSubscriber(receiver);