Skip to content

Commit 0adef7b

Browse files
committed
Provide consolidated image for each port being streamed
1 parent a7047f3 commit 0adef7b

16 files changed

Lines changed: 494 additions & 404 deletions

doc/motion_config.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,11 +2536,20 @@ <h3><a name="stream_preview_newline"></a> stream_preview_newline </h3>
25362536
<h3><a name="stream_allcam_params"></a> stream_allcam_params</h3>
25372537
<ul>
25382538
<li> Values: String | Default: Not Defined</li>
2539-
Comma separated parameters for the video streams and consolidated image.
2539+
Comma separated parameters for the consolidated image video streams.
25402540
The consolidated image puts together a single image of all the cameras currently
2541-
running. Format is parm1=value1,parm2=value2 etc.
2541+
running on the webcontrol_port. Format is parm1=value1,parm2=value2 etc.
25422542
<p></p>
25432543
<div>
2544+
<i><h4>Muliple webcontrol ports</h4></i>
2545+
<ul>
2546+
Since consolidated cameras streams may be available on multiple ports,
2547+
parameter names can be customized to provide different values per port.
2548+
Simply append the applicable port number to the parameter name. For example,
2549+
the parameter values of <code>row=2;row8082=3</code> would indicate that the
2550+
default row would be 2 and for the consolidated stream provided
2551+
on <code>webcontrol_port 8082</code> the row would be 3
2552+
</ul>
25442553
<i><h4>row</h4></i>
25452554
<ul>
25462555
<li> Values: positive integers | Default: Not Defined </li>
@@ -2592,6 +2601,14 @@ <h3><a name="stream_allcam_params"></a> stream_allcam_params</h3>
25922601
</ul>
25932602
<p></p>
25942603
</div>
2604+
<div>
2605+
<i><h4>scale</h4></i>
2606+
<ul>
2607+
<li> Values: Integers | Default: 100 </li>
2608+
The percentage to scale the image. Numbers greater than 100 are permitted.
2609+
</ul>
2610+
<p></p>
2611+
</div>
25952612

25962613
<p></p>
25972614
Note that the row and col must be continuous without gaps in the numbers.

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ motion_SOURCES = \
3636
libcam.hpp libcam.cpp \
3737
logger.hpp logger.cpp \
3838
motion.hpp motion.cpp \
39-
allcam.hpp allcam.cpp \
4039
schedule.hpp schedule.cpp \
4140
camera.hpp camera.cpp \
4241
movie.hpp movie.cpp \
@@ -49,6 +48,7 @@ motion_SOURCES = \
4948
video_convert.hpp video_convert.cpp \
5049
video_loopback.hpp video_loopback.cpp \
5150
webu.hpp webu.cpp \
51+
webu_allcam.hpp webu_allcam.cpp \
5252
webu_ans.hpp webu_ans.cpp \
5353
webu_file.hpp webu_file.cpp \
5454
webu_html.hpp webu_html.cpp \

src/camera.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,9 +2093,6 @@ cls_camera::cls_camera(cls_motapp *p_app)
20932093
device_status = STATUS_CLOSED;
20942094
memset(&imgs, 0, sizeof(ctx_images));
20952095
memset(&stream, 0, sizeof(ctx_stream));
2096-
memset(&all_loc, 0, sizeof(ctx_all_loc));
2097-
memset(&all_sizes, 0, sizeof(ctx_all_sizes));
2098-
all_sizes.reset = true;
20992096
}
21002097

21012098
cls_camera::~cls_camera()

src/camera.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ class cls_camera {
144144
cls_rotate *rotate;
145145
cls_netcam *netcam;
146146
cls_netcam *netcam_high;
147-
ctx_all_loc all_loc;
148-
ctx_all_sizes all_sizes;
149147
cls_draw *draw;
150148
cls_picture *picture;
151149

@@ -159,6 +157,7 @@ class cls_camera {
159157
bool restart;
160158
bool finish;
161159
bool conf_chg;
160+
bool allcam_reset;
162161
int threadnr;
163162
int noise;
164163
bool detecting_motion;

src/motion.cpp

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#include "util.hpp"
2121
#include "conf.hpp"
2222
#include "logger.hpp"
23-
#include "allcam.hpp"
2423
#include "schedule.hpp"
2524
#include "camera.hpp"
2625
#include "sound.hpp"
2726
#include "dbse.hpp"
2827
#include "webu.hpp"
28+
#include "webu_allcam.hpp"
2929
#include "video_v4l2.hpp"
3030
#include "movie.hpp"
3131
#include "netcam.hpp"
@@ -455,6 +455,7 @@ void cls_motapp::check_restart()
455455
webu_list[indx1]->cfg = cam_list[indx2]->cfg;
456456
}
457457
}
458+
webu_list[indx1]->webuindx = indx1;
458459
webu_list[indx1]->startup();
459460
webu_list[indx1]->restart = false;
460461
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
@@ -516,6 +517,8 @@ void cls_motapp::init_webu()
516517

