ffserver_config.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. /**
  45. * This holds the stream parameters for an AVStream, it cannot be a AVStream
  46. * because AVStreams cannot be instanciated without a AVFormatContext, especially
  47. * not outside libavformat.
  48. *
  49. * The fields of this struct have the same semantics as the fields of an AVStream.
  50. */
  51. typedef struct LayeredAVStream {
  52. int index;
  53. int id;
  54. AVCodecParameters *codecpar;
  55. AVCodecContext *codec;
  56. AVRational time_base;
  57. int pts_wrap_bits;
  58. AVRational sample_aspect_ratio;
  59. char *recommended_encoder_configuration;
  60. } LayeredAVStream;
  61. /* description of each stream of the ffserver.conf file */
  62. typedef struct FFServerStream {
  63. enum FFServerStreamType stream_type;
  64. char filename[1024]; /* stream filename */
  65. struct FFServerStream *feed; /* feed we are using (can be null if coming from file) */
  66. AVDictionary *in_opts; /* input parameters */
  67. AVDictionary *metadata; /* metadata to set on the stream */
  68. AVInputFormat *ifmt; /* if non NULL, force input format */
  69. AVOutputFormat *fmt;
  70. FFServerIPAddressACL *acl;
  71. char dynamic_acl[1024];
  72. int nb_streams;
  73. int prebuffer; /* Number of milliseconds early to start */
  74. int64_t max_time; /* Number of milliseconds to run */
  75. int send_on_key;
  76. LayeredAVStream *streams[FFSERVER_MAX_STREAMS];
  77. int feed_streams[FFSERVER_MAX_STREAMS]; /* index of streams in the feed */
  78. char feed_filename[1024]; /* file name of the feed storage, or
  79. input file name for a stream */
  80. pid_t pid; /* Of ffmpeg process */
  81. time_t pid_start; /* Of ffmpeg process */
  82. char **child_argv;
  83. struct FFServerStream *next;
  84. unsigned bandwidth; /* bandwidth, in kbits/s */
  85. /* RTSP options */
  86. char *rtsp_option;
  87. /* multicast specific */
  88. int is_multicast;
  89. struct in_addr multicast_ip;
  90. int multicast_port; /* first port used for multicast */
  91. int multicast_ttl;
  92. int loop; /* if true, send the stream in loops (only meaningful if file) */
  93. char single_frame; /* only single frame */
  94. /* feed specific */
  95. int feed_opened; /* true if someone is writing to the feed */
  96. int is_feed; /* true if it is a feed */
  97. int readonly; /* True if writing is prohibited to the file */
  98. int truncate; /* True if feeder connection truncate the feed file */
  99. int conns_served;
  100. int64_t bytes_served;
  101. int64_t feed_max_size; /* maximum storage size, zero means unlimited */
  102. int64_t feed_write_index; /* current write position in feed (it wraps around) */
  103. int64_t feed_size; /* current size of feed */
  104. struct FFServerStream *next_feed;
  105. } FFServerStream;
  106. typedef struct FFServerConfig {
  107. char *filename;
  108. FFServerStream *first_feed; /* contains only feeds */
  109. FFServerStream *first_stream; /* contains all streams, including feeds */
  110. unsigned int nb_max_http_connections;
  111. unsigned int nb_max_connections;
  112. uint64_t max_bandwidth;
  113. int debug;
  114. int bitexact;
  115. char logfilename[1024];
  116. struct sockaddr_in http_addr;
  117. struct sockaddr_in rtsp_addr;
  118. int errors;
  119. int warnings;
  120. int use_defaults;
  121. // Following variables MUST NOT be used outside configuration parsing code.
  122. enum AVCodecID guessed_audio_codec_id;
  123. enum AVCodecID guessed_video_codec_id;
  124. AVDictionary *video_opts; /* AVOptions for video encoder */
  125. AVDictionary *audio_opts; /* AVOptions for audio encoder */
  126. AVCodecContext *dummy_actx; /* Used internally to test audio AVOptions. */
  127. AVCodecContext *dummy_vctx; /* Used internally to test video AVOptions. */
  128. int no_audio;
  129. int no_video;
  130. int line_num;
  131. int stream_use_defaults;
  132. } FFServerConfig;
  133. void ffserver_get_arg(char *buf, int buf_size, const char **pp);
  134. void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
  135. FFServerIPAddressACL *ext_acl,
  136. const char *p, const char *filename, int line_num);
  137. int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
  138. void ffserver_free_child_args(void *argsp);
  139. #endif /* FFSERVER_CONFIG_H */