Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #include "ptpobjinfoparser.h" |
2 | |||
3 | const char* PTPObjInfoParser::acNames[] PROGMEM = |
||
4 | { |
||
5 | msgUndefined, |
||
6 | msgAssociation, |
||
7 | msgScript, |
||
8 | msgExecutable, |
||
9 | msgText, |
||
10 | msgHTML, |
||
11 | msgDPOF, |
||
12 | msgAIFF, |
||
13 | msgWAV, |
||
14 | msgMP3, |
||
15 | msgAVI, |
||
16 | msgMPEG, |
||
17 | msgASF, |
||
18 | msgQT |
||
19 | }; |
||
20 | |||
21 | const char* PTPObjInfoParser::imNames[] PROGMEM = |
||
22 | { |
||
23 | msgUndefined, |
||
24 | msgEXIF_JPEG, |
||
25 | msgTIFF_EP, |
||
26 | msgFlashPix, |
||
27 | msgBMP, |
||
28 | msgCIFF, |
||
29 | msgUndefined_0x3806, |
||
30 | msgGIF, |
||
31 | msgJFIF, |
||
32 | msgPCD, |
||
33 | msgPICT, |
||
34 | msgPNG, |
||
35 | msgUndefined_0x380C, |
||
36 | msgTIFF, |
||
37 | msgTIFF_IT, |
||
38 | msgJP2, |
||
39 | msgJPX, |
||
40 | }; |
||
41 | |||
42 | void PTPObjInfoParser::PrintFormat(uint16_t op) |
||
43 | { |
||
44 | Serial.print(op, HEX); |
||
45 | Serial.print("\t"); |
||
46 | //Notify(msgTab); |
||
47 | |||
48 | if ((((op >> 8) & 0xFF) == 0x30) && ((op & 0xFF) <= (PTP_OFC_QT & 0xFF))) |
||
49 | Notify((char*)pgm_read_word(&acNames[(op & 0xFF)])); |
||
50 | else |
||
51 | if ((((op >> 8) & 0xFF) == 0x38) && ((op & 0xFF) <= (PTP_OFC_JPX & 0xFF))) |
||
52 | Notify((char*)pgm_read_word(&imNames[(op & 0xFF)])); |
||
53 | else |
||
54 | { |
||
55 | switch (op) |
||
56 | { |
||
57 | case MTP_OFC_Undefined_Firmware: |
||
58 | Notify(msgUndefined_Firmware); |
||
59 | break; |
||
60 | case MTP_OFC_Windows_Image_Format: |
||
61 | Notify(msgWindows_Image_Format); |
||
62 | break; |
||
63 | case MTP_OFC_Undefined_Audio: |
||
64 | Notify(msgUndefined_Audio); |
||
65 | break; |
||
66 | case MTP_OFC_WMA: |
||
67 | Notify(msgWMA); |
||
68 | break; |
||
69 | case MTP_OFC_OGG: |
||
70 | Notify(msgOGG); |
||
71 | break; |
||
72 | case MTP_OFC_AAC: |
||
73 | Notify(msgAAC); |
||
74 | break; |
||
75 | case MTP_OFC_Audible: |
||
76 | Notify(msgAudible); |
||
77 | break; |
||
78 | case MTP_OFC_FLAC: |
||
79 | Notify(msgFLAC); |
||
80 | break; |
||
81 | case MTP_OFC_Undefined_Video: |
||
82 | Notify(msgUndefined_Video); |
||
83 | break; |
||
84 | case MTP_OFC_WMV: |
||
85 | Notify(msgWMV); |
||
86 | break; |
||
87 | case MTP_OFC_MP4_Container: |
||
88 | Notify(msgMP4_Container); |
||
89 | break; |
||
90 | case MTP_OFC_MP2: |
||
91 | Notify(msgMP2); |
||
92 | break; |
||
93 | case MTP_OFC_3GP_Container: |
||
94 | Notify(msg3GP_Container); |
||
95 | break; |
||
96 | default: |
||
97 | Notify(PSTR("Vendor defined")); |
||
98 | } |
||
99 | } |
||
100 | Notify(PSTR("\r\n")); |
||
101 | } |
||
102 | |||
103 | void PTPObjInfoParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset) |
||
104 | { |
||
105 | uint16_t cntdn = (uint16_t)len; |
||
106 | uint8_t *p = (uint8_t*)pbuf; |
||
107 | |||
108 | switch (nStage) |
||
109 | { |
||
110 | case 0: |
||
111 | p += 12; |
||
112 | cntdn -= 12; |
||
113 | nStage ++; |
||
114 | case 1: |
||
115 | Notify(PSTR("Storage ID:\t\t")); |
||
116 | theBuffer.valueSize = 4; |
||
117 | valueParser.Initialize(&theBuffer); |
||
118 | nStage ++; |
||
119 | case 2: |
||
120 | if (!valueParser.Parse(&p, &cntdn)) |
||
121 | return; |
||
122 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
123 | nStage ++; |
||
124 | case 3: |
||
125 | Notify(PSTR("\r\nObject Format:\t\t")); |
||
126 | theBuffer.valueSize = 2; |
||
127 | valueParser.Initialize(&theBuffer); |
||
128 | nStage ++; |
||
129 | case 4: |
||
130 | if (!valueParser.Parse(&p, &cntdn)) |
||
131 | return; |
||
132 | PrintFormat(*((uint16_t*)theBuffer.pValue)); |
||
133 | nStage ++; |
||
134 | case 5: |
||
135 | Notify(PSTR("Protection Status:\t")); |
||
136 | theBuffer.valueSize = 2; |
||
137 | valueParser.Initialize(&theBuffer); |
||
138 | nStage ++; |
||
139 | case 6: |
||
140 | if (!valueParser.Parse(&p, &cntdn)) |
||
141 | return; |
||
142 | PrintHex<uint16_t>(*((uint16_t*)theBuffer.pValue)); |
||
143 | nStage ++; |
||
144 | case 7: |
||
145 | Notify(PSTR("\r\nObject Compressed Size:\t")); |
||
146 | theBuffer.valueSize = 4; |
||
147 | valueParser.Initialize(&theBuffer); |
||
148 | nStage ++; |
||
149 | case 8: |
||
150 | if (!valueParser.Parse(&p, &cntdn)) |
||
151 | return; |
||
152 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
153 | nStage ++; |
||
154 | case 9: |
||
155 | Notify(PSTR("\r\nThumb Format:\t\t")); |
||
156 | theBuffer.valueSize = 2; |
||
157 | valueParser.Initialize(&theBuffer); |
||
158 | nStage ++; |
||
159 | case 10: |
||
160 | if (!valueParser.Parse(&p, &cntdn)) |
||
161 | return; |
||
162 | PrintFormat(*((uint16_t*)theBuffer.pValue)); |
||
163 | nStage ++; |
||
164 | case 11: |
||
165 | Notify(PSTR("Thumb Compressed Size:\t")); |
||
166 | theBuffer.valueSize = 4; |
||
167 | valueParser.Initialize(&theBuffer); |
||
168 | nStage ++; |
||
169 | case 12: |
||
170 | if (!valueParser.Parse(&p, &cntdn)) |
||
171 | return; |
||
172 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
173 | nStage ++; |
||
174 | case 13: |
||
175 | Notify(PSTR("\r\nThumb Pix Width:\t")); |
||
176 | theBuffer.valueSize = 4; |
||
177 | valueParser.Initialize(&theBuffer); |
||
178 | nStage ++; |
||
179 | case 14: |
||
180 | if (!valueParser.Parse(&p, &cntdn)) |
||
181 | return; |
||
182 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
183 | nStage ++; |
||
184 | case 15: |
||
185 | Notify(PSTR("\r\nThumb Pix Height:\t")); |
||
186 | theBuffer.valueSize = 4; |
||
187 | valueParser.Initialize(&theBuffer); |
||
188 | nStage ++; |
||
189 | case 16: |
||
190 | if (!valueParser.Parse(&p, &cntdn)) |
||
191 | return; |
||
192 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
193 | nStage ++; |
||
194 | case 17: |
||
195 | Notify(PSTR("\r\nImage Pix Width:\t")); |
||
196 | theBuffer.valueSize = 4; |
||
197 | valueParser.Initialize(&theBuffer); |
||
198 | nStage ++; |
||
199 | case 18: |
||
200 | if (!valueParser.Parse(&p, &cntdn)) |
||
201 | return; |
||
202 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
203 | nStage ++; |
||
204 | case 19: |
||
205 | Notify(PSTR("\r\nImage Pix Height:\t")); |
||
206 | theBuffer.valueSize = 4; |
||
207 | valueParser.Initialize(&theBuffer); |
||
208 | nStage ++; |
||
209 | case 20: |
||
210 | if (!valueParser.Parse(&p, &cntdn)) |
||
211 | return; |
||
212 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
213 | nStage ++; |
||
214 | case 21: |
||
215 | Notify(PSTR("\r\nImage Bit Depth:\t")); |
||
216 | theBuffer.valueSize = 4; |
||
217 | valueParser.Initialize(&theBuffer); |
||
218 | nStage ++; |
||
219 | case 22: |
||
220 | if (!valueParser.Parse(&p, &cntdn)) |
||
221 | return; |
||
222 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
223 | nStage ++; |
||
224 | case 23: |
||
225 | Notify(PSTR("\r\nParent Object:\t\t")); |
||
226 | theBuffer.valueSize = 4; |
||
227 | valueParser.Initialize(&theBuffer); |
||
228 | nStage ++; |
||
229 | case 24: |
||
230 | if (!valueParser.Parse(&p, &cntdn)) |
||
231 | return; |
||
232 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
233 | nStage ++; |
||
234 | case 25: |
||
235 | Notify(PSTR("\r\nAssociation Type:\t")); |
||
236 | theBuffer.valueSize = 2; |
||
237 | valueParser.Initialize(&theBuffer); |
||
238 | nStage ++; |
||
239 | case 26: |
||
240 | if (!valueParser.Parse(&p, &cntdn)) |
||
241 | return; |
||
242 | PrintHex<uint16_t>(*((uint16_t*)theBuffer.pValue)); |
||
243 | nStage ++; |
||
244 | case 27: |
||
245 | Notify(PSTR("\r\nAssociation Desc:\t")); |
||
246 | theBuffer.valueSize = 4; |
||
247 | valueParser.Initialize(&theBuffer); |
||
248 | nStage ++; |
||
249 | case 28: |
||
250 | if (!valueParser.Parse(&p, &cntdn)) |
||
251 | return; |
||
252 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
253 | nStage ++; |
||
254 | case 29: |
||
255 | Notify(PSTR("\r\nSequence Number:\t")); |
||
256 | theBuffer.valueSize = 4; |
||
257 | valueParser.Initialize(&theBuffer); |
||
258 | nStage ++; |
||
259 | case 30: |
||
260 | if (!valueParser.Parse(&p, &cntdn)) |
||
261 | return; |
||
262 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
263 | nStage ++; |
||
264 | case 31: |
||
265 | Notify(PSTR("\r\nFile Name:\t\t")); |
||
266 | arrayParser.Initialize(1, 2, &theBuffer); |
||
267 | nStage ++; |
||
268 | case 32: |
||
269 | if (!arrayParser.Parse(&p, &cntdn, (PTP_ARRAY_EL_FUNC)&PrintChar)) |
||
270 | return; |
||
271 | nStage ++; |
||
272 | case 33: |
||
273 | Notify(PSTR("\r\nCapture Date:\t\t")); |
||
274 | arrayParser.Initialize(1, 2, &theBuffer); |
||
275 | nStage ++; |
||
276 | case 34: |
||
277 | if (!arrayParser.Parse(&p, &cntdn, (PTP_ARRAY_EL_FUNC)&PrintChar)) |
||
278 | return; |
||
279 | nStage ++; |
||
280 | case 35: |
||
281 | Notify(PSTR("\r\nModification Date:\t")); |
||
282 | arrayParser.Initialize(1, 2, &theBuffer); |
||
283 | nStage ++; |
||
284 | case 36: |
||
285 | if (!arrayParser.Parse(&p, &cntdn, (PTP_ARRAY_EL_FUNC)&PrintChar)) |
||
286 | return; |
||
287 | nStage ++; |
||
288 | case 37: |
||
289 | Notify(PSTR("\r\nKeywords:\t")); |
||
290 | arrayParser.Initialize(1, 2, &theBuffer); |
||
291 | nStage ++; |
||
292 | case 38: |
||
293 | if (!arrayParser.Parse(&p, &cntdn, (PTP_ARRAY_EL_FUNC)&PrintChar)) |
||
294 | return; |
||
295 | Notify(PSTR("\r\n")); |
||
296 | nStage = 0; |
||
297 | } |
||
298 | } |