CHDK_DE Vorschauversion  Trunk Rev. 5648
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
remotecap.c-Dateireferenz
#include "ptp.h"
#include "stdlib.h"
#include "platform.h"
#include "conf.h"
#include "remotecap_core.h"
#include "module_load.h"
#include "modules.h"
#include "raw.h"
#include "cachebit.h"
+ Include-Abhängigkeitsdiagramm für remotecap.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define HOOK_WAIT_MAX_DEFAULT   3000
 

Funktionen

int remotecap_get_target_support (void)
 
int remotecap_get_target (void)
 
void remotecap_set_timeout (int timeout)
 
void remotecap_is_ready (int *available_type, int *file_num)
 
static void remotecap_set_available_data_type (int type)
 
static void remotecap_reset (void)
 
int remotecap_set_target (int type, int lstart, int lcount)
 
int remotecap_using_dng_module (void)
 
static int remotecap_wait (int datatype)
 
static void remotecap_type_complete (int type)
 
void filewrite_set_discard_file (int state)
 
int filewrite_get_file_chunk (char **addr, unsigned *size, unsigned n, int *pos)
 
void remotecap_raw_available (char *rawadr)
 
int remotecap_get_data_chunk (int fmt, char **addr, unsigned int *size, int *pos)
 
int remotecap_send_complete (int rcgd_status, int type)
 

Variablen

static int hook_wait_max =HOOK_WAIT_MAX_DEFAULT
 
static int available_image_data =0
 
static int pending_image_data =0
 
static int remote_file_target =0
 
static int target_file_num
 
static ptp_data_chunk raw_chunk
 
static ptp_data_chunk dng_hdr_chunk
 
static int startline =0
 
static int linecount =0
 

Makro-Dokumentation

#define HOOK_WAIT_MAX_DEFAULT   3000

Definiert in Zeile 11 der Datei remotecap.c.

Dokumentation der Funktionen

int filewrite_get_file_chunk ( char **  addr,
unsigned *  size,
unsigned  n,
int *  pos 
)
void filewrite_set_discard_file ( int  state)

Definiert in Zeile 115 der Datei filewrite.c.

115  {
116  ignore_current_write = state;
117 }
int remotecap_get_data_chunk ( int  fmt,
char **  addr,
unsigned int *  size,
int *  pos 
)

Definiert in Zeile 293 der Datei remotecap.c.

294 {
295  int status = REMOTECAP_CHUNK_STATUS_LAST; // default = no more chunks
296  *pos = -1; // default = sequential
297 
298  switch (fmt & remotecap_get_target() & available_image_data)
299  {
300  case PTP_CHDK_CAPTURE_RAW: //raw
301  *addr=(char*)raw_chunk.address;
302  *size=raw_chunk.length;
303  break;
305  case PTP_CHDK_CAPTURE_CRAW: //canon raw
306  case PTP_CHDK_CAPTURE_JPG: //jpeg
307  fwt_last_status = filewrite_get_file_chunk(addr,size,fwt_curr_chunk,pos);
308  fwt_curr_chunk+=1;
309  if(fwt_last_status != REMOTECAP_FWT_CHUNK_STATUS_LAST) {
311  }
312 #ifdef CAM_HAS_CANON_RAW
313  else {
314  fwt_curr_chunk=0;
315  }
316 #endif
317  break;
318 #endif
319  case PTP_CHDK_CAPTURE_DNGHDR: // dng header
320  *addr=(char*)dng_hdr_chunk.address;
321  *size=dng_hdr_chunk.length;
322  break;
323  default:
324  /*
325  * attempting to get an unsupported, unavailable or not requested format
326  * will free all hooks, deactiveate remotecap, and return error status
327  */
328  *addr=NULL;
329  *size=0;
330  }
331  if(*addr == NULL) {
332  remotecap_reset();
334  }
335 
336  return status;
337 }
int remotecap_get_target ( void  )

Definiert in Zeile 51 der Datei remotecap.c.

51  {
52  return remote_file_target;
53 }
int remotecap_get_target_support ( void  )

Definiert in Zeile 40 der Datei remotecap.c.

40  {
42 #ifdef CAM_HAS_FILEWRITETASK_HOOK
43  ret |= PTP_CHDK_CAPTURE_JPG;
44 #ifdef CAM_HAS_CANON_RAW
45  ret |= PTP_CHDK_CAPTURE_CRAW;
46 #endif
47 #endif
48  return ret;
49 }
void remotecap_is_ready ( int *  available_type,
int *  file_num 
)

Definiert in Zeile 67 der Datei remotecap.c.

67  {
68  if ( remotecap_get_target() ) {
69  *available_type = available_image_data;
71  *file_num = target_file_num;
72  } else {
73  *file_num = 0;
74  }
75  }
76  else {
77  *available_type = PTP_CHDK_CAPTURE_NOTSET;
78  *file_num = 0;
79  }
80 }
void remotecap_raw_available ( char *  rawadr)

Definiert in Zeile 169 der Datei remotecap.c.

