]> git.sesse.net Git - nageru/blob - flags.cpp
Add an option --http-coarse-timebase for streaming to MP4.
[nageru] / flags.cpp
1 #include "flags.h"
2
3 #include <getopt.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 Flags global_flags;
8
9 void usage()
10 {
11         fprintf(stderr, "Usage: nageru [OPTION]...\n");
12         fprintf(stderr, "\n");
13         fprintf(stderr, "  -h, --help                      print usage information\n");
14         fprintf(stderr, "  -c, --num-cards                 set number of input cards (default 2)\n");
15         fprintf(stderr, "  -t, --theme=FILE                choose theme (default theme.lua)\n");
16         fprintf(stderr, "  -v, --va-display=SPEC           VA-API device for H.264 encoding\n");
17         fprintf(stderr, "                                    ($DISPLAY spec or /dev/dri/render* path)\n");
18         fprintf(stderr, "      --http-uncompressed-video   send uncompressed NV12 video to HTTP clients\n");
19         fprintf(stderr, "      --http-mux=NAME             mux to use for HTTP streams (default " DEFAULT_STREAM_MUX_NAME ")\n");
20         fprintf(stderr, "      --http-coarse-timebase      use less timebase for HTTP (recommended for muxers\n");
21         fprintf(stderr, "                                  that handle large pts poorly, like e.g. MP4)\n");
22         fprintf(stderr, "      --flat-audio                start with most audio processing turned off\n");
23         fprintf(stderr, "      --no-flush-pbos             do not explicitly signal texture data uploads\n");
24         fprintf(stderr, "                                    (will give display corruption, but makes it\n");
25         fprintf(stderr, "                                    possible to run with apitrace in real time)\n");
26 }
27
28 void parse_flags(int argc, char * const argv[])
29 {
30         static const option long_options[] = {
31                 { "help", no_argument, 0, 'h' },
32                 { "num-cards", required_argument, 0, 'c' },
33                 { "theme", required_argument, 0, 't' },
34                 { "va-display", required_argument, 0, 1000 },
35                 { "http-uncompressed-video", no_argument, 0, 1001 },
36                 { "http-mux", required_argument, 0, 1004 },
37                 { "http-coarse-timebase", no_argument, 0, 1005 },
38                 { "flat-audio", no_argument, 0, 1002 },
39                 { "no-flush-pbos", no_argument, 0, 1003 },
40                 { 0, 0, 0, 0 }
41         };
42         for ( ;; ) {
43                 int option_index = 0;
44                 int c = getopt_long(argc, argv, "c:t:", long_options, &option_index);
45
46                 if (c == -1) {
47                         break;
48                 }
49                 switch (c) {
50                 case 'c':
51                         global_flags.num_cards = atoi(optarg);
52                         break;
53                 case 't':
54                         global_flags.theme_filename = optarg;
55                         break;
56                 case 1000:
57                         global_flags.va_display = optarg;
58                         break;
59                 case 1001:
60                         global_flags.uncompressed_video_to_http = true;
61                         break;
62                 case 1004:
63                         global_flags.stream_mux_name = optarg;
64                         break;
65                 case 1005:
66                         global_flags.stream_coarse_timebase = true;
67                         break;
68                 case 1002:
69                         global_flags.flat_audio = true;
70                         break;
71                 case 1003:
72                         global_flags.flush_pbos = false;
73                         break;
74                 case 'h':
75                         usage();
76                         exit(0);
77                 default:
78                         fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
79                         fprintf(stderr, "\n");
80                         usage();
81                         exit(1);
82                 }
83         }
84 }