517518
p_webu = nullptr;
518519

520+
webu_list.clear();
521+
519522
if (cfg->webcontrol_port != 0) {
520523
p_webu = new cls_webu(this, cfg);
521524
webu_list.push_back(p_webu);
@@ -542,6 +545,7 @@ void cls_motapp::init_webu()
542545
}
543546

544547
for (indx1=0; indx1<webu_cnt; indx1++) {
548+
webu_list[indx1]->webuindx = indx1;
545549
webu_list[indx1]->startup();
546550
}
547551

@@ -563,7 +567,6 @@ void cls_motapp::init(int p_argc, char *p_argv[])
563567
conf_src = nullptr;
564568
cfg = nullptr;
565569
dbse = nullptr;
566-
allcam = nullptr;
567570
schedule = nullptr;
568571
cam_list.clear();
569572
snd_list.clear();
@@ -597,7 +600,6 @@ void cls_motapp::init(int p_argc, char *p_argv[])
597600
av_init();
598601

599602
dbse = new cls_dbse(this);
600-
allcam = new cls_allcam(this);
601603
schedule = new cls_schedule(this);
602604
init_webu();
603605

@@ -624,28 +626,35 @@ void cls_motapp::deinit()
624626
av_deinit();
625627
pid_remove();
626628

627-
mydelete(dbse);
628-
mydelete(allcam)
629-
mydelete(schedule)
630-
mydelete(conf_src);
631-
mydelete(cfg);
632-
633629
for (indx = 0; indx < cam_cnt;indx++) {
630+
cam_list[indx]->handler_shutdown();
634631
mydelete(cam_list[indx]);
635632
}
636633

637634
for (indx = 0; indx < snd_cnt;indx++) {
635+
snd_list[indx]->handler_shutdown();
638636
mydelete(snd_list[indx]);
639637
}
640638

641639
for (indx = 0; indx < webu_cnt;indx++) {
640+
webu_list[indx]->shutdown();
642641
mydelete(webu_list[indx]);
643642
}
644643

644+
dbse->shutdown();
645+
mydelete(dbse);
646+
647+
schedule->handler_shutdown();
648+
mydelete(schedule)
649+
650+
mydelete(conf_src);
651+
mydelete(cfg);
652+
645653
pthread_mutex_destroy(&mutex_camlst);
646654
pthread_mutex_destroy(&mutex_post);
647655

