Skip to content
Snippets Groups Projects
ffserver.c 66.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Fabrice Bellard's avatar
    Fabrice Bellard committed
        const char *config_filename;
        int c;
    
        register_all();
    
        config_filename = "/etc/ffserver.conf";
    
        for(;;) {
            c = getopt_long_only(argc, argv, "Lh?f:", NULL, NULL);
            if (c == -1)
                break;
            switch(c) {
            case 'L':
                licence();
                exit(1);
            case '?':
            case 'h':
                help();
                exit(1);
            case 'f':
                config_filename = optarg;
                break;
            default:
                exit(2);
            }
        }
    
        /* address on which the server will handle connections */
        my_addr.sin_family = AF_INET;
        my_addr.sin_port = htons (8080);
        my_addr.sin_addr.s_addr = htonl (INADDR_ANY);
        nb_max_connections = 5;
    
        nb_max_bandwidth = 1000;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        first_stream = NULL;
        logfilename[0] = '\0';
    
        if (parse_ffconfig(config_filename) < 0) {
            fprintf(stderr, "Incorrect config file - exiting.\n");
            exit(1);
        }
    
        build_feed_streams();
    
        /* signal init */
        signal(SIGPIPE, SIG_IGN);
    
        /* open log file if needed */
        if (logfilename[0] != '\0') {
            if (!strcmp(logfilename, "-"))
                logfile = stdout;
            else
                logfile = fopen(logfilename, "w");
        }
    
        if (http_server(my_addr) < 0) {
            fprintf(stderr, "Could start http server\n");
            exit(1);
        }
    
        return 0;
    }