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 note:
14// This function is intentionally non-Doxygen: the authoritative API documentation is in
15// gstreamer_options.h. Here we keep only implementation-focused comments.
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 a GStreamerDefinition (format, filename, type).
21 auto goutput_node = gopts->getOptionNode("gstreamer");
22
23 for (auto goutput_item : goutput_node) {
24 goutputs.emplace_back(
25 gopts->get_variable_in_option<string>(goutput_item, "format", goptions::NODFLT),
26 gopts->get_variable_in_option<string>(goutput_item, "filename", goptions::NODFLT),
27 gopts->get_variable_in_option<string>(goutput_item, "type", "event")
28 );
29 }
30
31 return goutputs;
32}
33
34
35// returns array of options definitions
36// Implementation note:
37// The help string is user-facing CLI documentation (not Doxygen). Doxygen docs live in the header.
40
41 string help = "Define a Output format and name\n";
42 help += "This option defines a GStreamer output. It can be used to write events or frame streams.\n";
43 help += "\n";
44 help += "The file extension is added automatically based on the format.\n";
45 help += "Supported formats:\n";
46 for (auto& format : GStreamer::supported_formats()) { help += " - " + format + "\n"; }
47 help += "\n";
48 help += "Output types\n";
49 help += "\n";
50 help += " - event: write events\n";
51 help += " - stream: write frame stream\n";
52 help += "\n";
53 help += "Example that defines two gstreamer outputs:\n";
54 help += "-gstreamer=\"[{format: root, filename: out}, {format: jlabsro, filename: out}}]\"\n";
55
56 // Buffer flush limit: how many events are kept in memory before being flushed by each streamer.
58 "number of events kept in memory before flushing them to the filestream"), help);
59
60 vector<GVariable> gstreamer = {
61 {"filename", goptions::NODFLT, "name of output file"},
62 {"format", goptions::NODFLT, "format of output file"},
63 {"type", "event", "type of output file"},
64
65 };
66
67 goptions.defineOption(GSTREAMER_LOGGER, "define a gstreamer output", gstreamer, help);
68
70
71 return goptions;
72}
73}
static const std::vector< std::string > & supported_formats()
Return the list of supported output formats.
Definition gstreamer.cc:8
Shared constants and error codes for the gstreamer module.
#define DEFAULT_GSTREAMER_BUFFER_FLUSH_LIMIT
Default number of buffered events before a GStreamer flushes its internal event buffer.
Core streaming interface for gstreamer output plugins.
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
vector< GStreamerDefinition > getGStreamerDefinition(const std::shared_ptr< GOptions > &gopts)
Parse gstreamer output definitions from options.
GOptions defineOptions()
Contribute gstreamer options to the global option set.