169  {
170  // get file number as early as possible, before blocking
171  // but don't set until after so it doesn't change value for remotecap_is_ready
172  int next_file_num = get_target_file_num();
173 /*
174 ensure raw hook is blocked until any prevous remotecap shot is finished or times out
175 if prevous times out, remotecap settings will be cleared due to the time out, so no
176 remotecap will be done, although writes will still be skipped
177 wait == 0 timeout shouldn't get hit here unless the script is fiddling with the
178 timeout value, but it ensures that we don't block indefinitely.
179 */
180  int wait = hook_wait_max;
181  while (wait && pending_image_data) {
182  msleep(10);
183  wait--;
184  }
185  if(wait == 0) {
186  remotecap_reset();
187  }
189  target_file_num = next_file_num;
190 // TODO technically this could probably wait until after the raw stuff is done,
191 // provided the actual chunks are transmitted
192 // TODO this should probably just be noop if hook doesn't exist
193 #ifdef CAM_HAS_FILEWRITETASK_HOOK
195  fwt_curr_chunk=0; //needs to be done here
196 #ifdef CAM_HAS_CANON_RAW
198  fwt_expect_file_count = 2;
199  } else {
200  fwt_expect_file_count = 1;
201  }
202 #else
203  fwt_expect_file_count = 1;
204 #endif
205 #endif //CAM_HAS_FILEWRITETASK_HOOK
207  started();
209 
210  if(!remotecap_wait(PTP_CHDK_CAPTURE_DNGHDR)) {
211  remotecap_reset();
212  }
214  remotecap_type_complete(PTP_CHDK_CAPTURE_DNGHDR);
215  finished();
216  }
217 
219  return;
220  }
221 
222  started();
223 
226 
227  if(!remotecap_wait(PTP_CHDK_CAPTURE_RAW)) {
228  remotecap_reset();
229  }
230  remotecap_type_complete(PTP_CHDK_CAPTURE_RAW);
231 
232  finished();
233 }
static void remotecap_reset ( void  )
static

Definiert in Zeile 89 der Datei remotecap.c.

89  {
93  // TODO do we need remotecap_fwt_chunks_done() ?
94 }
int remotecap_send_complete ( int  rcgd_status,
int  type 
)

Definiert in Zeile 339 der Datei remotecap.c.

339  {
340  // timeout or canceled: the data type we were sending is no longer available
341  int timeout_flag = (available_image_data != type);
342  if(rcgd_status == REMOTECAP_CHUNK_STATUS_LAST) {
343  // currently only one data type can be available at a time
345  }
346 #ifdef CAM_FILEWRITETASK_MULTIPASS
347  else if(type == PTP_CHDK_CAPTURE_JPG && fwt_last_status == REMOTECAP_FWT_CHUNK_STATUS_SESS_LAST) {
348  remotecap_fwt_chunks_done(); // make file_chunks NULL, immediately
349  fwt_session_wait = 0;
350  }
351 #endif
352  if((rcgd_status == REMOTECAP_CHUNK_STATUS_ERROR) || timeout_flag) {
353  return 0;
354  }
355  // else more chunks of current type, no action needed
356  return 1;
357 }
static void remotecap_set_available_data_type ( int  type)
static

Definiert in Zeile 83 der Datei remotecap.c.

84 {
85  available_image_data = type;
86 }
int remotecap_set_target ( int  type,
int  lstart,
int  lcount 
)

Definiert in Zeile 97 der Datei remotecap.c.

98 {
99  // fail if invalid / unsupported type requested,
100  // or current mode cannot support requested types
101  if ((type & ~remotecap_get_target_support())
103  || ((type & PTP_CHDK_CAPTURE_RAW) && !is_raw_possible())
104 #ifdef CAM_HAS_CANON_RAW
107 #endif
109  // other drive modes do not work on these cams currently
110  || (shooting_get_drive_mode() != 0)
111 #endif
112  ) {
113  remotecap_reset();
114  return 0;
115  }
116  // clear requested
117  if(type==0) {
118  remotecap_reset();
119  return 1;
120  }
121  // invalid range, return error
122  if(lstart<0 || lstart>CAM_RAW_ROWS-1 || lcount<0 || lcount+lstart>CAM_RAW_ROWS) {
123  remotecap_reset();
124  return 0;
125  }
126  // default lcount = to end of buffer
127  if(lcount == 0) {
128  lcount = CAM_RAW_ROWS - lstart;
129  }
130  remote_file_target=type;
131  startline=lstart;
132  linecount=lcount;
133  return 1;
134 }
void remotecap_set_timeout ( int  timeout)

Definiert in Zeile 58 der Datei remotecap.c.

59 {
60  if(timeout <= 0) {
62  } else {
63  hook_wait_max = timeout/10;
64  }
65 }
static void remotecap_type_complete ( int  type)
static

Definiert in Zeile 162 der Datei remotecap.c.

162  {
164 }
int remotecap_using_dng_module ( void  )

Definiert in Zeile 141 der Datei remotecap.c.

141  {
143 }
static int remotecap_wait ( int  datatype)
static

Definiert in Zeile 149 der Datei remotecap.c.

149  {
150  int wait = hook_wait_max;
151 
153 
154  while (wait && (available_image_data & datatype)) {
155  msleep(10);
156  wait--;
157  }
158  return wait;
159 }

Variablen-Dokumentation

int available_image_data =0
static

Definiert in Zeile 14 der Datei remotecap.c.

ptp_data_chunk dng_hdr_chunk
static

Definiert in Zeile 23 der Datei remotecap.c.

int hook_wait_max =HOOK_WAIT_MAX_DEFAULT
static

Definiert in Zeile 12 der Datei remotecap.c.

int linecount =0
static

Definiert in Zeile 27 der Datei remotecap.c.

int pending_image_data =0
static

Definiert in Zeile 16 der Datei remotecap.c.

ptp_data_chunk raw_chunk
static

Definiert in Zeile 22 der Datei remotecap.c.

int remote_file_target =0
static

Definiert in Zeile 18 der Datei remotecap.c.

int startline =0
static

Definiert in Zeile 26 der Datei remotecap.c.

int target_file_num
static

Definiert in Zeile 20 der Datei remotecap.c.