From 5b75f5d767cc2e828a4bdca6ace8b4ad81622caa Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 18 Jun 2021 23:12:19 -0600 Subject: [PATCH] Allow any type of netcam --- src/motion_loop.cpp | 9 +-------- src/netcam.cpp | 19 ++++++------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 929a3862..4e88529b 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -471,14 +471,7 @@ static int init_camera_type(struct ctx_cam *cam) } if (cam->conf->netcam_url != "") { - if ((cam->conf->netcam_url.compare(0,5,"mjpeg") == 0) || - (cam->conf->netcam_url.compare(0,4,"http") == 0) || - (cam->conf->netcam_url.compare(0,4,"v4l2") == 0) || - (cam->conf->netcam_url.compare(0,4,"file") == 0) || - (cam->conf->netcam_url.compare(0,4,"rtmp") == 0) || - (cam->conf->netcam_url.compare(0,4,"rtsp") == 0)) { - cam->camera_type = CAMERA_TYPE_NETCAM; - } + cam->camera_type = CAMERA_TYPE_NETCAM; return 0; } diff --git a/src/netcam.cpp b/src/netcam.cpp index 8a070831..375acd96 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -159,7 +159,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) char *s; int i; - const char *re = "(http|ftp|mjpg|mjpeg|rtsp|rtmp)://(((.*):(.*))@)?" + const char *re = "(.*)://(((.*):(.*))@)?" "([^/:]|[-_.a-z0-9]+)(:([0-9]+))?($|(/[^*]*))"; regex_t pattbuf; regmatch_t matches[10]; @@ -167,9 +167,6 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) if (!strncmp(text_url, "file", 4)) { re = "(file)://(((.*):(.*))@)?([/:])?(:([0-9]+))?($|(/[^*]*))"; } - if (!strncmp(text_url, "jpeg", 4)) { - re = "(jpeg)://(((.*):(.*))@)?([/:])?(:([0-9]+))?($|(/[^*]*))"; - } if (!strncmp(text_url, "v4l2", 4)) { re = "(v4l2)://(((.*):(.*))@)?([/:])?(:([0-9]+))?($|(/[^*]*))"; } @@ -1380,13 +1377,15 @@ static void netcam_set_options(struct ctx_netcam *netcam) tmpval = (char*)mymalloc(PATH_MAX); if (mystreq(netcam->service, "rtsp") || + mystreq(netcam->service, "rtsps") || mystreq(netcam->service, "rtmp")) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO,_("%s: Setting rtsp/rtmp") ,netcam->cameratype); util_parms_add_default(netcam->params,"rtsp_transport","tcp"); //util_parms_add_default(netcam->params,"allowed_media_types", "video"); - } else if (mystreq(netcam->service, "http")) { + } else if (mystreq(netcam->service, "http") || + mystreq(netcam->service, "https")) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO ,_("%s: Setting input_format mjpeg"),netcam->cameratype); netcam->format_context->iformat = av_find_input_format("mjpeg"); @@ -1476,14 +1475,8 @@ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO ,_("Setting up file")); } else { - if (mystreq(url.service, "mjpeg")) { - sprintf(url.service, "%s","http"); - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO - ,_("Setting up http")); - } else { - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO - ,_("Setting up %s "),url.service); - } + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO + ,_("Setting up %s "),url.service); if (userpass != NULL) { netcam->path =(char*) mymalloc(strlen(url.service) + 3 + strlen(userpass) + 1 + strlen(url.host) + 6 + strlen(url.path) + 2 );