@@ -136,189 +136,133 @@ static void event_vlp_putpipem(ctx_dev *cam)
136136
137137static void event_image_detect (ctx_dev *cam)
138138{
139- char fullfilename[PATH_MAX];
140139 char filename[PATH_MAX];
141140 int passthrough, retcd;
142141
143142 if (cam->new_img & NEWIMG_ON) {
144- mystrftime (cam, filename, sizeof (filename)
145- , cam->conf ->picture_filename .c_str ()
146- , &cam->current_image ->imgts , NULL , 0 );
147- retcd = snprintf (fullfilename, PATH_MAX, " %s/%s.%s"
148- , cam->conf ->target_dir .c_str (), filename
149- , cam->conf ->picture_type .c_str ());
150- if ((retcd < 0 ) || (retcd >= PATH_MAX)) {
151- MOTPLS_LOG (ERR, TYPE_EVENTS, NO_ERRNO
152- ,_ (" Error creating image file name" ));
153- return ;
154- }
143+ mypicname (cam, filename," %s/%s.%s"
144+ , cam->conf ->picture_filename
145+ , cam->conf ->picture_type );
155146 passthrough = mycheck_passthrough (cam);
156147 cam->filetype = FTYPE_IMAGE;
157- if ((cam->imgs .size_high > 0 ) && (! passthrough)) {
158- pic_save_norm (cam, fullfilename , cam->current_image ->image_high );
148+ if ((cam->imgs .size_high > 0 ) && (passthrough == false )) {
149+ pic_save_norm (cam, filename , cam->current_image ->image_high );
159150 } else {
160- pic_save_norm (cam, fullfilename ,cam->current_image ->image_norm );
151+ pic_save_norm (cam, filename ,cam->current_image ->image_norm );
161152 }
162- on_picture_save_command (cam, fullfilename );
163- dbse_exec (cam, fullfilename , " pic_save" );
153+ on_picture_save_command (cam, filename );
154+ dbse_exec (cam, filename , " pic_save" );
164155 }
165156}
166157
167158static void event_imagem_detect (ctx_dev *cam)
168159{
169- char fullfilename[PATH_MAX];
170160 char filename[PATH_MAX];
171- int retcd;
172161
173162 if (cam->conf ->picture_output_motion == " on" ) {
174- mystrftime (cam, filename, sizeof (filename)
175- , cam->conf ->picture_filename .c_str ()
176- , &cam->current_image ->imgts , NULL , 0 );
177- retcd = snprintf (fullfilename, PATH_MAX, " %s/%sm.%s"
178- , cam->conf ->target_dir .c_str (), filename
179- , cam->conf ->picture_type .c_str ());
180- if ((retcd < 0 ) || (retcd >= PATH_MAX)) {
181- MOTPLS_LOG (ERR, TYPE_EVENTS, NO_ERRNO
182- ,_ (" Error creating image motion file name" ));
183- return ;
184- }
163+ mypicname (cam, filename," %s/%sm.%s"
164+ , cam->conf ->picture_filename
165+ , cam->conf ->picture_type );
185166 cam->filetype = FTYPE_IMAGE_MOTION;
186- pic_save_norm (cam, fullfilename , cam->imgs .image_motion .image_norm );
187- on_picture_save_command (cam, fullfilename );
188- dbse_exec (cam, fullfilename , " pic_save" );
167+ pic_save_norm (cam, filename , cam->imgs .image_motion .image_norm );
168+ on_picture_save_command (cam, filename );
169+ dbse_exec (cam, filename , " pic_save" );
189170
190171 } else if (cam->conf ->picture_output_motion == " roi" ) {
191- mystrftime (cam, filename, sizeof (filename)
192- , cam->conf ->picture_filename .c_str ()
193- , &cam->current_image ->imgts , NULL , 0 );
194- retcd = snprintf (fullfilename, PATH_MAX, " %s/%sr.%s"
195- , cam->conf ->target_dir .c_str (), filename
196- , cam->conf ->picture_type .c_str ());
197- if ((retcd < 0 ) || (retcd >= PATH_MAX)) {
198- MOTPLS_LOG (ERR, TYPE_EVENTS, NO_ERRNO
199- ,_ (" Error creating image motion roi file name" ));
200- return ;
201- }
172+ mypicname (cam, filename," %s/%sr.%s"
173+ , cam->conf ->picture_filename
174+ , cam->conf ->picture_type );
202175 cam->filetype = FTYPE_IMAGE_ROI;
203- pic_save_roi (cam, fullfilename , cam->current_image ->image_norm );
204- on_picture_save_command (cam, fullfilename );
205- dbse_exec (cam, fullfilename , " pic_save" );
176+ pic_save_roi (cam, filename , cam->current_image ->image_norm );
177+ on_picture_save_command (cam, filename );
178+ dbse_exec (cam, filename , " pic_save" );
206179 }
207180}
208181
209182static void event_image_snapshot (ctx_dev *cam)
210183{
211- char fullfilename[PATH_MAX];
212184 char filename[PATH_MAX];
213- char filepath[PATH_MAX];
214185 char linkpath[PATH_MAX];
215- int offset, retcd, passthrough;
186+ int offset, passthrough;
216187
217188 offset = (int )cam->conf ->snapshot_filename .length () - 8 ;
218189 if (offset < 0 ) {
219190 offset = 1 ;
220191 }
221192
222193 if (cam->conf ->snapshot_filename .compare (offset, 8 , " lastsnap" ) != 0 ) {
223- mystrftime (cam, filepath, sizeof (filepath)
224- , cam->conf ->snapshot_filename .c_str ()
225- , &cam->current_image ->imgts , NULL , 0 );
226- retcd = snprintf (filename, PATH_MAX, " %s.%s" , filepath
227- , cam->conf ->picture_type .c_str ());
228- if (retcd <0 ) {
229- MOTPLS_LOG (INF, TYPE_STREAM, NO_ERRNO, _ (" Error option" ));
230- }
231-
232- retcd =snprintf (fullfilename, PATH_MAX, " %s/%s"
233- , cam->conf ->target_dir .c_str (), filename);
234- if (retcd <0 ) {
235- MOTPLS_LOG (INF, TYPE_STREAM, NO_ERRNO, _ (" Error option" ));
236- }
194+ mypicname (cam, filename," %s/%s.%s"
195+ , cam->conf ->snapshot_filename
196+ , cam->conf ->picture_type );
237197 passthrough = mycheck_passthrough (cam);
238198 cam->filetype = FTYPE_IMAGE_SNAPSHOT;
239- if ((cam->imgs .size_high > 0 ) && (! passthrough)) {
240- pic_save_norm (cam, fullfilename , cam->current_image ->image_high );
199+ if ((cam->imgs .size_high > 0 ) && (passthrough == false )) {
200+ pic_save_norm (cam, filename , cam->current_image ->image_high );
241201 } else {
242- pic_save_norm (cam, fullfilename , cam->current_image ->image_norm );
202+ pic_save_norm (cam, filename , cam->current_image ->image_norm );
243203 }
244- on_picture_save_command (cam, fullfilename );
245- dbse_exec (cam, fullfilename , " pic_save" );
204+ on_picture_save_command (cam, filename );
205+ dbse_exec (cam, filename , " pic_save" );
246206
247207 /* Update symbolic link */
248- snprintf (linkpath, PATH_MAX, " %s/lastsnap.%s"
249- , cam->conf ->target_dir .c_str ()
250- , cam->conf ->picture_type .c_str ());
208+ mypicname (cam, linkpath," %s/%s.%s"
209+ , " lastsnap" , cam->conf ->picture_type );
251210 remove (linkpath);
252211 if (symlink (filename, linkpath)) {
253212 MOTPLS_LOG (ERR, TYPE_EVENTS, SHOW_ERRNO
254213 ,_ (" Could not create symbolic link [%s]" ), filename);
255214 return ;
256215 }
257- } else {
258- mystrftime (cam, filepath, sizeof (filepath)
259- , cam->conf ->snapshot_filename .c_str ()
260- , &cam->current_image ->imgts , NULL , 0 );
261- retcd = snprintf (filename, PATH_MAX, " %s.%s" , filepath
262- , cam->conf ->picture_type .c_str ());
263- if (retcd <0 ) {
264- MOTPLS_LOG (INF, TYPE_STREAM, NO_ERRNO, _ (" Error option" ));
265- }
266-
267- retcd = snprintf (fullfilename, PATH_MAX, " %s/%s"
268- , cam->conf ->target_dir .c_str (), filename);
269- if (retcd <0 ) {
270- MOTPLS_LOG (INF, TYPE_STREAM, NO_ERRNO, _ (" Error option" ));
271- }
272216
273- remove (fullfilename);
217+ } else {
218+ mypicname (cam, filename," %s/%s.%s"
219+ , cam->conf ->snapshot_filename
220+ , cam->conf ->picture_type );
221+ remove (filename);
274222 passthrough = mycheck_passthrough (cam);
275223 cam->filetype = FTYPE_IMAGE_SNAPSHOT;
276224 if ((cam->imgs .size_high > 0 ) && (!passthrough)) {
277- pic_save_norm (cam, fullfilename , cam->current_image ->image_high );
225+ pic_save_norm (cam, filename , cam->current_image ->image_high );
278226 } else {
279- pic_save_norm (cam, fullfilename , cam->current_image ->image_norm );
227+ pic_save_norm (cam, filename , cam->current_image ->image_norm );
280228 }
281- on_picture_save_command (cam, fullfilename );
282- dbse_exec (cam, fullfilename , " pic_save" );
229+ on_picture_save_command (cam, filename );
230+ dbse_exec (cam, filename , " pic_save" );
283231 }
284232
285233 cam->snapshot = 0 ;
286234}
287235
288236static void event_image_preview (ctx_dev *cam)
289237{
290- char previewname[PATH_MAX];
291238 char filename[PATH_MAX];
292239 ctx_image_data *saved_current_image;
293- int passthrough, retcd ;
240+ int passthrough;
294241
295242 if (cam->imgs .image_preview .diffs ) {
296243 saved_current_image = cam->current_image ;
244+ saved_current_image->imgts = cam->current_image ->imgts ;
245+
297246 cam->current_image = &cam->imgs .image_preview ;
247+ cam->current_image ->imgts = cam->imgs .image_preview .imgts ;
298248
299- mystrftime (cam, filename, sizeof (filename), cam->conf ->picture_filename .c_str ()
300- , &cam->imgs .image_preview .imgts , NULL , 0 );
249+ mypicname (cam, filename," %s/%s.%s"
250+ , cam->conf ->picture_filename
251+ , cam->conf ->picture_type );
301252
302- retcd = snprintf (previewname, PATH_MAX, " %s/%s.%s"
303- , cam->conf ->target_dir .c_str (), filename
304- , cam->conf ->picture_type .c_str ());
305- if ((retcd < 0 ) || (retcd >= PATH_MAX)) {
306- MOTPLS_LOG (ERR, TYPE_EVENTS, NO_ERRNO
307- ,_ (" Error creating preview file name" ));
308- return ;
309- }
310253 passthrough = mycheck_passthrough (cam);
311254 cam->filetype = FTYPE_IMAGE;
312- if ((cam->imgs .size_high > 0 ) && (! passthrough)) {
313- pic_save_norm (cam, previewname , cam->imgs .image_preview .image_high );
255+ if ((cam->imgs .size_high > 0 ) && (passthrough == false )) {
256+ pic_save_norm (cam, filename , cam->imgs .image_preview .image_high );
314257 } else {
315- pic_save_norm (cam, previewname , cam->imgs .image_preview .image_norm );
258+ pic_save_norm (cam, filename , cam->imgs .image_preview .image_norm );
316259 }
317- on_picture_save_command (cam, previewname );
318- dbse_exec (cam, previewname , " pic_save" );
260+ on_picture_save_command (cam, filename );
261+ dbse_exec (cam, filename , " pic_save" );
319262
320263 /* Restore global context values. */
321264 cam->current_image = saved_current_image;
265+ cam->current_image ->imgts = saved_current_image->imgts ;
322266 }
323267}
324268
0 commit comments