CHDK_DE Vorschauversion  Trunk Rev. 5249
 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)
 
void remotecap_type_complete (int type)
 
void filewrite_set_discard_jpeg (int state)
 
int filewrite_get_jpeg_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_jpeg_chunk ( char **  addr,
unsigned *  size,
unsigned  n,
int *  pos 
)
void filewrite_set_discard_jpeg ( 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 250 der Datei remotecap.c.

251 {
252  int status = REMOTECAP_CHUNK_STATUS_LAST; // default = no more chunks
253  *pos = -1; // default = sequential
254 
255  switch (fmt & remotecap_get_target() & available_image_data)
256  {
257  case PTP_CHDK_CAPTURE_RAW: //raw
258  *addr=(char*)raw_chunk.address;
259  *size=raw_chunk.length;
260  break;
262  case PTP_CHDK_CAPTURE_JPG: //jpeg
263  jpeg_last_status = filewrite_get_jpeg_chunk(addr,size,jpeg_curr_chunk,pos);
264  jpeg_curr_chunk+=1;
265  if(jpeg_last_status != REMOTECAP_JPEG_CHUNK_STATUS_LAST) {
267  }
268  break;
269 #endif
270  case PTP_CHDK_CAPTURE_DNGHDR: // dng header
271  *addr=(char*)dng_hdr_chunk.address;
272  *size=dng_hdr_chunk.length;
273  break;
274  default:
275  /*
276  * attempting to get an unsupported, unavailable or not requested format
277  * will free all hooks, deactiveate remotecap, and return error status
278  */
279  *addr=NULL;
280  *size=0;
281  }
282  if(*addr == NULL) {
283  remotecap_reset();
285  }
286 
287  return status;
288 }
int remotecap_get_target ( void  )

Definiert in Zeile 46 der Datei remotecap.c.

46  {
47  return remote_file_target;
48 }
int remotecap_get_target_support ( void  )

Definiert in Zeile 38 der Datei remotecap.c.

38  {
40 #ifdef CAM_HAS_FILEWRITETASK_HOOK
41  ret |= PTP_CHDK_CAPTURE_JPG;
42 #endif
43  return ret;
44 }
void remotecap_is_ready ( int *  available_type,
int *  file_num 
)

Definiert in Zeile 62 der Datei remotecap.c.

62  {
63  if ( remotecap_get_target() ) {
64  *available_type = available_image_data;
66  *file_num = target_file_num;
67  } else {
68  *file_num = 0;
69  }
70  }
71  else {
72  *available_type = PTP_CHDK_CAPTURE_NOTSET;
73  *file_num = 0;
74  }
75 }
void remotecap_raw_available ( char *  rawadr)

Definiert in Zeile 160 der Datei remotecap.c.

160  {
161  // get file number as early as possible, before blocking
162  // but don't set until after so it doesn't change value for remotecap_is_ready
163  int next_file_num = get_target_file_num();
164 /*
165 ensure raw hook is blocked until any prevous remotecap shot is finished or times out
166 if prevous times out, remotecap settings will be cleared due to the time out, so no
167 remotecap will be done, althouth writes will still be skipped
168 wait == 0 timeout shouldn't get hit here unless the script is fiddling with the
169 timeout value, but it ensures that we don't block indefinitely.
170 */
171  int wait = hook_wait_max;
172  while (wait && pending_image_data) {
173  msleep(10);
174  wait--;
175  }
176  if(wait == 0) {
177  remotecap_reset();
178  }
180  target_file_num = next_file_num;
181 // TODO technically this could probably wait until after the raw stuff is done,
182 // provided the actual chunks are transmitted
183 // TODO this should probably just be noop if hook doesn't exist
184 #ifdef CAM_HAS_FILEWRITETASK_HOOK
186  jpeg_curr_chunk=0; //needs to be done here
187 #endif //CAM_HAS_FILEWRITETASK_HOOK
189  started();
191 
192  if(!remotecap_wait(PTP_CHDK_CAPTURE_DNGHDR)) {
193  remotecap_reset();
194  }
196  remotecap_type_complete(PTP_CHDK_CAPTURE_DNGHDR);
197  finished();
198  }
199 
201  return;
202  }
203 
204  started();
205 
208 
209  if(!remotecap_wait(PTP_CHDK_CAPTURE_RAW)) {
210  remotecap_reset();
211  }
212  remotecap_type_complete(PTP_CHDK_CAPTURE_RAW);
213 
214  finished();
215 }
static void remotecap_reset ( void  )
static

Definiert in Zeile 84 der Datei remotecap.c.

84  {
88  // TODO do we need remotecap_jpeg_chunks_done() ?
89 }
int remotecap_send_complete ( int  rcgd_status,
int  type 
)

Definiert in Zeile 290 der Datei remotecap.c.

290  {
291  // timeout or canceled: the data type we were sending is no longer available
292  int timeout_flag = (available_image_data != type);
293  if(rcgd_status == REMOTECAP_CHUNK_STATUS_LAST) {
294  // currently only one data type can be available at a time
296  }
297 #ifdef CAM_FILEWRITETASK_MULTIPASS
298  else if(type == PTP_CHDK_CAPTURE_JPG && jpeg_last_status == REMOTECAP_JPEG_CHUNK_STATUS_SESS_LAST) {
299  remotecap_jpeg_chunks_done(); // make jpeg_chunks NULL, immediately
300  jpeg_session_wait = 0;
301  }
302 #endif
303  if((rcgd_status == REMOTECAP_CHUNK_STATUS_ERROR) || timeout_flag) {
304  return 0;
305  }
306  // else more chunks of current type, no action needed
307  return 1;
308 }
static void remotecap_set_available_data_type ( int  type)
static

Definiert in Zeile 78 der Datei remotecap.c.

79 {
80  available_image_data = type;
81 }
int remotecap_set_target ( int  type,
int  lstart,
int  lcount 
)

Definiert in Zeile 92 der Datei remotecap.c.

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

Definiert in Zeile 53 der Datei remotecap.c.

54 {
55  if(timeout <= 0) {
57  } else {
58  hook_wait_max = timeout/10;
59  }
60 }
void remotecap_type_complete ( int  type)

Definiert in Zeile 153 der Datei remotecap.c.

153  {
155 }
int remotecap_using_dng_module ( void  )

Definiert in Zeile 132 der Datei remotecap.c.

132  {
134 }
static int remotecap_wait ( int  datatype)
static

Definiert in Zeile 140 der Datei remotecap.c.

140  {
141  int wait = hook_wait_max;
142 
144 
145  while (wait && (available_image_data & datatype)) {
146  msleep(10);
147  wait--;
148  }
149  return wait;
150 }

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.