1 package net.osdn.gokigen.a01d.camera.canon.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.canon.operation.CanonCaptureControl;
21 import net.osdn.gokigen.a01d.camera.canon.operation.CanonFocusingControl;
22 import net.osdn.gokigen.a01d.camera.canon.wrapper.connection.CanonConnection;
23 import net.osdn.gokigen.a01d.camera.canon.operation.CanonZoomLensControl;
24 import net.osdn.gokigen.a01d.camera.canon.wrapper.hardware.CanonCameraInformation;
25 import net.osdn.gokigen.a01d.camera.canon.wrapper.liveview.CanonLiveViewControl;
26 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
27 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
28 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
29 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
30 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpAsyncResponseReceiver;
31 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
32 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.IPtpIpRunModeHolder;
33 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpRunMode;
34 import net.osdn.gokigen.a01d.camera.canon.wrapper.status.CanonStatusChecker;
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 CanonInterfaceProvider 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.0.1";
49 private final Activity activity;
50 private final PtpIpRunMode runmode;
51 private final CanonCameraInformation cameraInformation;
52 private CanonCaptureControl captureControl;
53 private CanonFocusingControl focusingControl;
54 private CanonConnection canonConnection;
55 private PtpIpCommandPublisher commandPublisher;
56 private CanonLiveViewControl liveViewControl;
57 private PtpIpAsyncResponseReceiver asyncReceiver;
58 private CanonZoomLensControl zoomControl;
59 private CanonStatusChecker statusChecker;
60 private ICameraStatusUpdateNotify statusListener;
61 private IInformationReceiver informationReceiver;
63 public CanonInterfaceProvider(@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 CanonLiveViewControl(context, this, 10); //
68 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
69 statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT);
70 canonConnection = new CanonConnection(context, provider, this, statusChecker);
71 cameraInformation = new CanonCameraInformation();
72 zoomControl = new CanonZoomLensControl(context, commandPublisher);
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 CanonCaptureControl(commandPublisher, frameDisplayer);
83 focusingControl = new CanonFocusingControl(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);