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