gstreamer
Loading...
Searching...
No Matches
gstreamer_options.cc
Go to the documentation of this file.
1// gstreamer
2#include "gstreamer_options.h"
4
6#include "gstreamer.h"
7
8// namespace to define options
9namespace gstreamer {
10using std::string;
11using std::vector;
12
13// Implementation summary:
14// Parse the user-provided "gstreamer" option node into normalized
15// GStreamerDefinition objects used later by plugin-loading helpers.
16vector<GStreamerDefinition> getGStreamerDefinition(const std::shared_ptr<GOptions>& gopts) {
17 vector<GStreamerDefinition> goutputs;
18
19 // The "gstreamer" option node contains a list of output objects.
20 // Each object is flattened into one GStreamerDefinition:
21 // - format : plugin selector
22 // - filename : output base name
23 // - type : semantic stream type, defaulting to "event"
24 auto goutput_node = gopts->getOptionNode("gstreamer");
25
26 for (auto goutput_item : goutput_node) {
27 goutputs.emplace_back(
28 gopts->get_variable_in_option<string>(goutput_item, "format", goptions::NODFLT),
29 gopts->get_variable_in_option<string>(goutput_item, "filename", goptions::NODFLT),
30 gopts->get_variable_in_option<string>(goutput_item, "type", "event")
31 );
32 }
33
34 return goutputs;
35}
36
37
38// Implementation summary:
39// Define the gstreamer module options and aggregate the options contributed
40// by dependent modules used together with the streaming layer.
43
44 // User-facing CLI help for the -gstreamer structured option.
45 // The file extension is added automatically by the selected plugin.
46 string help = "Define a Output format and name\n";
47 help += "This option defines a GStreamer output. It can be used to write events or frame streams.\n";
48 help += "\n";
49 help += "The file extension is added automatically based on the format.\n";
50 help += "Supported formats:\n";
51 for (auto& format : GStreamer::supported_formats()) { help += " - " + format + "\n"; }
52 help += "\n";
53 help += "Output types\n";
54 help += "\n";
55 help += " - event: write events\n";
56 help += " - stream: write frame stream\n";
57 help += "\n";
58 help += "Example that defines two gstreamer outputs:\n";
59 help += "-gstreamer=\"[{format: root, filename: out}, {format: jlabsro, filename: out}}]\"\n";
60
61 // Buffer flush limit:
62 // controls how many events each streamer instance may retain in memory
63 // before the base class forces a flush to the backend.
65 "number of events kept in memory before flushing them to the filestream"), help);
66
67 // Schema of each object in the -gstreamer array.
68 vector<GVariable> gstreamer = {
69 {"filename", goptions::NODFLT, "name of output file"},
70 {"format", goptions::NODFLT, "format of output file"},
71 {"type", "event", "type of output file"},
72 };
73
74 goptions.defineOption(GSTREAMER_LOGGER, "define a gstreamer output", gstreamer, help);
75
76 // Merge dependent-module options so callers can build a single composite
77 // GOptions definition for applications and examples.
79
80 return goptions;
81}
82}
static const std::vector< std::string > & supported_formats()
Return the list of output format tokens supported by the module.
Definition gstreamer.cc:11
vector< GStreamerDefinition > getGStreamerDefinition(const std::shared_ptr< GOptions > &gopts)
Parse all configured gstreamer output definitions from the options container.
GOptions defineOptions()
Define the options contributed by the gstreamer module.
Shared constants and error codes for the gstreamer module.
#define DEFAULT_GSTREAMER_BUFFER_FLUSH_LIMIT
Default number of buffered events before a GStreamer instance flushes its internal buffer.
Core streaming interface and helper utilities for the gstreamer module.
Option and configuration helpers for the gstreamer module.
constexpr const char * GSTREAMER_LOGGER
Logger category name used by gstreamer components.
GOptions defineOptions()
const std::string NODFLT