1 package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.playback;
3 import android.util.Log;
5 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
7 import java.util.Arrays;
9 import java.util.TimeZone;
11 public class CanonImageContentInfo implements ICameraContent
13 private final String TAG = toString();
14 private final int indexNumber;
15 private final String contentPath;
16 private boolean isDateValid;
18 private final byte[] rx_body;
20 public CanonImageContentInfo(int indexNumber, String contentPath, byte[] binaryData, int offset, int length)
22 this.indexNumber = indexNumber;
23 this.contentPath = contentPath;
24 this.rx_body = Arrays.copyOfRange(binaryData, offset, offset + length);
28 if (rx_body.length >= 0x33)
30 long objectDate = (rx_body[0x30] & 0xff) + ((rx_body[0x31] & 0xff) << 8);
31 objectDate = objectDate + ((rx_body[0x32] & 0xff) << 16) + ((rx_body[0x33] & 0xff) << 24);
33 // UTC から 端末のタイムゾーンに変換する(オフセット時間をとる)
34 TimeZone tz = TimeZone.getDefault();
35 Date now = new Date();
36 long offsetFromUtc = tz.getOffset(now.getTime());
38 date = new Date(objectDate * 1000 - offsetFromUtc);
49 Log.v(TAG, " > CONTENT : " + date + " ");
53 public String getCameraId()
59 public String getCardId()
65 public String getContentPath()
71 public String getContentName()
75 if (rx_body.length > 0x20)
77 int copySize = (rx_body.length < (0x20 + 8 + 3)) ? rx_body.length : (0x20 + 8 + 1 + 3);
78 byte[] fileNameArray = Arrays.copyOfRange(rx_body, 0x20, copySize);
79 return (new String(fileNameArray));
86 Log.v(TAG, " > File Name : " + indexNumber + ".JPG");
87 return ("" + indexNumber + ".JPG");
91 public String getOriginalName()
93 return (getContentName());
97 public boolean isRaw()
101 String target = getContentName().toLowerCase();
102 return ((target.endsWith("crw")) || (target.endsWith("cr2")) || (target.endsWith("cr3")));
112 public boolean isMovie()
116 String target = getContentName().toLowerCase();
117 return ((target.endsWith("mov")) || (target.endsWith("mp4")));
127 public boolean isDateValid()
129 return (isDateValid);
133 public boolean isContentNameValid()
139 public Date getCapturedDate()
145 public void setCapturedDate(Date date)
160 return (indexNumber);
163 public int getOriginalSize()
167 return((rx_body[0x14] & 0xff) + ((rx_body[0x15] & 0xff) << 8) +
168 ((rx_body[0x16] & 0xff) << 16) + ((rx_body[0x17] & 0xff) << 24));
182 return ((rx_body[4] & 0xff) + ((rx_body[5] & 0xff) << 8) +
183 ((rx_body[6] & 0xff) << 16) + ((rx_body[7] & 0xff) << 24));