Adjust braces on function declarations

This commit is contained in:
MrDave
2020-11-21 20:39:32 -07:00
committed by Mr-Dave
parent 54a09a60a4
commit 1684e05200
25 changed files with 1541 additions and 899 deletions

View File

@@ -35,18 +35,12 @@
/* Increment for *smartmask_buffer in alg_diff_standard. */
#define SMARTMASK_SENSITIVITY_INCR 5
#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \
if (sp<stack+MAXS && Y+(DY) >= 0 && Y+(DY) < height) \
{sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;}
#define POP(Y, XL, XR, DY) /* pop segment off stack */ \
{sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;}
typedef struct {
short y, xl, xr, dy;
} Segment;
void alg_locate_center_size(struct ctx_images *imgs, int width, int height, struct ctx_coord *cent) {
void alg_locate_center_size(struct ctx_images *imgs, int width, int height, struct ctx_coord *cent)
{
unsigned char *out = imgs->image_motion.image_norm;
int *labels = imgs->labels;
int x, y, centc = 0, xdist = 0, ydist = 0;
@@ -102,15 +96,17 @@ void alg_locate_center_size(struct ctx_images *imgs, int width, int height, stru
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(labels++) & 32768) {
if (x > cent->x)
if (x > cent->x) {
xdist += x - cent->x;
else if (x < cent->x)
} else if (x < cent->x) {
xdist += cent->x - x;
}
if (y > cent->y)
if (y > cent->y) {
ydist += y - cent->y;
else if (y < cent->y)
} else if (y < cent->y) {
ydist += cent->y - y;
}
centc++;
}
@@ -121,15 +117,17 @@ void alg_locate_center_size(struct ctx_images *imgs, int width, int height, stru
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(out++)) {
if (x > cent->x)
if (x > cent->x) {
xdist += x - cent->x;
else if (x < cent->x)
} else if (x < cent->x) {
xdist += cent->x - x;
}
if (y > cent->y)
if (y > cent->y) {
ydist += y - cent->y;
else if (y < cent->y)
} else if (y < cent->y) {
ydist += cent->y - y;
}
centc++;
}
@@ -150,25 +148,29 @@ void alg_locate_center_size(struct ctx_images *imgs, int width, int height, stru
cent->maxy = cent->y + ydist / centc * 2;
}
if (cent->maxx > width - 1)
if (cent->maxx > width - 1) {
cent->maxx = width - 1;
else if (cent->maxx < 0)
} else if (cent->maxx < 0) {
cent->maxx = 0;
}
if (cent->maxy > height - 1)
if (cent->maxy > height - 1) {
cent->maxy = height - 1;
else if (cent->maxy < 0)
} else if (cent->maxy < 0) {
cent->maxy = 0;
}
if (cent->minx > width - 1)
if (cent->minx > width - 1) {
cent->minx = width - 1;
else if (cent->minx < 0)
} else if (cent->minx < 0) {
cent->minx = 0;
}
if (cent->miny > height - 1)
if (cent->miny > height - 1) {
cent->miny = height - 1;
else if (cent->miny < 0)
} else if (cent->miny < 0) {
cent->miny = 0;
}
/* Align for better locate box handling */
cent->minx += cent->minx % 2;
@@ -188,7 +190,8 @@ void alg_locate_center_size(struct ctx_images *imgs, int width, int height, stru
}
void alg_noise_tune(struct ctx_cam *cam, unsigned char *new_var) {
void alg_noise_tune(struct ctx_cam *cam, unsigned char *new_var)
{
struct ctx_images *imgs = &cam->imgs;
int i;
unsigned char *ref = imgs->ref;
@@ -201,8 +204,9 @@ void alg_noise_tune(struct ctx_cam *cam, unsigned char *new_var) {
for (; i > 0; i--) {
diff = ABS(*ref - *new_var);
if (mask)
if (mask) {
diff = ((diff * *mask++) / 255);
}
if (*smartmask) {
sum += diff + 1;
@@ -214,33 +218,40 @@ void alg_noise_tune(struct ctx_cam *cam, unsigned char *new_var) {
smartmask++;
}
if (count > 3) /* Avoid divide by zero. */
if (count > 3) {
/* Avoid divide by zero. */
sum /= count / 3;
}
/* 5: safe, 4: regular, 3: more sensitive */
cam->noise = 4 + (cam->noise + sum) / 2;
}
void alg_threshold_tune(struct ctx_cam *cam, int diffs, int motion) {
void alg_threshold_tune(struct ctx_cam *cam, int diffs, int motion)
{
int i;
int sum = 0, top = diffs;
if (!diffs)
if (!diffs) {
return;
}
if (motion)
if (motion) {
diffs = cam->threshold / 4;
}
for (i = 0; i < THRESHOLD_TUNE_LENGTH - 1; i++) {
sum += cam->diffs_last[i];
if (cam->diffs_last[i + 1] && !motion)
if (cam->diffs_last[i + 1] && !motion) {
cam->diffs_last[i] = cam->diffs_last[i + 1];
else
} else {
cam->diffs_last[i] = cam->threshold / 4;
}
if (cam->diffs_last[i] > top)
if (cam->diffs_last[i] > top) {
top = cam->diffs_last[i];
}
}
sum += cam->diffs_last[i];
@@ -248,11 +259,13 @@ void alg_threshold_tune(struct ctx_cam *cam, int diffs, int motion) {
sum /= THRESHOLD_TUNE_LENGTH / 4;
if (sum < top * 2)
if (sum < top * 2) {
sum = top * 2;
}
if (sum < cam->conf->threshold)
if (sum < cam->conf->threshold) {
cam->threshold = (cam->threshold + sum) / 2;
}
}
/*
@@ -264,16 +277,23 @@ void alg_threshold_tune(struct ctx_cam *cam, int diffs, int motion) {
* Filled horizontal segment of scanline y for xl <= x <= xr.
* Parent segment was on line y - dy. dy = 1 or -1
*/
#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \
if (sp<stack+MAXS && Y+(DY) >= 0 && Y+(DY) < height) \
{sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;}
#define POP(Y, XL, XR, DY) /* pop segment off stack */ \
{sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;}
static int alg_iflood(int x, int y, int width, int height,
unsigned char *out, int *labels, int newvalue, int oldvalue)
unsigned char *out, int *labels, int newvalue, int oldvalue)
{
int l, x1, x2, dy;
Segment stack[MAXS], *sp = stack; /* Stack of filled segments. */
int count = 0;
if (x < 0 || x >= width || y < 0 || y >= height)
if (x < 0 || x >= width || y < 0 || y >= height) {
return 0;
}
PUSH(y, x, x, 1); /* Needed in some cases. */
PUSH(y + 1, x, x, -1); /* Seed segment (popped 1st). */
@@ -290,13 +310,15 @@ static int alg_iflood(int x, int y, int width, int height,
count++;
}
if (x >= x1)
if (x >= x1) {
goto skip;
}
l = x + 1;
if (l < x1)
if (l < x1) {
PUSH(y, l, x1 - 1, -dy); /* Leak on left? */
}
x = x1 + 1;
@@ -308,13 +330,12 @@ static int alg_iflood(int x, int y, int width, int height,
PUSH(y, l, x - 1, dy);
if (x > x2 + 1)
if (x > x2 + 1) {
PUSH(y, x2 + 1, x - 1, -dy); /* Leak on right? */
}
skip:
for (x++; x <= x2 && !(out[y * width + x] != 0 && labels[y * width + x] == oldvalue); x++);
l = x;
} while (x <= x2);
}
@@ -353,23 +374,21 @@ static int alg_labeling(struct ctx_cam *cam)
}
/* Already visited by alg_iflood */
if (labels[pixelpos] > 0)
if (labels[pixelpos] > 0) {
continue;
}
labelsize = alg_iflood(ix, iy, width, height, out, labels, current_label, 0);
if (labelsize > 0) {
//MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "Label: %i (%i) Size: %i (%i,%i)",
// current_label, cam->current_image->total_labels,
// labelsize, ix, iy);
/* Label above threshold? Mark it again (add 32768 to labelnumber). */
if (labelsize > cam->threshold) {
labelsize = alg_iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label);
imgs->labelgroup_max += labelsize;
imgs->labels_above++;
} else if(max_under < labelsize)
} else if(max_under < labelsize) {
max_under = labelsize;
}
if (imgs->labelsize_max < labelsize) {
imgs->labelsize_max = labelsize;
@@ -383,10 +402,6 @@ static int alg_labeling(struct ctx_cam *cam)
pixelpos++; /* Compensate for ix < width - 1 */
}
//MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%i Labels found. Largest connected Area: %i Pixel(s). "
// "Largest Label: %i", imgs->largest_label, imgs->labelsize_max,
// cam->current_image->total_labels);
/* Return group of significant labels or if that's none, the next largest
* group (which is under the threshold, but especially for setup gives an
* idea how close it was).
@@ -429,10 +444,11 @@ static int alg_dilate9(unsigned char *img, int width, int height, void *buffer)
row3 = rowTemp;
/* If we're at the last row, fill with zeros, otherwise copy from img. */
if (y == height - 1)
if (y == height - 1) {
memset(row3, 0, width);
else
} else {
memcpy(row3, yp + width, width);
}
/* Init slots 0 and 1 in the moving window. */
window[0] = MAX3(row1[0], row2[0], row3[0]);
@@ -454,10 +470,11 @@ static int alg_dilate9(unsigned char *img, int width, int height, void *buffer)
* If the value is larger than the current max, use it. Otherwise,
* calculate a new max (because the new value may not be the max.
*/
if (latest >= blob)
if (latest >= blob) {
blob = latest;
else
} else {
blob = MAX3(window[0], window[1], window[2]);
}
/* Write the max value (blob) to the image. */
if (blob != 0) {
@@ -466,8 +483,9 @@ static int alg_dilate9(unsigned char *img, int width, int height, void *buffer)
}
/* Wrap around the window index if necessary. */
if (++widx == 3)
if (++widx == 3) {
widx = 0;
}
}
/* Store zeros in the vertical sides. */
@@ -509,10 +527,11 @@ static int alg_dilate5(unsigned char *img, int width, int height, void *buffer)
row3 = rowTemp;
/* If we're at the last row, fill with zeros, otherwise copy from img. */
if (y == height - 1)
if (y == height - 1) {
memset(row3, 0, width);
else
} else {
memcpy(row3, yp + width, width);
}
/* Init mem and set blob to force an evaluation of the entire + shape. */
mem = MAX2(row2[0], row2[1]);
@@ -562,10 +581,11 @@ static int alg_erode9(unsigned char *img, int width, int height, void *buffer, u
memcpy(Row1, Row2, width);
memcpy(Row2, Row3, width);
if (y == height - 1)
if (y == height - 1) {
memset(Row3, flag, width);
else
} else {
memcpy(Row3, img + (y + 1) * width, width);
}
for (i = width - 2; i >= 1; i--) {
if (Row1[i - 1] == 0 ||
@@ -576,10 +596,11 @@ static int alg_erode9(unsigned char *img, int width, int height, void *buffer, u
Row2[i + 1] == 0 ||
Row3[i - 1] == 0 ||
Row3[i] == 0 ||
Row3[i + 1] == 0)
Row3[i + 1] == 0) {
img[y * width + i] = 0;
else
} else {
sum++;
}
}
img[y * width] = img[y * width + width - 1] = flag;
@@ -603,20 +624,22 @@ static int alg_erode5(unsigned char *img, int width, int height, void *buffer, u
memcpy(Row1, Row2, width);
memcpy(Row2, Row3, width);
if (y == height - 1)
if (y == height - 1) {
memset(Row3, flag, width);
else
} else {
memcpy(Row3, img + (y + 1) * width, width);
}
for (i = width - 2; i >= 1; i--) {
if (Row1[i] == 0 ||
Row2[i - 1] == 0 ||
Row2[i] == 0 ||
Row2[i + 1] == 0 ||
Row3[i] == 0)
Row3[i] == 0) {
img[y * width + i] = 0;
else
} else {
sum++;
}
}
img[y * width] = img[y * width + width - 1] = flag;
@@ -624,11 +647,12 @@ static int alg_erode5(unsigned char *img, int width, int height, void *buffer, u
return sum;
}
void alg_despeckle(struct ctx_cam *cam) {
void alg_despeckle(struct ctx_cam *cam)
{
int diffs, width, height, done, i, len;
unsigned char *out, *common_buffer;
if ((cam->conf->despeckle_filter == "") || cam->current_image->diffs <= 0){
if ((cam->conf->despeckle_filter == "") || cam->current_image->diffs <= 0) {
if (cam->imgs.labelsize_max) cam->imgs.labelsize_max = 0;
return;
}
@@ -685,7 +709,8 @@ void alg_despeckle(struct ctx_cam *cam) {
return;
}
void alg_tune_smartmask(struct ctx_cam *cam) {
void alg_tune_smartmask(struct ctx_cam *cam)
{
int i, diff;
int motionsize = cam->imgs.motionsize;
unsigned char *smartmask = cam->imgs.smartmask;
@@ -707,17 +732,19 @@ void alg_tune_smartmask(struct ctx_cam *cam) {
diff = smartmask_buffer[i] / sensitivity;
if (diff) {
if (smartmask[i] <= diff + 80)
if (smartmask[i] <= diff + 80) {
smartmask[i] += diff;
else
} else {
smartmask[i] = 80;
}
smartmask_buffer[i] %= sensitivity;
}
/* Transfer raw mask to the final stage when above trigger value. */
if (smartmask[i] > 20)
if (smartmask[i] > 20) {
smartmask_final[i] = 0;
else
} else {
smartmask_final[i] = 255;
}
}
/* Further expansion (here:erode due to inverted logic!) of the mask. */
diff = alg_erode9(smartmask_final, cam->imgs.width, cam->imgs.height,
@@ -730,7 +757,8 @@ void alg_tune_smartmask(struct ctx_cam *cam) {
/* Increment for *smartmask_buffer in alg_diff_standard. */
#define SMARTMASK_SENSITIVITY_INCR 5
static int alg_diff_nomask(struct ctx_cam *cam, unsigned char *new_var) {
static int alg_diff_nomask(struct ctx_cam *cam, unsigned char *new_var)
{
unsigned char *ref = cam->imgs.ref;
unsigned char *out = cam->imgs.image_motion.image_norm;
@@ -757,13 +785,11 @@ static int alg_diff_nomask(struct ctx_cam *cam, unsigned char *new_var) {
clock_gettime(CLOCK_REALTIME, &ts2);
//MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO
// ,"Diffs %d detected %ld - %ld", diffs,ts2.tv_sec,ts2.tv_nsec/1000);
return diffs;
}
static int alg_diff_mask(struct ctx_cam *cam, unsigned char *new_img) {
static int alg_diff_mask(struct ctx_cam *cam, unsigned char *new_img)
{
unsigned char *ref = cam->imgs.ref;
unsigned char *out = cam->imgs.image_motion.image_norm;
unsigned char *mask = cam->imgs.mask;
@@ -778,7 +804,7 @@ static int alg_diff_mask(struct ctx_cam *cam, unsigned char *new_img) {
for (i = 0; i < imgsz; i++) {
curdiff = abs(*ref - *new_img);
if (mask){
if (mask) {
curdiff = ((curdiff * *mask) / 255);
mask++;
}
@@ -795,7 +821,8 @@ static int alg_diff_mask(struct ctx_cam *cam, unsigned char *new_img) {
return diffs;
}
static int alg_diff_smart(struct ctx_cam *cam, unsigned char *new_img) {
static int alg_diff_smart(struct ctx_cam *cam, unsigned char *new_img)
{
unsigned char *ref = cam->imgs.ref;
unsigned char *out = cam->imgs.image_motion.image_norm;
@@ -819,7 +846,9 @@ static int alg_diff_smart(struct ctx_cam *cam, unsigned char *new_img) {
if (cam->event_nr != cam->prev_event) {
(*smartmask_buffer) += SMARTMASK_SENSITIVITY_INCR;
}
if (!*smartmask_final) curdiff = 0;
if (!*smartmask_final) {
curdiff = 0;
}
}
smartmask_final++;
smartmask_buffer++;
@@ -838,7 +867,8 @@ static int alg_diff_smart(struct ctx_cam *cam, unsigned char *new_img) {
return diffs;
}
static int alg_diff_masksmart(struct ctx_cam *cam, unsigned char *new_img) {
static int alg_diff_masksmart(struct ctx_cam *cam, unsigned char *new_img)
{
unsigned char *ref = cam->imgs.ref;
unsigned char *out = cam->imgs.image_motion.image_norm;
unsigned char *mask = cam->imgs.mask;
@@ -857,7 +887,7 @@ static int alg_diff_masksmart(struct ctx_cam *cam, unsigned char *new_img) {
for (i = 0; i < imgsz; i++) {
curdiff = abs(*ref - *new_img);
if (mask){
if (mask) {
curdiff = ((curdiff * *mask) / 255);
mask++;
}
@@ -887,7 +917,8 @@ static int alg_diff_masksmart(struct ctx_cam *cam, unsigned char *new_img) {
}
static char alg_diff_fast(struct ctx_cam *cam, int max_n_changes, unsigned char *new_var) {
static char alg_diff_fast(struct ctx_cam *cam, int max_n_changes, unsigned char *new_var)
{
struct ctx_images *imgs = &cam->imgs;
int i;
int diffs = 0;
@@ -900,7 +931,6 @@ static char alg_diff_fast(struct ctx_cam *cam, int max_n_changes, unsigned char
max_n_changes /= step;
i = imgs->motionsize;
for (; i > 0; i -= step) {
@@ -925,7 +955,8 @@ static char alg_diff_fast(struct ctx_cam *cam, int max_n_changes, unsigned char
return 0;
}
static void alg_diff_standard(struct ctx_cam *cam) {
static void alg_diff_standard(struct ctx_cam *cam)
{
if (cam->smartmask_speed == 0){
if (cam->imgs.mask == NULL) {
@@ -943,7 +974,8 @@ static void alg_diff_standard(struct ctx_cam *cam) {
}
void alg_diff(struct ctx_cam *cam) {
void alg_diff(struct ctx_cam *cam)
{
if (cam->detecting_motion || cam->motapp->setup_mode) {
alg_diff_standard(cam);
@@ -956,7 +988,8 @@ void alg_diff(struct ctx_cam *cam) {
}
}
void alg_lightswitch(struct ctx_cam *cam) {
void alg_lightswitch(struct ctx_cam *cam)
{
if (cam->conf->lightswitch_percent > 1 && !cam->lost_connection) {
if (cam->current_image->diffs > (cam->imgs.motionsize * cam->conf->lightswitch_percent / 100)) {
@@ -969,7 +1002,8 @@ void alg_lightswitch(struct ctx_cam *cam) {
}
}
void alg_switchfilter(struct ctx_cam *cam) {
void alg_switchfilter(struct ctx_cam *cam)
{
/* TODO: This function needs evaluation.
* Lots of random numbers and unknown logic
@@ -1024,7 +1058,8 @@ void alg_switchfilter(struct ctx_cam *cam) {
* action - UPDATE_REF_FRAME or RESET_REF_FRAME
*
*/
void alg_update_reference_frame(struct ctx_cam *cam, int action) {
void alg_update_reference_frame(struct ctx_cam *cam, int action)
{
int accept_timer = cam->lastrate * ACCEPT_STATIC_OBJECT_TIME;
int i, threshold_ref;
int *ref_dyn = cam->imgs.ref_dyn;
@@ -1075,7 +1110,8 @@ void alg_update_reference_frame(struct ctx_cam *cam, int action) {
}
/*Copy in new reference frame*/
void alg_new_update_frame(ctx_cam *cam) {
void alg_new_update_frame(ctx_cam *cam)
{
/* There used to be a lot more to this function before.....*/
memcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
@@ -1083,7 +1119,8 @@ void alg_new_update_frame(ctx_cam *cam) {
}
/*Calculate the center location of changes*/
static void alg_new_location_center(ctx_cam *cam) {
static void alg_new_location_center(ctx_cam *cam)
{
int width = cam->imgs.width;
int height = cam->imgs.height;
ctx_coord *cent = &cam->current_image->location;
@@ -1117,7 +1154,8 @@ static void alg_new_location_center(ctx_cam *cam) {
}
/*Calculate distribution and variances of changes*/
static void alg_new_location_dist(ctx_cam *cam) {
static void alg_new_location_dist(ctx_cam *cam)
{
ctx_images *imgs = &cam->imgs;
int width = cam->imgs.width;
int height = cam->imgs.height;
@@ -1197,7 +1235,8 @@ static void alg_new_location_dist(ctx_cam *cam) {
}
/* Ensure min/max are within limits*/
static void alg_new_location_minmax(ctx_cam *cam) {
static void alg_new_location_minmax(ctx_cam *cam)
{
int width = cam->imgs.width;
int height = cam->imgs.height;
@@ -1239,7 +1278,8 @@ static void alg_new_location_minmax(ctx_cam *cam) {
}
/* Determine the location and standard deviations of changes*/
static void alg_new_location(ctx_cam *cam) {
static void alg_new_location(ctx_cam *cam)
{
alg_new_location_center(cam);
@@ -1312,7 +1352,8 @@ static void alg_new_stddev(ctx_cam *cam)
}
/* Determine base differences */
static void alg_new_diff_base(ctx_cam *cam) {
static void alg_new_diff_base(ctx_cam *cam)
{
ctx_images *imgs = &cam->imgs;
int indx = 0;
@@ -1349,13 +1390,13 @@ static void alg_new_diff_base(ctx_cam *cam) {
}
cam->current_image->diffs_raw = diffs;
diffs_net = abs(diffs_net);
if (diffs_net > 0 ){
if (diffs_net > 0 ) {
cam->current_image->diffs_ratio = (diffs *10) / diffs_net;
} else {
cam->current_image->diffs_ratio = diffs;
}
if (cam->current_image->diffs_ratio > cam->conf->threshold_ratio){
if (cam->current_image->diffs_ratio > cam->conf->threshold_ratio) {
cam->current_image->diffs = 0;
} else {
cam->current_image->diffs= diffs;
@@ -1364,7 +1405,8 @@ static void alg_new_diff_base(ctx_cam *cam) {
return;
}
void alg_new_diff(ctx_cam *cam) {
void alg_new_diff(ctx_cam *cam)
{
alg_new_diff_base(cam);

View File

@@ -39,10 +39,10 @@
using namespace cv;
static void algsec_img_show(ctx_cam *cam, Mat &mat_src
, std::vector<Rect> &src_pos, std::vector<double> &src_weights
, std::string algmethod, ctx_algsec_model &algmdl){
, std::vector<Rect> &src_pos, std::vector<double> &src_weights
, std::string algmethod, ctx_algsec_model &algmdl)
{
std::vector<Rect> fltr_pos;
std::vector<double> fltr_weights;
@@ -61,17 +61,17 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src
Rect r = src_pos[indx0];
double w = src_weights[indx0];
for (indx1=0; indx1<src_pos.size(); indx1++){
for (indx1=0; indx1<src_pos.size(); indx1++) {
if (indx1 != indx0 && (r & src_pos[indx1])==r) break;
}
if ((indx1==src_pos.size()) && (w > algmdl.threshold_motion)){
if ((indx1==src_pos.size()) && (w > algmdl.threshold_motion)) {
fltr_pos.push_back(r);
fltr_weights.push_back(w);
algmdl.isdetected = true;
}
}
if (algmdl.isdetected){
if (algmdl.isdetected) {
for (indx0=0; indx0<fltr_pos.size(); indx0++) {
Rect r = fltr_pos[indx0];
r.x += cvRound(r.width*0.1);
@@ -90,7 +90,7 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src
* the first image, we rely upon the connection count to tell us whether we
* need to expend the CPU to compress and load the secondary images */
if ((cam->stream.secondary.cnct_count >0) ||
(cam->imgs.size_secondary == 0)){
(cam->imgs.size_secondary == 0)) {
param[0] = cv::IMWRITE_JPEG_QUALITY;
param[1] = 75;
cv::imencode(".jpg", mat_src, buff, param);
@@ -101,7 +101,8 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src
}
}
static void algsec_img_roi(ctx_cam *cam, Mat &mat_src, Mat &mat_dst){
static void algsec_img_roi(ctx_cam *cam, Mat &mat_src, Mat &mat_dst)
{
cv::Rect roi;
int width,height, x, y;
@@ -111,25 +112,35 @@ static void algsec_img_roi(ctx_cam *cam, Mat &mat_src, Mat &mat_dst){
width = cam->current_image->location.width;
height= cam->current_image->location.height;
if (width > cam->imgs.height) width =cam->imgs.height;
if (height > cam->imgs.width) height =cam->imgs.width;
if (width > cam->imgs.height) {
width =cam->imgs.height;
}
if (height > cam->imgs.width) {
height =cam->imgs.width;
}
if (width > height){
height= width;
if (width > height) {
height = width;
x = cam->current_image->location.minx;
y = cam->current_image->location.miny - ((width - height)/2);
if (y < 0) y = 0;
if ((y+height) > cam->imgs.height) y = cam->imgs.height - height;
if (y < 0) {
y = 0;
}
if ((y+height) > cam->imgs.height) {
y = cam->imgs.height - height;
}
} else {
width = height;
x = cam->current_image->location.minx - ((height - width)/2);
y = cam->current_image->location.miny;
if (x < 0) x = 0;
if ((x+width) > cam->imgs.width) x = cam->imgs.width - width;
if (x < 0) {
x = 0;
}
if ((x+width) > cam->imgs.width) {
x = cam->imgs.width - width;
}
}
roi.x = x;
@@ -156,20 +167,21 @@ static void algsec_img_roi(ctx_cam *cam, Mat &mat_src, Mat &mat_dst){
}
static void algsec_detect_hog(ctx_cam *cam, ctx_algsec_model &algmdl){
static void algsec_detect_hog(ctx_cam *cam, ctx_algsec_model &algmdl)
{
std::vector<double> detect_weights;
std::vector<Rect> detect_pos;
Mat mat_dst;
try {
if (algmdl.imagetype == "color"){
if (algmdl.imagetype == "color") {
/* AFAIK, the detector uses grey so users shouldn't really use this*/
Mat mat_src = Mat(cam->imgs.height*3/2, cam->imgs.width
, CV_8UC1, (void*)cam->algsec->image_norm);
cvtColor(mat_src, mat_dst, COLOR_YUV2RGB_YV12);
} else if (algmdl.imagetype == "roi"){
} else if (algmdl.imagetype == "roi") {
/*Discard really small and large images */
if ((cam->current_image->location.width < 64) ||
(cam->current_image->location.height < 64) ||
@@ -206,7 +218,8 @@ static void algsec_detect_hog(ctx_cam *cam, ctx_algsec_model &algmdl){
}
}
static void algsec_detect_haar(ctx_cam *cam, ctx_algsec_model &algmdl){
static void algsec_detect_haar(ctx_cam *cam, ctx_algsec_model &algmdl)
{
std::vector<double> detect_weights;
std::vector<Rect> detect_pos;
@@ -214,13 +227,13 @@ static void algsec_detect_haar(ctx_cam *cam, ctx_algsec_model &algmdl){
Mat mat_dst;
try {
if (algmdl.imagetype == "color"){
if (algmdl.imagetype == "color") {
/* AFAIK, the detector uses grey so users shouldn't really use this*/
Mat mat_src = Mat(cam->imgs.height*3/2, cam->imgs.width
, CV_8UC1, (void*)cam->algsec->image_norm);
cvtColor(mat_src, mat_dst, COLOR_YUV2RGB_YV12);
} else if (algmdl.imagetype == "roi"){
} else if (algmdl.imagetype == "roi") {
/*Discard really small and large images */
if ((cam->current_image->location.width < 64) ||
(cam->current_image->location.height < 64) ||
@@ -254,16 +267,17 @@ static void algsec_detect_haar(ctx_cam *cam, ctx_algsec_model &algmdl){
}
}
static void algsec_load_haar(ctx_algsec_model &algmdl){
static void algsec_load_haar(ctx_algsec_model &algmdl)
{
/* If loading fails, reset the method to invalidate detection */
try {
if (algmdl.modelfile == ""){
if (algmdl.modelfile == "") {
algmdl.method = 0;
MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, _("No secondary model specified."));
return;
}
if (!algmdl.haar_cascade.load(algmdl.modelfile)){
if (!algmdl.haar_cascade.load(algmdl.modelfile)) {
/* Loading failed, reset method*/
algmdl.method = 0;
MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, _("Failed loading model %s")
@@ -278,7 +292,8 @@ static void algsec_load_haar(ctx_algsec_model &algmdl){
}
}
static void algsec_parms_log(ctx_algsec_model &algmdl){
static void algsec_parms_log(ctx_algsec_model &algmdl)
{
motion_log(INF, TYPE_ALL, NO_ERRNO,0, "%-25s %s","modelfile", algmdl.modelfile.c_str());
motion_log(INF, TYPE_ALL, NO_ERRNO,0, "%-25s %0.6f","threshold_motion", algmdl.threshold_motion);
@@ -297,7 +312,8 @@ static void algsec_parms_log(ctx_algsec_model &algmdl){
}
static void algsec_parms_defaults(ctx_algsec_model &algmdl){
static void algsec_parms_defaults(ctx_algsec_model &algmdl)
{
algmdl.threshold_motion = 1.1;
algmdl.imagetype = "full";
@@ -310,7 +326,7 @@ static void algsec_parms_defaults(ctx_algsec_model &algmdl){
algmdl.haar_minsize = 8;
algmdl.haar_minneighbors = 8;
if (algmdl.method == 1){
if (algmdl.method == 1) {
algmdl.scalefactor = 1.1;
algmdl.threshold_model = 1.4;
} else {
@@ -343,7 +359,8 @@ static void algsec_parms_parse_microdetail(std::string &vin, ctx_algsec_model &a
}
/* Parse parm based upon equals*/
static void algsec_parms_parse_detail(std::string &vin, ctx_algsec_model &algmdl){
static void algsec_parms_parse_detail(std::string &vin, ctx_algsec_model &algmdl)
{
/* modelfile=/home/whatever/model.xml,threshold_motion=50*/
@@ -408,7 +425,7 @@ static void algsec_parms_parse(ctx_cam *cam){
std::string tmp;
if (cam->algsec->models.config != ""){
if (cam->algsec->models.config != "") {
st_comma = 0;
en_comma = cam->algsec->models.config.find(',', st_comma);
while (en_comma != std::string::npos){

View File

@@ -53,7 +53,7 @@ struct ctx_algsec_model {
int haar_maxsize;
bool isdetected; /* Bool reset for each image as to whether a detection occurred */
#ifdef HAVE_OPENCV
cv::CascadeClassifier haar_cascade; //Haar Cascade (if applicable)
cv::CascadeClassifier haar_cascade; /*Haar Cascade (if applicable) */
cv::HOGDescriptor hog;
#endif
};

View File

File diff suppressed because it is too large Load Diff

View File

@@ -24,8 +24,8 @@
#include "logger.hpp"
#include "dbse.hpp"
/*Edits to validate parms for database use */
static int dbse_global_edits(struct ctx_cam **cam_list){
static int dbse_global_edits(struct ctx_cam **cam_list)
{
int retcd = 0;
@@ -53,7 +53,8 @@ static int dbse_global_edits(struct ctx_cam **cam_list){
}
void dbse_global_deinit(struct ctx_cam **cam_list){
void dbse_global_deinit(struct ctx_cam **cam_list)
{
int indx;
@@ -88,7 +89,8 @@ void dbse_global_deinit(struct ctx_cam **cam_list){
}
void dbse_global_init(struct ctx_cam **cam_list){
void dbse_global_init(struct ctx_cam **cam_list)
{
int indx;
indx = 0;
@@ -171,7 +173,8 @@ void dbse_global_init(struct ctx_cam **cam_list){
}
}
static void dbse_init_mysql(struct ctx_cam *cam){
static void dbse_init_mysql(struct ctx_cam *cam)
{
#if defined(HAVE_MYSQL)
// close database to be sure that we are not leaking
@@ -210,7 +213,8 @@ static void dbse_init_mysql(struct ctx_cam *cam){
}
static void dbse_init_mariadb(struct ctx_cam *cam){
static void dbse_init_mariadb(struct ctx_cam *cam)
{
#if defined(HAVE_MARIADB)
// close database to be sure that we are not leaking
@@ -248,7 +252,8 @@ static void dbse_init_mariadb(struct ctx_cam *cam){
}
static void dbse_init_sqlite3(struct ctx_cam *cam){
static void dbse_init_sqlite3(struct ctx_cam *cam)
{
#ifdef HAVE_SQLITE3
if (cam->cam_list[0]->dbse->database_sqlite3 != 0) {
MOTION_LOG(NTC, TYPE_DB, NO_ERRNO,_("SQLite3 using shared handle"));
@@ -281,7 +286,8 @@ static void dbse_init_sqlite3(struct ctx_cam *cam){
}
static void dbse_init_pgsql(struct ctx_cam *cam){
static void dbse_init_pgsql(struct ctx_cam *cam)
{
#ifdef HAVE_PGSQL
char connstring[255];
/* Create the connection string.
@@ -313,7 +319,8 @@ static void dbse_init_pgsql(struct ctx_cam *cam){
return;
}
void dbse_init(struct ctx_cam *cam){
void dbse_init(struct ctx_cam *cam)
{
if (cam->conf->database_type != "") {
MOTION_LOG(NTC, TYPE_DB, NO_ERRNO
@@ -337,7 +344,8 @@ void dbse_init(struct ctx_cam *cam){
return;
}
void dbse_deinit(struct ctx_cam *cam){
void dbse_deinit(struct ctx_cam *cam)
{
if (cam->conf->database_type != "") {
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing database"));
@@ -372,7 +380,8 @@ void dbse_deinit(struct ctx_cam *cam){
}
void dbse_sqlmask_update(struct ctx_cam *cam){
void dbse_sqlmask_update(struct ctx_cam *cam)
{
/*
* Set the sql mask file according to the SQL config options
* We update it for every frame in case the config was updated
@@ -385,7 +394,8 @@ void dbse_sqlmask_update(struct ctx_cam *cam){
}
static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id)
{
#if defined(HAVE_MYSQL)
MOTION_LOG(DBG, TYPE_DB, NO_ERRNO, "Executing mysql query");
@@ -436,7 +446,8 @@ static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
}
static void dbse_mariadb_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
static void dbse_mariadb_exec(char *sqlquery,struct ctx_cam *cam, int save_id)
{
#if defined(HAVE_MARIADB)
MOTION_LOG(DBG, TYPE_DB, NO_ERRNO, "Executing mysql query");
@@ -487,7 +498,8 @@ static void dbse_mariadb_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
}
static void dbse_pgsql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
static void dbse_pgsql_exec(char *sqlquery,struct ctx_cam *cam, int save_id)
{
#ifdef HAVE_PGSQL
MOTION_LOG(DBG, TYPE_DB, NO_ERRNO, "Executing postgresql query");
PGresult *res;
@@ -532,7 +544,8 @@ static void dbse_pgsql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
}
static void dbse_sqlite3_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
static void dbse_sqlite3_exec(char *sqlquery,struct ctx_cam *cam, int save_id)
{
#ifdef HAVE_SQLITE3
int res;
char *errmsg = 0;
@@ -553,7 +566,8 @@ static void dbse_sqlite3_exec(char *sqlquery,struct ctx_cam *cam, int save_id) {
#endif /* HAVE_SQLITE3 */
}
void dbse_firstmotion(struct ctx_cam *cam){
void dbse_firstmotion(struct ctx_cam *cam)
{
char sqlquery[PATH_MAX];
@@ -577,7 +591,8 @@ void dbse_firstmotion(struct ctx_cam *cam){
}
void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1) {
void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1)
{
char sqlquery[PATH_MAX];
mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query.c_str(),
@@ -600,8 +615,8 @@ void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct times
}
void dbse_fileclose(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1) {
void dbse_fileclose(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1)
{
char sqlquery[PATH_MAX];
mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_stop.c_str(),

View File

@@ -1078,10 +1078,9 @@ struct draw_char draw_table[]= {
};
#define NEWLINE "\\n"
/**
* draw_textn
*/
static int draw_textn(unsigned char *image, int startx, int starty, int width, const char *text, int len, int factor)
static int draw_textn(unsigned char *image, int startx, int starty, int width
, const char *text, int len, int factor)
{
int x, y;
@@ -1137,10 +1136,8 @@ static int draw_textn(unsigned char *image, int startx, int starty, int width,
return 0;
}
/**
* draw_text
*/
int draw_text(unsigned char *image, int width, int height, int startx, int starty, const char *text, int factor)
int draw_text(unsigned char *image, int width, int height, int startx, int starty
, const char *text, int factor)
{
int num_nl = 0;
const char *end, *begin;
@@ -1189,8 +1186,8 @@ int draw_text(unsigned char *image, int width, int height, int startx, int start
return 0;
}
/** initialize_chars */
int draw_init_chars(void) {
int draw_init_chars(void)
{
unsigned int i;
size_t draw_table_size;
@@ -1209,7 +1206,8 @@ int draw_init_chars(void) {
return 0;
}
void draw_init_scale(struct ctx_cam *cam){
void draw_init_scale(struct ctx_cam *cam)
{
/* Consider that web interface may change conf values at any moment.
* The below can put two sections in the image so make sure that after
@@ -1238,9 +1236,8 @@ void draw_init_scale(struct ctx_cam *cam){
}
/** Draws a box around the movement. */
static void draw_location(struct ctx_coord *cent, struct ctx_images *imgs, int width, unsigned char *new_var,
int style, int mode)
static void draw_location(struct ctx_coord *cent, struct ctx_images *imgs, int width
, unsigned char *new_var, int style, int mode)
{
unsigned char *out = imgs->image_motion.image_norm;
int x, y;
@@ -1302,10 +1299,8 @@ static void draw_location(struct ctx_coord *cent, struct ctx_images *imgs, int w
}
}
/** Draws a RED box around the movement. */
static void draw_red_location(struct ctx_coord *cent, struct ctx_images *imgs, int width, unsigned char *new_var,
int style, int mode)
static void draw_red_location(struct ctx_coord *cent, struct ctx_images *imgs, int width
, unsigned char *new_var, int style, int mode)
{
unsigned char *out = imgs->image_motion.image_norm;
unsigned char *new_u, *new_v;
@@ -1413,7 +1408,8 @@ static void draw_red_location(struct ctx_coord *cent, struct ctx_images *imgs, i
}
}
void draw_locate_preview(struct ctx_cam *cam, struct ctx_image_data *img){
void draw_locate_preview(struct ctx_cam *cam, struct ctx_image_data *img)
{
/* draw locate box here when mode = LOCATE_PREVIEW */
if (cam->locate_motion_mode == LOCATE_PREVIEW) {
@@ -1433,7 +1429,8 @@ void draw_locate_preview(struct ctx_cam *cam, struct ctx_image_data *img){
}
}
void draw_locate(struct ctx_cam *cam, struct ctx_image_data *img){
void draw_locate(struct ctx_cam *cam, struct ctx_image_data *img)
{
struct ctx_images *imgs = &cam->imgs;
struct ctx_coord *location = &img->location;
@@ -1455,8 +1452,8 @@ void draw_locate(struct ctx_cam *cam, struct ctx_image_data *img){
}
}
/** Draw the smart mask on the motion images */
void draw_smartmask(struct ctx_cam *cam, unsigned char *out) {
void draw_smartmask(struct ctx_cam *cam, unsigned char *out)
{
int i, x, v, width, height, line;
struct ctx_images *imgs = &cam->imgs;
unsigned char *smartmask = imgs->smartmask_final;
@@ -1493,8 +1490,8 @@ void draw_smartmask(struct ctx_cam *cam, unsigned char *out) {
}
}
/** Draw the fixed mask on the motion images */
void draw_fixed_mask(struct ctx_cam *cam, unsigned char *out){
void draw_fixed_mask(struct ctx_cam *cam, unsigned char *out)
{
int i, x, v, width, height, line;
struct ctx_images *imgs = &cam->imgs;
unsigned char *mask = imgs->mask;
@@ -1531,8 +1528,8 @@ void draw_fixed_mask(struct ctx_cam *cam, unsigned char *out){
}
}
/** Draw largest label on the motion images */
void draw_largest_label(struct ctx_cam *cam, unsigned char *out) {
void draw_largest_label(struct ctx_cam *cam, unsigned char *out)
{
int i, x, v, width, height, line;
struct ctx_images *imgs = &cam->imgs;
int *labels = imgs->labels;

View File

@@ -68,19 +68,6 @@ const char *eventList[] = {
"EVENT_LAST"
};
/**
* eventToString
*
* returns string label of the event
*/
/**
* Future use debug / notification function
static const char *eventToString(motion_event e)
{
return eventList[(int)e];
}
*/
/**
* exec_command
* Execute 'command' with 'arg' as its argument.
@@ -121,8 +108,8 @@ static void exec_command(struct ctx_cam *cam, const char *command, char *filenam
}
static void event_newfile(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)cam;
(void)evnt;
@@ -136,8 +123,8 @@ static void event_newfile(struct ctx_cam *cam, motion_event evnt
static void event_beep(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -158,8 +145,8 @@ static void event_beep(struct ctx_cam *cam, motion_event evnt
* to the config parameter.
*/
static void on_picture_save_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int filetype = (unsigned long)ftype;
@@ -175,8 +162,8 @@ static void on_picture_save_command(struct ctx_cam *cam, motion_event evnt
}
static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -189,8 +176,8 @@ static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt
}
static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -206,8 +193,8 @@ static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt
}
static void event_sqlnewfile(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int sqltype = (unsigned long)ftype;
@@ -224,8 +211,8 @@ static void event_sqlnewfile(struct ctx_cam *cam, motion_event evnt
}
static void event_sqlfileclose(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int sqltype = (unsigned long)ftype;
@@ -243,8 +230,8 @@ static void event_sqlfileclose(struct ctx_cam *cam, motion_event evnt
}
static void on_area_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -257,8 +244,8 @@ static void on_area_command(struct ctx_cam *cam, motion_event evnt
}
static void on_event_start_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -271,8 +258,8 @@ static void on_event_start_command(struct ctx_cam *cam, motion_event evnt
}
static void on_event_end_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -285,8 +272,8 @@ static void on_event_end_command(struct ctx_cam *cam, motion_event evnt
}
static void event_stream_put(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)fname;
@@ -299,8 +286,8 @@ static void event_stream_put(struct ctx_cam *cam, motion_event evnt
static void event_vlp_putpipe(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)fname;
@@ -321,8 +308,8 @@ const char *imageext(struct ctx_cam *cam) {
}
static void event_image_detect(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
char fullfilename[PATH_MAX];
char filename[PATH_MAX];
@@ -352,8 +339,8 @@ static void event_image_detect(struct ctx_cam *cam, motion_event evnt
}
static void event_imagem_detect(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
char fullfilename[PATH_MAX];
char filename[PATH_MAX];
@@ -390,8 +377,8 @@ static void event_imagem_detect(struct ctx_cam *cam, motion_event evnt
}
static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
char fullfilename[PATH_MAX];
char filename[PATH_MAX];
@@ -442,8 +429,8 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt
}
static void event_image_preview(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
char previewname[PATH_MAX];
char filename[PATH_MAX];
@@ -482,8 +469,8 @@ static void event_image_preview(struct ctx_cam *cam, motion_event evnt
}
static void event_camera_lost(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -496,8 +483,8 @@ static void event_camera_lost(struct ctx_cam *cam, motion_event evnt
}
static void event_secondary_detect(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -512,8 +499,8 @@ static void event_secondary_detect(struct ctx_cam *cam, motion_event evnt
}
static void event_camera_found(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -526,8 +513,8 @@ static void event_camera_found(struct ctx_cam *cam, motion_event evnt
}
static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int filetype = (unsigned long) ftype;
@@ -540,8 +527,8 @@ static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt
}
static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -561,8 +548,8 @@ static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt
}
static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int retcd;
char stamp[PATH_MAX] = "";
@@ -629,8 +616,8 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt
}
static void event_extpipe_put(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int passthrough;
@@ -662,8 +649,8 @@ static void event_extpipe_put(struct ctx_cam *cam, motion_event evnt
}
static void event_new_video(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -682,8 +669,8 @@ static void event_new_video(struct ctx_cam *cam, motion_event evnt
}
static void event_movie_newfile(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int retcd;
@@ -719,8 +706,8 @@ static void event_movie_newfile(struct ctx_cam *cam, motion_event evnt
}
static void event_movie_timelapse(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int retcd;
@@ -748,8 +735,8 @@ static void event_movie_timelapse(struct ctx_cam *cam, motion_event evnt
}
static void event_movie_put(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)fname;
@@ -768,8 +755,8 @@ static void event_movie_put(struct ctx_cam *cam, motion_event evnt
}
static void event_movie_closefile(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -793,8 +780,8 @@ static void event_movie_closefile(struct ctx_cam *cam, motion_event evnt
}
static void event_movie_timelapseend(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
(void)evnt;
(void)img_data;
@@ -960,8 +947,8 @@ struct event_handlers event_handlers[] = {
* as a code reading friendly solution to avoid a stream of compiler warnings in gcc 4.0.
*/
void event(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname
,void *ftype, struct timespec *ts1) {
,struct ctx_image_data *img_data, char *fname,void *ftype, struct timespec *ts1)
{
int i=-1;
while (event_handlers[++i].handler) {

View File

@@ -164,10 +164,8 @@ static void put_subjectarea(struct tiff_writing *into, const struct ctx_coord *b
* exif data to be inserted into jpeg or webp files
*
*/
unsigned exif_prepare(unsigned char **exif,
const struct ctx_cam *cam,
const struct timespec *ts_in1,
const struct ctx_coord *box)
unsigned exif_prepare(unsigned char **exif, const struct ctx_cam *cam,
const struct timespec *ts_in1, const struct ctx_coord *box)
{
/* description, datetime, and subtime are the values that are actually
* put into the EXIF data

View File

@@ -49,32 +49,7 @@
#include "jpegutils.hpp"
#include "exif.hpp"
#include <setjmp.h>
/* This is a workaround regarding these defines. The config.h file defines
* HAVE_STDLIB_H as 1 whereas the jpeglib.h just defines it without a value.
* this causes massive warnings/error on mis-matched definitions. We do not
* control either of these so we have to suffer through this workaround hack
*/
#if (HAVE_STDLIB_H == 1)
#undef HAVE_STDLIB_H
#define HAVE_STDLIB_H_ORIG 1
#endif
#include <jpeglib.h>
#ifdef HAVE_STDLIB_H
#ifdef HAVE_STDLIB_H_ORIG
#undef HAVE_STDLIB_H
#undef HAVE_STDLIB_H_ORIG
#define HAVE_STDLIB_H 1
#else
#undef HAVE_STDLIB_H
#endif
#endif
#include <jerror.h>
#include <assert.h>
@@ -416,10 +391,8 @@ static GLOBAL(int) _jpeg_mem_size(j_compress_ptr cinfo)
* It must be called after jpeg_start_compress() but before
* any image data is written by jpeg_write_scanlines().
*/
static void put_jpeg_exif(j_compress_ptr cinfo,
const struct ctx_cam *cam,
const struct timespec *ts1,
const struct ctx_coord *box)
static void put_jpeg_exif(j_compress_ptr cinfo, const struct ctx_cam *cam,
const struct timespec *ts1, const struct ctx_coord *box)
{
unsigned char *exif = NULL;
unsigned exif_len = exif_prepare(&exif, cam, ts1, box);
@@ -447,7 +420,7 @@ static void put_jpeg_exif(j_compress_ptr cinfo,
* Success 0, Failure -1
*/
int jpgutl_decode_jpeg (unsigned char *jpeg_data_in, int jpeg_data_len,
unsigned int width, unsigned int height, unsigned char *volatile img_out)
unsigned int width, unsigned int height, unsigned char *volatile img_out)
{
JSAMPARRAY line; /* Array of decomp data lines */
unsigned char *wline; /* Will point to line[0] */
@@ -544,8 +517,8 @@ int jpgutl_decode_jpeg (unsigned char *jpeg_data_in, int jpeg_data_len,
}
int jpgutl_put_yuv420p(unsigned char *dest_image, int image_size,
unsigned char *input_image, int width, int height, int quality,
struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
unsigned char *input_image, int width, int height, int quality,
struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
{
int i, j, jpeg_image_size;
@@ -633,8 +606,8 @@ int jpgutl_put_yuv420p(unsigned char *dest_image, int image_size,
int jpgutl_put_grey(unsigned char *dest_image, int image_size,
unsigned char *input_image, int width, int height, int quality,
struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
unsigned char *input_image, int width, int height, int quality,
struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
{
int y, dest_image_size;
JSAMPROW row_ptr[1];

View File

@@ -33,7 +33,8 @@ static const char *log_level_str[] = {NULL, "EMG", "ALR", "CRT", "ERR", "WRN", "
static struct ctx_motapp *log_motapp; /*Used to access the parms mutex for updates*/
/** Returns index of log type or 0 if not valid type. */
static int log_get_type(const char *type) {
static int log_get_type(const char *type)
{
unsigned int i, ret = 0;
unsigned int maxtype = sizeof(log_type_str)/sizeof(const char *);
@@ -47,7 +48,8 @@ static int log_get_type(const char *type) {
return ret;
}
void log_set_type(const char *new_logtype) {
void log_set_type(const char *new_logtype)
{
if ( mystreq(new_logtype, log_type_str[log_type]) ) return;
@@ -57,7 +59,8 @@ void log_set_type(const char *new_logtype) {
}
void log_set_level(int new_loglevel) {
void log_set_level(int new_loglevel)
{
if (new_loglevel == log_level) return;
@@ -68,7 +71,8 @@ void log_set_level(int new_loglevel) {
}
/** Sets mode of logging, could be using syslog or files. */
static void log_set_mode(int mode) {
static void log_set_mode(int mode)
{
int prev_mode = log_mode;
log_mode = mode;
@@ -83,7 +87,8 @@ static void log_set_mode(int mode) {
}
/** Sets logfile to be used instead of syslog. */
static void log_set_logfile(const char *logfile_name) {
static void log_set_logfile(const char *logfile_name)
{
/* Setup temporary to let log if myfopen fails */
log_set_mode(LOGMODE_SYSLOG);
@@ -98,7 +103,8 @@ static void log_set_logfile(const char *logfile_name) {
}
/** Return string with human readable time */
static char *str_time(void) {
static char *str_time(void)
{
static char buffer[16];
time_t now = 0;
@@ -111,7 +117,8 @@ static char *str_time(void) {
* This routine is used for printing all informational, debug or error
* messages produced by any of the other motion functions.
*/
void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt, ...){
void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt, ...)
{
int errno_save, n;
char buf[1024]= {0};
char usrfmt[1024]= {0};
@@ -245,7 +252,8 @@ void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt
}
void log_init(struct ctx_motapp *motapp){
void log_init(struct ctx_motapp *motapp)
{
if ((motapp->log_level > ALL) ||
(motapp->log_level == 0)) {
@@ -290,7 +298,8 @@ void log_init(struct ctx_motapp *motapp){
}
void log_deinit(struct ctx_motapp *motapp){
void log_deinit(struct ctx_motapp *motapp)
{
if (logfile != NULL) {
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Closing logfile (%s)."),
@@ -302,7 +311,8 @@ void log_deinit(struct ctx_motapp *motapp){
}
void log_set_motapp(struct ctx_motapp *motapp){
void log_set_motapp(struct ctx_motapp *motapp)
{
/* Need better design to avoid the need to do this. Extern motapp to whole app? */
log_motapp = motapp; /* Set our static pointer used for locking parms mutex*/

View File

@@ -286,7 +286,8 @@ static void destroy_camera_buffer_structures(ctx_mmalcam_ptr mmalcam)
* -1 on any failure
*/
int mmalcam_start(struct ctx_cam *cam) {
int mmalcam_start(struct ctx_cam *cam)
{
#ifdef HAVE_MMAL
ctx_mmalcam_ptr mmalcam;
@@ -368,7 +369,8 @@ int mmalcam_start(struct ctx_cam *cam) {
* Returns: Nothing.
*
*/
void mmalcam_cleanup(struct ctx_mmalcam *mmalcam) {
void mmalcam_cleanup(struct ctx_mmalcam *mmalcam)
{
#ifdef HAVE_MMAL
MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, _("MMAL Camera cleanup"));
@@ -404,7 +406,8 @@ void mmalcam_cleanup(struct ctx_mmalcam *mmalcam) {
*
* Returns: Error code
*/
int mmalcam_next(struct ctx_cam *cam, struct ctx_image_data *img_data) {
int mmalcam_next(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
#ifdef HAVE_MMAL
ctx_mmalcam_ptr mmalcam;

View File

@@ -44,7 +44,8 @@
#define IMAGE_BUFFER_FLUSH ((unsigned int)-1)
static void mlp_ring_resize(struct ctx_cam *cam, int new_size) {
static void mlp_ring_resize(struct ctx_cam *cam, int new_size)
{
int smallest, i;
struct ctx_image_data *tmp;
@@ -89,7 +90,8 @@ static void mlp_ring_resize(struct ctx_cam *cam, int new_size) {
}
}
static void mlp_ring_destroy(struct ctx_cam *cam) {
static void mlp_ring_destroy(struct ctx_cam *cam)
{
int i;
if (cam->imgs.image_ring == NULL) return;
@@ -105,7 +107,8 @@ static void mlp_ring_destroy(struct ctx_cam *cam) {
cam->imgs.ring_size = 0;
}
static void mlp_ring_process_debug(struct ctx_cam *cam){
static void mlp_ring_process_debug(struct ctx_cam *cam)
{
char tmp[32];
const char *t;
@@ -130,7 +133,8 @@ static void mlp_ring_process_debug(struct ctx_cam *cam){
}
static void mlp_ring_process(struct ctx_cam *cam, unsigned int max_images) {
static void mlp_ring_process(struct ctx_cam *cam, unsigned int max_images)
{
struct ctx_image_data *saved_current_image = cam->current_image;
@@ -182,7 +186,8 @@ static void mlp_ring_process(struct ctx_cam *cam, unsigned int max_images) {
cam->current_image = saved_current_image;
}
static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img) {
static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img)
{
if (img->flags & IMAGE_TRIGGER) {
if (cam->event_nr != cam->prev_event) {
@@ -210,7 +215,8 @@ static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img
}
static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *img) {
static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *img)
{
struct ctx_config *conf = cam->conf;
unsigned int distX, distY;
@@ -240,7 +246,8 @@ static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *im
}
static void mlp_mask_privacy(struct ctx_cam *cam){
static void mlp_mask_privacy(struct ctx_cam *cam)
{
if (cam->imgs.mask_privacy == NULL) return;
@@ -316,7 +323,8 @@ static void mlp_mask_privacy(struct ctx_cam *cam){
}
}
static int init_camera_type(struct ctx_cam *cam){
static int init_camera_type(struct ctx_cam *cam)
{
cam->camera_type = CAMERA_TYPE_UNKNOWN;
@@ -349,7 +357,8 @@ static int init_camera_type(struct ctx_cam *cam){
}
/** Get first images from camera at startup */
static void mlp_init_firstimage(struct ctx_cam *cam) {
static void mlp_init_firstimage(struct ctx_cam *cam)
{
int indx;
@@ -370,7 +379,8 @@ static void mlp_init_firstimage(struct ctx_cam *cam) {
}
/** Check the image size to determine if modulo 8 and over 64 */
static int mlp_check_szimg(struct ctx_cam *cam){
static int mlp_check_szimg(struct ctx_cam *cam)
{
/* Revalidate we got a valid image size */
if ((cam->imgs.width % 8) || (cam->imgs.height % 8)) {
@@ -396,7 +406,8 @@ static int mlp_check_szimg(struct ctx_cam *cam){
}
/** Set the items required for the area detect */
static void mlp_init_areadetect(struct ctx_cam *cam){
static void mlp_init_areadetect(struct ctx_cam *cam)
{
/* Initialize area detection */
cam->area_minx[0] = cam->area_minx[3] = cam->area_minx[6] = 0;
@@ -422,7 +433,8 @@ static void mlp_init_areadetect(struct ctx_cam *cam){
}
/** Allocate the required buffers */
static void mlp_init_buffers(struct ctx_cam *cam){
static void mlp_init_buffers(struct ctx_cam *cam)
{
cam->imgs.ref =(unsigned char*) mymalloc(cam->imgs.size_norm);
cam->imgs.image_motion.image_norm = (unsigned char*)mymalloc(cam->imgs.size_norm);
@@ -447,7 +459,8 @@ static void mlp_init_buffers(struct ctx_cam *cam){
}
static void mlp_init_values(struct ctx_cam *cam) {
static void mlp_init_values(struct ctx_cam *cam)
{
cam->event_nr=1;
@@ -477,7 +490,8 @@ static void mlp_init_values(struct ctx_cam *cam) {
}
static int mlp_init_cam_start(struct ctx_cam *cam) {
static int mlp_init_cam_start(struct ctx_cam *cam)
{
cam->video_dev = vid_start(cam);
@@ -506,7 +520,8 @@ static int mlp_init_cam_start(struct ctx_cam *cam) {
}
static void mlp_init_ref(struct ctx_cam *cam) {
static void mlp_init_ref(struct ctx_cam *cam)
{
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
@@ -524,7 +539,8 @@ static void mlp_init_ref(struct ctx_cam *cam) {
}
/** mlp_init */
static int mlp_init(struct ctx_cam *cam) {
static int mlp_init(struct ctx_cam *cam)
{
mythreadname_set("ml",cam->threadnr,cam->conf->camera_name.c_str());
@@ -578,7 +594,8 @@ static int mlp_init(struct ctx_cam *cam) {
}
/** clean up all memory etc. from motion init */
void mlp_cleanup(struct ctx_cam *cam) {
void mlp_cleanup(struct ctx_cam *cam)
{
event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, NULL);
event(cam, EVENT_ENDMOTION, NULL, NULL, NULL, NULL);
@@ -668,7 +685,8 @@ void mlp_cleanup(struct ctx_cam *cam) {
}
static void mlp_areadetect(struct ctx_cam *cam){
static void mlp_areadetect(struct ctx_cam *cam)
{
int i, j, z = 0;
if ((cam->conf->area_detect != "" ) &&
@@ -694,7 +712,8 @@ static void mlp_areadetect(struct ctx_cam *cam){
}
static void mlp_prepare(struct ctx_cam *cam){
static void mlp_prepare(struct ctx_cam *cam)
{
int frame_buffer_size;
@@ -733,7 +752,8 @@ static void mlp_prepare(struct ctx_cam *cam){
}
static void mlp_resetimages(struct ctx_cam *cam){
static void mlp_resetimages(struct ctx_cam *cam)
{
if (cam->conf->minimum_frame_time) {
cam->minimum_frame_time_downcounter = cam->conf->minimum_frame_time;
@@ -764,7 +784,8 @@ static void mlp_resetimages(struct ctx_cam *cam){
}
static int mlp_retry(struct ctx_cam *cam){
static int mlp_retry(struct ctx_cam *cam)
{
/*
* If a camera is not available we keep on retrying every 10 seconds
@@ -813,7 +834,8 @@ static int mlp_retry(struct ctx_cam *cam){
return 0;
}
static int mlp_capture(struct ctx_cam *cam){
static int mlp_capture(struct ctx_cam *cam)
{
const char *tmpin;
char tmpout[80];
@@ -896,7 +918,8 @@ static int mlp_capture(struct ctx_cam *cam){
}
static void mlp_detection(struct ctx_cam *cam){
static void mlp_detection(struct ctx_cam *cam)
{
if (cam->frame_skip) {
cam->frame_skip--;
@@ -920,7 +943,8 @@ static void mlp_detection(struct ctx_cam *cam){
}
static void mlp_tuning(struct ctx_cam *cam){
static void mlp_tuning(struct ctx_cam *cam)
{
if ((cam->conf->noise_tune && cam->shots == 0) &&
(!cam->detecting_motion && (cam->current_image->diffs <= cam->threshold))) {
@@ -947,7 +971,8 @@ static void mlp_tuning(struct ctx_cam *cam){
}
static void mlp_overlay(struct ctx_cam *cam){
static void mlp_overlay(struct ctx_cam *cam)
{
char tmp[PATH_MAX];
@@ -1024,7 +1049,8 @@ static void mlp_overlay(struct ctx_cam *cam){
}
static void mlp_actions_emulate(struct ctx_cam *cam){
static void mlp_actions_emulate(struct ctx_cam *cam)
{
int indx;
@@ -1046,7 +1072,8 @@ static void mlp_actions_emulate(struct ctx_cam *cam){
}
static void mlp_actions_motion(struct ctx_cam *cam){
static void mlp_actions_motion(struct ctx_cam *cam)
{
int indx, frame_count = 0;
int pos = cam->imgs.ring_in;
@@ -1084,7 +1111,8 @@ static void mlp_actions_motion(struct ctx_cam *cam){
mlp_detected(cam, cam->video_dev, cam->current_image);
}
static void mlp_actions_event(struct ctx_cam *cam){
static void mlp_actions_event(struct ctx_cam *cam)
{
if ((cam->conf->movie_max_time > 0) &&
(cam->event_nr == cam->prev_event) &&
@@ -1125,7 +1153,8 @@ static void mlp_actions_event(struct ctx_cam *cam){
}
}
static void mlp_actions(struct ctx_cam *cam){
static void mlp_actions(struct ctx_cam *cam)
{
if ((cam->current_image->diffs > cam->threshold) &&
(cam->current_image->diffs < cam->threshold_maximum)) {
@@ -1162,7 +1191,8 @@ static void mlp_actions(struct ctx_cam *cam){
}
static void mlp_setupmode(struct ctx_cam *cam){
static void mlp_setupmode(struct ctx_cam *cam)
{
if (cam->motapp->setup_mode) {
char msg[1024] = "\0";
@@ -1196,7 +1226,8 @@ static void mlp_setupmode(struct ctx_cam *cam){
}
static void mlp_snapshot(struct ctx_cam *cam){
static void mlp_snapshot(struct ctx_cam *cam)
{
if ((cam->conf->snapshot_interval > 0 && cam->shots == 0 &&
cam->frame_curr_ts.tv_sec % cam->conf->snapshot_interval <=
@@ -1208,7 +1239,8 @@ static void mlp_snapshot(struct ctx_cam *cam){
}
static void mlp_timelapse(struct ctx_cam *cam){
static void mlp_timelapse(struct ctx_cam *cam)
{
struct tm timestamp_tm;
@@ -1257,7 +1289,8 @@ static void mlp_timelapse(struct ctx_cam *cam){
}
static void mlp_loopback(struct ctx_cam *cam){
static void mlp_loopback(struct ctx_cam *cam)
{
if (cam->motapp->setup_mode) {
event(cam, EVENT_IMAGE, &cam->imgs.image_motion, NULL, &cam->pipe, &cam->current_image->imgts);
@@ -1274,7 +1307,8 @@ static void mlp_loopback(struct ctx_cam *cam){
}
static void mlp_parmsupdate(struct ctx_cam *cam){
static void mlp_parmsupdate(struct ctx_cam *cam)
{
/* Check for some config parameter changes but only every second */
if (cam->shots != 0) return;
@@ -1360,7 +1394,8 @@ static void mlp_parmsupdate(struct ctx_cam *cam){
}
static void mlp_frametiming(struct ctx_cam *cam){
static void mlp_frametiming(struct ctx_cam *cam)
{
int indx;
struct timespec ts2;
@@ -1402,7 +1437,8 @@ static void mlp_frametiming(struct ctx_cam *cam){
}
/** Thread function for each camera */
void *motion_loop(void *arg) {
void *motion_loop(void *arg)
{
struct ctx_cam *cam =(struct ctx_cam *) arg;

View File

@@ -33,7 +33,8 @@ pthread_key_t tls_key_threadnr;
volatile enum MOTION_SIGNAL motsignal;
/** Process signals sent */
static void motion_signal_process(struct ctx_motapp *motapp){
static void motion_signal_process(struct ctx_motapp *motapp)
{
int indx;
switch(motsignal){
@@ -79,7 +80,8 @@ static void motion_signal_process(struct ctx_motapp *motapp){
}
/** Handle signals sent */
static void sig_handler(int signo) {
static void sig_handler(int signo)
{
/*The FALLTHROUGH is a special comment required by compiler. Do not edit it*/
switch(signo) {
@@ -120,7 +122,8 @@ static void sigchild_handler(int signo)
}
/** Attach handlers to a number of signals that Motion need to catch. */
static void setup_signals(void){
static void setup_signals(void)
{
struct sigaction sig_handler_action;
struct sigaction sigchild_action;
@@ -158,7 +161,8 @@ static void setup_signals(void){
}
/** Remove the process id file ( pid file ) before motion exit. */
static void motion_remove_pid(struct ctx_motapp *motapp) {
static void motion_remove_pid(struct ctx_motapp *motapp)
{
if ((motapp->daemon) &&
(motapp->pid_file != "") &&
@@ -173,7 +177,8 @@ static void motion_remove_pid(struct ctx_motapp *motapp) {
}
/** Turn Motion into a daemon through forking. */
static void motion_daemon(struct ctx_motapp *motapp) {
static void motion_daemon(struct ctx_motapp *motapp)
{
int fd;
FILE *pidf = NULL;
struct sigaction sig_ign_action;
@@ -259,7 +264,8 @@ static void motion_daemon(struct ctx_motapp *motapp) {
sigaction(SIGTSTP, &sig_ign_action, NULL);
}
static void motion_shutdown(struct ctx_motapp *motapp){
static void motion_shutdown(struct ctx_motapp *motapp)
{
motion_remove_pid(motapp);
@@ -275,7 +281,8 @@ static void motion_shutdown(struct ctx_motapp *motapp){
}
static void motion_camera_ids(struct ctx_cam **cam_list){
static void motion_camera_ids(struct ctx_cam **cam_list)
{
/* Set the camera id's on the ctx_cam. They must be unique */
int indx, indx2;
int invalid_ids;
@@ -313,7 +320,8 @@ static void motion_camera_ids(struct ctx_cam **cam_list){
}
}
static void motion_ntc(void){
static void motion_ntc(void)
{
#ifdef HAVE_V4L2
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,_("v4l2 : available"));
@@ -366,7 +374,8 @@ static void motion_ntc(void){
}
/** Initialize upon start up or restart */
static void motion_startup(struct ctx_motapp *motapp, int daemonize, int argc, char *argv[]) {
static void motion_startup(struct ctx_motapp *motapp, int daemonize, int argc, char *argv[])
{
log_set_motapp(motapp); /* This is needed prior to any function possibly calling motion_log*/
@@ -408,7 +417,8 @@ static void motion_startup(struct ctx_motapp *motapp, int daemonize, int argc, c
}
/** Start a camera thread */
static void motion_start_thread(struct ctx_motapp *motapp, int indx){
static void motion_start_thread(struct ctx_motapp *motapp, int indx)
{
pthread_attr_t thread_attr;
pthread_mutex_lock(&motapp->global_lock);
@@ -434,7 +444,8 @@ static void motion_start_thread(struct ctx_motapp *motapp, int indx){
}
static void motion_restart(struct ctx_motapp *motapp, int argc, char **argv){
static void motion_restart(struct ctx_motapp *motapp, int argc, char **argv)
{
MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO,_("Restarting motion."));
@@ -449,7 +460,8 @@ static void motion_restart(struct ctx_motapp *motapp, int argc, char **argv){
}
static void motion_watchdog(struct ctx_motapp *motapp, int indx){
static void motion_watchdog(struct ctx_motapp *motapp, int indx)
{
/* Notes:
* To test scenarios, just double lock a mutex in a spawned thread.
@@ -540,7 +552,8 @@ static void motion_watchdog(struct ctx_motapp *motapp, int indx){
}
static int motion_check_threadcount(struct ctx_motapp *motapp){
static int motion_check_threadcount(struct ctx_motapp *motapp)
{
/* Return 1 if we should break out of loop */
/* It has been observed that this is not counting every
@@ -588,7 +601,8 @@ static int motion_check_threadcount(struct ctx_motapp *motapp){
}
static void motion_init(struct ctx_motapp *motapp){
static void motion_init(struct ctx_motapp *motapp)
{
motapp->cam_list = NULL;
pthread_mutex_init(&motapp->global_lock, NULL);
@@ -623,7 +637,8 @@ static void motion_init(struct ctx_motapp *motapp){
}
/** Main entry point of Motion. */
int main (int argc, char **argv) {
int main (int argc, char **argv)
{
int indx;
struct ctx_motapp *motapp;

View File

@@ -42,11 +42,8 @@
#include "movie.hpp"
/****************************************************************************
****************************************************************************
****************************************************************************/
/*********************************************/
static void movie_free_nal(struct ctx_movie *movie){
static void movie_free_nal(struct ctx_movie *movie)
{
if (movie->nal_info) {
free(movie->nal_info);
movie->nal_info = NULL;
@@ -54,7 +51,8 @@ static void movie_free_nal(struct ctx_movie *movie){
}
}
static void movie_encode_nal(struct ctx_movie *movie){
static void movie_encode_nal(struct ctx_movie *movie)
{
// h264_v4l2m2m has NAL units separated from the first frame, which makes
// some players very unhappy.
if ((movie->pkt.pts == 0) && (!(movie->pkt.flags & AV_PKT_FLAG_KEY))) {
@@ -74,7 +72,8 @@ static void movie_encode_nal(struct ctx_movie *movie){
}
}
static int movie_timelapse_exists(const char *fname){
static int movie_timelapse_exists(const char *fname)
{
FILE *file;
file = fopen(fname, "r");
if (file)
@@ -85,7 +84,8 @@ static int movie_timelapse_exists(const char *fname){
return 0;
}
static int movie_timelapse_append(struct ctx_movie *movie, AVPacket pkt){
static int movie_timelapse_append(struct ctx_movie *movie, AVPacket pkt)
{
FILE *file;
file = fopen(movie->filename, "a");
@@ -138,7 +138,8 @@ static int movie_timelapse_append(struct ctx_movie *movie, AVPacket pkt){
}
#endif
static void movie_free_context(struct ctx_movie *movie){
static void movie_free_context(struct ctx_movie *movie)
{
if (movie->picture != NULL){
myframe_free(movie->picture);
@@ -157,7 +158,8 @@ static void movie_free_context(struct ctx_movie *movie){
}
static int movie_get_oformat(struct ctx_movie *movie){
static int movie_get_oformat(struct ctx_movie *movie)
{
size_t codec_name_len = strcspn(movie->codec_name, ":");
char *codec_name =(char*) malloc(codec_name_len + 1);
@@ -293,7 +295,8 @@ static int movie_get_oformat(struct ctx_movie *movie){
return 0;
}
static int movie_encode_video(struct ctx_movie *movie){
static int movie_encode_video(struct ctx_movie *movie)
{
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
//ffmpeg version 3.1 and after
@@ -400,7 +403,8 @@ static int movie_encode_video(struct ctx_movie *movie){
}
static int movie_set_pts(struct ctx_movie *movie, const struct timespec *ts1){
static int movie_set_pts(struct ctx_movie *movie, const struct timespec *ts1)
{
int64_t pts_interval;
@@ -439,7 +443,8 @@ static int movie_set_pts(struct ctx_movie *movie, const struct timespec *ts1){
return 0;
}
static int movie_set_pktpts(struct ctx_movie *movie, const struct timespec *ts1){
static int movie_set_pktpts(struct ctx_movie *movie, const struct timespec *ts1)
{
int64_t pts_interval;
@@ -478,7 +483,8 @@ static int movie_set_pktpts(struct ctx_movie *movie, const struct timespec *ts1)
return 0;
}
static int movie_set_quality(struct ctx_movie *movie){
static int movie_set_quality(struct ctx_movie *movie)
{
movie->opts = 0;
if (movie->quality > 100) movie->quality = 100;
@@ -540,7 +546,8 @@ struct blacklist_t
const char *reason;
};
static const char *movie_codec_is_blacklisted(const char *codec_name){
static const char *movie_codec_is_blacklisted(const char *codec_name)
{
static struct blacklist_t blacklisted_codec[] =
{
@@ -568,7 +575,8 @@ static const char *movie_codec_is_blacklisted(const char *codec_name){
return NULL;
}
static int movie_set_codec_preferred(struct ctx_movie *movie){
static int movie_set_codec_preferred(struct ctx_movie *movie)
{
size_t codec_name_len = strcspn(movie->codec_name, ":");
movie->codec = NULL;
@@ -615,7 +623,8 @@ static int movie_set_codec_preferred(struct ctx_movie *movie){
}
static int movie_set_codec(struct ctx_movie *movie){
static int movie_set_codec(struct ctx_movie *movie)
{
int retcd;
char errstr[128];
@@ -742,7 +751,8 @@ static int movie_set_codec(struct ctx_movie *movie){
return 0;
}
static int movie_set_stream(struct ctx_movie *movie){
static int movie_set_stream(struct ctx_movie *movie)
{
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
int retcd;
@@ -822,7 +832,8 @@ static int movie_alloc_video_buffer(AVFrame *frame, int align)
}
static int movie_set_picture(struct ctx_movie *movie){
static int movie_set_picture(struct ctx_movie *movie)
{
int retcd;
char errstr[128];
@@ -860,7 +871,8 @@ static int movie_set_picture(struct ctx_movie *movie){
}
static int movie_set_outputfile(struct ctx_movie *movie){
static int movie_set_outputfile(struct ctx_movie *movie)
{
int retcd;
char errstr[128];
@@ -927,7 +939,8 @@ static int movie_set_outputfile(struct ctx_movie *movie){
}
static int movie_flush_codec(struct ctx_movie *movie){
static int movie_flush_codec(struct ctx_movie *movie)
{
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
//ffmpeg version 3.1 and after
@@ -991,7 +1004,8 @@ static int movie_flush_codec(struct ctx_movie *movie){
}
static int movie_put_frame(struct ctx_movie *movie, const struct timespec *ts1){
static int movie_put_frame(struct ctx_movie *movie, const struct timespec *ts1)
{
int retcd;
av_init_packet(&movie->pkt);
@@ -1029,7 +1043,8 @@ static int movie_put_frame(struct ctx_movie *movie, const struct timespec *ts1){
}
static void movie_passthru_reset(struct ctx_movie *movie){
static void movie_passthru_reset(struct ctx_movie *movie)
{
/* Reset the written flag at start of each event */
int indx;
@@ -1041,7 +1056,8 @@ static void movie_passthru_reset(struct ctx_movie *movie){
}
static void movie_passthru_write(struct ctx_movie *movie, int indx){
static void movie_passthru_write(struct ctx_movie *movie, int indx)
{
/* Write the packet in the buffer at indx to file */
char errstr[128];
int retcd;
@@ -1080,7 +1096,8 @@ static void movie_passthru_write(struct ctx_movie *movie, int indx){
}
static int movie_passthru_put(struct ctx_movie *movie, struct ctx_image_data *img_data){
static int movie_passthru_put(struct ctx_movie *movie, struct ctx_image_data *img_data)
{
int idnbr_image, idnbr_lastwritten, idnbr_stop, idnbr_firstkey;
int indx, indx_lastwritten, indx_firstkey;
@@ -1150,7 +1167,8 @@ static int movie_passthru_put(struct ctx_movie *movie, struct ctx_image_data *im
return 0;
}
static int movie_passthru_codec(struct ctx_movie *movie){
static int movie_passthru_codec(struct ctx_movie *movie)
{
int retcd;
AVStream *stream_in;
@@ -1235,7 +1253,8 @@ static int movie_passthru_codec(struct ctx_movie *movie){
}
void movie_avcodec_log(void *ignoreme, int errno_flag, const char *fmt, va_list vl){
void movie_avcodec_log(void *ignoreme, int errno_flag, const char *fmt, va_list vl)
{
char buf[1024];
char *end;
@@ -1267,7 +1286,8 @@ void movie_avcodec_log(void *ignoreme, int errno_flag, const char *fmt, va_list
}
static void movie_put_pix_nv21(struct ctx_movie *movie, struct ctx_image_data *img_data){
static void movie_put_pix_nv21(struct ctx_movie *movie, struct ctx_image_data *img_data)
{
unsigned char *image,*imagecr, *imagecb;
int cr_len, x, y;
@@ -1293,7 +1313,8 @@ static void movie_put_pix_nv21(struct ctx_movie *movie, struct ctx_image_data *i
}
static void movie_put_pix_yuv420(struct ctx_movie *movie, struct ctx_image_data *img_data){
static void movie_put_pix_yuv420(struct ctx_movie *movie, struct ctx_image_data *img_data)
{
unsigned char *image;
if (movie->high_resolution){
@@ -1309,12 +1330,8 @@ static void movie_put_pix_yuv420(struct ctx_movie *movie, struct ctx_image_data
}
/****************************************************************************
****************************************************************************
****************************************************************************/
void movie_global_init(void){
void movie_global_init(void)
{
MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, _("libavcodec version %d.%d.%d")
, LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO);
@@ -1344,7 +1361,8 @@ void movie_global_init(void){
}
void movie_global_deinit(void) {
void movie_global_deinit(void)
{
avformat_network_deinit();
@@ -1360,7 +1378,8 @@ void movie_global_deinit(void) {
}
int movie_open(struct ctx_movie *movie){
int movie_open(struct ctx_movie *movie)
{
int retcd;
@@ -1418,7 +1437,8 @@ int movie_open(struct ctx_movie *movie){
}
void movie_close(struct ctx_movie *movie){
void movie_close(struct ctx_movie *movie)
{
if (movie != NULL) {
@@ -1442,7 +1462,8 @@ void movie_close(struct ctx_movie *movie){
}
int movie_put_image(struct ctx_movie *movie, struct ctx_image_data *img_data, const struct timespec *ts1){
int movie_put_image(struct ctx_movie *movie, struct ctx_image_data *img_data, const struct timespec *ts1)
{
int retcd = 0;
int cnt = 0;
@@ -1497,7 +1518,8 @@ int movie_put_image(struct ctx_movie *movie, struct ctx_image_data *img_data, co
}
void movie_reset_start_time(struct ctx_movie *movie, const struct timespec *ts1){
void movie_reset_start_time(struct ctx_movie *movie, const struct timespec *ts1)
{
int64_t one_frame_interval = av_rescale_q(1,(AVRational){1, movie->fps},movie->video_st->time_base);
if (one_frame_interval <= 0)
one_frame_interval = 1;
@@ -1508,7 +1530,8 @@ void movie_reset_start_time(struct ctx_movie *movie, const struct timespec *ts1)
}
static const char* movie_init_codec(struct ctx_cam *cam){
static const char* movie_init_codec(struct ctx_cam *cam)
{
/* The following section allows for testing of all the various containers
* that Motion permits. The container type is pre-pended to the name of the
@@ -1544,7 +1567,8 @@ static const char* movie_init_codec(struct ctx_cam *cam){
}
int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){
int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1)
{
char stamp[PATH_MAX];
const char *codec;
int retcd;
@@ -1601,7 +1625,8 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){
}
int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){
int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1)
{
char stamp[PATH_MAX];
const char *codec;
int retcd;
@@ -1652,7 +1677,8 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){
}
int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){
int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1)
{
char tmp[PATH_MAX];
const char *codec_mpg = "mpg";

View File

@@ -41,7 +41,8 @@
#include "video_v4l2.hpp" /* Needed to validate palette for v4l2 via netcam */
#include "movie.hpp"
static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) {
static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes)
{
int min_size_to_alloc;
int real_alloc;
int new_size;
@@ -106,7 +107,8 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) {
* Returns: The string which was matched
*
*/
static char *netcam_url_match(regmatch_t m, const char *input) {
static char *netcam_url_match(regmatch_t m, const char *input)
{
char *match = NULL;
int len;
@@ -122,7 +124,8 @@ static char *netcam_url_match(regmatch_t m, const char *input) {
return match;
}
static void netcam_url_invalid(struct url_t *parse_url){
static void netcam_url_invalid(struct url_t *parse_url)
{
MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO,_("Invalid URL. Can not parse values."));
@@ -150,7 +153,8 @@ static void netcam_url_invalid(struct url_t *parse_url){
* Returns: Nothing
*
*/
static void netcam_url_parse(struct url_t *parse_url, const char *text_url) {
static void netcam_url_parse(struct url_t *parse_url, const char *text_url)
{
char *s;
int i;
@@ -246,7 +250,8 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) {
* Returns: Nothing
*
*/
static void netcam_url_free(struct url_t *parse_url) {
static void netcam_url_free(struct url_t *parse_url)
{
free(parse_url->service);
parse_url->service = NULL;
@@ -260,7 +265,8 @@ static void netcam_url_free(struct url_t *parse_url) {
parse_url->path = NULL;
}
static int netcam_check_pixfmt(struct ctx_netcam *netcam){
static int netcam_check_pixfmt(struct ctx_netcam *netcam)
{
/* Determine if the format is YUV420P */
int retcd;
@@ -272,7 +278,8 @@ static int netcam_check_pixfmt(struct ctx_netcam *netcam){
}
static void netcam_pktarray_free(struct ctx_netcam *netcam){
static void netcam_pktarray_free(struct ctx_netcam *netcam)
{
int indx;
pthread_mutex_lock(&netcam->mutex_pktarray);
@@ -291,7 +298,8 @@ static void netcam_pktarray_free(struct ctx_netcam *netcam){
}
static void netcam_null_context(struct ctx_netcam *netcam){
static void netcam_null_context(struct ctx_netcam *netcam)
{
netcam->swsctx = NULL;
netcam->swsframe_in = NULL;
@@ -304,7 +312,8 @@ static void netcam_null_context(struct ctx_netcam *netcam){
}
static void netcam_close_context(struct ctx_netcam *netcam){
static void netcam_close_context(struct ctx_netcam *netcam)
{
if (netcam->swsctx != NULL) sws_freeContext(netcam->swsctx);
if (netcam->swsframe_in != NULL) myframe_free(netcam->swsframe_in);
@@ -319,7 +328,8 @@ static void netcam_close_context(struct ctx_netcam *netcam){
}
static void netcam_pktarray_resize(struct ctx_cam *cam, int is_highres){
static void netcam_pktarray_resize(struct ctx_cam *cam, int is_highres)
{
/* This is called from netcam_next and is on the motion loop thread
* The netcam->mutex is locked around the call to this function.
*/
@@ -386,7 +396,8 @@ static void netcam_pktarray_resize(struct ctx_cam *cam, int is_highres){
}
static void netcam_pktarray_add(struct ctx_netcam *netcam){
static void netcam_pktarray_add(struct ctx_netcam *netcam)
{
int indx_next;
int retcd;
@@ -438,7 +449,8 @@ static void netcam_pktarray_add(struct ctx_netcam *netcam){
}
static int netcam_decode_sw(struct ctx_netcam *netcam){
static int netcam_decode_sw(struct ctx_netcam *netcam)
{
int retcd;
char errstr[128];
@@ -468,7 +480,8 @@ static int netcam_decode_sw(struct ctx_netcam *netcam){
}
static int netcam_decode_vaapi(struct ctx_netcam *netcam){
static int netcam_decode_vaapi(struct ctx_netcam *netcam)
{
int retcd;
char errstr[128];
@@ -518,7 +531,8 @@ static int netcam_decode_vaapi(struct ctx_netcam *netcam){
* 1 valid data
*/
static int netcam_decode_video(struct ctx_netcam *netcam){
static int netcam_decode_video(struct ctx_netcam *netcam)
{
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
@@ -591,7 +605,8 @@ static int netcam_decode_video(struct ctx_netcam *netcam){
}
static int netcam_decode_packet(struct ctx_netcam *netcam){
static int netcam_decode_packet(struct ctx_netcam *netcam)
{
int frame_size;
int retcd;
@@ -626,7 +641,8 @@ static int netcam_decode_packet(struct ctx_netcam *netcam){
return frame_size;
}
static void netcam_hwdecoders(struct ctx_netcam *netcam){
static void netcam_hwdecoders(struct ctx_netcam *netcam)
{
/* High Res pass through does not decode images into frames*/
if (netcam->high_resolution && netcam->passthrough) return;
@@ -653,7 +669,8 @@ static void netcam_hwdecoders(struct ctx_netcam *netcam){
return;
}
static enum AVPixelFormat netcam_getfmt_vaapi(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) {
static enum AVPixelFormat netcam_getfmt_vaapi(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
{
const enum AVPixelFormat *p;
(void)avctx;
@@ -665,7 +682,8 @@ static enum AVPixelFormat netcam_getfmt_vaapi(AVCodecContext *avctx, const enum
return AV_PIX_FMT_NONE;
}
static void netcam_decoder_error(struct ctx_netcam *netcam, int retcd, const char* fnc_nm){
static void netcam_decoder_error(struct ctx_netcam *netcam, int retcd, const char* fnc_nm)
{
char errstr[128];
@@ -697,7 +715,8 @@ static void netcam_decoder_error(struct ctx_netcam *netcam, int retcd, const cha
}
static int netcam_init_vaapi(struct ctx_netcam *netcam){
static int netcam_init_vaapi(struct ctx_netcam *netcam)
{
int retcd;
@@ -742,7 +761,8 @@ static int netcam_init_vaapi(struct ctx_netcam *netcam){
return 0;
}
static int netcam_init_swdecoder(struct ctx_netcam *netcam) {
static int netcam_init_swdecoder(struct ctx_netcam *netcam)
{
int retcd;
@@ -784,7 +804,8 @@ static int netcam_init_swdecoder(struct ctx_netcam *netcam) {
return 0;
}
static int netcam_open_codec(struct ctx_netcam *netcam) {
static int netcam_open_codec(struct ctx_netcam *netcam)
{
int retcd;
@@ -823,7 +844,8 @@ static int netcam_open_codec(struct ctx_netcam *netcam) {
return 0;
}
static struct ctx_netcam *netcam_new_context(void){
static struct ctx_netcam *netcam_new_context(void)
{
struct ctx_netcam *ret;
/* Note that mymalloc will exit on any problem. */
@@ -834,7 +856,8 @@ static struct ctx_netcam *netcam_new_context(void){
return ret;
}
static int netcam_interrupt(void *ctx){
static int netcam_interrupt(void *ctx)
{
struct ctx_netcam *netcam = (struct ctx_netcam *)ctx;
if (netcam->finish){
@@ -877,7 +900,8 @@ static int netcam_interrupt(void *ctx){
return FALSE;
}
static int netcam_open_sws(struct ctx_netcam *netcam){
static int netcam_open_sws(struct ctx_netcam *netcam)
{
if (netcam->finish) return -1; /* This just speeds up the shutdown time */
@@ -953,7 +977,8 @@ static int netcam_open_sws(struct ctx_netcam *netcam){
}
static int netcam_resize(struct ctx_netcam *netcam){
static int netcam_resize(struct ctx_netcam *netcam)
{
int retcd;
char errstr[128];
@@ -1045,7 +1070,8 @@ static int netcam_resize(struct ctx_netcam *netcam){
}
static int netcam_read_image(struct ctx_netcam *netcam){
static int netcam_read_image(struct ctx_netcam *netcam)
{
int size_decoded, retcd, haveimage, errcnt;
char errstr[128];
@@ -1085,7 +1111,7 @@ static int netcam_read_image(struct ctx_netcam *netcam){
if (netcam->interrupted) {
MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO
,_("%s: Interrupted")
,netcam->cameratype);
,netcam->cameratype);
} else {
av_strerror(retcd, errstr, sizeof(errstr));
MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO
@@ -1160,7 +1186,8 @@ static int netcam_read_image(struct ctx_netcam *netcam){
return 0;
}
static int netcam_ntc(struct ctx_netcam *netcam){
static int netcam_ntc(struct ctx_netcam *netcam)
{
if ((netcam->finish) || (!netcam->first_image)) return 0;
@@ -1185,7 +1212,8 @@ static int netcam_ntc(struct ctx_netcam *netcam){
}
static void netcam_set_http(struct ctx_netcam *netcam){
static void netcam_set_http(struct ctx_netcam *netcam)
{
netcam->format_context->iformat = av_find_input_format("mjpeg");
MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO
@@ -1193,7 +1221,8 @@ static void netcam_set_http(struct ctx_netcam *netcam){
}
static void netcam_set_rtsp(struct ctx_netcam *netcam){
static void netcam_set_rtsp(struct ctx_netcam *netcam)
{
if (netcam->rtsp_uses_tcp) {
av_dict_set(&netcam->opts, "rtsp_transport", "tcp", 0);
@@ -1214,7 +1243,8 @@ static void netcam_set_rtsp(struct ctx_netcam *netcam){
}
}
static void netcam_set_file(struct ctx_netcam *netcam){
static void netcam_set_file(struct ctx_netcam *netcam)
{
/* This is a place holder for the moment. We will add into
* this function any options that must be set for ffmpeg to
@@ -1226,7 +1256,8 @@ static void netcam_set_file(struct ctx_netcam *netcam){
}
static void netcam_set_v4l2(struct ctx_netcam *netcam){
static void netcam_set_v4l2(struct ctx_netcam *netcam)
{
char optsize[10], optfmt[10], optfps[10];
char *fourcc;
@@ -1293,7 +1324,8 @@ static void netcam_set_v4l2(struct ctx_netcam *netcam){
}
static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) {
static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam )
{
char userpass[PATH_MAX];
struct url_t url;
@@ -1357,7 +1389,8 @@ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) {
}
static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) {
static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam )
{
/* Set the parameters to be used with our camera */
int retcd;
@@ -1433,7 +1466,8 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) {
}
static int netcam_set_dimensions (struct ctx_cam *cam) {
static int netcam_set_dimensions (struct ctx_cam *cam)
{
cam->imgs.width = 0;
cam->imgs.height = 0;
@@ -1470,7 +1504,8 @@ static int netcam_set_dimensions (struct ctx_cam *cam) {
return 0;
}
static int netcam_copy_stream(struct ctx_netcam *netcam){
static int netcam_copy_stream(struct ctx_netcam *netcam)
{
/* Make a static copy of the stream information for use in passthrough processing */
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
AVStream *transfer_stream, *stream_in;
@@ -1523,7 +1558,8 @@ static int netcam_copy_stream(struct ctx_netcam *netcam){
}
static int netcam_open_context(struct ctx_netcam *netcam){
static int netcam_open_context(struct ctx_netcam *netcam)
{
int retcd;
char errstr[128];
@@ -1683,7 +1719,8 @@ static int netcam_open_context(struct ctx_netcam *netcam){
}
static int netcam_connect(struct ctx_netcam *netcam){
static int netcam_connect(struct ctx_netcam *netcam)
{
if (netcam_open_context(netcam) < 0) return -1;
@@ -1731,7 +1768,8 @@ static int netcam_connect(struct ctx_netcam *netcam){
return 0;
}
static void netcam_shutdown(struct ctx_netcam *netcam){
static void netcam_shutdown(struct ctx_netcam *netcam)
{
if (netcam) {
netcam_close_context(netcam);
@@ -1759,7 +1797,8 @@ static void netcam_shutdown(struct ctx_netcam *netcam){
}
static void netcam_handler_wait(struct ctx_netcam *netcam){
static void netcam_handler_wait(struct ctx_netcam *netcam)
{
long usec_maxrate, usec_delay;
pthread_mutex_lock(&netcam->motapp->mutex_parms);
@@ -1784,7 +1823,8 @@ static void netcam_handler_wait(struct ctx_netcam *netcam){
}
static void netcam_handler_reconnect(struct ctx_netcam *netcam){
static void netcam_handler_reconnect(struct ctx_netcam *netcam)
{
int retcd;
@@ -1820,7 +1860,8 @@ static void netcam_handler_reconnect(struct ctx_netcam *netcam){
}
static void *netcam_handler(void *arg){
static void *netcam_handler(void *arg)
{
struct ctx_netcam *netcam =(struct ctx_netcam *) arg;
@@ -1867,7 +1908,8 @@ static void *netcam_handler(void *arg){
pthread_exit(NULL);
}
static int netcam_start_handler(struct ctx_netcam *netcam){
static int netcam_start_handler(struct ctx_netcam *netcam)
{
int retcd, wait_counter;
pthread_attr_t handler_attribute;
@@ -1915,7 +1957,8 @@ static int netcam_start_handler(struct ctx_netcam *netcam){
}
int netcam_setup(struct ctx_cam *cam){
int netcam_setup(struct ctx_cam *cam)
{
int retcd;
int indx_cam, indx_max;
@@ -1987,7 +2030,8 @@ int netcam_setup(struct ctx_cam *cam){
}
int netcam_next(struct ctx_cam *cam, struct ctx_image_data *img_data){
int netcam_next(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
/* This is called from the motion loop thread */
@@ -2024,7 +2068,8 @@ int netcam_next(struct ctx_cam *cam, struct ctx_image_data *img_data){
return 0;
}
void netcam_cleanup(struct ctx_cam *cam, int init_retry_flag){
void netcam_cleanup(struct ctx_cam *cam, int init_retry_flag)
{
/*
* If the init_retry_flag is not set this function was

View File

@@ -39,10 +39,8 @@
* It must be called after WebPEncode() and the result
* can then be written out to webp a file
*/
static void pic_webp_exif(WebPMux* webp_mux,
const struct ctx_cam *cam,
const struct timespec *ts1,
const struct ctx_coord *box)
static void pic_webp_exif(WebPMux* webp_mux, const struct ctx_cam *cam,
const struct timespec *ts1, const struct ctx_coord *box)
{
unsigned char *exif = NULL;
unsigned exif_len = exif_prepare(&exif, cam, ts1, box);
@@ -67,7 +65,7 @@ static void pic_webp_exif(WebPMux* webp_mux,
/** Save image as webp to file */
static void pic_save_webp(FILE *fp, unsigned char *image, int width, int height,
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
{
#ifdef HAVE_WEBP
/* Create a config present and check for compatible library version */
@@ -156,7 +154,8 @@ static void pic_save_webp(FILE *fp, unsigned char *image, int width, int height,
/** Save image as yuv420p jpeg to file */
static void pic_save_yuv420p(FILE *fp, unsigned char *image, int width, int height,
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box) {
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
{
int sz = 0;
int image_size = cam->imgs.size_norm;
@@ -171,7 +170,8 @@ static void pic_save_yuv420p(FILE *fp, unsigned char *image, int width, int heig
/** Save image as grey jpeg to file */
static void pic_save_grey(FILE *picture, unsigned char *image, int width, int height,
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box) {
int quality, struct ctx_cam *cam, struct timespec *ts1, struct ctx_coord *box)
{
int sz = 0;
int image_size = cam->imgs.size_norm;
@@ -184,7 +184,8 @@ static void pic_save_grey(FILE *picture, unsigned char *image, int width, int he
}
/** Save image as greyscale ppm image to file */
static void pic_save_ppm(FILE *picture, unsigned char *image, int width, int height) {
static void pic_save_ppm(FILE *picture, unsigned char *image, int width, int height)
{
int x, y;
unsigned char *l = image;
unsigned char *u = image + width * height;
@@ -243,9 +244,9 @@ static void pic_save_ppm(FILE *picture, unsigned char *image, int width, int hei
/** Put picture into memory as jpg */
int pic_put_memory(struct ctx_cam *cam, unsigned char* dest_image, int image_size, unsigned char *image,
int quality, int width, int height) {
int pic_put_memory(struct ctx_cam *cam, unsigned char* dest_image, int image_size
, unsigned char *image, int quality, int width, int height)
{
struct timespec ts1;
clock_gettime(CLOCK_REALTIME, &ts1);
@@ -261,8 +262,8 @@ int pic_put_memory(struct ctx_cam *cam, unsigned char* dest_image, int image_siz
}
/* Write the picture to a file */
static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image, int quality, int ftype){
static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image, int quality, int ftype)
{
int width, height;
int passthrough;
@@ -290,7 +291,8 @@ static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image,
}
/* Saves image to a file in format requested */
void pic_save_norm(struct ctx_cam *cam, char *file, unsigned char *image, int ftype) {
void pic_save_norm(struct ctx_cam *cam, char *file, unsigned char *image, int ftype)
{
FILE *picture;
picture = myfopen(file, "w");
@@ -317,7 +319,8 @@ void pic_save_norm(struct ctx_cam *cam, char *file, unsigned char *image, int ft
}
/* Saves image to a file in format requested */
void pic_save_roi(struct ctx_cam *cam, char *file, unsigned char *image) {
void pic_save_roi(struct ctx_cam *cam, char *file, unsigned char *image)
{
FILE *picture;
int image_size, sz, indxh;
ctx_coord *bx;
@@ -380,7 +383,8 @@ void pic_save_roi(struct ctx_cam *cam, char *file, unsigned char *image) {
}
/** Get the pgm file used as fixed mask */
unsigned char *pic_load_pgm(FILE *picture, int width, int height) {
unsigned char *pic_load_pgm(FILE *picture, int width, int height)
{
int x, y, mask_width, mask_height, maxval;
char line[256];
@@ -466,7 +470,8 @@ unsigned char *pic_load_pgm(FILE *picture, int width, int height) {
}
/** Write out a base mask file if needed */
static void pic_write_mask(struct ctx_cam *cam, const char *file) {
static void pic_write_mask(struct ctx_cam *cam, const char *file)
{
FILE *picture;
picture = myfopen(file, "w");
@@ -504,7 +509,8 @@ static void pic_write_mask(struct ctx_cam *cam, const char *file) {
"re-run motion to enable mask feature"), cam->conf->mask_file.c_str());
}
void pic_scale_img(int width_src, int height_src, unsigned char *img_src, unsigned char *img_dst){
void pic_scale_img(int width_src, int height_src, unsigned char *img_src, unsigned char *img_dst)
{
int i = 0, x, y;
for (y = 0; y < height_src; y+=2)
@@ -521,7 +527,8 @@ void pic_scale_img(int width_src, int height_src, unsigned char *img_src, unsign
return;
}
void pic_save_preview(struct ctx_cam *cam, struct ctx_image_data *img) {
void pic_save_preview(struct ctx_cam *cam, struct ctx_image_data *img)
{
unsigned char *image_norm, *image_high;
/* Save our pointers to our memory locations for images*/
@@ -552,7 +559,8 @@ void pic_save_preview(struct ctx_cam *cam, struct ctx_image_data *img) {
}
void pic_init_privacy(struct ctx_cam *cam){
void pic_init_privacy(struct ctx_cam *cam)
{
int indxrow, indxcol;
int start_cr, offset_cb, start_cb;
@@ -658,7 +666,8 @@ void pic_init_privacy(struct ctx_cam *cam){
}
void pic_init_mask(struct ctx_cam *cam){
void pic_init_mask(struct ctx_cam *cam)
{
FILE *picture;

View File

@@ -65,7 +65,8 @@ static void reverse_inplace_quad(unsigned char *src, int size)
}
}
static void flip_inplace_horizontal(unsigned char *src, int width, int height) {
static void flip_inplace_horizontal(unsigned char *src, int width, int height)
{
uint8_t *nsrc, *ndst;
uint8_t tmp;
int l,w;
@@ -116,8 +117,7 @@ static void flip_inplace_vertical(unsigned char *src, int width, int height)
*
* Returns: nothing
*/
static void rot90cw(unsigned char *src, unsigned char *dst, int size,
int width, int height)
static void rot90cw(unsigned char *src, unsigned char *dst, int size, int width, int height)
{
unsigned char *endp;
unsigned char *base;
@@ -149,8 +149,7 @@ static void rot90cw(unsigned char *src, unsigned char *dst, int size,
*
* Returns: nothing
*/
static inline void rot90ccw(unsigned char *src, unsigned char *dst,
int size, int width, int height)
static inline void rot90ccw(unsigned char *src, unsigned char *dst, int size, int width, int height)
{
unsigned char *endp;
unsigned char *base;
@@ -178,7 +177,8 @@ static inline void rot90ccw(unsigned char *src, unsigned char *dst,
*
* Returns: nothing
*/
void rotate_init(struct ctx_cam *cam){
void rotate_init(struct ctx_cam *cam)
{
int size_norm, size_high;
cam->rotate_data =(struct ctx_rotate*) mymalloc(sizeof(struct ctx_rotate));
@@ -268,7 +268,8 @@ void rotate_init(struct ctx_cam *cam){
*
* Returns: nothing
*/
void rotate_deinit(struct ctx_cam *cam){
void rotate_deinit(struct ctx_cam *cam)
{
if (cam->rotate_data->buffer_norm)
free(cam->rotate_data->buffer_norm);
@@ -297,7 +298,8 @@ void rotate_deinit(struct ctx_cam *cam){
* 0 - success
* -1 - failure (shouldn't happen)
*/
int rotate_map(struct ctx_cam *cam, struct ctx_image_data *img_data){
int rotate_map(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
/*
* The image format is YUV 4:2:0 planar, which has the pixel
* data is divided in three parts:

View File

@@ -25,19 +25,6 @@
#include "track.hpp"
#ifdef HAVE_V4L2
/*UVC*/
#ifndef V4L2_CID_PAN_RELATIVE
#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
#endif
#ifndef V4L2_CID_TILT_RELATIVE
#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
#endif
#ifndef V4L2_CID_PAN_RESET
#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
#endif
#ifndef V4L2_CID_TILT_RESET
#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
#endif
#define INCPANTILT 64 // 1 degree
#include <linux/videodev2.h>
#endif
@@ -46,13 +33,9 @@
#define TRACK_TYPE_UVC 2
/******************************************************************************
Logitech QuickCam Sphere camera tracking code by oBi
Modify by Dirk Wesenberg(Munich) 30.03.07
- for new API in uvcvideo
- add Trace-steps for investigation
******************************************************************************/
static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
/**Center the uvc camera*/
static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle)
{
#ifdef HAVE_V4L2
/* CALC ABSOLUTE MOVING : Act.Position +/- delta to request X and Y */
@@ -113,14 +96,11 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
*/
//get mininum
//pan.value = queryctrl.minimum;
cam->track->minx = -4480 / INCPANTILT;
cam->track->miny = -1920 / INCPANTILT;
//get maximum
cam->track->maxx = 4480 / INCPANTILT;
cam->track->maxy = 1920 / INCPANTILT;
//pan.value = queryctrl.maximum;
cam->track->dev = dev;
cam->track->pan_angle = 0;
@@ -138,11 +118,11 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
,_("INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ")
,x_angle, y_angle);
if (x_angle <= cam->track->maxx && x_angle >= cam->track->minx){
if (x_angle <= cam->track->maxx && x_angle >= cam->track->minx) {
move_x_degrees = x_angle - (cam->track->pan_angle);
}
if (y_angle <= cam->track->maxy && y_angle >= cam->track->miny){
if (y_angle <= cam->track->maxy && y_angle >= cam->track->miny) {
move_y_degrees = y_angle - (cam->track->tilt_angle);
}
@@ -166,7 +146,6 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
if (move_x_degrees != 0) {
control_s.id = V4L2_CID_PAN_RELATIVE;
//control_s.value = pan.value;
control_s.value = pan.s16.pan;
if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
@@ -176,13 +155,12 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
}
/* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */
if ((move_x_degrees != 0) && (move_y_degrees != 0)){
if ((move_x_degrees != 0) && (move_y_degrees != 0)) {
SLEEP(1, 0);
}
if (move_y_degrees != 0) {
control_s.id = V4L2_CID_TILT_RELATIVE;
//control_s.value = pan.value;
control_s.value = pan.s16.tilt;
if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
@@ -223,8 +201,10 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) {
}
/**Move the uvc camera*/
static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
, struct ctx_images *imgs, int manual) {
, struct ctx_images *imgs, int manual)
{
#ifdef HAVE_V4L2
/* RELATIVE MOVING : Act.Position +/- X and Y */
@@ -288,10 +268,10 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
/* If we are on auto track we calculate delta, otherwise we use user input in degrees */
if (!manual) {
if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8){
if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) {
return 0;
}
if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8){
if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) {
return 0;
}
@@ -318,19 +298,19 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
* Check current position of camera and see if we need to adjust
* values down to what is left to move
*/
if (move_x_degrees < 0 && (cam->track->minx - cam->track->pan_angle) > move_x_degrees){
if (move_x_degrees < 0 && (cam->track->minx - cam->track->pan_angle) > move_x_degrees) {
move_x_degrees = cam->track->minx - cam->track->pan_angle;
}
if (move_x_degrees > 0 && (cam->track->maxx - cam->track->pan_angle) < move_x_degrees){
if (move_x_degrees > 0 && (cam->track->maxx - cam->track->pan_angle) < move_x_degrees) {
move_x_degrees = cam->track->maxx - cam->track->pan_angle;
}
if (move_y_degrees < 0 && (cam->track->miny - cam->track->tilt_angle) > move_y_degrees){
if (move_y_degrees < 0 && (cam->track->miny - cam->track->tilt_angle) > move_y_degrees) {
move_y_degrees = cam->track->miny - cam->track->tilt_angle;
}
if (move_y_degrees > 0 && (cam->track->maxy - cam->track->tilt_angle) < move_y_degrees){
if (move_y_degrees > 0 && (cam->track->maxy - cam->track->tilt_angle) < move_y_degrees) {
move_y_degrees = cam->track->maxy - cam->track->tilt_angle;
}
}
@@ -376,7 +356,7 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
}
/* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */
if ((move_x_degrees != 0) && (move_y_degrees != 0)){
if ((move_x_degrees != 0) && (move_y_degrees != 0)) {
SLEEP (1, 0);
}
@@ -404,11 +384,11 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
,_("Before_REL_Y_Angel : x= %d , Y= %d")
,cam->track->pan_angle, cam->track->tilt_angle);
if (move_x_degrees != 0){
if (move_x_degrees != 0) {
cam->track->pan_angle += -pan.s16.pan / INCPANTILT;
}
if (move_y_degrees != 0){
if (move_y_degrees != 0) {
cam->track->tilt_angle += -pan.s16.tilt / INCPANTILT;
}
@@ -428,9 +408,10 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
#endif /* HAVE_V4L2 */
}
static int generic_move(struct ctx_cam *cam, enum track_action action, int manual, int xoff
, int yoff, struct ctx_coord *cent, struct ctx_images *imgs) {
/**Move the generic camera*/
static int generic_move(struct ctx_cam *cam, enum track_action action, int manual
, int xoff, int yoff, struct ctx_coord *cent, struct ctx_images *imgs)
{
char fmtcmd[PATH_MAX];
cam->track->posx += cent->x;
@@ -447,7 +428,7 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua
setsid();
/* Provides data as environment variables */
if (manual){
if (manual) {
setenv("TRACK_MANUAL", "manual", 1);
}
switch (action) {
@@ -479,7 +460,7 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua
* Close any file descriptor except console because we will
* like to see error messages
*/
for (i = getdtablesize() - 1; i > 2; i--){
for (i = getdtablesize() - 1; i > 2; i--) {
close(i);
}
@@ -500,36 +481,43 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua
return cam->conf->track_move_wait;
}
void track_init(struct ctx_cam *cam){
/* Initialize the tracking functionality */
void track_init(struct ctx_cam *cam)
{
cam->track = new ctx_track;
memset(cam->track,0,sizeof(ctx_track));
cam->track->dev = -1; /* dev open */
if (cam->conf->track_type)
if (cam->conf->track_type) {
cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0);
}
}
void track_deinit(struct ctx_cam *cam){
/* Clean up the tracking functionality */
void track_deinit(struct ctx_cam *cam)
{
delete cam->track;
}
/* Add a call to your functions here: */
int track_center(struct ctx_cam *cam, int dev,
int manual, int xoff, int yoff)
/* Center the camera */
int track_center(struct ctx_cam *cam, int dev, int manual, int xoff, int yoff)
{
struct ctx_coord cent;
(void)dev;
if (!manual && !cam->conf->track_auto) return 0;
if (!manual && !cam->conf->track_auto) {
return 0;
}
if (cam->conf->track_type == TRACK_TYPE_UVC){
if (cam->conf->track_type == TRACK_TYPE_UVC) {
return uvc_center(cam, dev, xoff, yoff);
} else if (cam->conf->track_type == TRACK_TYPE_GENERIC) {
if (cam->conf->track_generic_move != ""){
if (cam->conf->track_generic_move != "") {
cent.x = -cam->track->posx;
cent.y = -cam->track->posy;
return generic_move(cam, TRACK_CENTER, manual,0 ,0 ,&cent , NULL);
@@ -548,9 +536,11 @@ int track_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
, struct ctx_images *imgs, int manual)
{
if (!manual && !cam->conf->track_auto) return 0;
if (!manual && !cam->conf->track_auto) {
return 0;
}
if (cam->conf->track_type == TRACK_TYPE_UVC){
if (cam->conf->track_type == TRACK_TYPE_UVC) {
return uvc_move(cam, dev, cent, imgs, manual);
} else if (cam->conf->track_type == TRACK_TYPE_GENERIC) {
if (cam->conf->track_generic_move != "") {
@@ -561,7 +551,8 @@ int track_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
}
MOTION_LOG(WRN, TYPE_TRACK, SHOW_ERRNO
,_("internal error, %hu is not a known track-type"), cam->conf->track_type);
,_("internal error, %hu is not a known track-type")
, cam->conf->track_type);
return 0;
}

View File

@@ -711,7 +711,8 @@ void vid_close(struct ctx_cam *cam)
* -1 if failed to open device.
* -3 image dimensions are not modulo 8
*/
int vid_start(struct ctx_cam *cam) {
int vid_start(struct ctx_cam *cam)
{
int dev = -1;
if (cam->camera_type == CAMERA_TYPE_MMAL) {
@@ -770,7 +771,8 @@ int vid_start(struct ctx_cam *cam) {
* with bit 0 set Non fatal V4L error (copy grey image and discard this image)
* with bit 1 set Non fatal Netcam error
*/
int vid_next(struct ctx_cam *cam, struct ctx_image_data *img_data){
int vid_next(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
if (cam->camera_type == CAMERA_TYPE_MMAL) {
if (cam->mmalcam == NULL) {

View File

@@ -59,7 +59,8 @@ typedef struct capent {const char *cap; unsigned int code;} capentT;
{"Last",0}
};
static int vlp_open_vidpipe(void) {
static int vlp_open_vidpipe(void)
{
int pipe_fd = -1;
char pipepath[255];
@@ -130,7 +131,8 @@ static int vlp_open_vidpipe(void) {
return pipe_fd;
}
static void vlp_show_vcap(struct v4l2_capability *cap) {
static void vlp_show_vcap(struct v4l2_capability *cap)
{
unsigned int vers = cap->version;
unsigned int c = cap->capabilities;
int i;
@@ -147,7 +149,8 @@ static void vlp_show_vcap(struct v4l2_capability *cap) {
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "------------------------");
}
static void vlp_show_vfmt(struct v4l2_format *v) {
static void vlp_show_vfmt(struct v4l2_format *v)
{
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "type: type: %d",v->type);
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "fmt.pix.width: %d",v->fmt.pix.width);
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "fmt.pix.height: %d",v->fmt.pix.height);
@@ -159,7 +162,8 @@ static void vlp_show_vfmt(struct v4l2_format *v) {
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "------------------------");
}
int vlp_startpipe(const char *dev_name, int width, int height) {
int vlp_startpipe(const char *dev_name, int width, int height)
{
int dev;
struct v4l2_format v;
struct v4l2_capability vc;
@@ -219,7 +223,8 @@ int vlp_startpipe(const char *dev_name, int width, int height) {
#endif /* HAVE_V4L2 && !BSD */
int vlp_putpipe(int dev, unsigned char *image, int imgsize) {
int vlp_putpipe(int dev, unsigned char *image, int imgsize)
{
#if (defined(HAVE_V4L2)) && (!defined(BSD))
return write(dev, image, imgsize);
@@ -231,7 +236,8 @@ int vlp_putpipe(int dev, unsigned char *image, int imgsize) {
#endif
}
void vlp_init(struct ctx_cam *cam){
void vlp_init(struct ctx_cam *cam)
{
#if defined(HAVE_V4L2) && !defined(BSD)
/* open video loopback devices if enabled */

View File

@@ -80,7 +80,8 @@
char fourcc[5];
} palette_item;
static void v4l2_palette_init(palette_item *palette_array){
static void v4l2_palette_init(palette_item *palette_array)
{
int indx;
@@ -133,7 +134,8 @@ static void v4l2_palette_init(palette_item *palette_array){
return ret;
}
static void v4l2_vdev_free(struct ctx_cam *cam){
static void v4l2_vdev_free(struct ctx_cam *cam)
{
int indx;
/* free the information we collected regarding the controls */
@@ -155,7 +157,8 @@ static void v4l2_vdev_free(struct ctx_cam *cam){
}
}
static int v4l2_vdev_init(struct ctx_cam *cam){
static int v4l2_vdev_init(struct ctx_cam *cam)
{
/* Create the v4l2 ctx_cam within the main thread ctx_cam */
cam->vdev =(struct ctx_vdev*) mymalloc(sizeof(struct ctx_vdev));
@@ -168,7 +171,8 @@ static int v4l2_vdev_init(struct ctx_cam *cam){
}
static int v4l2_ctrls_count(struct video_dev *curdev){
static int v4l2_ctrls_count(struct video_dev *curdev)
{
/* Get the count of how many controls and menu items the device supports */
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -201,7 +205,8 @@ static int v4l2_ctrls_count(struct video_dev *curdev){
}
static int v4l2_ctrls_list(struct video_dev *curdev){
static int v4l2_ctrls_list(struct video_dev *curdev)
{
/* Get the names of the controls and menu items the device supports */
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -292,7 +297,8 @@ static int v4l2_ctrls_list(struct video_dev *curdev){
}
static int v4l2_ctrls_set(struct video_dev *curdev) {
static int v4l2_ctrls_set(struct video_dev *curdev)
{
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
struct vid_devctrl_ctx *devitem;
@@ -332,7 +338,8 @@ static int v4l2_ctrls_set(struct video_dev *curdev) {
return 0;
}
static int v4l2_parms_set(struct ctx_cam *cam, struct video_dev *curdev){
static int v4l2_parms_set(struct ctx_cam *cam, struct video_dev *curdev)
{
struct vid_devctrl_ctx *devitem;
struct ctx_usrctrl *usritem;
@@ -383,7 +390,8 @@ static int v4l2_parms_set(struct ctx_cam *cam, struct video_dev *curdev){
}
static int v4l2_input_select(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_input_select(struct ctx_cam *cam, struct video_dev *curdev)
{
/* Set the input number for the device if applicable */
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -436,7 +444,8 @@ static int v4l2_input_select(struct ctx_cam *cam, struct video_dev *curdev) {
return 0;
}
static int v4l2_norm_select(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_norm_select(struct ctx_cam *cam, struct video_dev *curdev)
{
/* Set the video standard (norm) for the device NTSC/PAL/etc*/
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -500,7 +509,8 @@ static int v4l2_norm_select(struct ctx_cam *cam, struct video_dev *curdev) {
return 0;
}
static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev)
{
/* Set the frequency for the tuner */
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -548,7 +558,8 @@ static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev)
return 0;
}
static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pixformat){
static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pixformat)
{
/* Set the pixel format for the camera*/
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -619,7 +630,8 @@ static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pi
return -1;
}
static int v4l2_pixfmt_select(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_pixfmt_select(struct ctx_cam *cam, struct video_dev *curdev)
{
/* Find and select the pixel format for camera*/
@@ -722,7 +734,8 @@ static int v4l2_pixfmt_select(struct ctx_cam *cam, struct video_dev *curdev) {
}
static int v4l2_mmap_set(struct video_dev *curdev) {
static int v4l2_mmap_set(struct video_dev *curdev)
{
/* Set the memory mapping from device to Motion*/
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -820,7 +833,8 @@ static int v4l2_mmap_set(struct video_dev *curdev) {
return 0;
}
static int v4l2_imgs_set(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_imgs_set(struct ctx_cam *cam, struct video_dev *curdev)
{
/* Set the items on the imgs */
cam->imgs.width = curdev->width;
@@ -834,7 +848,8 @@ static int v4l2_imgs_set(struct ctx_cam *cam, struct video_dev *curdev) {
}
static int v4l2_capture(struct ctx_cam *cam, struct video_dev *curdev, unsigned char *map) {
static int v4l2_capture(struct ctx_cam *cam, struct video_dev *curdev, unsigned char *map)
{
/* Capture a image */
/* FIXME: This function needs to be refactored*/
@@ -985,7 +1000,8 @@ static int v4l2_capture(struct ctx_cam *cam, struct video_dev *curdev, unsigned
return 1;
}
static int v4l2_device_init(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_device_init(struct ctx_cam *cam, struct video_dev *curdev)
{
src_v4l2_t *vid_source;
@@ -1022,7 +1038,8 @@ static int v4l2_device_init(struct ctx_cam *cam, struct video_dev *curdev) {
return 0;
}
static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, unsigned char *map) {
static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, unsigned char *map)
{
int indx, retcd;
@@ -1070,7 +1087,8 @@ static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, un
}
static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev)
{
int fd_device;
/* Open the video device */
@@ -1100,7 +1118,8 @@ static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev) {
}
static void v4l2_device_close(struct video_dev *curdev) {
static void v4l2_device_close(struct video_dev *curdev)
{
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
enum v4l2_buf_type type;
@@ -1117,7 +1136,8 @@ static void v4l2_device_close(struct video_dev *curdev) {
}
}
static void v4l2_device_cleanup(struct video_dev *curdev) {
static void v4l2_device_cleanup(struct video_dev *curdev)
{
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -1151,7 +1171,8 @@ static void v4l2_device_cleanup(struct video_dev *curdev) {
}
static int v4l2_device_capability(struct video_dev *curdev) {
static int v4l2_device_capability(struct video_dev *curdev)
{
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
@@ -1200,7 +1221,8 @@ static int v4l2_device_capability(struct video_dev *curdev) {
return 0;
}
static int v4l2_fps_set(struct ctx_cam *cam, struct video_dev *curdev) {
static int v4l2_fps_set(struct ctx_cam *cam, struct video_dev *curdev)
{
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
struct v4l2_streamparm setfps;
@@ -1229,7 +1251,8 @@ static int v4l2_fps_set(struct ctx_cam *cam, struct video_dev *curdev) {
#endif /* HAVE_V4L2 */
void v4l2_mutex_init(void) {
void v4l2_mutex_init(void)
{
#ifdef HAVE_V4L2
pthread_mutex_init(&v4l2_mutex, NULL);
#else
@@ -1237,7 +1260,8 @@ void v4l2_mutex_init(void) {
#endif // HAVE_V4L2
}
void v4l2_mutex_destroy(void) {
void v4l2_mutex_destroy(void)
{
#ifdef HAVE_V4L2
pthread_mutex_destroy(&v4l2_mutex);
#else
@@ -1245,7 +1269,8 @@ void v4l2_mutex_destroy(void) {
#endif // HAVE_V4L2
}
int v4l2_start(struct ctx_cam *cam) {
int v4l2_start(struct ctx_cam *cam)
{
#ifdef HAVE_V4L2
int retcd;
@@ -1320,7 +1345,8 @@ int v4l2_start(struct ctx_cam *cam) {
#endif // HAVE_V4l2
}
void v4l2_cleanup(struct ctx_cam *cam) {
void v4l2_cleanup(struct ctx_cam *cam)
{
#ifdef HAVE_V4L2
struct video_dev *dev = v4l2_devices;
@@ -1386,7 +1412,8 @@ void v4l2_cleanup(struct ctx_cam *cam) {
#endif // HAVE_V4L2
}
int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data) {
int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
#ifdef HAVE_V4L2
int ret = -2;
struct ctx_config *conf = cam->conf;
@@ -1431,7 +1458,8 @@ int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data) {
#endif // HAVE_V4L2
}
int v4l2_palette_valid(char *v4l2_device, int v4l2_palette) {
int v4l2_palette_valid(char *v4l2_device, int v4l2_palette)
{
#ifdef HAVE_V4L2
/* This function is a boolean that returns true(1) if the palette selected in the
@@ -1486,7 +1514,8 @@ int v4l2_palette_valid(char *v4l2_device, int v4l2_palette) {
#endif // HAVE_V4L2
}
void v4l2_palette_fourcc(int v4l2_palette, char *fourcc) {
void v4l2_palette_fourcc(int v4l2_palette, char *fourcc)
{
#ifdef HAVE_V4L2
/* This function populates the provided fourcc pointer with the fourcc code for the
@@ -1516,7 +1545,8 @@ void v4l2_palette_fourcc(int v4l2_palette, char *fourcc) {
#endif // HAVE_V4L2
}
int v4l2_parms_valid(char *v4l2_device, int v4l2_palette, int v4l2_fps, int v4l2_width, int v4l2_height){
int v4l2_parms_valid(char *v4l2_device, int v4l2_palette, int v4l2_fps, int v4l2_width, int v4l2_height)
{
#ifdef HAVE_V4L2
/* This function is a boolean that returns true(1) if the parms selected in the

View File

@@ -73,7 +73,8 @@ struct mhdstart_ctx {
};
static void webu_context_init(struct ctx_cam **camlst, struct ctx_cam *cam, struct webui_ctx *webui) {
static void webu_context_init(struct ctx_cam **camlst, struct ctx_cam *cam, struct webui_ctx *webui)
{
int indx;
@@ -127,7 +128,8 @@ static void webu_context_init(struct ctx_cam **camlst, struct ctx_cam *cam, stru
return;
}
static void webu_context_null(struct webui_ctx *webui) {
static void webu_context_null(struct webui_ctx *webui)
{
/* Null out all the pointers in our webui context */
webui->url = NULL;
webui->hostname = NULL;
@@ -153,7 +155,8 @@ static void webu_context_null(struct webui_ctx *webui) {
return;
}
static void webu_context_free(struct webui_ctx *webui) {
static void webu_context_free(struct webui_ctx *webui)
{
if (webui->hostname != NULL) free(webui->hostname);
if (webui->url != NULL) free(webui->url);
@@ -182,7 +185,8 @@ static void webu_context_free(struct webui_ctx *webui) {
return;
}
static void webu_badreq(struct webui_ctx *webui){
static void webu_badreq(struct webui_ctx *webui)
{
/* This function is used in this webu module as a central function when there is a bad
* request. Since sometimes we will be unable to determine what camera context (stream
* or camera) originated the request and we have NULL for camlist and cam, we default the
@@ -206,7 +210,8 @@ static void webu_badreq(struct webui_ctx *webui){
}
}
void webu_write(struct webui_ctx *webui, const char *buf) {
void webu_write(struct webui_ctx *webui, const char *buf)
{
/* Copy the buf data to our response buffer. If the response buffer is not large enough to
* accept our new data coming in, then expand it in chunks of 10
*/
@@ -238,7 +243,8 @@ void webu_write(struct webui_ctx *webui, const char *buf) {
return;
}
static int webu_url_decode(char *urlencoded, size_t length) {
static int webu_url_decode(char *urlencoded, size_t length)
{
/* We are sent a URI encoded string and this decodes it to characters
* If the sent URL that isn't valid, then we clear out the URL
* so it is not processed in further functions. The "answer" functions
@@ -298,7 +304,8 @@ static int webu_url_decode(char *urlencoded, size_t length) {
}
static void webu_parms_edit(struct webui_ctx *webui) {
static void webu_parms_edit(struct webui_ctx *webui)
{
/* Determine the thread number provided.
* If no thread provided, assign it to -1
@@ -351,7 +358,8 @@ static void webu_parms_edit(struct webui_ctx *webui) {
}
}
static void webu_parseurl_parms(struct webui_ctx *webui, char *st_pos) {
static void webu_parseurl_parms(struct webui_ctx *webui, char *st_pos)
{
/* Parse the parameters of the URI
* Earlier functions have assigned the st_pos to the slash after the action and it is
@@ -444,7 +452,8 @@ static void webu_parseurl_parms(struct webui_ctx *webui, char *st_pos) {
}
static void webu_parseurl_reset(struct webui_ctx *webui) {
static void webu_parseurl_reset(struct webui_ctx *webui)
{
/* Reset the variables to empty strings*/
@@ -458,7 +467,8 @@ static void webu_parseurl_reset(struct webui_ctx *webui) {
}
static int webu_parseurl(struct webui_ctx *webui) {
static int webu_parseurl(struct webui_ctx *webui)
{
/* Parse the sent URI into the commands and parameters
* so we can check the resulting strings in later functions
* and determine what actions to take.
@@ -556,7 +566,8 @@ static int webu_parseurl(struct webui_ctx *webui) {
}
void webu_process_action(struct webui_ctx *webui) {
void webu_process_action(struct webui_ctx *webui)
{
/* Process the actions from the webcontrol that the user requested. This is used
* for both the html and text interface. The text interface just adds a additional
* response whereas the html just performs the action
@@ -672,7 +683,8 @@ void webu_process_action(struct webui_ctx *webui) {
}
}
static int webu_process_config_set(struct webui_ctx *webui) {
static int webu_process_config_set(struct webui_ctx *webui)
{
/* Process the request to change the configuration parameters. Used
* both the html and text interfaces. If the parameter was found, then
* we return 0 otherwise a -1 to tell the calling function whether it
@@ -743,7 +755,8 @@ static int webu_process_config_set(struct webui_ctx *webui) {
}
int webu_process_config(struct webui_ctx *webui) {
int webu_process_config(struct webui_ctx *webui)
{
int retcd;
@@ -772,7 +785,8 @@ int webu_process_config(struct webui_ctx *webui) {
}
int webu_process_track(struct webui_ctx *webui) {
int webu_process_track(struct webui_ctx *webui)
{
/* Call the tracking move functions as requested */
struct ctx_coord cent;
int retcd;
@@ -814,7 +828,8 @@ int webu_process_track(struct webui_ctx *webui) {
}
static void webu_clientip(struct webui_ctx *webui) {
static void webu_clientip(struct webui_ctx *webui)
{
/* Extract the IP of the client that is connecting. When the
* user specifies Motion to use IPV6 and a IPV4 address comes to us
* the IPv4 address is prepended with a ::ffff: We then trim that off
@@ -860,7 +875,8 @@ static void webu_clientip(struct webui_ctx *webui) {
}
static void webu_hostname(struct webui_ctx *webui, int ctrl) {
static void webu_hostname(struct webui_ctx *webui, int ctrl)
{
/* use the hostname the browser used to connect to us when
* constructing links to the stream ports. If available
@@ -915,7 +931,8 @@ static void webu_hostname(struct webui_ctx *webui, int ctrl) {
return;
}
static int webu_mhd_digest_fail(struct webui_ctx *webui,int signal_stale) {
static int webu_mhd_digest_fail(struct webui_ctx *webui,int signal_stale)
{
/* Create a denied response to user*/
struct MHD_Response *response;
int retcd;
@@ -936,7 +953,8 @@ static int webu_mhd_digest_fail(struct webui_ctx *webui,int signal_stale) {
return retcd;
}
static int webu_mhd_digest(struct webui_ctx *webui) {
static int webu_mhd_digest(struct webui_ctx *webui)
{
/* Perform the digest authentication. This function gets called a couple of
* times by MHD during the authentication process.
*/
@@ -976,7 +994,8 @@ static int webu_mhd_digest(struct webui_ctx *webui) {
}
static int webu_mhd_basic_fail(struct webui_ctx *webui) {
static int webu_mhd_basic_fail(struct webui_ctx *webui)
{
/* Create a denied response to user*/
struct MHD_Response *response;
int retcd;
@@ -996,7 +1015,8 @@ static int webu_mhd_basic_fail(struct webui_ctx *webui) {
}
static int webu_mhd_basic(struct webui_ctx *webui) {
static int webu_mhd_basic(struct webui_ctx *webui)
{
/* Perform Basic Authentication. */
char *user, *pass;
@@ -1027,7 +1047,8 @@ static int webu_mhd_basic(struct webui_ctx *webui) {
}
static void webu_mhd_auth_parse(struct webui_ctx *webui, int ctrl){
static void webu_mhd_auth_parse(struct webui_ctx *webui, int ctrl)
{
int auth_len;
char *col_pos;
@@ -1073,7 +1094,8 @@ static void webu_mhd_auth_parse(struct webui_ctx *webui, int ctrl){
}
static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){
static int webu_mhd_auth(struct webui_ctx *webui, int ctrl)
{
/* Set everything up for calling the authentication functions */
unsigned int rand1,rand2;
@@ -1131,7 +1153,8 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){
}
static int webu_mhd_send(struct webui_ctx *webui, int ctrl) {
static int webu_mhd_send(struct webui_ctx *webui, int ctrl)
{
/* Send the response that we created back to the user. Now if the user
* provided a really bad URL, then we couldn't determine which Motion context
* they were wanting. In this situation, we have a webui->cam = NULL and we
@@ -1177,7 +1200,8 @@ static int webu_mhd_send(struct webui_ctx *webui, int ctrl) {
return retcd;
}
static void webu_answer_strm_type(struct webui_ctx *webui) {
static void webu_answer_strm_type(struct webui_ctx *webui)
{
/* Assign the type of stream that is being answered*/
if ((mystreq(webui->uri_cmd1,"stream")) ||
@@ -1219,14 +1243,9 @@ static void webu_answer_strm_type(struct webui_ctx *webui) {
}
static int webu_answer_ctrl(void *cls
, struct MHD_Connection *connection
, const char *url
, const char *method
, const char *version
, const char *upload_data
, size_t *upload_data_size
, void **ptr) {
static int webu_answer_ctrl(void *cls, struct MHD_Connection *connection, const char *url, const char *method
, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr)
{
/* This function "answers" the request for a webcontrol.*/
int retcd;
@@ -1291,14 +1310,9 @@ static int webu_answer_ctrl(void *cls
}
static int webu_answer_strm(void *cls
, struct MHD_Connection *connection
, const char *url
, const char *method
, const char *version
, const char *upload_data
, size_t *upload_data_size
, void **ptr) {
static int webu_answer_strm(void *cls, struct MHD_Connection *connection, const char *url, const char *method
, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr)
{
/* Answer the request for all the streams*/
int retcd;
@@ -1376,7 +1390,8 @@ static int webu_answer_strm(void *cls
}
static void *webu_mhd_init(void *cls, const char *uri, struct MHD_Connection *connection) {
static void *webu_mhd_init(void *cls, const char *uri, struct MHD_Connection *connection)
{
/* This is called at the very start of getting a request before the "answer"
* is processed. There are two variations of this and the difference is how
* we call the webu_context_init. When we are processing for the webcontrol or
@@ -1417,7 +1432,8 @@ static void *webu_mhd_init(void *cls, const char *uri, struct MHD_Connection *co
return webui;
}
static void *webu_mhd_init_one(void *cls, const char *uri, struct MHD_Connection *connection) {
static void *webu_mhd_init_one(void *cls, const char *uri, struct MHD_Connection *connection)
{
/* This function initializes all the webui variables as we are getting a request. This
* variation of the init is the one used when the user has specified a unique port number
* for each camera. The variation is in how the webu_context_init is invoked. This passes
@@ -1451,10 +1467,9 @@ static void *webu_mhd_init_one(void *cls, const char *uri, struct MHD_Connection
return webui;
}
static void webu_mhd_deinit(void *cls
, struct MHD_Connection *connection
, void **con_cls
, enum MHD_RequestTerminationCode toe) {
static void webu_mhd_deinit(void *cls, struct MHD_Connection *connection
, void **con_cls, enum MHD_RequestTerminationCode toe)
{
/* This is the function called as the connection is closed so we free our webui variables*/
struct webui_ctx *webui =(struct webui_ctx *) *con_cls;
@@ -1500,7 +1515,8 @@ static void webu_mhd_deinit(void *cls
return;
}
static void webu_mhd_features_basic(struct mhdstart_ctx *mhdst){
static void webu_mhd_features_basic(struct mhdstart_ctx *mhdst)
{
/* Use the MHD function to see what features it supports*/
#if MHD_VERSION < 0x00094400
(void)mhdst;
@@ -1523,7 +1539,8 @@ static void webu_mhd_features_basic(struct mhdstart_ctx *mhdst){
#endif
}
static void webu_mhd_features_digest(struct mhdstart_ctx *mhdst){
static void webu_mhd_features_digest(struct mhdstart_ctx *mhdst)
{
/* Use the MHD function to see what features it supports*/
#if MHD_VERSION < 0x00094400
(void)mhdst;
@@ -1546,7 +1563,8 @@ static void webu_mhd_features_digest(struct mhdstart_ctx *mhdst){
#endif
}
static void webu_mhd_features_ipv6(struct mhdstart_ctx *mhdst){
static void webu_mhd_features_ipv6(struct mhdstart_ctx *mhdst)
{
/* Use the MHD function to see what features it supports
* If we have a really old version of MHD, then we will just support
* IPv4
@@ -1568,7 +1586,8 @@ static void webu_mhd_features_ipv6(struct mhdstart_ctx *mhdst){
#endif
}
static void webu_mhd_features_tls(struct mhdstart_ctx *mhdst){
static void webu_mhd_features_tls(struct mhdstart_ctx *mhdst)
{
/* Use the MHD function to see what features it supports
* If we have a really old version of MHD, then we will will not
* support the ssl/tls request.
@@ -1600,7 +1619,8 @@ static void webu_mhd_features_tls(struct mhdstart_ctx *mhdst){
#endif
}
static void webu_mhd_features(struct mhdstart_ctx *mhdst){
static void webu_mhd_features(struct mhdstart_ctx *mhdst)
{
/* This function goes through at least a few of the MHD features
* and adjusts the user parameters from the configuration as
* needed to reflect what MHD can do
@@ -1616,7 +1636,8 @@ static void webu_mhd_features(struct mhdstart_ctx *mhdst){
}
static char *webu_mhd_loadfile(const char *fname){
static char *webu_mhd_loadfile(const char *fname)
{
/* This function loads the requested certificate and key files into memory so we
* can use them as needed if the user wants ssl/tls support. If the user did not
* specify a file in the configuration, then we return NULL.
@@ -1655,7 +1676,8 @@ static char *webu_mhd_loadfile(const char *fname){
return file_char;
}
static void webu_mhd_checktls(struct mhdstart_ctx *mhdst){
static void webu_mhd_checktls(struct mhdstart_ctx *mhdst)
{
/* This function validates that if the user requested a SSL/TLS connection, then
* they also need to provide a certificate and key file. If those are not provided
* then we revise the configuration request for ssl/tls
@@ -1690,7 +1712,8 @@ static void webu_mhd_checktls(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts_init(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts_init(struct mhdstart_ctx *mhdst)
{
/* This function sets the init function to use for the MHD connection. If
* the connection is related to the webcontrol or the stream specified in the
* motion.conf file, then we pass in the full context list of all cameras. If
@@ -1712,7 +1735,8 @@ static void webu_mhd_opts_init(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts_deinit(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts_deinit(struct mhdstart_ctx *mhdst)
{
/* Set the MHD option on the function to call when the connection closes */
mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_NOTIFY_COMPLETED;
mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = (intptr_t)webu_mhd_deinit;
@@ -1721,7 +1745,8 @@ static void webu_mhd_opts_deinit(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst)
{
/* Set the MHD option on the acceptable connections. This is used to handle the
* motion configuation option of localhost only.
*/
@@ -1775,7 +1800,8 @@ static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst)
{
/* Set the MHD option for the type of authentication that we will be using. This
* function is when we are wanting to use digest authentication
*/
@@ -1808,7 +1834,8 @@ static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts_tls(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts_tls(struct mhdstart_ctx *mhdst)
{
/* Set the MHD options needed when we want TLS connections */
if ((( mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls)) ||
((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls))) {
@@ -1826,7 +1853,8 @@ static void webu_mhd_opts_tls(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_opts(struct mhdstart_ctx *mhdst){
static void webu_mhd_opts(struct mhdstart_ctx *mhdst)
{
/* Set all the options we need based upon the motion configuration parameters*/
mhdst->mhd_opt_nbr = 0;
@@ -1850,7 +1878,8 @@ static void webu_mhd_opts(struct mhdstart_ctx *mhdst){
}
static void webu_mhd_flags(struct mhdstart_ctx *mhdst){
static void webu_mhd_flags(struct mhdstart_ctx *mhdst)
{
/* This sets the MHD startup flags based upon what user put into configuration */
mhdst->mhd_flags = MHD_USE_THREAD_PER_CONNECTION;
@@ -1865,7 +1894,8 @@ static void webu_mhd_flags(struct mhdstart_ctx *mhdst){
}
static void webu_strm_ntc(struct ctx_cam **camlst, int indxthrd){
static void webu_strm_ntc(struct ctx_cam **camlst, int indxthrd)
{
int indx;
if (indxthrd == 0 ){
@@ -1891,7 +1921,8 @@ static void webu_strm_ntc(struct ctx_cam **camlst, int indxthrd){
}
}
static void webu_init_ctrl(struct ctx_motapp *motapp){
static void webu_init_ctrl(struct ctx_motapp *motapp)
{
/* This is the function that actually starts the MHD daemon for handling the webcontrol.
* There are many options for MHD and they will vary depending upon what our Motion user
* has requested in the configuration. There are many functions in this module to assign
@@ -1949,7 +1980,8 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){
return;
}
static void webu_init_strm(struct ctx_cam **cam_list){
static void webu_init_strm(struct ctx_cam **cam_list)
{
/* This function starts up the daemon for the streams. It loops through
* all of the camera context's provided and starts streams as requested. If
* the thread number is zero, then it starts the full list stream context
@@ -2021,7 +2053,8 @@ static void webu_init_strm(struct ctx_cam **cam_list){
return;
}
static void webu_init_ports(struct ctx_cam **cam_list){
static void webu_init_ports(struct ctx_cam **cam_list)
{
/* Perform check for duplicate ports being specified. The config loading will
* duplicate ports from the motion.conf file to all the cameras so we do not
* log these duplicates to the user and instead just silently set them to zero
@@ -2067,7 +2100,8 @@ static void webu_init_ports(struct ctx_cam **cam_list){
}
}
void webu_deinit(struct ctx_motapp *motapp) {
void webu_deinit(struct ctx_motapp *motapp)
{
/* This function is called from the main Motion loop to shutdown the
* various MHD connections
*/
@@ -2089,7 +2123,8 @@ void webu_deinit(struct ctx_motapp *motapp) {
}
}
void webu_init(struct ctx_motapp *motapp) {
void webu_init(struct ctx_motapp *motapp)
{
/* This function is called from the main motion thread to start up the
* webcontrol and streams. We need to block some signals otherwise MHD
* will not function correctly.

View File

@@ -64,7 +64,8 @@ struct strminfo_ctx {
int motion_images;
};
static void webu_html_style_navbar(struct webui_ctx *webui) {
static void webu_html_style_navbar(struct webui_ctx *webui)
{
/* Write out the style section of the web page */
char response[WEBUI_LEN_RESP];
@@ -89,7 +90,8 @@ static void webu_html_style_navbar(struct webui_ctx *webui) {
}
static void webu_html_style_dropdown(struct webui_ctx *webui) {
static void webu_html_style_dropdown(struct webui_ctx *webui)
{
/* Write out the style section of the web page */
char response[WEBUI_LEN_RESP];
@@ -138,7 +140,8 @@ static void webu_html_style_dropdown(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_style_input(struct webui_ctx *webui) {
static void webu_html_style_input(struct webui_ctx *webui)
{
/* Write out the style section of the web page */
char response[WEBUI_LEN_RESP];
@@ -161,7 +164,8 @@ static void webu_html_style_input(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_style_base(struct webui_ctx *webui) {
static void webu_html_style_base(struct webui_ctx *webui)
{
/* Write out the style section of the web page */
char response[WEBUI_LEN_RESP];
@@ -222,7 +226,8 @@ static void webu_html_style_base(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_style(struct webui_ctx *webui) {
static void webu_html_style(struct webui_ctx *webui)
{
/* Write out the style section of the web page */
char response[WEBUI_LEN_RESP];
@@ -242,7 +247,8 @@ static void webu_html_style(struct webui_ctx *webui) {
}
static void webu_html_head(struct webui_ctx *webui) {
static void webu_html_head(struct webui_ctx *webui)
{
/* Write out the header section of the web page */
char response[WEBUI_LEN_RESP];
@@ -259,7 +265,8 @@ static void webu_html_head(struct webui_ctx *webui) {
}
static void webu_html_navbar_camera(struct webui_ctx *webui) {
static void webu_html_navbar_camera(struct webui_ctx *webui)
{
/*Write out the options included in the camera dropdown */
char response[WEBUI_LEN_RESP];
int indx;
@@ -322,7 +329,8 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) {
}
static void webu_html_navbar_action(struct webui_ctx *webui) {
static void webu_html_navbar_action(struct webui_ctx *webui)
{
/* Write out the options included in the actions dropdown*/
char response[WEBUI_LEN_RESP];
@@ -356,7 +364,8 @@ static void webu_html_navbar_action(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_navbar(struct webui_ctx *webui) {
static void webu_html_navbar(struct webui_ctx *webui)
{
/* Write the navbar section*/
char response[WEBUI_LEN_RESP];
@@ -378,7 +387,8 @@ static void webu_html_navbar(struct webui_ctx *webui) {
}
static void webu_html_config_notice(struct webui_ctx *webui) {
static void webu_html_config_notice(struct webui_ctx *webui)
{
/* Print out the header description of which parameters are included based upon the
* webcontrol_parms that was specified
*/
@@ -404,7 +414,8 @@ static void webu_html_config_notice(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_h3desc(struct webui_ctx *webui) {
static void webu_html_h3desc(struct webui_ctx *webui)
{
/* Write out the status description for the camera */
char response[WEBUI_LEN_RESP];
@@ -429,7 +440,8 @@ static void webu_html_h3desc(struct webui_ctx *webui) {
}
}
static void webu_html_config(struct webui_ctx *webui) {
static void webu_html_config(struct webui_ctx *webui)
{
/* Write out the options to put into the config dropdown
* We use html data attributes to store the values for the options
@@ -550,7 +562,8 @@ static void webu_html_config(struct webui_ctx *webui) {
}
static void webu_html_track(struct webui_ctx *webui) {
static void webu_html_track(struct webui_ctx *webui)
{
/* Write the section for handling the tracking function */
char response[WEBUI_LEN_RESP];
@@ -583,7 +596,8 @@ static void webu_html_track(struct webui_ctx *webui) {
}
static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) {
static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx)
{
/* This determines all the items we need to know to specify links and
* stream sources for the page. The options are 0-3 as of this writing
* where 0 = full streams, 1 = substreams, 2 = static images and 3 is
@@ -636,7 +650,8 @@ static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) {
}
static void webu_html_preview(struct webui_ctx *webui) {
static void webu_html_preview(struct webui_ctx *webui)
{
/* Write the initial version of the preview section. The javascript
* will change this section when user selects a different camera */
@@ -705,7 +720,8 @@ static void webu_html_preview(struct webui_ctx *webui) {
}
static void webu_html_script_action(struct webui_ctx *webui) {
static void webu_html_script_action(struct webui_ctx *webui)
{
/* Write the javascript action_click() function.
* We do not have a good notification section on the page so the successful
* submission and response is currently a empty if block for the future
@@ -770,7 +786,8 @@ static void webu_html_script_action(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_script_camera_thread(struct webui_ctx *webui) {
static void webu_html_script_camera_thread(struct webui_ctx *webui)
{
/* Write the javascript thread IF conditions of camera_click() function */
char response[WEBUI_LEN_RESP];
int indx, indx_st, preview_scale;
@@ -846,7 +863,8 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) {
return;
}
static void webu_html_script_camera_all(struct webui_ctx *webui) {
static void webu_html_script_camera_all(struct webui_ctx *webui)
{
/* Write the javascript "All" IF condition of camera_click() function */
char response[WEBUI_LEN_RESP];
int indx, indx_st, preview_scale;
@@ -915,7 +933,8 @@ static void webu_html_script_camera_all(struct webui_ctx *webui) {
return;
}
static void webu_html_script_camera(struct webui_ctx *webui) {
static void webu_html_script_camera(struct webui_ctx *webui)
{
/* Write the javascript camera_click() function */
char response[WEBUI_LEN_RESP];
@@ -942,7 +961,8 @@ static void webu_html_script_camera(struct webui_ctx *webui) {
}
static void webu_html_script_menucam(struct webui_ctx *webui) {
static void webu_html_script_menucam(struct webui_ctx *webui)
{
/* Write the javascript display_cameras() function */
char response[WEBUI_LEN_RESP];
@@ -959,7 +979,8 @@ static void webu_html_script_menucam(struct webui_ctx *webui) {
}
static void webu_html_script_menuact(struct webui_ctx *webui) {
static void webu_html_script_menuact(struct webui_ctx *webui)
{
/* Write the javascript display_actions() function */
char response[WEBUI_LEN_RESP];
@@ -976,7 +997,8 @@ static void webu_html_script_menuact(struct webui_ctx *webui) {
}
static void webu_html_script_evtclk(struct webui_ctx *webui) {
static void webu_html_script_evtclk(struct webui_ctx *webui)
{
/* Write the javascript 'click' EventListener */
char response[WEBUI_LEN_RESP];
@@ -993,7 +1015,8 @@ static void webu_html_script_evtclk(struct webui_ctx *webui) {
}
static void webu_html_script_cfgclk(struct webui_ctx *webui) {
static void webu_html_script_cfgclk(struct webui_ctx *webui)
{
/* Write the javascript config_click function
* We do not have a good notification section on the page so the successful
* submission and response is currently a empty if block for the future
@@ -1043,7 +1066,8 @@ static void webu_html_script_cfgclk(struct webui_ctx *webui) {
}
static void webu_html_script_cfgchg(struct webui_ctx *webui) {
static void webu_html_script_cfgchg(struct webui_ctx *webui)
{
/* Write the javascript option_change function */
char response[WEBUI_LEN_RESP];
@@ -1060,7 +1084,8 @@ static void webu_html_script_cfgchg(struct webui_ctx *webui) {
webu_write(webui, response);
}
static void webu_html_script_trkchg(struct webui_ctx *webui) {
static void webu_html_script_trkchg(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
@@ -1099,7 +1124,8 @@ static void webu_html_script_trkchg(struct webui_ctx *webui) {
}
static void webu_html_script_trkclk(struct webui_ctx *webui) {
static void webu_html_script_trkclk(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function track_click() {\n"
@@ -1147,7 +1173,8 @@ static void webu_html_script_trkclk(struct webui_ctx *webui) {
}
static void webu_html_script(struct webui_ctx *webui) {
static void webu_html_script(struct webui_ctx *webui)
{
/* Write the javascripts */
char response[WEBUI_LEN_RESP];
@@ -1177,7 +1204,8 @@ static void webu_html_script(struct webui_ctx *webui) {
}
static void webu_html_body(struct webui_ctx *webui) {
static void webu_html_body(struct webui_ctx *webui)
{
/* Write the body section of the form */
char response[WEBUI_LEN_RESP];
@@ -1201,7 +1229,8 @@ static void webu_html_body(struct webui_ctx *webui) {
}
static void webu_html_page(struct webui_ctx *webui) {
static void webu_html_page(struct webui_ctx *webui)
{
/* Write the main page html */
char response[WEBUI_LEN_RESP];
@@ -1219,7 +1248,8 @@ static void webu_html_page(struct webui_ctx *webui) {
}
void webu_html_badreq(struct webui_ctx *webui) {
void webu_html_badreq(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
@@ -1237,7 +1267,8 @@ void webu_html_badreq(struct webui_ctx *webui) {
}
void webu_html_main(struct webui_ctx *webui) {
void webu_html_main(struct webui_ctx *webui)
{
/* Note some detection and config requested actions call the
* action function. This is because the legacy interface

View File

@@ -36,7 +36,8 @@
static void webu_stream_mjpeg_checkbuffers(struct webui_ctx *webui) {
static void webu_stream_mjpeg_checkbuffers(struct webui_ctx *webui)
{
/* Allocate buffers if needed */
if (webui->resp_size < (size_t)webui->cam->imgs.size_norm){
if (webui->resp_page != NULL) free(webui->resp_page);
@@ -48,7 +49,8 @@ static void webu_stream_mjpeg_checkbuffers(struct webui_ctx *webui) {
}
static void webu_stream_mjpeg_delay(struct webui_ctx *webui) {
static void webu_stream_mjpeg_delay(struct webui_ctx *webui)
{
/* Sleep required time to get to the user requested frame
* rate for the stream
*/
@@ -79,7 +81,8 @@ static void webu_stream_mjpeg_delay(struct webui_ctx *webui) {
}
static void webu_stream_mjpeg_getimg(struct webui_ctx *webui) {
static void webu_stream_mjpeg_getimg(struct webui_ctx *webui)
{
long jpeg_size;
char resp_head[80];
int header_len;
@@ -136,7 +139,8 @@ static void webu_stream_mjpeg_getimg(struct webui_ctx *webui) {
}
static ssize_t webu_stream_mjpeg_response (void *cls, uint64_t pos, char *buf, size_t max){
static ssize_t webu_stream_mjpeg_response (void *cls, uint64_t pos, char *buf, size_t max)
{
/* This is the callback response function for MHD streams. It is kept "open" and
* in process during the entire time that the user has the stream open in the web
* browser. We sleep the requested amount of time between fetching images to match
@@ -180,7 +184,8 @@ static ssize_t webu_stream_mjpeg_response (void *cls, uint64_t pos, char *buf, s
}
static void webu_stream_static_getimg(struct webui_ctx *webui) {
static void webu_stream_static_getimg(struct webui_ctx *webui)
{
/* Obtain the current image, compress it to a JPG and put into webui->resp_page
* for MHD to send back to user
*/
@@ -201,7 +206,8 @@ static void webu_stream_static_getimg(struct webui_ctx *webui) {
}
static int webu_stream_checks(struct webui_ctx *webui) {
static int webu_stream_checks(struct webui_ctx *webui)
{
/* Perform edits to determine whether the user specified a valid URL
* for the particular port
*/
@@ -242,7 +248,8 @@ static int webu_stream_checks(struct webui_ctx *webui) {
return 0;
}
static void webu_stream_cnct_count(struct webui_ctx *webui) {
static void webu_stream_cnct_count(struct webui_ctx *webui)
{
/* Increment the counters for the connections to the streams */
int cnct_count;
@@ -288,7 +295,8 @@ static void webu_stream_cnct_count(struct webui_ctx *webui) {
}
int webu_stream_mjpeg(struct webui_ctx *webui) {
int webu_stream_mjpeg(struct webui_ctx *webui)
{
/* Create the stream for the motion jpeg */
int retcd;
struct MHD_Response *response;
@@ -322,7 +330,8 @@ int webu_stream_mjpeg(struct webui_ctx *webui) {
return retcd;
}
int webu_stream_static(struct webui_ctx *webui) {
int webu_stream_static(struct webui_ctx *webui)
{
/* Create the response for the static image request*/
int retcd;
struct MHD_Response *response;
@@ -363,7 +372,8 @@ int webu_stream_static(struct webui_ctx *webui) {
return retcd;
}
void webu_stream_init(struct ctx_cam *cam){
void webu_stream_init(struct ctx_cam *cam)
{
/* The image buffers are allocated in event_stream_put if needed
* NOTE: This runs on the motion_loop thread.
@@ -398,7 +408,8 @@ void webu_stream_init(struct ctx_cam *cam){
}
void webu_stream_deinit(struct ctx_cam *cam){
void webu_stream_deinit(struct ctx_cam *cam)
{
/* Need to check whether buffers were allocated since init
* function defers the allocations to event_stream_put
@@ -439,7 +450,8 @@ void webu_stream_deinit(struct ctx_cam *cam){
}
static void webu_stream_getimg_norm(struct ctx_cam *cam, struct ctx_image_data *img_data){
static void webu_stream_getimg_norm(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
/*This is on the motion_loop thread */
if (cam->stream.norm.jpeg_data == NULL){
cam->stream.norm.jpeg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
@@ -457,7 +469,8 @@ static void webu_stream_getimg_norm(struct ctx_cam *cam, struct ctx_image_data *
}
static void webu_stream_getimg_sub(struct ctx_cam *cam, struct ctx_image_data *img_data){
static void webu_stream_getimg_sub(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
/*This is on the motion_loop thread */
int subsize;
@@ -500,7 +513,8 @@ static void webu_stream_getimg_sub(struct ctx_cam *cam, struct ctx_image_data *i
}
static void webu_stream_getimg_motion(struct ctx_cam *cam){
static void webu_stream_getimg_motion(struct ctx_cam *cam)
{
/*This is on the motion_loop thread */
if (cam->stream.motion.jpeg_data == NULL){
@@ -519,7 +533,8 @@ static void webu_stream_getimg_motion(struct ctx_cam *cam){
}
static void webu_stream_getimg_source(struct ctx_cam *cam){
static void webu_stream_getimg_source(struct ctx_cam *cam)
{
/*This is on the motion_loop thread */
if (cam->stream.source.jpeg_data == NULL){
@@ -538,7 +553,8 @@ static void webu_stream_getimg_source(struct ctx_cam *cam){
}
static void webu_stream_getimg_secondary(struct ctx_cam *cam){
static void webu_stream_getimg_secondary(struct ctx_cam *cam)
{
/*This is on the motion_loop thread */
if (cam->imgs.size_secondary>0) {
@@ -558,7 +574,8 @@ static void webu_stream_getimg_secondary(struct ctx_cam *cam){
}
void webu_stream_getimg(struct ctx_cam *cam, struct ctx_image_data *img_data){
void webu_stream_getimg(struct ctx_cam *cam, struct ctx_image_data *img_data)
{
/*This is on the motion_loop thread */

View File

@@ -38,7 +38,8 @@
#include "webu.hpp"
#include "webu_text.hpp"
static void webu_text_seteol(struct webui_ctx *webui) {
static void webu_text_seteol(struct webui_ctx *webui)
{
/* Set the end of line character for text interface */
if (webui->camlst[0]->conf->webcontrol_interface == 2) {
snprintf(webui->text_eol, WEBUI_LEN_PARM,"%s","<br>");
@@ -48,7 +49,8 @@ static void webu_text_seteol(struct webui_ctx *webui) {
}
static void webu_text_camera_name(struct webui_ctx *webui) {
static void webu_text_camera_name(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
if (webui->camlst[webui->thread_nbr]->conf->camera_name == ""){
@@ -67,7 +69,8 @@ static void webu_text_camera_name(struct webui_ctx *webui) {
}
static void webu_text_back(struct webui_ctx *webui, const char *prevuri) {
static void webu_text_back(struct webui_ctx *webui, const char *prevuri)
{
char response[WEBUI_LEN_RESP];
if (webui->camlst[0]->conf->webcontrol_interface == 2) {
@@ -80,7 +83,8 @@ static void webu_text_back(struct webui_ctx *webui, const char *prevuri) {
}
static void webu_text_header(struct webui_ctx *webui) {
static void webu_text_header(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
if (webui->camlst[0]->conf->webcontrol_interface == 2) {
@@ -94,7 +98,8 @@ static void webu_text_header(struct webui_ctx *webui) {
}
}
static void webu_text_trailer(struct webui_ctx *webui) {
static void webu_text_trailer(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
if (webui->camlst[0]->conf->webcontrol_interface == 2) {
@@ -106,7 +111,8 @@ static void webu_text_trailer(struct webui_ctx *webui) {
}
void webu_text_badreq(struct webui_ctx *webui) {
void webu_text_badreq(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -121,7 +127,8 @@ void webu_text_badreq(struct webui_ctx *webui) {
return;
}
static void webu_text_page_raw(struct webui_ctx *webui) {
static void webu_text_page_raw(struct webui_ctx *webui)
{
/* Write the main page text */
char response[WEBUI_LEN_RESP];
int indx;
@@ -145,7 +152,8 @@ static void webu_text_page_raw(struct webui_ctx *webui) {
}
static void webu_text_page_basic(struct webui_ctx *webui) {
static void webu_text_page_basic(struct webui_ctx *webui)
{
/* Write the main page text */
char response[WEBUI_LEN_RESP];
int indx;
@@ -179,7 +187,8 @@ static void webu_text_page_basic(struct webui_ctx *webui) {
}
static void webu_text_list_raw(struct webui_ctx *webui) {
static void webu_text_list_raw(struct webui_ctx *webui)
{
/* Write out the options and values */
char response[WEBUI_LEN_RESP];
int indx_parm,retcd;
@@ -214,7 +223,8 @@ static void webu_text_list_raw(struct webui_ctx *webui) {
}
static void webu_text_list_basic(struct webui_ctx *webui) {
static void webu_text_list_basic(struct webui_ctx *webui)
{
/* Write out the options and values */
char response[WEBUI_LEN_RESP];
int indx_parm,retcd;
@@ -268,7 +278,8 @@ static void webu_text_list_basic(struct webui_ctx *webui) {
}
static void webu_text_set_menu(struct webui_ctx *webui) {
static void webu_text_set_menu(struct webui_ctx *webui)
{
/* Write out the options and values to allow user to set them*/
char response[WEBUI_LEN_RESP];
@@ -333,7 +344,8 @@ static void webu_text_set_menu(struct webui_ctx *webui) {
}
static void webu_text_set_query(struct webui_ctx *webui) {
static void webu_text_set_query(struct webui_ctx *webui)
{
/* Write out the options and values to allow user to set them*/
char response[WEBUI_LEN_RESP];
@@ -383,7 +395,8 @@ static void webu_text_set_query(struct webui_ctx *webui) {
}
static void webu_text_set_assign(struct webui_ctx *webui) {
static void webu_text_set_assign(struct webui_ctx *webui)
{
/* Set a particular configuration parameter to desired value */
char response[WEBUI_LEN_RESP];
@@ -412,7 +425,8 @@ static void webu_text_set_assign(struct webui_ctx *webui) {
}
static void webu_text_get_menu(struct webui_ctx *webui) {
static void webu_text_get_menu(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
int indx_parm;
@@ -459,7 +473,8 @@ static void webu_text_get_menu(struct webui_ctx *webui) {
}
static void webu_text_action_quit(struct webui_ctx *webui) {
static void webu_text_action_quit(struct webui_ctx *webui)
{
/* Shut down MotionPlus or the associated thread */
char response[WEBUI_LEN_RESP];
@@ -477,7 +492,8 @@ static void webu_text_action_quit(struct webui_ctx *webui) {
}
static void webu_text_action_makemovie(struct webui_ctx *webui) {
static void webu_text_action_makemovie(struct webui_ctx *webui)
{
/* end the event. Legacy api name*/
char response[WEBUI_LEN_RESP];
@@ -499,7 +515,8 @@ static void webu_text_action_makemovie(struct webui_ctx *webui) {
}
static void webu_text_action_eventstart(struct webui_ctx *webui) {
static void webu_text_action_eventstart(struct webui_ctx *webui)
{
/* Start the event*/
char response[WEBUI_LEN_RESP];
@@ -521,7 +538,8 @@ static void webu_text_action_eventstart(struct webui_ctx *webui) {
}
static void webu_text_action_eventend(struct webui_ctx *webui) {
static void webu_text_action_eventend(struct webui_ctx *webui)
{
/* End any active event*/
char response[WEBUI_LEN_RESP];
@@ -543,7 +561,8 @@ static void webu_text_action_eventend(struct webui_ctx *webui) {
}
static void webu_text_action_snapshot(struct webui_ctx *webui) {
static void webu_text_action_snapshot(struct webui_ctx *webui)
{
/* trigger a snapshot*/
char response[WEBUI_LEN_RESP];
@@ -565,7 +584,8 @@ static void webu_text_action_snapshot(struct webui_ctx *webui) {
}
static void webu_text_action_restart(struct webui_ctx *webui) {
static void webu_text_action_restart(struct webui_ctx *webui)
{
/* Restart*/
char response[WEBUI_LEN_RESP];
@@ -586,7 +606,8 @@ static void webu_text_action_restart(struct webui_ctx *webui) {
}
static void webu_text_action_start(struct webui_ctx *webui) {
static void webu_text_action_start(struct webui_ctx *webui)
{
/* un-pause the camera*/
char response[WEBUI_LEN_RESP];
@@ -608,7 +629,8 @@ static void webu_text_action_start(struct webui_ctx *webui) {
}
static void webu_text_action_pause(struct webui_ctx *webui) {
static void webu_text_action_pause(struct webui_ctx *webui)
{
/* pause the camera*/
char response[WEBUI_LEN_RESP];
@@ -630,7 +652,8 @@ static void webu_text_action_pause(struct webui_ctx *webui) {
}
static void webu_text_action_write(struct webui_ctx *webui) {
static void webu_text_action_write(struct webui_ctx *webui)
{
/* write the parms to file*/
char response[WEBUI_LEN_RESP];
@@ -652,7 +675,8 @@ static void webu_text_action_write(struct webui_ctx *webui) {
}
static void webu_text_action(struct webui_ctx *webui) {
static void webu_text_action(struct webui_ctx *webui)
{
/* Call the action functions */
if (mystreq(webui->uri_cmd2,"makemovie")){
@@ -694,7 +718,8 @@ static void webu_text_action(struct webui_ctx *webui) {
}
static void webu_text_track_pantilt(struct webui_ctx *webui) {
static void webu_text_track_pantilt(struct webui_ctx *webui)
{
/* Call the track function */
char response[WEBUI_LEN_RESP];
@@ -721,7 +746,8 @@ static void webu_text_track_pantilt(struct webui_ctx *webui) {
}
static void webu_text_track(struct webui_ctx *webui) {
static void webu_text_track(struct webui_ctx *webui)
{
/* Call the track function */
char response[WEBUI_LEN_RESP];
int retcd;
@@ -749,7 +775,8 @@ static void webu_text_track(struct webui_ctx *webui) {
}
static void webu_text_menu(struct webui_ctx *webui) {
static void webu_text_menu(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -773,7 +800,8 @@ static void webu_text_menu(struct webui_ctx *webui) {
}
static void webu_text_menu_config(struct webui_ctx *webui) {
static void webu_text_menu_config(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -794,7 +822,8 @@ static void webu_text_menu_config(struct webui_ctx *webui) {
}
static void webu_text_menu_action(struct webui_ctx *webui) {
static void webu_text_menu_action(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -817,7 +846,8 @@ static void webu_text_menu_action(struct webui_ctx *webui) {
}
static void webu_text_menu_detection(struct webui_ctx *webui) {
static void webu_text_menu_detection(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -839,7 +869,8 @@ static void webu_text_menu_detection(struct webui_ctx *webui) {
}
static void webu_text_menu_track(struct webui_ctx *webui) {
static void webu_text_menu_track(struct webui_ctx *webui)
{
char response[WEBUI_LEN_RESP];
webu_text_header(webui);
@@ -859,7 +890,8 @@ static void webu_text_menu_track(struct webui_ctx *webui) {
}
static void webu_text_submenu(struct webui_ctx *webui) {
static void webu_text_submenu(struct webui_ctx *webui)
{
if ((mystreq(webui->uri_cmd1,"config")) &&
(strlen(webui->uri_cmd2) == 0)) {
@@ -886,7 +918,8 @@ static void webu_text_submenu(struct webui_ctx *webui) {
}
void webu_text_get_query(struct webui_ctx *webui) {
void webu_text_get_query(struct webui_ctx *webui)
{
/* Write out the option value for one parm */
char response[WEBUI_LEN_RESP];
int indx_parm, retcd;
@@ -967,7 +1000,8 @@ void webu_text_get_query(struct webui_ctx *webui) {
}
void webu_text_status(struct webui_ctx *webui) {
void webu_text_status(struct webui_ctx *webui)
{
/* Write out the pause/active status */
char response[WEBUI_LEN_RESP];
@@ -1004,7 +1038,8 @@ void webu_text_status(struct webui_ctx *webui) {
webu_text_trailer(webui);
}
void webu_text_connection(struct webui_ctx *webui) {
void webu_text_connection(struct webui_ctx *webui)
{
/* Write out the connection status */
char response[WEBUI_LEN_RESP];
int indx, indx_st;
@@ -1046,7 +1081,8 @@ void webu_text_connection(struct webui_ctx *webui) {
webu_text_trailer(webui);
}
void webu_text_list(struct webui_ctx *webui) {
void webu_text_list(struct webui_ctx *webui)
{
if (webui->camlst[0]->conf->webcontrol_interface == 2) {
webu_text_list_basic(webui);
@@ -1056,7 +1092,8 @@ void webu_text_list(struct webui_ctx *webui) {
}
void webu_text_main(struct webui_ctx *webui) {
void webu_text_main(struct webui_ctx *webui)
{
/* Main entry point for processing requests for the text interface */