Revise from ctx_cam to ctx_dev

This commit is contained in:
Mr-Dave
2023-01-15 17:45:32 -07:00
parent da68668d96
commit 6ca04402bf
41 changed files with 438 additions and 438 deletions

View File

@@ -41,7 +41,7 @@
#include "webu_stream.hpp"
/* Resize the image ring */
static void mlp_ring_resize(ctx_cam *cam)
static void mlp_ring_resize(ctx_dev *cam)
{
int i, new_size;
ctx_image_data *tmp;
@@ -74,7 +74,7 @@ static void mlp_ring_resize(ctx_cam *cam)
}
/* Clean image ring */
static void mlp_ring_destroy(ctx_cam *cam)
static void mlp_ring_destroy(ctx_dev *cam)
{
int i;
@@ -98,7 +98,7 @@ static void mlp_ring_destroy(ctx_cam *cam)
}
/* Add debug messsage to image */
static void mlp_ring_process_debug(ctx_cam *cam)
static void mlp_ring_process_debug(ctx_dev *cam)
{
char tmp[32];
const char *t;
@@ -124,7 +124,7 @@ static void mlp_ring_process_debug(ctx_cam *cam)
}
/* Process the entire image ring */
static void mlp_ring_process(ctx_cam *cam)
static void mlp_ring_process(ctx_dev *cam)
{
ctx_image_data *saved_current_image = cam->current_image;
@@ -170,7 +170,7 @@ static void mlp_ring_process(ctx_cam *cam)
}
/* Reset the image info variables*/
static void mlp_info_reset(ctx_cam *cam)
static void mlp_info_reset(ctx_dev *cam)
{
cam->info_diff_cnt = 0;
cam->info_diff_tot = 0;
@@ -180,7 +180,7 @@ static void mlp_info_reset(ctx_cam *cam)
}
/* Process the motion detected items*/
static void mlp_detected_trigger(ctx_cam *cam, ctx_image_data *img)
static void mlp_detected_trigger(ctx_dev *cam, ctx_image_data *img)
{
time_t raw_time;
struct tm evt_tm;
@@ -222,7 +222,7 @@ static void mlp_detected_trigger(ctx_cam *cam, ctx_image_data *img)
}
/* call ptz camera center */
static void mlp_track_center(ctx_cam *cam)
static void mlp_track_center(ctx_dev *cam)
{
if ((cam->conf->ptz_auto_track) && (cam->conf->ptz_move_track != "")) {
cam->track_posx = 0;
@@ -233,7 +233,7 @@ static void mlp_track_center(ctx_cam *cam)
}
/* call ptz camera move */
static void mlp_track_move(ctx_cam *cam, ctx_coord *cent)
static void mlp_track_move(ctx_dev *cam, ctx_coord *cent)
{
if ((cam->conf->ptz_auto_track) && (cam->conf->ptz_move_track != "")) {
cam->track_posx += cent->x;
@@ -244,7 +244,7 @@ static void mlp_track_move(ctx_cam *cam, ctx_coord *cent)
}
/* motion detected */
static void mlp_detected(ctx_cam *cam, ctx_image_data *img)
static void mlp_detected(ctx_dev *cam, ctx_image_data *img)
{
ctx_config *conf = cam->conf;
unsigned int distX, distY;
@@ -273,7 +273,7 @@ static void mlp_detected(ctx_cam *cam, ctx_image_data *img)
}
/* Apply the privacy mask to image*/
static void mlp_mask_privacy(ctx_cam *cam)
static void mlp_mask_privacy(ctx_dev *cam)
{
if (cam->imgs.mask_privacy == NULL) {
return;
@@ -357,7 +357,7 @@ static void mlp_mask_privacy(ctx_cam *cam)
}
/* Close and clean up camera*/
void mlp_cam_close(ctx_cam *cam)
void mlp_cam_close(ctx_dev *cam)
{
if (cam->libcam != NULL) {
libcam_cleanup(cam);
@@ -380,7 +380,7 @@ void mlp_cam_close(ctx_cam *cam)
}
/* Start camera */
void mlp_cam_start(ctx_cam *cam)
void mlp_cam_start(ctx_dev *cam)
{
if (cam->camera_type == CAMERA_TYPE_LIBCAM) {
libcam_start(cam);
@@ -396,7 +396,7 @@ void mlp_cam_start(ctx_cam *cam)
}
/* Get next image from camera */
int mlp_cam_next(ctx_cam *cam, ctx_image_data *img_data)
int mlp_cam_next(ctx_dev *cam, ctx_image_data *img_data)
{
if (cam->camera_type == CAMERA_TYPE_LIBCAM) {
return libcam_next(cam, img_data);
@@ -410,7 +410,7 @@ int mlp_cam_next(ctx_cam *cam, ctx_image_data *img_data)
}
/* Assign the camera type */
static void mlp_init_camera_type(ctx_cam *cam)
static void mlp_init_camera_type(ctx_dev *cam)
{
if (cam->conf->libcam_name != "") {
cam->camera_type = CAMERA_TYPE_LIBCAM;
@@ -428,7 +428,7 @@ static void mlp_init_camera_type(ctx_cam *cam)
}
/** Get first images from camera at startup */
static void mlp_init_firstimage(ctx_cam *cam)
static void mlp_init_firstimage(ctx_dev *cam)
{
int indx;
const char *msg;
@@ -462,7 +462,7 @@ static void mlp_init_firstimage(ctx_cam *cam)
}
/** Check the image size to determine if modulo 8 and over 64 */
static void mlp_check_szimg(ctx_cam *cam)
static void mlp_check_szimg(ctx_dev *cam)
{
if ((cam->imgs.width % 8) || (cam->imgs.height % 8)) {
MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO
@@ -485,7 +485,7 @@ static void mlp_check_szimg(ctx_cam *cam)
}
/** Set the items required for the area detect */
static void mlp_init_areadetect(ctx_cam *cam)
static void mlp_init_areadetect(ctx_dev *cam)
{
cam->area_minx[0] = cam->area_minx[3] = cam->area_minx[6] = 0;
cam->area_miny[0] = cam->area_miny[1] = cam->area_miny[2] = 0;
@@ -509,7 +509,7 @@ static void mlp_init_areadetect(ctx_cam *cam)
}
/** Allocate the required buffers */
static void mlp_init_buffers(ctx_cam *cam)
static void mlp_init_buffers(ctx_dev *cam)
{
cam->imgs.ref =(unsigned char*) mymalloc(cam->imgs.size_norm);
cam->imgs.image_motion.image_norm = (unsigned char*)mymalloc(cam->imgs.size_norm);
@@ -536,7 +536,7 @@ static void mlp_init_buffers(ctx_cam *cam)
}
/* Initialize loop values */
static void mlp_init_values(ctx_cam *cam)
static void mlp_init_values(ctx_dev *cam)
{
cam->event_nr = 1;
cam->prev_event = 0;
@@ -566,7 +566,7 @@ static void mlp_init_values(ctx_cam *cam)
}
/* start the camera */
static void mlp_init_cam_start(ctx_cam *cam)
static void mlp_init_cam_start(ctx_dev *cam)
{
mlp_cam_start(cam);
@@ -583,7 +583,7 @@ static void mlp_init_cam_start(ctx_cam *cam)
}
/* initialize reference images*/
static void mlp_init_ref(ctx_cam *cam)
static void mlp_init_ref(ctx_dev *cam)
{
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
@@ -595,7 +595,7 @@ static void mlp_init_ref(ctx_cam *cam)
}
/** clean up all memory etc. from motion init */
void mlp_cleanup(ctx_cam *cam)
void mlp_cleanup(ctx_dev *cam)
{
event(cam, EVENT_TLAPSE_END, NULL, NULL, NULL, NULL);
if (cam->event_nr == cam->prev_event) {
@@ -653,7 +653,7 @@ void mlp_cleanup(ctx_cam *cam)
}
/* initialize everything for the loop */
static void mlp_init(ctx_cam *cam)
static void mlp_init(ctx_dev *cam)
{
if ((cam->camera_status != STATUS_INIT) &&
(cam->camera_status != STATUS_RESET)) {
@@ -712,7 +712,7 @@ static void mlp_init(ctx_cam *cam)
/* check the area detect */
static void mlp_areadetect(ctx_cam *cam)
static void mlp_areadetect(ctx_dev *cam)
{
int i, j, z = 0;
@@ -739,7 +739,7 @@ static void mlp_areadetect(ctx_cam *cam)
}
/* Prepare for the next iteration of loop*/
static void mlp_prepare(ctx_cam *cam)
static void mlp_prepare(ctx_dev *cam)
{
cam->watchdog = cam->conf->watchdog_tmo;
@@ -764,7 +764,7 @@ static void mlp_prepare(ctx_cam *cam)
}
/* reset the images */
static void mlp_resetimages(ctx_cam *cam)
static void mlp_resetimages(ctx_dev *cam)
{
/* ring_buffer_in is pointing to current pos, update before put in a new image */
if (++cam->imgs.ring_in >= cam->imgs.ring_size) {
@@ -793,7 +793,7 @@ static void mlp_resetimages(ctx_cam *cam)
}
/* Try to reconnect to camera */
static void mlp_retry(ctx_cam *cam)
static void mlp_retry(ctx_dev *cam)
{
int size_high;
@@ -825,7 +825,7 @@ static void mlp_retry(ctx_cam *cam)
}
/* Get next image from camera */
static int mlp_capture(ctx_cam *cam)
static int mlp_capture(ctx_dev *cam)
{
const char *tmpin;
char tmpout[80];
@@ -895,7 +895,7 @@ static int mlp_capture(ctx_cam *cam)
}
/* call detection */
static void mlp_detection(ctx_cam *cam)
static void mlp_detection(ctx_dev *cam)
{
if (cam->frame_skip) {
cam->frame_skip--;
@@ -913,7 +913,7 @@ static void mlp_detection(ctx_cam *cam)
}
/* tune the detection parameters*/
static void mlp_tuning(ctx_cam *cam)
static void mlp_tuning(ctx_dev *cam)
{
if ((cam->conf->noise_tune && cam->shots == 0) &&
(!cam->detecting_motion && (cam->current_image->diffs <= cam->threshold))) {
@@ -946,7 +946,7 @@ static void mlp_tuning(ctx_cam *cam)
}
/* apply image overlays */
static void mlp_overlay(ctx_cam *cam)
static void mlp_overlay(ctx_dev *cam)
{
char tmp[PATH_MAX];
@@ -1016,7 +1016,7 @@ static void mlp_overlay(ctx_cam *cam)
}
/* emulate motion */
static void mlp_actions_emulate(ctx_cam *cam)
static void mlp_actions_emulate(ctx_dev *cam)
{
int indx;
@@ -1039,7 +1039,7 @@ static void mlp_actions_emulate(ctx_cam *cam)
}
/* call the actions */
static void mlp_actions_motion(ctx_cam *cam)
static void mlp_actions_motion(ctx_dev *cam)
{
int indx, frame_count = 0;
int pos = cam->imgs.ring_in;
@@ -1081,7 +1081,7 @@ static void mlp_actions_motion(ctx_cam *cam)
}
/* call the event actions*/
static void mlp_actions_event(ctx_cam *cam)
static void mlp_actions_event(ctx_dev *cam)
{
if ((cam->conf->event_gap > 0) &&
((cam->frame_curr_ts.tv_sec - cam->lasttime ) >= cam->conf->event_gap)) {
@@ -1132,7 +1132,7 @@ static void mlp_actions_event(ctx_cam *cam)
}
static void mlp_actions(ctx_cam *cam)
static void mlp_actions(ctx_dev *cam)
{
if ((cam->current_image->diffs > cam->threshold) &&
(cam->current_image->diffs < cam->threshold_maximum)) {
@@ -1189,7 +1189,7 @@ static void mlp_actions(ctx_cam *cam)
}
/* Process for setup mode */
static void mlp_setupmode(ctx_cam *cam)
static void mlp_setupmode(ctx_dev *cam)
{
if (cam->motapp->setup_mode) {
char msg[1024] = "\0";
@@ -1223,7 +1223,7 @@ static void mlp_setupmode(ctx_cam *cam)
}
/* Snapshot interval*/
static void mlp_snapshot(ctx_cam *cam)
static void mlp_snapshot(ctx_dev *cam)
{
if ((cam->conf->snapshot_interval > 0 && cam->shots == 0 &&
cam->frame_curr_ts.tv_sec % cam->conf->snapshot_interval <=
@@ -1235,7 +1235,7 @@ static void mlp_snapshot(ctx_cam *cam)
}
/* Create timelapse video*/
static void mlp_timelapse(ctx_cam *cam)
static void mlp_timelapse(ctx_dev *cam)
{
struct tm timestamp_tm;
@@ -1285,7 +1285,7 @@ static void mlp_timelapse(ctx_cam *cam)
}
/* send images to loopback device*/
static void mlp_loopback(ctx_cam *cam)
static void mlp_loopback(ctx_dev *cam)
{
if (cam->motapp->setup_mode) {
event(cam, EVENT_IMAGE, &cam->imgs.image_motion, NULL, &cam->pipe, &cam->current_image->imgts);
@@ -1302,7 +1302,7 @@ static void mlp_loopback(ctx_cam *cam)
}
/* Update parameters from web interface*/
static void mlp_parmsupdate(ctx_cam *cam)
static void mlp_parmsupdate(ctx_dev *cam)
{
/* Check for some config parameter changes but only every second */
if (cam->shots != 0) {
@@ -1377,7 +1377,7 @@ static void mlp_parmsupdate(ctx_cam *cam)
}
/* sleep the loop to get framerate requested */
static void mlp_frametiming(ctx_cam *cam)
static void mlp_frametiming(ctx_dev *cam)
{
int indx;
struct timespec ts2;
@@ -1421,7 +1421,7 @@ static void mlp_frametiming(ctx_cam *cam)
/** main processing loop for each camera */
void *motion_loop(void *arg)
{
ctx_cam *cam =(ctx_cam *) arg;
ctx_dev *cam =(ctx_dev *) arg;
cam->running_cam = true;