Send Motion-user mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/motion-user
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Motion-user digest..."


Today's Topics:

   1. motion, its webserver & tcp-fastopen (folkert)
   2. Re: texts & external events (folkert)
   3. Re: texts & external events (tosiara)


----------------------------------------------------------------------

Message: 1
Date: Tue, 24 Nov 2015 14:18:43 +0100
From: folkert <[email protected]>
Subject: [Motion-user] motion, its webserver & tcp-fastopen
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi,

This patch enables TCP fastopen for the motion web-server, when
available.
TCP fastopen slightly improves latency for http-requests.

Note that this can also be used when requesting data (being a client so
to say) from a http-server but this requires a bit more code.

Index: webhttpd.c
===================================================================
--- webhttpd.c  (revision 564)
+++ webhttpd.c  (working copy)
@@ -12,6 +12,7 @@
  */
 #include "webhttpd.h"    /* already includes motion.h */
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <stddef.h>
@@ -2393,6 +2394,7 @@
     struct sigaction act;
     char *authentication = NULL;
     char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
+    int qlen = DEF_MAXWEBQUEUE; // or SOMAXCONN
 
     /* Initialize the mutex */
     pthread_mutex_init(&httpd_mutex, NULL);
@@ -2455,6 +2457,12 @@
                 break;
             }
 
+            /* it is totally harmless if this fails. if it succeeds, it may 
slightly improve the
+             * latency of the web-server */
+#ifdef TCP_FASTOPEN
+            (void)setsockopt(sd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen));
+#endif
+
             MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd failed 
bind() interface %s"
                        " / port %s, retrying", hbuf, sbuf);
             close(sd);


Folkert van Heusden

-- 
MultiTail is een flexibele tool voor het volgen van logfiles en
uitvoer van commando's. Filteren, van kleur voorzien, mergen,
'diff-view', etc. http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



------------------------------

Message: 2
Date: Tue, 24 Nov 2015 14:19:45 +0100
From: folkert <[email protected]>
Subject: Re: [Motion-user] texts & external events
To: Motion discussion list <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

That's ok but Kenneth's wiki says the github things are not official?

