YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FfmpegGrabber_ParamsParser.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6
7// Generated by yarpDeviceParamParserGenerator (1.0)
8// This is an automatically generated file. Please do not edit it.
9// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.
10
11// Generated on: Sat Apr 6 12:45:14 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FfmpegGrabberParamsCOMPONENT, "yarp.device.FfmpegGrabber")
20}
21
22
26
27
28std::vector<std::string> FfmpegGrabber_ParamsParser::getListOfParams() const
29{
30 std::vector<std::string> params;
31 params.push_back("source");
32 params.push_back("loop");
33 params.push_back("sync");
34 params.push_back("nodelay");
35 params.push_back("pace");
36 params.push_back("v4l");
37 params.push_back("v4l1");
38 params.push_back("v4l2");
39 params.push_back("ieee1394");
40 params.push_back("v4ldevice");
41 params.push_back("audio");
42 params.push_back("audio_rate");
43 params.push_back("channels");
44 params.push_back("time_base_num");
45 params.push_back("time_base_den");
46 params.push_back("channel");
47 params.push_back("standard");
48 params.push_back("width");
49 params.push_back("height");
50 params.push_back("devname");
51 return params;
52}
53
54
56{
57 //Check for --help option
58 if (config.check("help"))
59 {
60 yCInfo(FfmpegGrabberParamsCOMPONENT) << getDocumentationOfDeviceParams();
61 }
62
63 std::string config_string = config.toString();
64 yarp::os::Property prop_check(config_string.c_str());
65 //Parser of parameter source
66 {
67 if (config.check("source"))
68 {
69 m_source = config.find("source").asString();
70 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'source' using value:" << m_source;
71 }
72 else
73 {
74 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'source' using DEFAULT value:" << m_source;
75 }
76 prop_check.unput("source");
77 }
78
79 //Parser of parameter loop
80 {
81 if (config.check("loop"))
82 {
83 m_loop = config.find("loop").asBool();
84 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'loop' using value:" << m_loop;
85 }
86 else
87 {
88 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'loop' using DEFAULT value:" << m_loop;
89 }
90 prop_check.unput("loop");
91 }
92
93 //Parser of parameter sync
94 {
95 if (config.check("sync"))
96 {
97 m_sync = config.find("sync").asString();
98 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'sync' using value:" << m_sync;
99 }
100 else
101 {
102 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'sync' using DEFAULT value:" << m_sync;
103 }
104 prop_check.unput("sync");
105 }
106
107 //Parser of parameter nodelay
108 {
109 if (config.check("nodelay"))
110 {
111 m_nodelay = config.find("nodelay").asBool();
112 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'nodelay' using value:" << m_nodelay;
113 }
114 else
115 {
116 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'nodelay' using DEFAULT value:" << m_nodelay;
117 }
118 prop_check.unput("nodelay");
119 }
120
121 //Parser of parameter pace
122 {
123 if (config.check("pace"))
124 {
125 m_pace = config.find("pace").asFloat64();
126 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'pace' using value:" << m_pace;
127 }
128 else
129 {
130 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'pace' using DEFAULT value:" << m_pace;
131 }
132 prop_check.unput("pace");
133 }
134
135 //Parser of parameter v4l
136 {
137 if (config.check("v4l"))
138 {
139 m_v4l = config.find("v4l").asBool();
140 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l' using value:" << m_v4l;
141 }
142 else
143 {
144 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l' using DEFAULT value:" << m_v4l;
145 }
146 prop_check.unput("v4l");
147 }
148
149 //Parser of parameter v4l1
150 {
151 if (config.check("v4l1"))
152 {
153 m_v4l1 = config.find("v4l1").asBool();
154 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l1' using value:" << m_v4l1;
155 }
156 else
157 {
158 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l1' using DEFAULT value:" << m_v4l1;
159 }
160 prop_check.unput("v4l1");
161 }
162
163 //Parser of parameter v4l2
164 {
165 if (config.check("v4l2"))
166 {
167 m_v4l2 = config.find("v4l2").asBool();
168 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l2' using value:" << m_v4l2;
169 }
170 else
171 {
172 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4l2' using DEFAULT value:" << m_v4l2;
173 }
174 prop_check.unput("v4l2");
175 }
176
177 //Parser of parameter ieee1394
178 {
179 if (config.check("ieee1394"))
180 {
181 m_ieee1394 = config.find("ieee1394").asBool();
182 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'ieee1394' using value:" << m_ieee1394;
183 }
184 else
185 {
186 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'ieee1394' using DEFAULT value:" << m_ieee1394;
187 }
188 prop_check.unput("ieee1394");
189 }
190
191 //Parser of parameter v4ldevice
192 {
193 if (config.check("v4ldevice"))
194 {
195 m_v4ldevice = config.find("v4ldevice").asString();
196 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4ldevice' using value:" << m_v4ldevice;
197 }
198 else
199 {
200 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'v4ldevice' using DEFAULT value:" << m_v4ldevice;
201 }
202 prop_check.unput("v4ldevice");
203 }
204
205 //Parser of parameter audio
206 {
207 if (config.check("audio"))
208 {
209 m_audio = config.find("audio").asString();
210 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'audio' using value:" << m_audio;
211 }
212 else
213 {
214 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'audio' using DEFAULT value:" << m_audio;
215 }
216 prop_check.unput("audio");
217 }
218
219 //Parser of parameter audio_rate
220 {
221 if (config.check("audio_rate"))
222 {
223 m_audio_rate = config.find("audio_rate").asInt64();
224 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'audio_rate' using value:" << m_audio_rate;
225 }
226 else
227 {
228 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'audio_rate' using DEFAULT value:" << m_audio_rate;
229 }
230 prop_check.unput("audio_rate");
231 }
232
233 //Parser of parameter channels
234 {
235 if (config.check("channels"))
236 {
237 m_channels = config.find("channels").asInt64();
238 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'channels' using value:" << m_channels;
239 }
240 else
241 {
242 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'channels' using DEFAULT value:" << m_channels;
243 }
244 prop_check.unput("channels");
245 }
246
247 //Parser of parameter time_base_num
248 {
249 if (config.check("time_base_num"))
250 {
251 m_time_base_num = config.find("time_base_num").asInt64();
252 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'time_base_num' using value:" << m_time_base_num;
253 }
254 else
255 {
256 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'time_base_num' using DEFAULT value:" << m_time_base_num;
257 }
258 prop_check.unput("time_base_num");
259 }
260
261 //Parser of parameter time_base_den
262 {
263 if (config.check("time_base_den"))
264 {
265 m_time_base_den = config.find("time_base_den").asInt64();
266 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'time_base_den' using value:" << m_time_base_den;
267 }
268 else
269 {
270 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'time_base_den' using DEFAULT value:" << m_time_base_den;
271 }
272 prop_check.unput("time_base_den");
273 }
274
275 //Parser of parameter channel
276 {
277 if (config.check("channel"))
278 {
279 m_channel = config.find("channel").asInt64();
280 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'channel' using value:" << m_channel;
281 }
282 else
283 {
284 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'channel' using DEFAULT value:" << m_channel;
285 }
286 prop_check.unput("channel");
287 }
288
289 //Parser of parameter standard
290 {
291 if (config.check("standard"))
292 {
293 m_standard = config.find("standard").asString();
294 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'standard' using value:" << m_standard;
295 }
296 else
297 {
298 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'standard' using DEFAULT value:" << m_standard;
299 }
300 prop_check.unput("standard");
301 }
302
303 //Parser of parameter width
304 {
305 if (config.check("width"))
306 {
307 m_width = config.find("width").asInt64();
308 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'width' using value:" << m_width;
309 }
310 else
311 {
312 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'width' using DEFAULT value:" << m_width;
313 }
314 prop_check.unput("width");
315 }
316
317 //Parser of parameter height
318 {
319 if (config.check("height"))
320 {
321 m_height = config.find("height").asInt64();
322 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'height' using value:" << m_height;
323 }
324 else
325 {
326 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'height' using DEFAULT value:" << m_height;
327 }
328 prop_check.unput("height");
329 }
330
331 //Parser of parameter devname
332 {
333 if (config.check("devname"))
334 {
335 m_devname = config.find("devname").asString();
336 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'devname' using value:" << m_devname;
337 }
338 else
339 {
340 yCInfo(FfmpegGrabberParamsCOMPONENT) << "Parameter 'devname' using DEFAULT value:" << m_devname;
341 }
342 prop_check.unput("devname");
343 }
344
345 /*
346 //This code check if the user set some parameter which are not check by the parser
347 //If the parser is set in strict mode, this will generate an error
348 if (prop_check.size() > 0)
349 {
350 bool extra_params_found = false;
351 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
352 {
353 if (m_parser_is_strict)
354 {
355 yCError(FfmpegGrabberParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
356 extra_params_found = true;
357 }
358 else
359 {
360 yCWarning(FfmpegGrabberParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
361 }
362 }
363
364 if (m_parser_is_strict && extra_params_found)
365 {
366 return false;
367 }
368 }
369 */
370 return true;
371}
372
373
375{
376 std::string doc;
377 doc = doc + std::string("\n=============================================\n");
378 doc = doc + std::string("This is the help for device: FfmpegGrabber\n");
379 doc = doc + std::string("\n");
380 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
381 doc = doc + std::string("'source': media file to read from\n");
382 doc = doc + std::string("'loop': media should loop (default)\n");
383 doc = doc + std::string("'sync': sync on image or audio (if have to choose)?\n");
384 doc = doc + std::string("'nodelay': media will play in simulated realtime unless this is present\n");
385 doc = doc + std::string("'pace': simulated realtime multiplier factor (must be <1 right now)\n");
386 doc = doc + std::string("'v4l': if present, read from video4linux\n");
387 doc = doc + std::string("'v4l1': if present, read from video4linux\n");
388 doc = doc + std::string("'v4l2': if present, read from video4linux\n");
389 doc = doc + std::string("'ieee1394': if present, read from firewire\n");
390 doc = doc + std::string("'v4ldevice': device name\n");
391 doc = doc + std::string("'audio': optional audio device name\n");
392 doc = doc + std::string("'audio_rate': audio sample rate\n");
393 doc = doc + std::string("'channels': number of channels\n");
394 doc = doc + std::string("'time_base_num': numerator of basic time unit\n");
395 doc = doc + std::string("'time_base_den': denominator of basic time unit\n");
396 doc = doc + std::string("'channel': channel identifier\n");
397 doc = doc + std::string("'standard': pal versus ntsc\n");
398 doc = doc + std::string("'width': width of image\n");
399 doc = doc + std::string("'height': height of image\n");
400 doc = doc + std::string("'devname': firewire device name\n");
401 doc = doc + std::string("\n");
402 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
403 doc = doc + " yarpdev --device ffmpeg_grabber --source default.avi --loop true --sync image --nodelay false --pace 1.0 --v4l false --v4l1 false --v4l2 false --ieee1394 false --v4ldevice /dev/video0 --audio /dev/dsp --audio_rate 44100 --channels 1 --time_base_num 1 --time_base_den 29 --channel 0 --standard <optional_value> --width 640 --height 480 --devname /dev/dv1394\n";
404 doc = doc + std::string("Using only mandatory params:\n");
405 doc = doc + " yarpdev --device ffmpeg_grabber\n";
406 doc = doc + std::string("=============================================\n\n"); return doc;
407}
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
A class for storing options and configuration information.
Definition Property.h:33
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
#define yCInfo(component,...)
#define YARP_LOG_COMPONENT(name,...)