Depreciate old stream module

This commit is contained in:
Mr-DaveDev
2020-09-19 20:22:42 -06:00
committed by GitHub
parent 62be47c4fe
commit b34cae1ca0
8 changed files with 116 additions and 1584 deletions

View File

@@ -11,6 +11,6 @@ bin_PROGRAMS = motion
motion_SOURCES = motion.c logger.c conf.c draw.c jpegutils.c video_loopback.c \
video_v4l2.c video_common.c video_bktr.c netcam.c netcam_http.c netcam_ftp.c \
netcam_jpeg.c netcam_wget.c netcam_rtsp.c track.c alg.c event.c picture.c \
rotate.c translate.c md5.c stream.c ffmpeg.c \
rotate.c translate.c md5.c ffmpeg.c \
webu.c webu_html.c webu_stream.c webu_text.c mmalcam.c $(MMAL_SRC)

View File

@@ -389,19 +389,52 @@ static void event_stream_put(struct context *cnt,
{
int subsize;
if (cnt->conf.stream_preview_method == 99){
if (cnt->conf.stream_port)
stream_put(cnt, &cnt->stream, &cnt->stream_count, img_data->image_norm, 0);
} else {
pthread_mutex_lock(&cnt->mutex_stream);
/* Normal stream processing */
if (cnt->stream_norm.cnct_count > 0){
if (cnt->stream_norm.jpeg_data == NULL){
cnt->stream_norm.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (img_data->image_norm != NULL){
cnt->stream_norm.jpeg_size = put_picture_memory(cnt
,cnt->stream_norm.jpeg_data
pthread_mutex_lock(&cnt->mutex_stream);
/* Normal stream processing */
if (cnt->stream_norm.cnct_count > 0){
if (cnt->stream_norm.jpeg_data == NULL){
cnt->stream_norm.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (img_data->image_norm != NULL){
cnt->stream_norm.jpeg_size = put_picture_memory(cnt
,cnt->stream_norm.jpeg_data
,cnt->imgs.size_norm
,img_data->image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
}
/* Substream processing */
if (cnt->stream_sub.cnct_count > 0){
if (cnt->stream_sub.jpeg_data == NULL){
cnt->stream_sub.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (img_data->image_norm != NULL){
/* Resulting substream image must be multiple of 8 */
if (((cnt->imgs.width % 16) == 0) &&
((cnt->imgs.height % 16) == 0)) {
subsize = ((cnt->imgs.width / 2) * (cnt->imgs.height / 2) * 3 / 2);
if (cnt->imgs.substream_image == NULL){
cnt->imgs.substream_image = mymalloc(subsize);
}
pic_scale_img(cnt->imgs.width
,cnt->imgs.height
,img_data->image_norm
,cnt->imgs.substream_image);
cnt->stream_sub.jpeg_size = put_picture_memory(cnt
,cnt->stream_sub.jpeg_data
,subsize
,cnt->imgs.substream_image
,cnt->conf.stream_quality
,(cnt->imgs.width / 2)
,(cnt->imgs.height / 2));
} else {
/* Substream was not multiple of 8 so send full image*/
cnt->stream_sub.jpeg_size = put_picture_memory(cnt
,cnt->stream_sub.jpeg_data
,cnt->imgs.size_norm
,img_data->image_norm
,cnt->conf.stream_quality
@@ -409,78 +442,41 @@ static void event_stream_put(struct context *cnt,
,cnt->imgs.height);
}
}
}
/* Substream processing */
if (cnt->stream_sub.cnct_count > 0){
if (cnt->stream_sub.jpeg_data == NULL){
cnt->stream_sub.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (img_data->image_norm != NULL){
/* Resulting substream image must be multiple of 8 */
if (((cnt->imgs.width % 16) == 0) &&
((cnt->imgs.height % 16) == 0)) {
subsize = ((cnt->imgs.width / 2) * (cnt->imgs.height / 2) * 3 / 2);
if (cnt->imgs.substream_image == NULL){
cnt->imgs.substream_image = mymalloc(subsize);
}
pic_scale_img(cnt->imgs.width
,cnt->imgs.height
,img_data->image_norm
,cnt->imgs.substream_image);
cnt->stream_sub.jpeg_size = put_picture_memory(cnt
,cnt->stream_sub.jpeg_data
,subsize
,cnt->imgs.substream_image
,cnt->conf.stream_quality
,(cnt->imgs.width / 2)
,(cnt->imgs.height / 2));
} else {
/* Substream was not multiple of 8 so send full image*/
cnt->stream_sub.jpeg_size = put_picture_memory(cnt
,cnt->stream_sub.jpeg_data
,cnt->imgs.size_norm
,img_data->image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
}
/* Motion stream processing */
if (cnt->stream_motion.cnct_count > 0){
if (cnt->stream_motion.jpeg_data == NULL){
cnt->stream_motion.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
/* Motion stream processing */
if (cnt->stream_motion.cnct_count > 0){
if (cnt->stream_motion.jpeg_data == NULL){
cnt->stream_motion.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (cnt->imgs.img_motion.image_norm != NULL){
cnt->stream_motion.jpeg_size = put_picture_memory(cnt
,cnt->stream_motion.jpeg_data
,cnt->imgs.size_norm
,cnt->imgs.img_motion.image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
if (cnt->imgs.img_motion.image_norm != NULL){
cnt->stream_motion.jpeg_size = put_picture_memory(cnt
,cnt->stream_motion.jpeg_data
,cnt->imgs.size_norm
,cnt->imgs.img_motion.image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
}
/* Source stream processing */
if (cnt->stream_source.cnct_count > 0){
if (cnt->stream_source.jpeg_data == NULL){
cnt->stream_source.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
if (cnt->imgs.image_virgin.image_norm != NULL){
cnt->stream_source.jpeg_size = put_picture_memory(cnt
,cnt->stream_source.jpeg_data
,cnt->imgs.size_norm
,cnt->imgs.image_virgin.image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
/* Source stream processing */
if (cnt->stream_source.cnct_count > 0){
if (cnt->stream_source.jpeg_data == NULL){
cnt->stream_source.jpeg_data = mymalloc(cnt->imgs.size_norm);
}
pthread_mutex_unlock(&cnt->mutex_stream);
}
if (cnt->imgs.image_virgin.image_norm != NULL){
cnt->stream_source.jpeg_size = put_picture_memory(cnt
,cnt->stream_source.jpeg_data
,cnt->imgs.size_norm
,cnt->imgs.image_virgin.image_norm
,cnt->conf.stream_quality
,cnt->imgs.width
,cnt->imgs.height);
}
}
pthread_mutex_unlock(&cnt->mutex_stream);
}

View File

@@ -1513,30 +1513,6 @@ static int motion_init(struct context *cnt)
cnt->threshold_maximum = (cnt->imgs.height * cnt->imgs.width * 3) / 2;
}
if (cnt->conf.stream_preview_method == 99){
/* This is the depreciated Stop stream process */
/* Initialize stream server if stream port is specified to not 0 */
if (cnt->conf.stream_port) {
if (stream_init (&(cnt->stream), cnt->conf.stream_port, cnt->conf.stream_localhost,
cnt->conf.webcontrol_ipv6, cnt->conf.stream_cors_header) == -1) {
MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO
,_("Problem enabling motion-stream server in port %d")
,cnt->conf.stream_port);
cnt->conf.stream_port = 0;
cnt->finish = 1;
} else {
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
,_("Started motion-stream server on port %d (auth %s)")
,cnt->conf.stream_port
,cnt->conf.stream_auth_method ? _("Enabled"):_("Disabled"));
}
}
} /* End of legacy stream methods*/
/* Prevent first few frames from triggering motion... */
cnt->moved = 8;
@@ -1634,12 +1610,6 @@ static int motion_init(struct context *cnt)
*/
static void motion_cleanup(struct context *cnt) {
if (cnt->conf.stream_preview_method == 99){
/* This is the depreciated Stop stream process */
if ((cnt->conf.stream_port) && (cnt->stream.socket != -1))
stream_stop(&cnt->stream);
}
event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, NULL);
event(cnt, EVENT_ENDMOTION, NULL, NULL, NULL, NULL);

View File

@@ -65,7 +65,6 @@ struct image_data;
#include "logger.h"
#include "conf.h"
#include "stream.h"
#include "track.h"
#include "netcam.h"
@@ -455,9 +454,6 @@ struct context {
int pipe;
int mpipe;
struct stream stream;
int stream_count;
char hostname[PATH_MAX];
char *netcam_decoder;

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,50 +0,0 @@
/*
* stream.h
*
* Include file for stream.c
* Copyright (C) 2002 Jeroen Vreeken (pe1rxq@amsat.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _INCLUDE_STREAM_H_
#define _INCLUDE_STREAM_H_
struct stream_buffer {
unsigned char *ptr;
int ref;
long size;
};
struct stream {
int socket;
FILE *fwrite;
struct stream_buffer *tmpbuffer;
char *cors_header;
long filepos;
int nr;
unsigned long int last;
struct stream *prev;
struct stream *next;
};
int stream_init(struct stream *stm,
int port,
int localhost,
int ipv6_enabled,
const char *cors_header);
void stream_put(struct context *, struct stream *, int *, unsigned char *, int);
void stream_stop(struct stream *);
#endif /* _INCLUDE_STREAM_H_ */

View File

@@ -2106,11 +2106,9 @@ void webu_start(struct context **cnt) {
indxthrd++;
}
if (cnt[0]->conf.stream_preview_method != 99){
webu_start_ports(cnt);
webu_start_ports(cnt);
webu_start_strm(cnt);
}
webu_start_strm(cnt);
webu_start_ctrl(cnt);

View File

@@ -570,57 +570,48 @@ static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) {
* what images are to be sent but also whether we have tls/ssl.
* There are WAY too many options for this.
*/
if (strm_info->cntlst[indx]->conf.stream_preview_method == 99){
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","");
/* If using the main port,we need to insert a thread number into url*/
if (strm_info->cntlst[0]->conf.stream_port != 0) {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"/%d"
,strm_info->cntlst[indx]->camera_id);
strm_info->port = strm_info->cntlst[0]->conf.stream_port;
if (strm_info->cntlst[0]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
} else {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"%s","");
strm_info->port = strm_info->cntlst[indx]->conf.stream_port;
} else {
/* If using the main port,we need to insert a thread number into url*/
if (strm_info->cntlst[0]->conf.stream_port != 0) {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"/%d"
,strm_info->cntlst[indx]->camera_id);
strm_info->port = strm_info->cntlst[0]->conf.stream_port;
if (strm_info->cntlst[0]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
if (strm_info->cntlst[indx]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"%s","");
strm_info->port = strm_info->cntlst[indx]->conf.stream_port;
if (strm_info->cntlst[indx]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
}
if (strm_info->motion_images){
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/motion");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/motion");
} else {
/* Assign what images and links we want */
if (strm_info->cntlst[indx]->conf.stream_preview_method == 1){
/* Substream for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/substream");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 2){
/* Static image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/current");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 4){
/* Source image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/source");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/source");
} else {
/* Full stream for preview (method 0 or 3)*/
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/stream");
}
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
}
if (strm_info->motion_images){
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/motion");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/motion");
} else {
/* Assign what images and links we want */
if (strm_info->cntlst[indx]->conf.stream_preview_method == 1){
/* Substream for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/substream");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 2){
/* Static image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/current");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 4){
/* Source image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/source");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/source");
} else {
/* Full stream for preview (method 0 or 3)*/
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/stream");
}
}
}
static void webu_html_preview(struct webui_ctx *webui) {