|
|
|
@ -59,7 +59,7 @@ |
|
|
|
|
|
|
|
|
|
#include "cmdutils.h" |
|
|
|
|
|
|
|
|
|
const char program_name[] = "ffserver"; |
|
|
|
|
const char program_name[] = "avserver"; |
|
|
|
|
const int program_birth_year = 2000; |
|
|
|
|
|
|
|
|
|
static const OptionDef options[]; |
|
|
|
@ -200,7 +200,7 @@ typedef struct IPAddressACL { |
|
|
|
|
struct in_addr last; |
|
|
|
|
} IPAddressACL; |
|
|
|
|
|
|
|
|
|
/* description of each stream of the ffserver.conf file */ |
|
|
|
|
/* description of each stream of the avserver.conf file */ |
|
|
|
|
typedef struct FFStream { |
|
|
|
|
enum StreamType stream_type; |
|
|
|
|
char filename[1024]; /* stream filename */ |
|
|
|
@ -299,10 +299,10 @@ static int rtp_new_av_stream(HTTPContext *c, |
|
|
|
|
static const char *my_program_name; |
|
|
|
|
static const char *my_program_dir; |
|
|
|
|
|
|
|
|
|
static const char *config_filename = "/etc/ffserver.conf"; |
|
|
|
|
static const char *config_filename = "/etc/avserver.conf"; |
|
|
|
|
|
|
|
|
|
static int ffserver_debug; |
|
|
|
|
static int ffserver_daemon; |
|
|
|
|
static int avserver_debug; |
|
|
|
|
static int avserver_daemon; |
|
|
|
|
static int no_launch; |
|
|
|
|
static int need_to_start_children; |
|
|
|
|
|
|
|
|
@ -320,7 +320,7 @@ static AVLFG random_state; |
|
|
|
|
|
|
|
|
|
static FILE *logfile = NULL; |
|
|
|
|
|
|
|
|
|
/* FIXME: make ffserver work with IPv6 */ |
|
|
|
|
/* FIXME: make avserver work with IPv6 */ |
|
|
|
|
/* resolve host with also IP address parsing */ |
|
|
|
|
static int resolve_host(struct in_addr *sin_addr, const char *hostname) |
|
|
|
|
{ |
|
|
|
@ -480,7 +480,7 @@ static void start_children(FFStream *feed) |
|
|
|
|
for (i = 3; i < 256; i++) |
|
|
|
|
close(i); |
|
|
|
|
|
|
|
|
|
if (!ffserver_debug) { |
|
|
|
|
if (!avserver_debug) { |
|
|
|
|
i = open("/dev/null", O_RDWR); |
|
|
|
|
if (i != -1) { |
|
|
|
|
dup2(i, 0); |
|
|
|
@ -620,7 +620,7 @@ static int http_server(void) |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
http_log("FFserver started.\n"); |
|
|
|
|
http_log("AVserver started.\n"); |
|
|
|
|
|
|
|
|
|
start_children(first_feed); |
|
|
|
|
|
|
|
|
@ -664,7 +664,7 @@ static int http_server(void) |
|
|
|
|
poll_entry->events = POLLOUT; |
|
|
|
|
poll_entry++; |
|
|
|
|
} else { |
|
|
|
|
/* when ffserver is doing the timing, we work by
|
|
|
|
|
/* when avserver is doing the timing, we work by
|
|
|
|
|
looking at which packet need to be sent every |
|
|
|
|
10 ms */ |
|
|
|
|
delay1 = 10; /* one tick wait XXX: 10 ms assumed */ |
|
|
|
@ -1480,7 +1480,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
|
|
|
|
|
|
av_strlcpy(c->protocol, protocol, sizeof(c->protocol)); |
|
|
|
|
|
|
|
|
|
if (ffserver_debug) |
|
|
|
|
if (avserver_debug) |
|
|
|
|
http_log("%s - - New connection: %s %s\n", inet_ntoa(c->from_addr.sin_addr), cmd, url); |
|
|
|
|
|
|
|
|
|
/* find the filename and the optional info string in the request */ |
|
|
|
@ -1643,7 +1643,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
|
"Content-type: video/x-ms-asf\r\n" |
|
|
|
|
"\r\n" |
|
|
|
|
"<ASX Version=\"3\">\r\n" |
|
|
|
|
//"<!-- Autogenerated by ffserver -->\r\n"
|
|
|
|
|
//"<!-- Autogenerated by avserver -->\r\n"
|
|
|
|
|
"<ENTRY><REF HREF=\"http://%s/%s%s\"/></ENTRY>\r\n" |
|
|
|
|
"</ASX>\r\n", hostbuf, filename, info); |
|
|
|
|
break; |
|
|
|
@ -1652,7 +1652,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
|
"HTTP/1.0 200 RAM Follows\r\n" |
|
|
|
|
"Content-type: audio/x-pn-realaudio\r\n" |
|
|
|
|
"\r\n" |
|
|
|
|
"# Autogenerated by ffserver\r\n" |
|
|
|
|
"# Autogenerated by avserver\r\n" |
|
|
|
|
"http://%s/%s%s\r\n", hostbuf, filename, info); |
|
|
|
|
break; |
|
|
|
|
case REDIR_ASF: |
|
|
|
@ -3458,7 +3458,7 @@ static int rtp_new_av_stream(HTTPContext *c, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/********************************************************************/ |
|
|
|
|
/* ffserver initialization */ |
|
|
|
|
/* avserver initialization */ |
|
|
|
|
|
|
|
|
|
static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int copy) |
|
|
|
|
{ |
|
|
|
@ -3914,10 +3914,10 @@ static void load_module(const char *filename) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init_func = dlsym(dll, "ffserver_module_init"); |
|
|
|
|
init_func = dlsym(dll, "avserver_module_init"); |
|
|
|
|
if (!init_func) { |
|
|
|
|
fprintf(stderr, |
|
|
|
|
"%s: init function 'ffserver_module_init()' not found\n", |
|
|
|
|
"%s: init function 'avserver_module_init()' not found\n", |
|
|
|
|
filename); |
|
|
|
|
dlclose(dll); |
|
|
|
|
} |
|
|
|
@ -3926,7 +3926,7 @@ static void load_module(const char *filename) |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
static int ffserver_opt_default(const char *opt, const char *arg, |
|
|
|
|
static int avserver_opt_default(const char *opt, const char *arg, |
|
|
|
|
AVCodecContext *avctx, int type) |
|
|
|
|
{ |
|
|
|
|
int ret = 0; |
|
|
|
@ -3936,7 +3936,7 @@ static int ffserver_opt_default(const char *opt, const char *arg, |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int ffserver_opt_preset(const char *arg, |
|
|
|
|
static int avserver_opt_preset(const char *arg, |
|
|
|
|
AVCodecContext *avctx, int type, |
|
|
|
|
enum CodecID *audio_id, enum CodecID *video_id) |
|
|
|
|
{ |
|
|
|
@ -3967,7 +3967,7 @@ static int ffserver_opt_preset(const char *arg, |
|
|
|
|
*video_id = opt_video_codec(tmp2); |
|
|
|
|
}else if(!strcmp(tmp, "scodec")){ |
|
|
|
|
/* opt_subtitle_codec(tmp2); */ |
|
|
|
|
}else if(ffserver_opt_default(tmp, tmp2, avctx, type) < 0){ |
|
|
|
|
}else if(avserver_opt_default(tmp, tmp2, avctx, type) < 0){ |
|
|
|
|
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); |
|
|
|
|
ret = 1; |
|
|
|
|
break; |
|
|
|
@ -3979,7 +3979,7 @@ static int ffserver_opt_preset(const char *arg, |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static AVOutputFormat *ffserver_guess_format(const char *short_name, const char *filename, |
|
|
|
|
static AVOutputFormat *avserver_guess_format(const char *short_name, const char *filename, |
|
|
|
|
const char *mime_type) |
|
|
|
|
{ |
|
|
|
|
AVOutputFormat *fmt = av_guess_format(short_name, filename, mime_type); |
|
|
|
@ -4066,7 +4066,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
ERROR("%s:%d: Invalid host/IP address: %s\n", arg); |
|
|
|
|
} |
|
|
|
|
} else if (!strcasecmp(cmd, "NoDaemon")) { |
|
|
|
|
ffserver_daemon = 0; |
|
|
|
|
avserver_daemon = 0; |
|
|
|
|
} else if (!strcasecmp(cmd, "RTSPPort")) { |
|
|
|
|
get_arg(arg, sizeof(arg), &p); |
|
|
|
|
val = atoi(arg); |
|
|
|
@ -4103,7 +4103,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
} else |
|
|
|
|
max_bandwidth = llval; |
|
|
|
|
} else if (!strcasecmp(cmd, "CustomLog")) { |
|
|
|
|
if (!ffserver_debug) |
|
|
|
|
if (!avserver_debug) |
|
|
|
|
get_arg(logfilename, sizeof(logfilename), &p); |
|
|
|
|
} else if (!strcasecmp(cmd, "<Feed")) { |
|
|
|
|
/*********************************************/ |
|
|
|
@ -4227,7 +4227,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL); |
|
|
|
|
stream->fmt = avserver_guess_format(NULL, stream->filename, NULL); |
|
|
|
|
avcodec_get_context_defaults2(&video_enc, AVMEDIA_TYPE_VIDEO); |
|
|
|
|
avcodec_get_context_defaults2(&audio_enc, AVMEDIA_TYPE_AUDIO); |
|
|
|
|
audio_id = CODEC_ID_NONE; |
|
|
|
@ -4267,7 +4267,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
/* jpeg cannot be used here, so use single frame jpeg */ |
|
|
|
|
if (!strcmp(arg, "jpeg")) |
|
|
|
|
strcpy(arg, "mjpeg"); |
|
|
|
|
stream->fmt = ffserver_guess_format(arg, NULL, NULL); |
|
|
|
|
stream->fmt = avserver_guess_format(arg, NULL, NULL); |
|
|
|
|
if (!stream->fmt) { |
|
|
|
|
ERROR("Unknown Format: %s\n", arg); |
|
|
|
|
} |
|
|
|
@ -4430,7 +4430,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
avctx = &audio_enc; |
|
|
|
|
type = AV_OPT_FLAG_AUDIO_PARAM; |
|
|
|
|
} |
|
|
|
|
if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { |
|
|
|
|
if (avserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { |
|
|
|
|
ERROR("AVOption error: %s %s\n", arg, arg2); |
|
|
|
|
} |
|
|
|
|
} else if (!strcasecmp(cmd, "AVPresetVideo") || |
|
|
|
@ -4447,7 +4447,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
|
audio_enc.codec_id = audio_id; |
|
|
|
|
type = AV_OPT_FLAG_AUDIO_PARAM; |
|
|
|
|
} |
|
|
|
|
if (ffserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) { |
|
|
|
|
if (avserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) { |
|
|
|
|
ERROR("AVPreset error: %s\n", arg); |
|
|
|
|
} |
|
|
|
|
} else if (!strcasecmp(cmd, "VideoTag")) { |
|
|
|
@ -4638,14 +4638,14 @@ static void handle_child_exit(int sig) |
|
|
|
|
|
|
|
|
|
static void opt_debug(void) |
|
|
|
|
{ |
|
|
|
|
ffserver_debug = 1; |
|
|
|
|
ffserver_daemon = 0; |
|
|
|
|
avserver_debug = 1; |
|
|
|
|
avserver_daemon = 0; |
|
|
|
|
logfilename[0] = '-'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void show_help(void) |
|
|
|
|
{ |
|
|
|
|
printf("usage: ffserver [options]\n" |
|
|
|
|
printf("usage: avserver [options]\n" |
|
|
|
|
"Hyper fast multi format Audio/Video streaming server\n"); |
|
|
|
|
printf("\n"); |
|
|
|
|
show_help_options(options, "Main options:\n", 0, 0); |
|
|
|
@ -4655,7 +4655,7 @@ static const OptionDef options[] = { |
|
|
|
|
#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" }, |
|
|
|
|
{ "f", HAS_ARG | OPT_STRING, {(void*)&config_filename }, "use configfile instead of /etc/avserver.conf", "configfile" }, |
|
|
|
|
{ NULL }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -4669,7 +4669,7 @@ int main(int argc, char **argv) |
|
|
|
|
|
|
|
|
|
my_program_name = argv[0]; |
|
|
|
|
my_program_dir = getcwd(0, 0); |
|
|
|
|
ffserver_daemon = 1; |
|
|
|
|
avserver_daemon = 1; |
|
|
|
|
|
|
|
|
|
parse_options(argc, argv, options, NULL); |
|
|
|
|
|
|
|
|
@ -4703,7 +4703,7 @@ int main(int argc, char **argv) |
|
|
|
|
compute_bandwidth(); |
|
|
|
|
|
|
|
|
|
/* put the process in background and detach it from its TTY */ |
|
|
|
|
if (ffserver_daemon) { |
|
|
|
|
if (avserver_daemon) { |
|
|
|
|
int pid; |
|
|
|
|
|
|
|
|
|
pid = fork(); |
|
|
|
@ -4730,7 +4730,7 @@ int main(int argc, char **argv) |
|
|
|
|
/* signal init */ |
|
|
|
|
signal(SIGPIPE, SIG_IGN); |
|
|
|
|
|
|
|
|
|
if (ffserver_daemon) |
|
|
|
|
if (avserver_daemon) |
|
|
|
|
chdir("/"); |
|
|
|
|
|
|
|
|
|
if (http_server() < 0) { |