]> git.sesse.net Git - ffmpeg/blob - ffserver_config.h
Merge commit '46278ec90ac5ad1dab5e85991f176afe49003fee'
[ffmpeg] / ffserver_config.h
1 /*
2  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef FFSERVER_CONFIG_H
22 #define FFSERVER_CONFIG_H
23
24 #define FFM_PACKET_SIZE 4096
25
26 #include "libavutil/dict.h"
27 #include "libavformat/avformat.h"
28 #include "libavformat/network.h"
29
30 #define FFSERVER_MAX_STREAMS 20
31
32 /* each generated stream is described here */
33 enum FFServerStreamType {
34     STREAM_TYPE_LIVE,
35     STREAM_TYPE_STATUS,
36     STREAM_TYPE_REDIRECT,
37 };
38
39 enum FFServerIPAddressAction {
40     IP_ALLOW = 1,
41     IP_DENY,
42 };
43
44 typedef struct FFServerIPAddressACL {
45     struct FFServerIPAddressACL *next;
46     enum FFServerIPAddressAction action;
47     /* These are in host order */
48     struct in_addr first;
49     struct in_addr last;
50 } FFServerIPAddressACL;
51
52 /* description of each stream of the ffserver.conf file */
53 typedef struct FFServerStream {
54     enum FFServerStreamType stream_type;
55     char filename[1024];          /* stream filename */
56     struct FFServerStream *feed;  /* feed we are using (can be null if coming from file) */
57     AVDictionary *in_opts;        /* input parameters */
58     AVDictionary *metadata;       /* metadata to set on the stream */
59     AVInputFormat *ifmt;          /* if non NULL, force input format */
60     AVOutputFormat *fmt;
61     FFServerIPAddressACL *acl;
62     char dynamic_acl[1024];
63     int nb_streams;
64     int prebuffer;                /* Number of milliseconds early to start */
65     int64_t max_time;             /* Number of milliseconds to run */
66     int send_on_key;
67     AVStream *streams[FFSERVER_MAX_STREAMS];
68     int feed_streams[FFSERVER_MAX_STREAMS]; /* index of streams in the feed */
69     char feed_filename[1024];     /* file name of the feed storage, or
70                                      input file name for a stream */
71     pid_t pid;                    /* Of ffmpeg process */
72     time_t pid_start;             /* Of ffmpeg process */
73     char **child_argv;
74     struct FFServerStream *next;
75     unsigned bandwidth;           /* bandwidth, in kbits/s */
76     /* RTSP options */
77     char *rtsp_option;
78     /* multicast specific */
79     int is_multicast;
80     struct in_addr multicast_ip;
81     int multicast_port;           /* first port used for multicast */
82     int multicast_ttl;
83     int loop;                     /* if true, send the stream in loops (only meaningful if file) */
84     char single_frame;            /* only single frame */
85
86     /* feed specific */
87     int feed_opened;              /* true if someone is writing to the feed */
88     int is_feed;                  /* true if it is a feed */
89     int readonly;                 /* True if writing is prohibited to the file */
90     int truncate;                 /* True if feeder connection truncate the feed file */
91     int conns_served;
92     int64_t bytes_served;
93     int64_t feed_max_size;        /* maximum storage size, zero means unlimited */
94     int64_t feed_write_index;     /* current write position in feed (it wraps around) */
95     int64_t feed_size;            /* current size of feed */
96     struct FFServerStream *next_feed;
97 } FFServerStream;
98
99 typedef struct FFServerConfig {
100     char *filename;
101     FFServerStream *first_feed;   /* contains only feeds */
102     FFServerStream *first_stream; /* contains all streams, including feeds */
103     unsigned int nb_max_http_connections;
104     unsigned int nb_max_connections;
105     uint64_t max_bandwidth;
106     int debug;
107     char logfilename[1024];
108     struct sockaddr_in http_addr;
109     struct sockaddr_in rtsp_addr;
110     int errors;
111     int warnings;
112     int use_defaults;
113     // Following variables MUST NOT be used outside configuration parsing code.
114     enum AVCodecID guessed_audio_codec_id;
115     enum AVCodecID guessed_video_codec_id;
116     AVDictionary *video_opts;     /* AVOptions for video encoder */
117     AVDictionary *audio_opts;     /* AVOptions for audio encoder */
118     AVCodecContext *dummy_actx;   /* Used internally to test audio AVOptions. */
119     AVCodecContext *dummy_vctx;   /* Used internally to test video AVOptions. */
120     int no_audio;
121     int no_video;
122     int line_num;
123     int stream_use_defaults;
124 } FFServerConfig;
125
126 void ffserver_get_arg(char *buf, int buf_size, const char **pp);
127
128 void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
129                             FFServerIPAddressACL *ext_acl,
130                             const char *p, const char *filename, int line_num);
131
132 int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
133
134 void ffserver_free_child_args(void *argsp);
135
136 #endif /* FFSERVER_CONFIG_H */