]> git.sesse.net Git - nageru/commitdiff
Add an option to record to another directory than the current one.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Apr 2017 10:52:22 +0000 (12:52 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Apr 2017 10:52:22 +0000 (12:52 +0200)
flags.cpp
flags.h
video_encoder.cpp

index acd054181c2403de736d7b0fe1cbef8d734761be..f7a29f7330eb34f218d1146c97ddf438b7441352 100644 (file)
--- a/flags.cpp
+++ b/flags.cpp
@@ -70,6 +70,7 @@ void usage()
        fprintf(stderr, "  -o, --output-card=CARD          also output signal to the given card (default none)\n");
        fprintf(stderr, "  -t, --theme=FILE                choose theme (default theme.lua)\n");
        fprintf(stderr, "  -I, --theme-dir=DIR             search for theme in this directory (can be given multiple times)\n");
+       fprintf(stderr, "  -r, --recording-dir=DIR         where to store disk recording\n");
        fprintf(stderr, "  -v, --va-display=SPEC           VA-API device for H.264 encoding\n");
        fprintf(stderr, "                                    ($DISPLAY spec or /dev/dri/render* path)\n");
        fprintf(stderr, "  -m, --map-signal=SIGNAL,CARD    set a default card mapping (can be given multiple times)\n");
@@ -145,6 +146,7 @@ void parse_flags(int argc, char * const argv[])
                { "output-card", required_argument, 0, 'o' },
                { "theme", required_argument, 0, 't' },
                { "theme-dir", required_argument, 0, 'I' },
+               { "recording-dir", required_argument, 0, 'r' },
                { "map-signal", required_argument, 0, 'm' },
                { "input-mapping", required_argument, 0, 'M' },
                { "va-display", required_argument, 0, 'v' },
@@ -197,7 +199,7 @@ void parse_flags(int argc, char * const argv[])
        string output_ycbcr_coefficients = "auto";
        for ( ;; ) {
                int option_index = 0;
-               int c = getopt_long(argc, argv, "c:t:I:v:m:M:w:h:", long_options, &option_index);
+               int c = getopt_long(argc, argv, "c:t:I:r:v:m:M:w:h:", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -221,6 +223,9 @@ void parse_flags(int argc, char * const argv[])
                case 'I':
                        theme_dirs.push_back(optarg);
                        break;
+               case 'r':
+                       global_flags.recording_dir = optarg;
+                       break;
                case 'm': {
                        char *ptr = strchr(optarg, ',');
                        if (ptr == nullptr) {
diff --git a/flags.h b/flags.h
index 7f39fdde11be10b18980c82ac5e3dfc4461f169c..66912defd00423dbb7289c21e928ea7781aad2bc 100644 (file)
--- a/flags.h
+++ b/flags.h
@@ -18,6 +18,7 @@ struct Flags {
        bool x264_video_to_http = false;
        bool x264_video_to_disk = false;  // Disables Quick Sync entirely. Implies x264_video_to_http == true.
        std::vector<std::string> theme_dirs { ".", "/usr/local/share/nageru" };
+       std::string recording_dir = ".";
        std::string theme_filename = "theme.lua";
        bool locut_enabled = true;
        bool gain_staging_auto = true;
index 6a4ebf7219b04ec7b7bd5c85cdcb0bff4ca60680..029652a6f576720f17f4ccfaec02d8503e4fc312 100644 (file)
@@ -40,7 +40,8 @@ string generate_local_dump_filename(int frame)
        // Use the frame number to disambiguate between two cuts starting
        // on the same second.
        char filename[256];
-       snprintf(filename, sizeof(filename), "%s%s-f%02d%s",
+       snprintf(filename, sizeof(filename), "%s/%s%s-f%02d%s",
+               global_flags.recording_dir.c_str(),
                LOCAL_DUMP_PREFIX, timestamp, frame % 100, LOCAL_DUMP_SUFFIX);
        return filename;
 }