]> git.sesse.net Git - ffmpeg/blobdiff - ffserver.c
rename HAVE_DLFCN to HAVE_DLFCN_H
[ffmpeg] / ffserver.c
index fbbe8270ab7bf2a5ca6074e4a88c311659dfb069..138e607ed685e0cb200c0f29b01f7cad4c651192 100644 (file)
@@ -2,19 +2,21 @@
  * Multiple format streaming server
  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * 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
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define HAVE_AV_CONFIG_H
 #include "avformat.h"
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <signal.h>
-#ifdef CONFIG_HAVE_DLFCN
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
 
+#include "version.h"
 #include "ffserver.h"
 
 /* maximum number of simultaneous HTTP connections */
@@ -232,10 +235,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 +281,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 +362,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 +1301,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 +1626,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 */
@@ -1795,7 +1790,7 @@ static void compute_stats(HTTPContext *c)
                 avg = fdata->avg_frame_size * (float)enc->rate * 8.0;
                 if (enc->codec->type == CODEC_TYPE_AUDIO && enc->frame_size > 0)
                     avg /= enc->frame_size;
-                url_fprintf(pb, "<TR><TD>%s <TD> %d <TD> %Ld <TD> %0.1f\n",
+                url_fprintf(pb, "<TR><TD>%s <TD> %d <TD> %"PRId64" <TD> %0.1f\n",
                              buf, enc->frame_number, fdata->data_count, avg / 1000.0);
             }
             url_fprintf(pb, "</TABLE>\n");
@@ -1917,7 +1912,7 @@ static int open_input_stream(HTTPContext *c, const char *info)
 
 #if 0
     { time_t when = stream_pos / 1000000;
-    http_log("Stream pos = %lld, time=%s", stream_pos, ctime(&when));
+    http_log("Stream pos = %"PRId64", time=%s", stream_pos, ctime(&when));
     }
 #endif
 
@@ -2406,7 +2401,7 @@ static int http_receive_data(HTTPContext *c)
            if header */
         if (c->data_count > FFM_PACKET_SIZE) {
 
-            //            printf("writing pos=0x%Lx size=0x%Lx\n", feed->feed_write_index, feed->feed_size);
+            //            printf("writing pos=0x%"PRIx64" size=0x%"PRIx64"\n", feed->feed_write_index, feed->feed_size);
             /* XXX: use llseek or url_seek */
             lseek(c->feed_fd, feed->feed_write_index, SEEK_SET);
             write(c->feed_fd, c->buffer, FFM_PACKET_SIZE);
@@ -2727,7 +2722,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 +2797,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 +3132,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 +3352,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;
@@ -3711,8 +3706,8 @@ static int opt_video_codec(const char *arg)
 
 /* simplistic plugin support */
 
-#ifdef CONFIG_HAVE_DLOPEN
-void load_module(const char *filename)
+#ifdef HAVE_DLOPEN
+static void load_module(const char *filename)
 {
     void *dll;
     void (*init_func)(void);
@@ -4154,6 +4149,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) {
@@ -4364,7 +4377,7 @@ static int parse_ffconfig(const char *filename)
             redirect = NULL;
         } else if (!strcasecmp(cmd, "LoadModule")) {
             get_arg(arg, sizeof(arg), &p);
-#ifdef CONFIG_HAVE_DLOPEN
+#ifdef HAVE_DLOPEN
             load_module(arg);
 #else
             fprintf(stderr, "%s:%d: Module support not compiled into this version: '%s'\n",
@@ -4406,7 +4419,7 @@ static void write_packet(FFCodec *ffenc,
 
 static void show_banner(void)
 {
-    printf("ffserver version " FFMPEG_VERSION ", Copyright (c) 2000-2003 Fabrice Bellard\n");
+    printf("ffserver version " FFMPEG_VERSION ", Copyright (c) 2000-2006 Fabrice Bellard, et al.\n");
 }
 
 static void show_help(void)
@@ -4425,19 +4438,19 @@ static void show_license(void)
 {
     show_banner();
     printf(
-    "This library is free software; you can redistribute it and/or\n"
+    "FFmpeg is free software; you can redistribute it and/or\n"
     "modify it under the terms of the GNU Lesser General Public\n"
     "License as published by the Free Software Foundation; either\n"
-    "version 2 of the License, or (at your option) any later version.\n"
+    "version 2.1 of the License, or (at your option) any later version.\n"
     "\n"
-    "This library is distributed in the hope that it will be useful,\n"
+    "FFmpeg is distributed in the hope that it will be useful,\n"
     "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
     "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
     "Lesser General Public License for more details.\n"
     "\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"
+    "License along with FFmpeg; if not, write to the Free Software\n"
+    "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n"
     );
 }