"Fossies" - the Fresh Open Source Software Archive

Member "motion-Release-4.3.0/src/ffmpeg.h" (14 Jan 2020, 3553 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 "ffmpeg.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef _INCLUDE_FFMPEG_H_
    2 #define _INCLUDE_FFMPEG_H_
    3 
    4 #include <stdio.h>
    5 #include <stdarg.h>
    6 #include <sys/time.h>
    7 #include <stdint.h>
    8 #include "config.h"
    9 struct image_data; /* forward declare for functions */
   10 struct rtsp_context;
   11 
   12 enum TIMELAPSE_TYPE {
   13     TIMELAPSE_NONE,         /* No timelapse, regular processing */
   14     TIMELAPSE_APPEND,       /* Use append version of timelapse */
   15     TIMELAPSE_NEW           /* Use create new file version of timelapse */
   16 };
   17 
   18 /* Enumeration of the user requested codecs that need special handling */
   19 enum USER_CODEC {
   20     USER_CODEC_V4L2M2M,    /* Requested codec for movie is h264_v4l2m2m */
   21     USER_CODEC_H264OMX,    /* Requested h264_omx */
   22     USER_CODEC_MPEG4OMX,   /* Requested mpeg4_omx */
   23     USER_CODEC_DEFAULT     /* All other default codecs */
   24 };
   25 
   26 #ifdef HAVE_FFMPEG
   27 
   28 #include <errno.h>
   29 #include <libavformat/avformat.h>
   30 #include <libavutil/imgutils.h>
   31 #include <libavutil/mathematics.h>
   32 #include <libavdevice/avdevice.h>
   33 
   34 #if (LIBAVFORMAT_VERSION_MAJOR >= 56)
   35 #define MY_PIX_FMT_YUV420P   AV_PIX_FMT_YUV420P
   36 #define MY_PIX_FMT_YUVJ420P  AV_PIX_FMT_YUVJ420P
   37 #define MyPixelFormat AVPixelFormat
   38 #else  //Old ffmpeg pixel formats
   39 #define MY_PIX_FMT_YUV420P   PIX_FMT_YUV420P
   40 #define MY_PIX_FMT_YUVJ420P  PIX_FMT_YUVJ420P
   41 #define MyPixelFormat PixelFormat
   42 #endif  //Libavformat >= 56
   43 
   44 #endif // HAVE_FFMPEG
   45 
   46 #ifdef HAVE_FFMPEG
   47 struct ffmpeg {
   48     AVFormatContext *oc;
   49     AVStream *video_st;
   50     AVCodecContext *ctx_codec;
   51     AVCodec *codec;
   52     AVPacket pkt;
   53     AVFrame *picture;       /* contains default image pointers */
   54     AVDictionary *opts;
   55     struct rtsp_context *rtsp_data;
   56     int width;
   57     int height;
   58     enum TIMELAPSE_TYPE tlapse;
   59     int fps;
   60     int bps;
   61     char *filename;
   62     int quality;
   63     const char *codec_name;
   64     int64_t last_pts;
   65     int64_t base_pts;
   66     int test_mode;
   67     int gop_cnt;
   68     struct timeval start_time;
   69     int            high_resolution;
   70     int            motion_images;
   71     int            passthrough;
   72     enum USER_CODEC     preferred_codec;
   73     char *nal_info;
   74     int  nal_info_len;
   75 };
   76 #else
   77 struct ffmpeg {
   78     struct rtsp_context *rtsp_data;
   79     int width;
   80     int height;
   81     enum TIMELAPSE_TYPE tlapse;
   82     int fps;
   83     int bps;
   84     char *filename;
   85     int quality;
   86     const char *codec_name;
   87     int64_t last_pts;
   88     int64_t base_pts;
   89     int test_mode;
   90     int gop_cnt;
   91     struct timeval start_time;
   92     int            high_resolution;
   93     int            motion_images;
   94     int            passthrough;
   95 };
   96 #endif // HAVE_FFMPEG
   97 
   98 
   99 
  100 #ifdef HAVE_FFMPEG
  101 
  102 AVFrame *my_frame_alloc(void);
  103 void my_frame_free(AVFrame *frame);
  104 void my_packet_unref(AVPacket pkt);
  105 void my_avcodec_close(AVCodecContext *codec_context);
  106 int my_image_get_buffer_size(enum MyPixelFormat pix_fmt, int width, int height);
  107 int my_image_copy_to_buffer(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height,int dest_size);
  108 int my_image_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height);
  109 int my_copy_packet(AVPacket *dest_pkt, AVPacket *src_pkt);
  110 
  111 #endif /* HAVE_FFMPEG */
  112 
  113 void ffmpeg_global_init(void);
  114 void ffmpeg_global_deinit(void);
  115 void ffmpeg_avcodec_log(void *, int, const char *, va_list);
  116 
  117 int ffmpeg_open(struct ffmpeg *ffmpeg);
  118 int ffmpeg_put_image(struct ffmpeg *ffmpeg, struct image_data *img_data, const struct timeval *tv1);
  119 void ffmpeg_close(struct ffmpeg *ffmpeg);
  120 void ffmpeg_reset_movie_start_time(struct ffmpeg *ffmpeg, const struct timeval *tv1);
  121 
  122 #endif /* _INCLUDE_FFMPEG_H_ */