OSDN Git Service

NIKON対応途中。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / camera / nikon / operation / NikonCaptureControl.java
1 package net.osdn.gokigen.a01d.camera.nikon.operation;
2
3 import android.util.Log;
4
5 import androidx.annotation.NonNull;
6
7 import net.osdn.gokigen.a01d.camera.ICaptureControl;
8 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
9 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
10 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
11 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
12
13 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.REQUEST_SHUTTER_ON;
14 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_DEVICE_READY;
15 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_GET_EVENT;
16
17 public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallback
18 {
19     private final String TAG = this.toString();
20     private final PtpIpCommandPublisher commandPublisher;
21     //private final IAutoFocusFrameDisplay frameDisplayer;
22     private boolean isDumpLog = true;
23
24     public NikonCaptureControl(@NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer)
25     {
26         this.commandPublisher = commandPublisher;
27         //this.frameDisplayer = frameDisplayer;
28     }
29
30     @Override
31     public void doCapture(int kind)
32     {
33         try
34         {
35             // シャッター
36             Log.v(TAG, " doCapture() ");
37
38             // シャッターを切る
39             commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, REQUEST_SHUTTER_ON, isDumpLog, 0, 0x9207, 8, 0xffffffff, 0x00));
40             commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, isDumpLog, 0, 0x90c8));
41             commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT, isDumpLog, 0, 0x90c7));
42         }
43         catch (Exception e)
44         {
45             e.printStackTrace();
46         }
47     }
48
49     @Override
50     public void receivedMessage(int id, byte[] rx_body)
51     {
52         Log.v(TAG, " CanonCaptureControl::receivedMessage() : ");
53         try
54         {
55             if ((rx_body.length > 10)&&((rx_body[8] != (byte) 0x01)||(rx_body[9] != (byte) 0x20)))
56             {
57                 Log.v(TAG, " --- RECEIVED NG REPLY. : " + id);
58             }
59         }
60         catch (Exception e)
61         {
62             e.printStackTrace();
63         }
64     }
65
66     @Override
67     public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
68     {
69         Log.v(TAG, " CanonCaptureControl::onReceiveProgress() : " + currentBytes + "/" + totalBytes);
70     }
71
72     @Override
73     public boolean isReceiveMulti()
74     {
75         return (false);
76     }
77
78 }