CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
remotecap.c-Dateireferenz
#include "ptp.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 10 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 116 der Datei filewrite.c.

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

Definiert in Zeile 292 der Datei remotecap.c.

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

Definiert in Zeile 50 der Datei remotecap.c.

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

Definiert in Zeile 39 der Datei remotecap.c.

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

Definiert in Zeile 66 der Datei remotecap.c.

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

Definiert in Zeile 168 der Datei remotecap.c.

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

Definiert in Zeile 88 der Datei remotecap.c.

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

Definiert in Zeile 338 der Datei remotecap.c.

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

Definiert in Zeile 82 der Datei remotecap.c.

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

Definiert in Zeile 96 der Datei remotecap.c.

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

Definiert in Zeile 57 der Datei remotecap.c.

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

Definiert in Zeile 161 der Datei remotecap.c.

161  {
163 }
int remotecap_using_dng_module ( void  )

Definiert in Zeile 140 der Datei remotecap.c.

140  {
142 }
static int remotecap_wait ( int  datatype)
static

Definiert in Zeile 148 der Datei remotecap.c.

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

Variablen-Dokumentation

int available_image_data =0
static

Definiert in Zeile 13 der Datei remotecap.c.

ptp_data_chunk dng_hdr_chunk
static

Definiert in Zeile 22 der Datei remotecap.c.

int hook_wait_max =HOOK_WAIT_MAX_DEFAULT
static

Definiert in Zeile 11 der Datei remotecap.c.

int linecount =0
static

Definiert in Zeile 26 der Datei remotecap.c.

int pending_image_data =0
static

Definiert in Zeile 15 der Datei remotecap.c.

ptp_data_chunk raw_chunk
static

Definiert in Zeile 21 der Datei remotecap.c.

int remote_file_target =0
static

Definiert in Zeile 17 der Datei remotecap.c.

int startline =0
static

Definiert in Zeile 25 der Datei remotecap.c.

int target_file_num
static

Definiert in Zeile 19 der Datei remotecap.c.