]> git.sesse.net Git - ffmpeg/blobdiff - ffserver.c
Avoid segfaulting if the swscale context cannot be allocated
[ffmpeg] / ffserver.c
index fbbe8270ab7bf2a5ca6074e4a88c311659dfb069..a8a78a7be6b396021d72a15640e3277ede9f68ce 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define HAVE_AV_CONFIG_H
 #include "avformat.h"
@@ -39,6 +39,7 @@
 #include <dlfcn.h>
 #endif
 
+#include "version.h"
 #include "ffserver.h"
 
 /* maximum number of simultaneous HTTP connections */
@@ -232,10 +233,10 @@ typedef struct FeedData {
 struct sockaddr_in my_http_addr;
 struct sockaddr_in my_rtsp_addr;
 
-char logfilename[1024];
-HTTPContext *first_http_ctx;
-FFStream *first_feed;   /* contains only feeds */
-FFStream *first_stream; /* contains all streams, including feeds */
+static char logfilename[1024];
+static HTTPContext *first_http_ctx;
+static FFStream *first_feed;   /* contains only feeds */
+static FFStream *first_stream; /* contains all streams, including feeds */
 
 static void new_connection(int server_fd, int is_rtsp);
 static void close_connection(HTTPContext *c);
@@ -278,11 +279,11 @@ static int ffserver_daemon;
 static int no_launch;
 static int need_to_start_children;
 
-int nb_max_connections;
-int nb_connections;
+static int nb_max_connections;
+static int nb_connections;
 
-int max_bandwidth;
-int current_bandwidth;
+static int max_bandwidth;
+static int current_bandwidth;
 
 static long cur_time;           // Making this global saves on passing it around everywhere
 
@@ -359,14 +360,6 @@ static int compute_datarate(DataRateData *drd, int64_t count)
     return ((count - drd->count1) * 1000) / (cur_time - drd->time1);
 }
 
-static int get_longterm_datarate(DataRateData *drd, int64_t count)
-{
-    /* You get the first 3 seconds flat out */
-    if (cur_time - drd->time1 < 3000)
-        return 0;
-    return compute_datarate(drd, count);
-}
-
 
 static void start_children(FFStream *feed)
 {
@@ -1306,8 +1299,8 @@ static int http_parse_request(HTTPContext *c)
         q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: text/html\r\n");
         q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n");
         q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<html><head><title>Too busy</title></head><body>\r\n");
-        q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "The server is too busy to serve your request at this time.<p>\r\n");
-        q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "The bandwidth being served (including your stream) is %dkbit/sec, and this exceeds the limit of %dkbit/sec\r\n",
+        q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<p>The server is too busy to serve your request at this time.</p>\r\n");
+        q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<p>The bandwidth being served (including your stream) is %dkbit/sec, and this exceeds the limit of %dkbit/sec.</p>\r\n",
             current_bandwidth, max_bandwidth);
         q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</body></html>\r\n");
 
@@ -1631,7 +1624,7 @@ static void compute_stats(HTTPContext *c)
                     strcpy(eosf - 4, ".asx");
                 } else if (strcmp(eosf - 3, ".rm") == 0) {
                     strcpy(eosf - 3, ".ram");
-                } else if (stream->fmt == &rtp_mux) {
+                } else if (stream->fmt == &rtp_muxer) {
                     /* generate a sample RTSP director if
                        unicast. Generate an SDP redirector if
                        multicast */
@@ -2727,7 +2720,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url)
         path++;
 
     for(stream = first_stream; stream != NULL; stream = stream->next) {
-        if (!stream->is_feed && stream->fmt == &rtp_mux &&
+        if (!stream->is_feed && stream->fmt == &rtp_muxer &&
             !strcmp(path, stream->filename)) {
             goto found;
         }
@@ -2802,7 +2795,7 @@ static void rtsp_cmd_setup(HTTPContext *c, const char *url,
 
     /* now check each stream */
     for(stream = first_stream; stream != NULL; stream = stream->next) {
-        if (!stream->is_feed && stream->fmt == &rtp_mux) {
+        if (!stream->is_feed && stream->fmt == &rtp_muxer) {
             /* accept aggregate filenames only if single stream */
             if (!strcmp(path, stream->filename)) {
                 if (stream->nb_streams != 1) {
@@ -3137,7 +3130,7 @@ static int rtp_new_av_stream(HTTPContext *c,
     ctx = av_alloc_format_context();
     if (!ctx)
         return -1;
-    ctx->oformat = &rtp_mux;
+    ctx->oformat = &rtp_muxer;
 
     st = av_mallocz(sizeof(AVStream));
     if (!st)
@@ -3357,7 +3350,7 @@ static void build_file_streams(void)
             /* try to open the file */
             /* open stream */
             stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
-            if (stream->fmt == &rtp_mux) {
+            if (stream->fmt == &rtp_muxer) {
                 /* specific case : if transport stream output to RTP,
                    we use a raw transport stream reader */
                 stream->ap_in->mpeg2ts_raw = 1;
@@ -3712,7 +3705,7 @@ static int opt_video_codec(const char *arg)
 /* simplistic plugin support */
 
 #ifdef CONFIG_HAVE_DLOPEN
-void load_module(const char *filename)
+static void load_module(const char *filename)
 {
     void *dll;
     void (*init_func)(void);
@@ -4154,6 +4147,24 @@ static int parse_ffconfig(const char *filename)
                 video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove
                 video_enc.flags |= CODEC_FLAG_4MV;
             }
+        } else if (!strcasecmp(cmd, "BitExact")) {
+            if (stream) {
+                video_enc.flags |= CODEC_FLAG_BITEXACT;
+            }
+        } else if (!strcasecmp(cmd, "DctFastint")) {
+            if (stream) {
+                video_enc.dct_algo  = FF_DCT_FASTINT;
+            }
+        } else if (!strcasecmp(cmd, "IdctSimple")) {
+            if (stream) {
+                video_enc.idct_algo = FF_IDCT_SIMPLE;
+            }
+        } else if (!strcasecmp(cmd, "Qscale")) {
+            get_arg(arg, sizeof(arg), &p);
+            if (stream) {
+                video_enc.flags |= CODEC_FLAG_QSCALE;
+                video_enc.global_quality = FF_QP2LAMBDA * atoi(arg);
+            }
         } else if (!strcasecmp(cmd, "VideoQDiff")) {
             get_arg(arg, sizeof(arg), &p);
             if (stream) {
@@ -4437,7 +4448,7 @@ static void show_license(void)
     "\n"
     "You should have received a copy of the GNU Lesser General Public\n"
     "License along with this library; if not, write to the Free Software\n"
-    "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n"
+    "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n"
     );
 }