}
}
-void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)
+static void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)
{
va_list vargs;
va_start(vargs, fmt);
*pp = p;
}
+static void get_arg(char *buf, int buf_size, const char **pp)
+{
+ const char *p;
+ char *q;
+ int quote;
+
+ p = *pp;
+ while (isspace(*p)) p++;
+ q = buf;
+ quote = 0;
+ if (*p == '\"' || *p == '\'')
+ quote = *p++;
+ for(;;) {
+ if (quote) {
+ if (*p == quote)
+ break;
+ } else {
+ if (isspace(*p))
+ break;
+ }
+ if (*p == '\0')
+ break;
+ if ((q - buf) < buf_size - 1)
+ *q++ = *p;
+ p++;
+ }
+ *q = '\0';
+ if (quote && *p == quote)
+ p++;
+ *pp = p;
+}
+
static int validate_acl(FFStream *stream, HTTPContext *c)
{
enum IPAddressAction last_action = IP_DENY;
}
redir_type = REDIR_NONE;
- if (match_ext(filename, "asx")) {
+ if (av_match_ext(filename, "asx")) {
redir_type = REDIR_ASX;
filename[strlen(filename)-1] = 'f';
- } else if (match_ext(filename, "asf") &&
+ } else if (av_match_ext(filename, "asf") &&
(!useragent || strncasecmp(useragent, "NSPlayer", 8) != 0)) {
/* if this isn't WMP or lookalike, return the redirector file */
redir_type = REDIR_ASF;
- } else if (match_ext(filename, "rpm,ram")) {
+ } else if (av_match_ext(filename, "rpm,ram")) {
redir_type = REDIR_RAM;
strcpy(filename + strlen(filename)-2, "m");
- } else if (match_ext(filename, "rtsp")) {
+ } else if (av_match_ext(filename, "rtsp")) {
redir_type = REDIR_RTSP;
compute_real_filename(filename, sizeof(filename) - 1);
- } else if (match_ext(filename, "sdp")) {
+ } else if (av_match_ext(filename, "sdp")) {
redir_type = REDIR_SDP;
compute_real_filename(filename, sizeof(filename) - 1);
}
stream = stream->next;
}
-#if 0
- {
- float avg;
- AVCodecContext *enc;
- char buf[1024];
-
- /* feed status */
- stream = first_feed;
- while (stream != NULL) {
- url_fprintf(pb, "<h1>Feed '%s'</h1>\n", stream->filename);
- url_fprintf(pb, "<table>\n");
- url_fprintf(pb, "<tr><td>Parameters<td>Frame count<td>Size<td>Avg bitrate (kbits/s)\n");
- for(i=0;i<stream->nb_streams;i++) {
- AVStream *st = stream->streams[i];
- FeedData *fdata = st->priv_data;
- enc = st->codec;
-
- avcodec_string(buf, sizeof(buf), enc);
- 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> %"PRId64" <td> %0.1f\n",
- buf, enc->frame_number, fdata->data_count, avg / 1000.0);
- }
- url_fprintf(pb, "</table>\n");
- stream = stream->next_feed;
- }
- }
-#endif
-
/* connection status */
url_fprintf(pb, "<h2>Connection Status</h2>\n");
if (input_filename[0] == '\0')
return -1;
-#if 0
- { time_t when = stream_pos / 1000000;
- http_log("Stream pos = %"PRId64", time=%s", stream_pos, ctime(&when));
- }
-#endif
-
/* open stream */
if ((ret = av_open_input_file(&s, input_filename, c->stream->ifmt,
buf_size, c->stream->ap_in)) < 0) {
if (ist->start_time != AV_NOPTS_VALUE)
c->cur_pts -= av_rescale_q(ist->start_time, ist->time_base, AV_TIME_BASE_Q);
c->cur_frame_duration = av_rescale_q(pkt.duration, ist->time_base, AV_TIME_BASE_Q);
-#if 0
- printf("index=%d pts=%0.3f duration=%0.6f\n",
- pkt.stream_index,
- (double)c->cur_pts /
- AV_TIME_BASE,
- (double)c->cur_frame_duration /
- AV_TIME_BASE);
-#endif
/* find RTP context */
c->packet_stream_index = pkt.stream_index;
ctx = c->rtp_ctx[c->packet_stream_index];
return;
}
-#if 0
- /* XXX: seek in stream */
- if (h->range_start != AV_NOPTS_VALUE) {
- printf("range_start=%0.3f\n", (double)h->range_start / AV_TIME_BASE);
- av_seek_frame(rtp_c->fmt_in, -1, h->range_start);
- }
-#endif
-
rtp_c->state = HTTPSTATE_SEND_DATA;
/* now everything is OK, so we can send the connection parameters */
ctx = avformat_alloc_context();
if (!ctx)
return -1;
- ctx->oformat = guess_format("rtp", NULL, NULL);
+ ctx->oformat = av_guess_format("rtp", NULL, NULL);
st = av_mallocz(sizeof(AVStream));
if (!st)
}
}
-static void get_arg(char *buf, int buf_size, const char **pp)
-{
- const char *p;
- char *q;
- int quote;
-
- p = *pp;
- while (isspace(*p)) p++;
- q = buf;
- quote = 0;
- if (*p == '\"' || *p == '\'')
- quote = *p++;
- for(;;) {
- if (quote) {
- if (*p == quote)
- break;
- } else {
- if (isspace(*p))
- break;
- }
- if (*p == '\0')
- break;
- if ((q - buf) < buf_size - 1)
- *q++ = *p;
- p++;
- }
- *q = '\0';
- if (quote && *p == quote)
- p++;
- *pp = p;
-}
-
/* add a codec and set the default parameters */
static void add_codec(FFStream *stream, AVCodecContext *av)
{
return ret;
}
+static AVOutputFormat *ffserver_guess_format(const char *short_name, const char *filename,
+ const char *mime_type)
+{
+ AVOutputFormat *fmt = av_guess_format(short_name, filename, mime_type);
+
+ if (fmt) {
+ AVOutputFormat *stream_fmt;
+ char stream_format_name[64];
+
+ snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream", fmt->name);
+ stream_fmt = av_guess_format(stream_format_name, NULL, NULL);
+
+ if (stream_fmt)
+ fmt = stream_fmt;
+ }
+
+ return fmt;
+}
+
static int parse_ffconfig(const char *filename)
{
FILE *f;
}
}
- feed->fmt = guess_format("ffm", NULL, NULL);
+ feed->fmt = av_guess_format("ffm", NULL, NULL);
/* defaut feed file */
snprintf(feed->feed_filename, sizeof(feed->feed_filename),
"/tmp/%s.ffm", feed->filename);
}
}
- stream->fmt = guess_stream_format(NULL, stream->filename, NULL);
+ stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL);
/* fetch avclass so AVOption works
* FIXME try to use avcodec_get_context_defaults2
* without changing defaults too much */
/* jpeg cannot be used here, so use single frame jpeg */
if (!strcmp(arg, "jpeg"))
strcpy(arg, "mjpeg");
- stream->fmt = guess_stream_format(arg, NULL, NULL);
+ stream->fmt = ffserver_guess_format(arg, NULL, NULL);
if (!stream->fmt) {
fprintf(stderr, "%s:%d: Unknown Format: %s\n",
filename, line_num, arg);
logfilename[0] = '-';
}
-static void opt_show_help(void)
+static void show_help(void)
{
printf("usage: ffserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
}
static const OptionDef options[] = {
- { "h", OPT_EXIT, {(void*)opt_show_help}, "show help" },
- { "version", OPT_EXIT, {(void*)show_version}, "show version" },
- { "L", OPT_EXIT, {(void*)show_license}, "show license" },
- { "formats", OPT_EXIT, {(void*)show_formats}, "show available formats, codecs, protocols, ..." },
+#include "cmdutils_common_opts.h"
{ "n", OPT_BOOL, {(void *)&no_launch }, "enable no-launch mode" },
{ "d", 0, {(void*)opt_debug}, "enable debug mode" },
{ "f", HAS_ARG | OPT_STRING, {(void*)&config_filename }, "use configfile instead of /etc/ffserver.conf", "configfile" },