You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
5.1KB

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