On Tue, Nov 24, 2015 at 03:16:36PM +0200, tosiara wrote:
> Hi,
> 
> thanks, it is really cool you share your changes!
> However it would be really useful if you could fork motion project on
> Github and create branches for every new feature. When branches are ready -
> issue pull request so maintainer can review your changes
> Use this as base fork: https://github.com/Mr-Dave/motion
> 
> If you are not familiar with Github - feel free to ask questions here on
> mail list or mail me directly
> 
> On Tue, Nov 24, 2015 at 3:09 PM, folkert <[email protected]> wrote:
> 
> > Hi,
> >
> > I've extended my patch a bit. I fixed that the defaults did not work.
> > Todo is adding a "center"-mode and maybe even a mode where one can
> > explicitly set the coordinates.
> >
> > I've also added something new:
> >
> > ext_event_udp_listener_port 1888
> > ext_event_show_time 5
> > ext_event_location upper-left
> >
> > What this does: it listens on an UDP port. Then when it receives a
> > text-packet on that port, it will show that text for 5 seconds on the
> > selected location.
> > Sending such a packet can be something simple as with this
> > python-script:
> >         #! /usr/bin/python
> >
> >         import socket
> >         import sys
> >
> >         UDP_IP = '127.0.0.1'
> >         UDP_PORT = 1888
> >         MESSAGE = sys.argv[1]
> >
> >         sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> >         sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
> >
> > e.g.:
> > ./send.py "some-one is at the front-door!"
> >
> > As you can see I use it myself for my door-bell which is connected to
> > a raspberry pi which sends udp messages to all kinds of devices around
> > the house.
> >
> > Index: conf.c
> > ===================================================================
> > --- conf.c      (revision 564)
> > +++ conf.c      (working copy)
> > @@ -147,9 +147,10 @@
> >      netcam_proxy:                   NULL,
> >      netcam_tolerant_check:          0,
> >      text_changes:                   0,
> > -    text_left:                      NULL,
> > -    text_right:                     DEF_TIMESTAMP,
> > -    text_event:                     DEF_EVENTSTAMP,
> > +    timestamp:                      DEF_TIMESTAMP,
> > +    timestamp_location:             NULL,
> > +    generic_text:                   NULL,
> > +    generic_text_location:          NULL,
> >      text_double:                    0,
> >      despeckle_filter:               NULL,
> >      area_detect:                    NULL,
> > @@ -159,6 +160,9 @@
> >      log_file:                       NULL,
> >      log_level:                      LEVEL_DEFAULT+10,
> >      log_type_str:                   NULL,
> > +    ext_event_udp_listener_port:    0,
> > +    ext_event_show_time:            5,
> > +    ext_event_location:             "upper-left",
> >  };
> >
> >
> > @@ -850,26 +854,46 @@
> >      print_string
> >      },
> >      {
> > -    "text_right",
> > +    "timestamp",
> >      "# Draws the timestamp using same options as C function strftime(3)\n"
> >      "# Default: %Y-%m-%d\\n%T = date in ISO format and time in 24 hour
> > clock\n"
> > -    "# Text is placed in lower right corner",
> > +    "# Text is placed in lower right corner (default, override with
> > timestamp_location)",
> >      0,
> > -    CONF_OFFSET(text_right),
> > +    CONF_OFFSET(timestamp),
> >      copy_string,
> >      print_string
> >      },
> >      {
> > -    "text_left",
> > +    "timestamp_location",
> > +    "# Where to place the timestamp-text. Can be upper-left,
> > upper-right,\n"
> > +    "# bottom-left or bottom-right.\n"
> > +    "# Default: Not defined = bottom-right\n",
> > +    0,
> > +    CONF_OFFSET(timestamp_location),
> > +    copy_string,
> > +    print_string
> > +    },
> > +    {
> > +    "generic_text",
> >      "# Draw a user defined text on the images using same options as C
> > function strftime(3)\n"
> >      "# Default: Not defined = no text\n"
> > -    "# Text is placed in lower left corner",
> > +    "# Text is placed in lower left corner (default, override with
> > generic_text_location)",
> >      0,
> > -    CONF_OFFSET(text_left),
> > +    CONF_OFFSET(generic_text),
> >      copy_string,
> >      print_string
> >      },
> > -     {
> > +    {
> > +    "generic_text_location",
> > +    "# Where to place the generic text. Can be upper-left, upper-right,\n"
> > +    "# ceter, bottom-left or bottom-right.\n"
> > +    "# Default: Not defined = bottom-left\n",
> > +    0,
> > +    CONF_OFFSET(generic_text_location),
> > +    copy_string,
> > +    print_string
> > +    },
> > +    {
> >      "text_changes",
> >      "# Draw the number of changed pixed on the images (default: off)\n"
> >      "# Will normally be set to off except when you setup and adjust the
> > motion settings\n"
> > @@ -901,6 +925,34 @@
> >      print_bool
> >      },
> >      {
> > +    "ext_event_udp_listener_port",
> > +    "# On what UDP port to listen for external (text-)events. They will\n"
> > +    "# be show on the screen for ext_event_show_time seconds at
> > position\n"
> > +    "# ext_event_location. You can send any text to it.\n",
> > +    0,
> > +    CONF_OFFSET(ext_event_udp_listener_port),
> > +    copy_int,
> > +    print_int
> > +    },
> > +    {
> > +    "ext_event_show_time",
> > +    "# How long to show an external event text.\n",
> > +    0,
> > +    CONF_OFFSET(ext_event_show_time),
> > +    copy_int,
> > +    print_int
> > +    },
> > +    {
> > +    "ext_event_location",
> > +    "# Where to place the external event text. Can be upper-left,
> > upper-right,\n"
> > +    "# bottom-left or bottom-right.\n"
> > +    "# Default: Not defined = center\n",
> > +    0,
> > +    CONF_OFFSET(ext_event_location),
> > +    copy_string,
> > +    print_string
> > +    },
> > +    {
> >      "exif_text",
> >      "# Text to include in a JPEG EXIF comment\n"
> >      "# May be any text, including conversion specifiers.\n"
> > @@ -1710,7 +1762,7 @@
> >                  /*
> >                   * If argument is in "" we will strip them off
> >                   * It is important that we can use "" so that we can use
> > -                 * leading spaces in text_left and text_right.
> > +                 * leading spaces in timestamp and generic_text.
> >                   */
> >                  if ((beg[0] == '"' && beg[strlen(beg)-1] == '"') ||
> >                      (beg[0] == '\'' && beg[strlen(beg)-1] == '\'')) {
> > Index: conf.h
> > ===================================================================
> > --- conf.h      (revision 564)
> > +++ conf.h      (working copy)
> > @@ -124,9 +124,11 @@
> >      const char *netcam_proxy;
> >      unsigned int netcam_tolerant_check;
> >      int text_changes;
> > -    const char *text_left;
> > -    const char *text_right;
> > +    const char *timestamp, *timestamp_location;
> > +    const char *generic_text, *generic_text_location;
> >      const char *text_event;
> > +    int ext_event_udp_listener_port, ext_event_show_time;
> > +    const char *ext_event_location;
> >      int text_double;
> >      const char *despeckle_filter;
> >      const char *area_detect;
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c    (revision 564)
> > +++ ffmpeg.c    (working copy)
> > @@ -374,7 +374,7 @@
> >  #endif
> >          /* Manually override the codec id. */
> >          if (of)
> > -            of->video_codec = CODEC_ID_MSMPEG4V2;
> > +            of->video_codec = AV_CODEC_ID_MSMPEG4V2;
> >
> >      } else if (strcmp(codec, "swf") == 0) {
> >          ext = ".swf";
> > @@ -390,7 +390,7 @@
> >  #else
> >          of = av_guess_format("flv", NULL, NULL);
> >  #endif
> > -        of->video_codec = CODEC_ID_FLV1;
> > +        of->video_codec = AV_CODEC_ID_FLV1;
> >      } else if (strcmp(codec, "ffv1") == 0) {
> >          ext = ".avi";
> >  #ifdef GUESS_NO_DEPRECATED
> > @@ -403,7 +403,7 @@
> >           * Requires strict_std_compliance to be <= -2
> >           */
> >          if (of)
> > -            of->video_codec = CODEC_ID_FFV1;
> > +            of->video_codec = AV_CODEC_ID_FFV1;
> >
> >      } else if (strcmp(codec, "mov") == 0) {
> >          ext = ".mov";
> > @@ -499,7 +499,7 @@
> >
> >      /* Create a new video stream and initialize the codecs. */
> >      ffmpeg->video_st = NULL;
> > -    if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) {
> > +    if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) {
> >  #if defined FF_API_NEW_AVIO
> >          ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec
> > */);
> >  #else
> > @@ -526,7 +526,7 @@
> >  #else
> >      c->codec_type = AVMEDIA_TYPE_VIDEO;
> >  #endif
> > -    is_mpeg1      = c->codec_id == CODEC_ID_MPEG1VIDEO;
> > +    is_mpeg1      = c->codec_id == AV_CODEC_ID_MPEG1VIDEO;
> >
> >      if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
> >          c->strict_std_compliance = -2;
> > Index: motion-dist.conf.in
> > ===================================================================
> > --- motion-dist.conf.in (revision 564)
> > +++ motion-dist.conf.in (working copy)
> > @@ -369,14 +369,24 @@
> >
> >  # Draws the timestamp using same options as C function strftime(3)
> >  # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
> > -# Text is placed in lower right corner
> > -text_right %Y-%m-%d\n%T-%q
> > +# Text is placed default in lower right corner. Change this with
> > timestamp_location
> > +timestamp %Y-%m-%d\n%T-%q
> >
> > +# Select where to place the "timestamp".
> > +# Default: Not defined = bottom-right
> > +# Can be bottom-left, bottom-right, upper-left, upper-right
> > +; timestamp bottom-right
> > +
> >  # Draw a user defined text on the images using same options as C function
> > strftime(3)
> >  # Default: Not defined = no text
> > -# Text is placed in lower left corner
> > -; text_left CAMERA %t
> > +# Text is placed default in lower left corner. Change this with
> > generic_text_location
> > +; generic_text CAMERA %t
> >
> > +# Select where to place the "generic_text".
> > +# Default: Not defined = bottom-left
> > +# Can be bottom-left, bottom-right, upper-left, upper-right
> > +; generic_text_location bottom-left
> > +
> >  # Draw the number of changed pixed on the images (default: off)
> >  # Will normally be set to off except when you setup and adjust the motion
> > settings
> >  # Text is placed in upper right corner
> > Index: motion.c
> > ===================================================================
> > --- motion.c    (revision 564)
> > +++ motion.c    (working copy)
> > @@ -26,6 +26,10 @@
> >  static int motion_init(struct context *cnt);
> >  static void motion_cleanup(struct context *cnt);
> >
> > +pthread_t ext_event_th;
> > +pthread_mutex_t ext_event_lock = PTHREAD_MUTEX_INITIALIZER;
> > +const char *ext_event_text = NULL;
> > +time_t ext_event_shown_since = 0;
> >
> >  /**
> >   * tls_key_threadnr
> > @@ -73,6 +77,59 @@
> >   */
> >  unsigned int restart = 0;
> >
> > +static void * ext_event_thread(void *p)
> > +{
> > +    struct context *cnt = (struct context *)p;
> > +    struct sockaddr_in name;
> > +    int set = 1, fd = -1;
> > +
> > +    if (cnt->conf.ext_event_udp_listener_port <= 0)
> > +        return NULL;
> > +
> > +    fd = socket(PF_INET, SOCK_DGRAM, 0);
> > +    if (fd == -1)
> > +    {
> > +        fprintf(stderr, "ext event UDP listener: failed creating socket:
> > %s\n", strerror(errno));
> > +        return NULL;
> > +    }
> > +
> > +    (void)setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof set);
> > +
> > +    name.sin_family = AF_INET;
> > +    name.sin_port = htons(cnt->conf.ext_event_udp_listener_port);
> > +    name.sin_addr.s_addr = htonl(INADDR_ANY);
> > +    if (bind(fd, (struct sockaddr *)&name, sizeof(name)) == -1)
> > +    {
> > +        fprintf(stderr, "ext event UDP listener: failed binding socket:
> > %s\n", strerror(errno));
> > +        close(fd);
> > +        return NULL;
> > +    }
> > +
> > +    while (!cnt->finish || cnt->makemovie)
> > +    {
> > +        char buffer[1024];
> > +        int rc = recv(fd, buffer, sizeof buffer - 1, 0);
> > +
> > +        if (rc == -1)
> > +            break;
> > +
> > +        if (rc == 0)
> > +            continue;
> > +
> > +        buffer[rc] = 0x00;
> > +
> > +        pthread_mutex_lock(&ext_event_lock);
> > +        free((void *)ext_event_text);
> > +        ext_event_text = strdup(buffer);
> > +        ext_event_shown_since = time(NULL);
> > +        pthread_mutex_unlock(&ext_event_lock);
> > +    }
> > +
> > +    close(fd);
> > +
> > +    return NULL;
> > +}
> > +
> >  /**
> >   * image_ring_resize
> >   *
> > @@ -942,6 +999,8 @@
> >      /* 2 sec startup delay so FPS is calculated correct */
> >      cnt->startup_frames = cnt->conf.frame_limit * 2;
> >
> > +    pthread_create(&ext_event_th, NULL, ext_event_thread, cnt);
> > +
> >      return 0;
> >  }
> >
> > @@ -1069,6 +1128,26 @@
> >      }
> >  }
> >
> > +void format_and_draw_text_at_location(struct context *const cnt, const
> > char *const text, const char *const location, const char *const
> > default_location)
> > +{
> > +    const char *const use_location = location ? location :
> > default_location;
> > +    int size_mul = cnt->conf.text_double ? 2 : 1;
> > +    char tmp[PATH_MAX];
> > +    mystrftime(cnt, tmp, sizeof(tmp), text,
> > &cnt->current_image->timestamp_tm, NULL, 0);
> > +
> > +    if (strcasecmp(use_location, "bottom-left") == 0)
> > +        draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 *
> > size_mul, cnt->imgs.width, tmp, cnt->conf.text_double);
> > +
> > +    else if (strcasecmp(use_location, "bottom-right") == 0)
> > +        draw_text(cnt->current_image->image, cnt->imgs.width - 10,
> > cnt->imgs.height - 10 * size_mul, cnt->imgs.width, tmp,
> > cnt->conf.text_double);
> > +
> > +    else if (strcasecmp(use_location, "upper-left") == 0)
> > +        draw_text(cnt->current_image->image, 10, 10, cnt->imgs.width,
> > tmp, cnt->conf.text_double);
> > +
> > +    else if (strcasecmp(use_location, "upper-right") == 0)
> > +        draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10,
> > cnt->imgs.width, tmp, cnt->conf.text_double);
> > +}
> > +
> >  /**
> >   * motion_loop
> >   *
> > @@ -1721,26 +1800,31 @@
> >                            cnt->imgs.width, tmp, cnt->conf.text_double);
> >              }
> >
> > -            /* Add text in lower left corner of the pictures */
> > -            if (cnt->conf.text_left) {
> > -                char tmp[PATH_MAX];
> > -                mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left,
> > -                           &cnt->current_image->timestamp_tm, NULL, 0);
> > -                draw_text(cnt->current_image->image, 10, cnt->imgs.height
> > - 10 * text_size_factor,
> > -                          cnt->imgs.width, tmp, cnt->conf.text_double);
> > -            }
> > +            /* Add generic text */
> > +            if (cnt->conf.generic_text)
> > +               format_and_draw_text_at_location(cnt,
> > cnt->conf.generic_text, cnt->conf.generic_text_location, "bottom-left");
> >
> > -            /* Add text in lower right corner of the pictures */
> > -            if (cnt->conf.text_right) {
> > -                char tmp[PATH_MAX];
> > -                mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right,
> > -                           &cnt->current_image->timestamp_tm, NULL, 0);
> > -                draw_text(cnt->current_image->image, cnt->imgs.width - 10,
> > -                          cnt->imgs.height - 10 * text_size_factor,
> > -                          cnt->imgs.width, tmp, cnt->conf.text_double);
> > +            /* Add timestamp */
> > +            if (cnt->conf.timestamp)
> > +               format_and_draw_text_at_location(cnt, cnt->conf.timestamp,
> > cnt->conf.timestamp_location, "bottom-right");
> > +
> > +            if (cnt->conf.ext_event_udp_listener_port > 0)
> > +            {
> > +                time_t now = time(NULL);
> > +
> > +                pthread_mutex_lock(&ext_event_lock);
> > +
> > +                if (now - ext_event_shown_since <=
> > cnt->conf.ext_event_show_time && ext_event_text != NULL)
> > +                       format_and_draw_text_at_location(cnt,
> > ext_event_text, cnt->conf.ext_event_location, "upper-left");
> > +                else
> > +                {
> > +                    free((void *)ext_event_text);
> > +                    ext_event_text = NULL;
> > +                }
> > +
> > +                pthread_mutex_unlock(&ext_event_lock);
> >              }
> >
> > -
> >          /***** MOTION LOOP - ACTIONS AND EVENT CONTROL SECTION *****/
> >
> >              if (cnt->current_image->diffs > cnt->threshold) {
> > Index: motion.h
> > ===================================================================
> > --- motion.h    (revision 564)
> > +++ motion.h    (working copy)
> > @@ -50,6 +50,8 @@
> >  #include <sys/param.h>
> >  #include <stdint.h>
> >
> > +#include <netinet/in.h>
> > +
> >  #define _LINUX_TIME_H 1
> >  #if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) &&
> > (!defined(BSD))
> >  #include <linux/videodev.h>
> >
> >
> > Folkert van Heusden
> >
> > --
> > To MultiTail einai ena polymorfiko ergaleio gia ta logfiles kai tin
> > eksodo twn entolwn. Prosferei: filtrarisma, xrwmatismo, sygxwneysi,
> > diaforetikes provoles. http://www.vanheusden.com/multitail/
> > ----------------------------------------------------------------------
> > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
> >
> >
> > ------------------------------------------------------------------------------
> > Go from Idea to Many App Stores Faster with Intel(R) XDK
> > Give your users amazing mobile app experiences with Intel(R) XDK.
> > Use one codebase in this all-in-one HTML5 development environment.
> > Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> > OSs.
> > http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> > _______________________________________________
> > Motion-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/motion-user
> > http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome
> >

> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140

> _______________________________________________
> Motion-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/motion-user
> http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome



Folkert van Heusden

-- 
Feeling generous? -> http://www.vanheusden.com/wishlist.php
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



------------------------------

Message: 3
Date: Tue, 24 Nov 2015 15:23:21 +0200
From: tosiara <[email protected]>
Subject: Re: [Motion-user] texts & external events
To: Motion discussion list <[email protected]>
Message-ID:
        <cachtdwsxmxxtzr2b0tclzgys5h4rtulnwxzrqvhwa8uib3-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Yes, Github repo is not an official one. But it is actively developed and
maintained which is more important in the world of open source

On Tue, Nov 24, 2015 at 3:19 PM, folkert <[email protected]> wrote:

> That's ok but Kenneth's wiki says the github things are not official?
>
> On Tue, Nov 24, 2015 at 03:16:36PM +0200, tosiara wrote:
> > Hi,
> >
> > thanks, it is really cool you share your changes!
> > However it would be really useful if you could fork motion project on
> > Github and create branches for every new feature. When branches are
> ready -
> > issue pull request so maintainer can review your changes
> > Use this as base fork: https://github.com/Mr-Dave/motion
> >
> > If you are not familiar with Github - feel free to ask questions here on
> > mail list or mail me directly
> >
> > On Tue, Nov 24, 2015 at 3:09 PM, folkert <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > I've extended my patch a bit. I fixed that the defaults did not work.
> > > Todo is adding a "center"-mode and maybe even a mode where one can
> > > explicitly set the coordinates.
> > >
> > > I've also added something new:
> > >
> > > ext_event_udp_listener_port 1888
> > > ext_event_show_time 5
> > > ext_event_location upper-left
> > >
> > > What this does: it listens on an UDP port. Then when it receives a
> > > text-packet on that port, it will show that text for 5 seconds on the
> > > selected location.
> > > Sending such a packet can be something simple as with this
> > > python-script:
> > >         #! /usr/bin/python
> > >
> > >         import socket
> > >         import sys
> > >
> > >         UDP_IP = '127.0.0.1'
> > >         UDP_PORT = 1888
> > >         MESSAGE = sys.argv[1]
> > >
> > >         sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> > >         sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
> > >
> > > e.g.:
> > > ./send.py "some-one is at the front-door!"
> > >
> > > As you can see I use it myself for my door-bell which is connected to
> > > a raspberry pi which sends udp messages to all kinds of devices around
> > > the house.
> > >
> > > Index: conf.c
> > > ===================================================================
> > > --- conf.c      (revision 564)
> > > +++ conf.c      (working copy)
> > > @@ -147,9 +147,10 @@
> > >      netcam_proxy:                   NULL,
> > >      netcam_tolerant_check:          0,
> > >      text_changes:                   0,
> > > -    text_left:                      NULL,
> > > -    text_right:                     DEF_TIMESTAMP,
> > > -    text_event:                     DEF_EVENTSTAMP,
> > > +    timestamp:                      DEF_TIMESTAMP,
> > > +    timestamp_location:             NULL,
> > > +    generic_text:                   NULL,
> > > +    generic_text_location:          NULL,
> > >      text_double:                    0,
> > >      despeckle_filter:               NULL,
> > >      area_detect:                    NULL,
> > > @@ -159,6 +160,9 @@
> > >      log_file:                       NULL,
> > >      log_level:                      LEVEL_DEFAULT+10,
> > >      log_type_str:                   NULL,
> > > +    ext_event_udp_listener_port:    0,
> > > +    ext_event_show_time:            5,
> > > +    ext_event_location:             "upper-left",
> > >  };
> > >
> > >
> > > @@ -850,26 +854,46 @@
> > >      print_string
> > >      },
> > >      {
> > > -    "text_right",
> > > +    "timestamp",
> > >      "# Draws the timestamp using same options as C function
> strftime(3)\n"
> > >      "# Default: %Y-%m-%d\\n%T = date in ISO format and time in 24 hour
> > > clock\n"
> > > -    "# Text is placed in lower right corner",
> > > +    "# Text is placed in lower right corner (default, override with
> > > timestamp_location)",
> > >      0,
> > > -    CONF_OFFSET(text_right),
> > > +    CONF_OFFSET(timestamp),
> > >      copy_string,
> > >      print_string
> > >      },
> > >      {
> > > -    "text_left",
> > > +    "timestamp_location",
> > > +    "# Where to place the timestamp-text. Can be upper-left,
> > > upper-right,\n"
> > > +    "# bottom-left or bottom-right.\n"
> > > +    "# Default: Not defined = bottom-right\n",
> > > +    0,
> > > +    CONF_OFFSET(timestamp_location),
> > > +    copy_string,
> > > +    print_string
> > > +    },
> > > +    {
> > > +    "generic_text",
> > >      "# Draw a user defined text on the images using same options as C
> > > function strftime(3)\n"
> > >      "# Default: Not defined = no text\n"
> > > -    "# Text is placed in lower left corner",
> > > +    "# Text is placed in lower left corner (default, override with
> > > generic_text_location)",
> > >      0,
> > > -    CONF_OFFSET(text_left),
> > > +    CONF_OFFSET(generic_text),
> > >      copy_string,
> > >      print_string
> > >      },
> > > -     {
> > > +    {
> > > +    "generic_text_location",
> > > +    "# Where to place the generic text. Can be upper-left,
> upper-right,\n"
> > > +    "# ceter, bottom-left or bottom-right.\n"
> > > +    "# Default: Not defined = bottom-left\n",
> > > +    0,
> > > +    CONF_OFFSET(generic_text_location),
> > > +    copy_string,
> > > +    print_string
> > > +    },
> > > +    {
> > >      "text_changes",
> > >      "# Draw the number of changed pixed on the images (default:
> off)\n"
> > >      "# Will normally be set to off except when you setup and adjust
> the
> > > motion settings\n"
> > > @@ -901,6 +925,34 @@
> > >      print_bool
> > >      },
> > >      {
> > > +    "ext_event_udp_listener_port",
> > > +    "# On what UDP port to listen for external (text-)events. They
> will\n"
> > > +    "# be show on the screen for ext_event_show_time seconds at
> > > position\n"
> > > +    "# ext_event_location. You can send any text to it.\n",
> > > +    0,
> > > +    CONF_OFFSET(ext_event_udp_listener_port),
> > > +    copy_int,
> > > +    print_int
> > > +    },
> > > +    {
> > > +    "ext_event_show_time",
> > > +    "# How long to show an external event text.\n",
> > > +    0,
> > > +    CONF_OFFSET(ext_event_show_time),
> > > +    copy_int,
> > > +    print_int
> > > +    },
> > > +    {
> > > +    "ext_event_location",
> > > +    "# Where to place the external event text. Can be upper-left,
> > > upper-right,\n"
> > > +    "# bottom-left or bottom-right.\n"
> > > +    "# Default: Not defined = center\n",
> > > +    0,
> > > +    CONF_OFFSET(ext_event_location),
> > > +    copy_string,
> > > +    print_string
> > > +    },
> > > +    {
> > >      "exif_text",
> > >      "# Text to include in a JPEG EXIF comment\n"
> > >      "# May be any text, including conversion specifiers.\n"
> > > @@ -1710,7 +1762,7 @@
> > >                  /*
> > >                   * If argument is in "" we will strip them off
> > >                   * It is important that we can use "" so that we can
> use
> > > -                 * leading spaces in text_left and text_right.
> > > +                 * leading spaces in timestamp and generic_text.
> > >                   */
> > >                  if ((beg[0] == '"' && beg[strlen(beg)-1] == '"') ||
> > >                      (beg[0] == '\'' && beg[strlen(beg)-1] == '\'')) {
> > > Index: conf.h
> > > ===================================================================
> > > --- conf.h      (revision 564)
> > > +++ conf.h      (working copy)
> > > @@ -124,9 +124,11 @@
> > >      const char *netcam_proxy;
> > >      unsigned int netcam_tolerant_check;
> > >      int text_changes;
> > > -    const char *text_left;
> > > -    const char *text_right;
> > > +    const char *timestamp, *timestamp_location;
> > > +    const char *generic_text, *generic_text_location;
> > >      const char *text_event;
> > > +    int ext_event_udp_listener_port, ext_event_show_time;
> > > +    const char *ext_event_location;
> > >      int text_double;
> > >      const char *despeckle_filter;
> > >      const char *area_detect;
> > > Index: ffmpeg.c
> > > ===================================================================
> > > --- ffmpeg.c    (revision 564)
> > > +++ ffmpeg.c    (working copy)
> > > @@ -374,7 +374,7 @@
> > >  #endif
> > >          /* Manually override the codec id. */
> > >          if (of)
> > > -            of->video_codec = CODEC_ID_MSMPEG4V2;
> > > +            of->video_codec = AV_CODEC_ID_MSMPEG4V2;
> > >
> > >      } else if (strcmp(codec, "swf") == 0) {
> > >          ext = ".swf";
> > > @@ -390,7 +390,7 @@
> > >  #else
> > >          of = av_guess_format("flv", NULL, NULL);
> > >  #endif
> > > -        of->video_codec = CODEC_ID_FLV1;
> > > +        of->video_codec = AV_CODEC_ID_FLV1;
> > >      } else if (strcmp(codec, "ffv1") == 0) {
> > >          ext = ".avi";
> > >  #ifdef GUESS_NO_DEPRECATED
> > > @@ -403,7 +403,7 @@
> > >           * Requires strict_std_compliance to be <= -2
> > >           */
> > >          if (of)
> > > -            of->video_codec = CODEC_ID_FFV1;
> > > +            of->video_codec = AV_CODEC_ID_FFV1;
> > >
> > >      } else if (strcmp(codec, "mov") == 0) {
> > >          ext = ".mov";
> > > @@ -499,7 +499,7 @@
> > >
> > >      /* Create a new video stream and initialize the codecs. */
> > >      ffmpeg->video_st = NULL;
> > > -    if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) {
> > > +    if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) {
> > >  #if defined FF_API_NEW_AVIO
> > >          ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /*
> Codec
> > > */);
> > >  #else
> > > @@ -526,7 +526,7 @@
> > >  #else
> > >      c->codec_type = AVMEDIA_TYPE_VIDEO;
> > >  #endif
> > > -    is_mpeg1      = c->codec_id == CODEC_ID_MPEG1VIDEO;
> > > +    is_mpeg1      = c->codec_id == AV_CODEC_ID_MPEG1VIDEO;
> > >
> > >      if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
> > >          c->strict_std_compliance = -2;
> > > Index: motion-dist.conf.in
> > > ===================================================================
> > > --- motion-dist.conf.in (revision 564)
> > > +++ motion-dist.conf.in (working copy)
> > > @@ -369,14 +369,24 @@
> > >
> > >  # Draws the timestamp using same options as C function strftime(3)
> > >  # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
> > > -# Text is placed in lower right corner
> > > -text_right %Y-%m-%d\n%T-%q
> > > +# Text is placed default in lower right corner. Change this with
> > > timestamp_location
> > > +timestamp %Y-%m-%d\n%T-%q
> > >
> > > +# Select where to place the "timestamp".
> > > +# Default: Not defined = bottom-right
> > > +# Can be bottom-left, bottom-right, upper-left, upper-right
> > > +; timestamp bottom-right
> > > +
> > >  # Draw a user defined text on the images using same options as C
> function
> > > strftime(3)
> > >  # Default: Not defined = no text
> > > -# Text is placed in lower left corner
> > > -; text_left CAMERA %t
> > > +# Text is placed default in lower left corner. Change this with
> > > generic_text_location
> > > +; generic_text CAMERA %t
> > >
> > > +# Select where to place the "generic_text".
> > > +# Default: Not defined = bottom-left
> > > +# Can be bottom-left, bottom-right, upper-left, upper-right
> > > +; generic_text_location bottom-left
> > > +
> > >  # Draw the number of changed pixed on the images (default: off)
> > >  # Will normally be set to off except when you setup and adjust the
> motion
> > > settings
> > >  # Text is placed in upper right corner
> > > Index: motion.c
> > > ===================================================================
> > > --- motion.c    (revision 564)
> > > +++ motion.c    (working copy)
> > > @@ -26,6 +26,10 @@
> > >  static int motion_init(struct context *cnt);
> > >  static void motion_cleanup(struct context *cnt);
> > >
> > > +pthread_t ext_event_th;
> > > +pthread_mutex_t ext_event_lock = PTHREAD_MUTEX_INITIALIZER;
> > > +const char *ext_event_text = NULL;
> > > +time_t ext_event_shown_since = 0;
> > >
> > >  /**
> > >   * tls_key_threadnr
> > > @@ -73,6 +77,59 @@
> > >   */
> > >  unsigned int restart = 0;
> > >
> > > +static void * ext_event_thread(void *p)
> > > +{
> > > +    struct context *cnt = (struct context *)p;
> > > +    struct sockaddr_in name;
> > > +    int set = 1, fd = -1;
> > > +
> > > +    if (cnt->conf.ext_event_udp_listener_port <= 0)
> > > +        return NULL;
> > > +
> > > +    fd = socket(PF_INET, SOCK_DGRAM, 0);
> > > +    if (fd == -1)
> > > +    {
> > > +        fprintf(stderr, "ext event UDP listener: failed creating
> socket:
> > > %s\n", strerror(errno));
> > > +        return NULL;
> > > +    }
> > > +
> > > +    (void)setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof set);
> > > +
> > > +    name.sin_family = AF_INET;
> > > +    name.sin_port = htons(cnt->conf.ext_event_udp_listener_port);
> > > +    name.sin_addr.s_addr = htonl(INADDR_ANY);
> > > +    if (bind(fd, (struct sockaddr *)&name, sizeof(name)) == -1)
> > > +    {
> > > +        fprintf(stderr, "ext event UDP listener: failed binding
> socket:
> > > %s\n", strerror(errno));
> > > +        close(fd);
> > > +        return NULL;
> > > +    }
> > > +
> > > +    while (!cnt->finish || cnt->makemovie)
> > > +    {
> > > +        char buffer[1024];
> > > +        int rc = recv(fd, buffer, sizeof buffer - 1, 0);
> > > +
> > > +        if (rc == -1)
> > > +            break;
> > > +
> > > +        if (rc == 0)
> > > +            continue;
> > > +
> > > +        buffer[rc] = 0x00;
> > > +
> > > +        pthread_mutex_lock(&ext_event_lock);
> > > +        free((void *)ext_event_text);
> > > +        ext_event_text = strdup(buffer);
> > > +        ext_event_shown_since = time(NULL);
> > > +        pthread_mutex_unlock(&ext_event_lock);
> > > +    }
> > > +
> > > +    close(fd);
> > > +
> > > +    return NULL;
> > > +}
> > > +
> > >  /**
> > >   * image_ring_resize
> > >   *
> > > @@ -942,6 +999,8 @@
> > >      /* 2 sec startup delay so FPS is calculated correct */
> > >      cnt->startup_frames = cnt->conf.frame_limit * 2;
> > >
> > > +    pthread_create(&ext_event_th, NULL, ext_event_thread, cnt);
> > > +
> > >      return 0;
> > >  }
> > >
> > > @@ -1069,6 +1128,26 @@
> > >      }
> > >  }
> > >
> > > +void format_and_draw_text_at_location(struct context *const cnt, const
> > > char *const text, const char *const location, const char *const
> > > default_location)
> > > +{
> > > +    const char *const use_location = location ? location :
> > > default_location;
> > > +    int size_mul = cnt->conf.text_double ? 2 : 1;
> > > +    char tmp[PATH_MAX];
> > > +    mystrftime(cnt, tmp, sizeof(tmp), text,
> > > &cnt->current_image->timestamp_tm, NULL, 0);
> > > +
> > > +    if (strcasecmp(use_location, "bottom-left") == 0)
> > > +        draw_text(cnt->current_image->image, 10, cnt->imgs.height -
> 10 *
> > > size_mul, cnt->imgs.width, tmp, cnt->conf.text_double);
> > > +
> > > +    else if (strcasecmp(use_location, "bottom-right") == 0)
> > > +        draw_text(cnt->current_image->image, cnt->imgs.width - 10,
> > > cnt->imgs.height - 10 * size_mul, cnt->imgs.width, tmp,
> > > cnt->conf.text_double);
> > > +
> > > +    else if (strcasecmp(use_location, "upper-left") == 0)
> > > +        draw_text(cnt->current_image->image, 10, 10, cnt->imgs.width,
> > > tmp, cnt->conf.text_double);
> > > +
> > > +    else if (strcasecmp(use_location, "upper-right") == 0)
> > > +        draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10,
> > > cnt->imgs.width, tmp, cnt->conf.text_double);
> > > +}
> > > +
> > >  /**
> > >   * motion_loop
> > >   *
> > > @@ -1721,26 +1800,31 @@
> > >                            cnt->imgs.width, tmp,
> cnt->conf.text_double);
> > >              }
> > >
> > > -            /* Add text in lower left corner of the pictures */
> > > -            if (cnt->conf.text_left) {
> > > -                char tmp[PATH_MAX];
> > > -                mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left,
> > > -                           &cnt->current_image->timestamp_tm, NULL,
> 0);
> > > -                draw_text(cnt->current_image->image, 10,
> cnt->imgs.height
> > > - 10 * text_size_factor,
> > > -                          cnt->imgs.width, tmp,
> cnt->conf.text_double);
> > > -            }
> > > +            /* Add generic text */
> > > +            if (cnt->conf.generic_text)
> > > +               format_and_draw_text_at_location(cnt,
> > > cnt->conf.generic_text, cnt->conf.generic_text_location,
> "bottom-left");
> > >
> > > -            /* Add text in lower right corner of the pictures */
> > > -            if (cnt->conf.text_right) {
> > > -                char tmp[PATH_MAX];
> > > -                mystrftime(cnt, tmp, sizeof(tmp),
> cnt->conf.text_right,
> > > -                           &cnt->current_image->timestamp_tm, NULL,
> 0);
> > > -                draw_text(cnt->current_image->image, cnt->imgs.width
> - 10,
> > > -                          cnt->imgs.height - 10 * text_size_factor,
> > > -                          cnt->imgs.width, tmp,
> cnt->conf.text_double);
> > > +            /* Add timestamp */
> > > +            if (cnt->conf.timestamp)
> > > +               format_and_draw_text_at_location(cnt,
> cnt->conf.timestamp,
> > > cnt->conf.timestamp_location, "bottom-right");
> > > +
> > > +            if (cnt->conf.ext_event_udp_listener_port > 0)
> > > +            {
> > > +                time_t now = time(NULL);
> > > +
> > > +                pthread_mutex_lock(&ext_event_lock);
> > > +
> > > +                if (now - ext_event_shown_since <=
> > > cnt->conf.ext_event_show_time && ext_event_text != NULL)
> > > +                       format_and_draw_text_at_location(cnt,
> > > ext_event_text, cnt->conf.ext_event_location, "upper-left");
> > > +                else
> > > +                {
> > > +                    free((void *)ext_event_text);
> > > +                    ext_event_text = NULL;
> > > +                }
> > > +
> > > +                pthread_mutex_unlock(&ext_event_lock);
> > >              }
> > >
> > > -
> > >          /***** MOTION LOOP - ACTIONS AND EVENT CONTROL SECTION *****/
> > >
> > >              if (cnt->current_image->diffs > cnt->threshold) {
> > > Index: motion.h
> > > ===================================================================
> > > --- motion.h    (revision 564)
> > > +++ motion.h    (working copy)
> > > @@ -50,6 +50,8 @@
> > >  #include <sys/param.h>
> > >  #include <stdint.h>
> > >
> > > +#include <netinet/in.h>
> > > +
> > >  #define _LINUX_TIME_H 1
> > >  #if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) &&
> > > (!defined(BSD))
> > >  #include <linux/videodev.h>
> > >
> > >
> > > Folkert van Heusden
> > >
> > > --
> > > To MultiTail einai ena polymorfiko ergaleio gia ta logfiles kai tin
> > > eksodo twn entolwn. Prosferei: filtrarisma, xrwmatismo, sygxwneysi,
> > > diaforetikes provoles. http://www.vanheusden.com/multitail/
> > > ----------------------------------------------------------------------
> > > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
> > >
> > >
> > >
> ------------------------------------------------------------------------------
> > > Go from Idea to Many App Stores Faster with Intel(R) XDK
> > > Give your users amazing mobile app experiences with Intel(R) XDK.
> > > Use one codebase in this all-in-one HTML5 development environment.
> > > Design, debug & build mobile apps & 2D/3D high-impact games for
> multiple
> > > OSs.
> > > http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> > > _______________________________________________
> > > Motion-user mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/motion-user
> > > http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome
> > >
>
> >
> ------------------------------------------------------------------------------
> > Go from Idea to Many App Stores Faster with Intel(R) XDK
> > Give your users amazing mobile app experiences with Intel(R) XDK.
> > Use one codebase in this all-in-one HTML5 development environment.
> > Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> > http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>
> > _______________________________________________
> > Motion-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/motion-user
> > http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome
>
>
>
> Folkert van Heusden
>
> --
> Feeling generous? -> http://www.vanheusden.com/wishlist.php
> ----------------------------------------------------------------------
> Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
>
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> Motion-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/motion-user
> http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140

------------------------------

_______________________________________________
Motion-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/motion-user


End of Motion-user Digest, Vol 114, Issue 6
*******************************************

Reply via email to