Revise context items in netcam

This commit is contained in:
Mr-Dave
2022-10-14 23:17:26 -06:00
parent 5b0bf172b3
commit 786f0c792b
2 changed files with 17 additions and 24 deletions

View File

@@ -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;

View File

@@ -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 */