ffserver_config.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #ifndef FFSERVER_CONFIG_H
  21. #define FFSERVER_CONFIG_H
  22. #include "libavutil/dict.h"
  23. #include "libavformat/avformat.h"
  24. #include "libavformat/network.h"
  25. #define FFSERVER_MAX_STREAMS 20
  26. /* each generated stream is described here */
  27. enum FFServerStreamType {
  28. STREAM_TYPE_LIVE,
  29. STREAM_TYPE_STATUS,
  30. STREAM_TYPE_REDIRECT,
  31. };
  32. enum FFServerIPAddressAction {
  33. IP_ALLOW = 1,
  34. IP_DENY,
  35. };
  36. typedef struct FFServerIPAddressACL {
  37. struct FFServerIPAddressACL *next;
  38. enum FFServerIPAddressAction action;
  39. /* These are in host order */
  40. struct in_addr first;
  41. struct in_addr last;
  42. } FFServerIPAddressACL;
  43. /* description of each stream of the ffserver.conf file */
  44. typedef struct FFServerStream {
  45. enum FFServerStreamType stream_type;
  46. char filename[1024]; /* stream filename */
  47. struct FFServerStream *feed; /* feed we are using (can be null if coming from file) */
  48. AVDictionary *in_opts; /* input parameters */
  49. AVDictionary *metadata; /* metadata to set on the stream */
  50. AVInputFormat *ifmt; /* if non NULL, force input format */
  51. AVOutputFormat *fmt;
  52. FFServerIPAddressACL *acl;
  53. char dynamic_acl[1024];
  54. int nb_streams;
  55. int prebuffer; /* Number of milliseconds early to start */
  56. int64_t max_time; /* Number of milliseconds to run */
  57. int send_on_key;
  58. AVStream *streams[FFSERVER_MAX_STREAMS];
  59. int feed_streams[FFSERVER_MAX_STREAMS]; /* index of streams in the feed */
  60. char feed_filename[1024]; /* file name of the feed storage, or
  61. input file name for a stream */
  62. pid_t pid; /* Of ffmpeg process */
  63. time_t pid_start; /* Of ffmpeg process */
  64. char **child_argv;
  65. struct FFServerStream *next;
  66. unsigned bandwidth; /* bandwidth, in kbits/s */
  67. /* RTSP options */
  68. char *rtsp_option;
  69. /* multicast specific */
  70. int is_multicast;
  71. struct in_addr multicast_ip;
  72. int multicast_port; /* first port used for multicast */
  73. int multicast_ttl;
  74. int loop; /* if true, send the stream in loops (only meaningful if file) */
  75. /* feed specific */
  76. int feed_opened; /* true if someone is writing to the feed */
  77. int is_feed; /* true if it is a feed */
  78. int readonly; /* True if writing is prohibited to the file */
  79. int truncate; /* True if feeder connection truncate the feed file */
  80. int conns_served;
  81. int64_t bytes_served;
  82. int64_t feed_max_size; /* maximum storage size, zero means unlimited */
  83. int64_t feed_write_index; /* current write position in feed (it wraps around) */
  84. int64_t feed_size; /* current size of feed */
  85. struct FFServerStream *next_feed;
  86. } FFServerStream;
  87. typedef struct FFServerConfig {
  88. char *filename;
  89. FFServerStream *first_feed; /* contains only feeds */
  90. FFServerStream *first_stream; /* contains all streams, including feeds */
  91. unsigned int nb_max_http_connections;
  92. unsigned int nb_max_connections;
  93. uint64_t max_bandwidth;
  94. int debug;
  95. char logfilename[1024];
  96. struct sockaddr_in http_addr;
  97. struct sockaddr_in rtsp_addr;
  98. int errors;
  99. int warnings;
  100. int use_defaults;
  101. // Following variables MUST NOT be used outside configuration parsing code.
  102. enum AVCodecID guessed_audio_codec_id;
  103. enum AVCodecID guessed_video_codec_id;
  104. AVDictionary *video_opts; /* AVOptions for video encoder */
  105. AVDictionary *audio_opts; /* AVOptions for audio encoder */
  106. AVCodecContext *dummy_actx; /* Used internally to test audio AVOptions. */
  107. AVCodecContext *dummy_vctx; /* Used internally to test video AVOptions. */
  108. int no_audio;
  109. int no_video;
  110. int line_num;
  111. int stream_use_defaults;
  112. } FFServerConfig;
  113. void ffserver_get_arg(char *buf, int buf_size, const char **pp);
  114. void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
  115. FFServerIPAddressACL *ext_acl,
  116. const char *p, const char *filename, int line_num);
  117. int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
  118. void ffserver_free_child_args(void *argsp);
  119. #endif /* FFSERVER_CONFIG_H */