648656
}
657+
649658
/* Check for whether to add a new cam */
650659
void cls_motapp::camera_add()
651660
{
@@ -664,8 +673,9 @@ void cls_motapp::camera_add()
664673
/* Check for whether to delete a new cam */
665674
void cls_motapp::camera_delete()
666675
{
667-
cls_camera *cam;
668-
int indx, chk_indx;
676+
cls_camera *cam;
677+
cls_webu *webu;
678+
int indx, indx2, chk_indx;
669679

670680
if (cam_delete < 0) {
671681
return;
@@ -692,54 +702,39 @@ void cls_motapp::camera_delete()
692702
return;
693703
}
694704
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "Camera stopped");
695-
696-
/* Determine whether to close a webcontrol port or assign
697-
a different config file for any other cameras using same port*/
698-
if ((cam->cfg->webcontrol_port != cfg->webcontrol_port) &&
699-
(cam->cfg->webcontrol_port != 0)) {
700-
/* Determine if a web control is using this config*/
701-
chk_indx = -1;
702-
for (indx = 0; indx < webu_cnt; indx++) {
703-
if (webu_list[indx]->cfg == cam->cfg) {
704-
chk_indx = indx;
705-
}
706-
}
707-
if (chk_indx != -1 ) {
708-
/*This config IS being used. Either change web control
709-
to use a different cam for the config or shutdown the
710-
webcontrol*/
705+
/* Reverse sequence so we can remove elements*/
706+
for (indx = webu_cnt-1; indx >=0; indx--) {
707+
webu = webu_list[indx];
708+
if ((cam->cfg->webcontrol_port == webu->cfg->webcontrol_port) ||
709+
(webu->cfg == cfg)) {
711710
chk_indx = -1;
712-
for (indx = 0; indx < cam_cnt; indx++) {
713-
if ((cam_list[indx]->cfg->webcontrol_port ==
714-
cam->cfg->webcontrol_port) &&
715-
(indx != cam_delete)) {
716-
chk_indx = indx;
711+
for (indx2 = 0; indx2 < webu->cam_cnt; indx2++) {
712+
if (webu->cam_list[indx2] == cam) {
713+
chk_indx = indx2;
717714
}
718715
}
719-
if (chk_indx == -1 ) {
720-
/* This was only cam on the web port so shut it down*/
721-
for (indx = 0; indx < webu_cnt; indx++) {
722-
if (webu_list[indx]->cfg->webcontrol_port ==
723-
cam->cfg->webcontrol_port) {
724-
chk_indx = indx;
725-
}
726-
}
727-
webu_list[chk_indx]->shutdown();
728-
mydelete(webu_list[chk_indx]);
729-
webu_list.erase(webu_list.begin() + chk_indx);
716+
if (chk_indx != -1) {
717+
pthread_mutex_lock(&webu->mutex_camlst);
718+
mydelete(webu->cam_list[chk_indx]);
719+
webu->cam_list.erase(cam_list.begin() + chk_indx);
720+
webu->cam_cnt--;
721+
pthread_mutex_unlock(&webu->mutex_camlst);
722+
}
723+
if (webu->cam_cnt == 0) {
724+
webu->shutdown();
725+
mydelete(webu);
726+
webu_list.erase(webu_list.begin() + indx);
730727
webu_cnt--;
731728
} else {
732-
/* The web port is being used by different cam*/
733-
/* assign the config for the different cam to the webu*/
734-
/* chk_indx has the index of the different cam*/
735-
for (indx = 0; indx < webu_cnt; indx++) {
736-
if (webu_list[indx]->cfg->webcontrol_port ==
737-
cam->cfg->webcontrol_port) {
738-
webu_list[indx]->cfg = cam_list[indx]->cfg;
739-
webu_list[chk_indx]->shutdown();
740-
webu_list[chk_indx]->startup();
741-
}
729+
if (webu->cfg == cam->cfg) {
730+
/*The cfg used was is the cam being deleted so we need
731+
to pick a different cfg for webcontrol. Just use the
732+
first camera at index 0.*/
733+
webu->cfg = webu->cam_list[0]->cfg;
734+
webu->shutdown();
735+
webu->startup();
742736
}
737+
webu->allcam->reset = true;
743738
}
744739
}
745740
}
@@ -751,7 +746,6 @@ void cls_motapp::camera_delete()
751746
pthread_mutex_unlock(&mutex_camlst);
752747

753748
cam_delete = -1;
754-
allcam->all_sizes.reset = true;
755749

756750
}
757751

src/motion.hpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,6 @@ enum DEVICE_STATUS {
131131
STATUS_OPENED /* Successfully started the device */
132132
};
133133

134-
struct ctx_all_loc {
135-
int row;
136-
int col;
137-
int offset_row;
138-
int offset_col;
139-
int offset_user_row;
140-
int offset_user_col;
141-
int scale;
142-
int xpct_st; /*Starting x location of image on percentage basis*/
143-
int xpct_en; /*Ending x location of image on percentage basis*/
144-
int ypct_st; /*Starting y location of image on percentage basis*/
145-
int ypct_en; /*Ending y location of image on percentage basis*/
146-
};
147-
148-
struct ctx_all_sizes {
149-
int src_w;
150-
int src_h;
151-
int src_sz;
152-
int dst_w;
153-
int dst_h;
154-
int dst_sz;
155-
bool reset;
156-
};
157-
158134
struct ctx_stream_data {
159135
u_char *jpg_data; /* Image compressed as JPG */
160136
int jpg_sz; /* The number of bytes for jpg */
@@ -197,7 +173,6 @@ class cls_motapp {
197173
cls_config *conf_src;
198174
cls_config *cfg;
199175
cls_dbse *dbse;
200-
cls_allcam *allcam;
201176
cls_schedule *schedule;
202177

203178
pthread_mutex_t mutex_camlst; /* Lock the list of cams while adding/removing */

src/schedule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class cls_schedule {
2828
bool handler_running;
2929
pthread_t handler_thread;
3030
void handler();
31+
void handler_shutdown();
3132

3233
bool restart;
3334
bool finish;
@@ -38,7 +39,6 @@ class cls_schedule {
3839
int watchdog;
3940

4041
void handler_startup();
41-
void handler_shutdown();
4242
void timing();
4343
void cleandir_cam(cls_camera *p_cam);
4444
void cleandir_run(cls_camera *p_cam);

0 commit comments

Comments
 (0)