"Fossies" - the Fresh Open Source Software Archive

Member "motion-Release-4.3.0/src/netcam_rtsp.h" (14 Jan 2020, 6103 Bytes) of package /linux/misc/motion-Release-4.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "netcam_rtsp.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef _INCLUDE_NETCAM_RTSP_H
    2 #define _INCLUDE_NETCAM_RTSP_H
    3 
    4 struct context;
    5 struct image_data;
    6 
    7 enum RTSP_STATUS {
    8     RTSP_CONNECTED,      /* The camera is currently connected */
    9     RTSP_READINGIMAGE,   /* Motion is reading a image from camera */
   10     RTSP_NOTCONNECTED,   /* The camera has never connected */
   11     RTSP_RECONNECTING   /* Motion is trying to reconnect to camera */
   12 };
   13 
   14 struct imgsize_context {
   15     int                   width;
   16     int                   height;
   17 };
   18 
   19 #ifdef HAVE_FFMPEG
   20 
   21 #include <libavcodec/avcodec.h>
   22 #include <libavformat/avformat.h>
   23 #include <libavformat/avio.h>
   24 #include <libavutil/avutil.h>
   25 #include <libavutil/imgutils.h>
   26 #include <libswscale/swscale.h>
   27 struct packet_item{
   28     AVPacket                  packet;
   29     int64_t                   idnbr;
   30     int                       iskey;
   31     int                       iswritten;
   32     struct timeval            timestamp_tv;
   33 };
   34 
   35 struct rtsp_context {
   36     AVFormatContext          *format_context;        /* Main format context for the camera */
   37     AVCodecContext           *codec_context;         /* Codec being sent from the camera */
   38     AVFrame                  *frame;                 /* Reusable frame for images from camera */
   39     AVFrame                  *swsframe_in;           /* Used when resizing image sent from camera */
   40     AVFrame                  *swsframe_out;          /* Used when resizing image sent from camera */
   41     struct SwsContext        *swsctx;                /* Context for the resizing of the image */
   42     AVPacket                  packet_recv;           /* The packet that is currently being processed */
   43     AVFormatContext          *transfer_format;       /* Format context just for transferring to pass-through */
   44     struct packet_item       *pktarray;              /* Pointer to array of packets for passthru processing */
   45     int                       pktarray_size;         /* The number of packets in array.  1 based */
   46     int                       pktarray_index;        /* The index to the most current packet in array */
   47     int64_t                   idnbr;                 /* A ID number to track the packet vs image */
   48     AVDictionary             *opts;                  /* AVOptions when opening the format context */
   49     int                       swsframe_size;         /* The size of the image after resizing */
   50     int                       video_stream_index;    /* Stream index associated with video from camera */
   51 
   52     enum RTSP_STATUS          status;                /* Status of whether the camera is connecting, closed, etc*/
   53     struct timeval            interruptstarttime;    /* The time set before calling the av functions */
   54     struct timeval            interruptcurrenttime;  /* Time during the interrupt to determine duration since start*/
   55     int                       interruptduration;      /* Seconds permitted before triggering a interrupt */
   56 
   57     netcam_buff_ptr           img_recv;         /* The image buffer that is currently being processed */
   58     netcam_buff_ptr           img_latest;       /* The most recent image buffer that finished processing */
   59 
   60     int                       interrupted;      /* Boolean for whether interrupt has been tripped */
   61     int                       finish;           /* Boolean for whether we are finishing the application */
   62     int                       high_resolution;  /* Boolean for whether this context is the Norm or High */
   63     int                       handler_finished; /* Boolean for whether the handler is running or not */
   64     int                       first_image;      /* Boolean for whether we have captured the first image */
   65     int                       passthrough;      /* Boolean for whether we are doing pass-through processing */
   66 
   67     char                     *path;             /* The connection string to use for the camera */
   68     char                      service[5];       /* String specifying the type of camera http, rtsp, v4l2 */
   69     const char               *camera_name;      /* The name of the camera as provided in the config file */
   70     char                      cameratype[30];   /* String specifying Normal or High for use in logging */
   71     struct imgsize_context    imgsize;          /* The image size parameters */
   72 
   73     int                       rtsp_uses_tcp;    /* Flag from config for whether to use tcp transport */
   74     int                       v4l2_palette;     /* Palette from config for v4l2 devices */
   75     int                       framerate;        /* Frames per second from configuration file */
   76     int                       reconnect_count;  /* Count of the times reconnection is tried*/
   77     int                       src_fps;          /* The fps provided from source*/
   78 
   79     struct timeval            frame_prev_tm;    /* The time set before calling the av functions */
   80     struct timeval            frame_curr_tm;    /* Time during the interrupt to determine duration since start*/
   81     struct config            *conf;             /* Pointer to conf parms of parent cnt*/
   82     char                      *decoder_nm;      /* User requested decoder */
   83     struct context            *cnt;
   84 
   85     char                      threadname[16];   /* The thread name*/
   86     int                       threadnbr;        /* The thread number */
   87     pthread_t                 thread_id;        /* thread i.d. for a camera-handling thread (if required). */
   88     pthread_mutex_t           mutex;            /* mutex used with conditional waits */
   89     pthread_mutex_t           mutex_transfer;   /* mutex used with transferring stream info for pass-through */
   90     pthread_mutex_t           mutex_pktarray;   /* mutex used with the packet array */
   91 
   92 };
   93 
   94 #else /* Do not have FFmpeg */
   95 
   96 struct rtsp_context {
   97     int                   dummy;
   98     pthread_t             thread_id;
   99     int                   handler_finished;
  100 };
  101 
  102 #endif /* end HAVE_FFMPEG  */
  103 
  104 int netcam_rtsp_setup(struct context *cnt);
  105 int netcam_rtsp_next(struct context *cnt, struct image_data *img_data);
  106 void netcam_rtsp_cleanup(struct context *cnt, int init_retry_flag);
  107 
  108 #endif /* _INCLUDE_NETCAM_RTSP_H */