From 786f0c792bc2bb97e7cae463016cc23484201913 Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Fri, 14 Oct 2022 23:17:26 -0600 Subject: [PATCH] Revise context items in netcam --- src/netcam.cpp | 24 ++++++++++++------------ src/netcam.hpp | 17 +++++------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/netcam.cpp b/src/netcam.cpp index 76510239..dc60aa11 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -125,7 +125,7 @@ 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(ctx_url *parse_url) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO,_("Invalid URL. Can not parse values.")); @@ -154,7 +154,7 @@ 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(ctx_url *parse_url, const char *text_url) { char *s; int i; @@ -177,7 +177,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) //MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "Entry netcam_url_parse data %s",text_url); - memset(parse_url, 0, sizeof(struct url_t)); + memset(parse_url, 0, sizeof(ctx_url)); /* * regcomp compiles regular expressions into a form that is * suitable for regexec searches @@ -249,7 +249,7 @@ 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(ctx_url *parse_url) { myfree(&parse_url->service); myfree(&parse_url->userpass); @@ -345,11 +345,11 @@ static void netcam_pktarray_resize(ctx_cam *cam, bool is_highres) * ...So....make this array big enough so we never catch our tail. :) */ - int64_t idnbr_last, idnbr_first; - int indx; - ctx_netcam *netcam; - struct packet_item *tmp; - int newsize; + int64_t idnbr_last, idnbr_first; + int indx; + ctx_netcam *netcam; + ctx_packet_item *tmp; + int newsize; if (is_highres) { idnbr_last = cam->imgs.image_ring[cam->imgs.ring_out].idnbr_high; @@ -374,9 +374,9 @@ static void netcam_pktarray_resize(ctx_cam *cam, bool is_highres) pthread_mutex_lock(&netcam->mutex_pktarray); if ((netcam->pktarray_size < newsize) || (netcam->pktarray_size < 30)) { - tmp =(packet_item*) mymalloc(newsize * sizeof(struct packet_item)); + tmp =(ctx_packet_item*) mymalloc(newsize * sizeof(ctx_packet_item)); if (netcam->pktarray_size > 0 ) { - memcpy(tmp, netcam->pktarray, sizeof(struct packet_item) * netcam->pktarray_size); + memcpy(tmp, netcam->pktarray, sizeof(ctx_packet_item) * netcam->pktarray_size); } for(indx = netcam->pktarray_size; indx < newsize; indx++) { tmp[indx].packet = NULL; @@ -1439,7 +1439,7 @@ static void netcam_set_path (ctx_cam *cam, ctx_netcam *netcam ) { char userpass[PATH_MAX]; - struct url_t url; + ctx_url url; int retcd; netcam->path = NULL; diff --git a/src/netcam.hpp b/src/netcam.hpp index fdc4e2ff..c5587106 100644 --- a/src/netcam.hpp +++ b/src/netcam.hpp @@ -22,9 +22,6 @@ #ifndef _INCLUDE_NETCAM_HPP_ #define _INCLUDE_NETCAM_HPP_ -struct context; -struct image_data; - #define NETCAM_GENERAL_ERROR 0x02 /* binary 000010 */ #define NETCAM_RESTART_ERROR 0x12 /* binary 010010 */ #define NETCAM_BUFFSIZE 4096 @@ -36,16 +33,12 @@ enum NETCAM_STATUS { NETCAM_RECONNECTING /* Motion is trying to reconnect to camera */ }; -struct imgsize_context { +struct ctx_imgsize { int width; int height; }; -/* - * struct url_t is used when parsing the user-supplied URL, as well as - * when attempting to connect to the netcam. - */ -struct url_t { +struct ctx_url { char *service; char *userpass; char *host; @@ -79,7 +72,7 @@ extern "C" { #include "libavutil/hwcontext.h" #include "libavutil/mem.h" } -struct packet_item{ +struct ctx_packet_item{ AVPacket *packet; int64_t idnbr; bool iskey; @@ -97,7 +90,7 @@ struct ctx_netcam { struct SwsContext *swsctx; /* Context for the resizing of the image */ AVPacket *packet_recv; /* The packet that is currently being processed */ AVFormatContext *transfer_format; /* Format context just for transferring to pass-through */ - struct packet_item *pktarray; /* Pointer to array of packets for passthru processing */ + ctx_packet_item *pktarray; /* Pointer to array of packets for passthru processing */ int pktarray_size; /* The number of packets in array. 1 based */ int pktarray_index; /* The index to the most current packet in array */ int64_t idnbr; /* A ID number to track the packet vs image */ @@ -131,7 +124,7 @@ struct ctx_netcam { char service[5]; /* String specifying the type of camera http, rtsp, v4l2 */ char camera_name[PATH_MAX]; /* The name of the camera as provided in the config file */ char cameratype[30]; /* String specifying Normal or High for use in logging */ - struct imgsize_context imgsize; /* The image size parameters */ + ctx_imgsize imgsize; /* The image size parameters */ int rtsp_uses_tcp; /* Flag from config for whether to use tcp transport */ int v4l2_palette; /* Palette from config for v4l2 devices */