MCPcopy Create free account
hub / github.com/Motion-Project/motion / event_create_extpipe

Function event_create_extpipe

src/event.c:768–859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

766}
767
768static void event_create_extpipe(struct context *cnt, motion_event eventtype
769 , struct image_data *img_data, char *filename, void *eventdata, struct timeval *tv1)
770{
771 int retcd;
772
773 (void)eventtype;
774 (void)img_data;
775 (void)filename;
776 (void)eventdata;
777
778 if ((cnt->conf.movie_extpipe_use) && (cnt->conf.movie_extpipe)) {
779 char stamp[PATH_MAX] = "";
780 const char *moviepath;
781
782 cnt->movie_last_shot = -1;
783 cnt->movie_fps = cnt->lastrate;
784 cnt->movie_tv.tv_sec = tv1->tv_sec;
785 cnt->movie_tv.tv_usec = tv1->tv_usec;
786
787 MOTION_LOG(INF, TYPE_EVENTS, NO_ERRNO, _("Source FPS %d"), cnt->movie_fps);
788
789 if (cnt->movie_fps < 2) {
790 cnt->movie_fps = 2;
791 }
792
793 /*
794 * conf.mpegpath would normally be defined but if someone deleted it by control interface
795 * it is better to revert to the default than fail
796 */
797 if (cnt->conf.movie_filename) {
798 moviepath = cnt->conf.movie_filename;
799 } else {
800 moviepath = DEF_MOVIEPATH;
801 MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, _("moviepath: %s"), moviepath);
802 }
803
804 mystrftime(cnt, stamp, sizeof(stamp), moviepath, tv1, NULL, 0);
805 snprintf(cnt->extpipefilename, PATH_MAX - 4, "%.*s/%.*s"
806 , (int)(PATH_MAX-5-strlen(stamp))
807 , cnt->conf.target_dir
808 , (int)(PATH_MAX-5-strlen(cnt->conf.target_dir))
809 , stamp);
810
811 if (access(cnt->conf.target_dir, W_OK)!= 0) {
812 /* Permission denied */
813 if (errno == EACCES) {
814 MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
815 ,_("no write access to target directory %s"), cnt->conf.target_dir);
816 return ;
817 /* Path not found - create it */
818 } else if (errno == ENOENT) {
819 MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
820 ,_("path not found, trying to create it %s ..."), cnt->conf.target_dir);
821 if (mycreate_path(cnt->extpipefilename) == -1) {
822 return;
823 }
824 } else {
825 MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO

Callers

nothing calls this directly

Calls 3

mystrftimeFunction · 0.85
mycreate_pathFunction · 0.85
eventFunction · 0.85

Tested by

no test coverage detected