YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ffmpegPortmonitor.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
15// Local imports
16#include "ffmpegPortmonitor.h"
17#include "constants.h"
18// YARP imports
20#include <yarp/os/Time.h>
21#include <yarp/sig/all.h>
22// Standard imports
23#include <cstring>
24#include <cmath>
25#include <algorithm>
26#include <iostream>
27#include <sstream>
28#include <mutex>
29#include <iomanip>
30
31// Ffmpeg imports
32extern "C" {
33 #include <libavcodec/avcodec.h>
34 #include <libavutil/opt.h>
35 #include <libavutil/imgutils.h>
36 #include <libavformat/avformat.h>
37 #include <libswscale/swscale.h>
38}
39
40using namespace yarp::os;
41using namespace yarp::sig;
42
43namespace {
45 "yarp.carrier.portmonitor.image_compression_ffmpeg",
49 nullptr)
50
51} // anonymous namespace
52
53// As per version 5.1.2 of ffmpeg, there seem to be race conditions between sws_scale and
54// sws_freeContext even when called from different instances on different threads.
55// We use a static mutex to prevent segmentation faults when connecting two port monitors
56// to the same sender or receiver.
57static std::mutex instances_mutex;
58
60{
61 // Check if this is sender or not
62 senderSide = (options.find("sender_side").asBool());
63 printStatistics = false;
69
70 // Parse command line parameters and set them into global variable "paramsMap"
71 int frameRate = 15;
73 return false;
74 }
75
76 // Prepare codec context
77 if (codecContext == NULL) {
79 } else {
80 yCError(FFMPEGMONITOR, "Codec context is already allocated");
81 return false;
82 }
83 if (!codecContext) {
84 yCError(FFMPEGMONITOR, "Could not allocate video codec context");
85 return false;
86 }
87
88 if (!codec->pix_fmts)
89 {
90 yCWarning(FFMPEGMONITOR, "The specified codec (%s) has unknown available pixel formats. There might be visualization issues.", codec->name);
91 }
92 else
93 {
94 std::stringstream pixelFormatList;
95 bool found = false;
96 size_t i = 0;
97 AVPixelFormat test = codec->pix_fmts[i];
98
99 if (test == AV_PIX_FMT_NONE)
100 {
101 yCError(FFMPEGMONITOR, "The specified codec (%s) has no available pixel format.", codec->name);
102 return false;
103 }
104
105 pixelFormatList << test;
106 while (test != AV_PIX_FMT_NONE)
107 {
108 if (test == pixelFormat)
109 {
110 found = true;
111 break;
112 }
113 ++i;
114 test = codec->pix_fmts[i];
115
116 if (test != AV_PIX_FMT_NONE)
117 {
118 pixelFormatList << ", " << test;
119 }
120 }
121
122 if (!found)
123 {
125
127 {
128 yCError(FFMPEGMONITOR, "The specified codec (%s) is not compatible with the default pixel format AV_PIX_FMT_YUV420P (code %d). "
129 "Try specifying the suggested pixel format of the codec with the option \"pixel_format.%d\". "
130 "The available pixel formats are %s.",
132 }
133 else
134 {
135 yCError(FFMPEGMONITOR, "The specified codec (%s) is not compatible with the specified pixel format (code %d). "
136 "The available pixel formats are as follows %s (suggested = %d).",
137 codec->name, pixelFormat, pixelFormatList.str().c_str(), suggestedFormat);
138 }
139 return false;
140 }
141 }
142
143 firstTime = true;
144
145 // Set time base parameter
146 codecContext->time_base.num = 1;
147 codecContext->time_base.den = frameRate;
148 // Set command line params
149 if (setCommandLineParams() == -1) {
150 return false;
151 }
152
153 return true;
154}
155
157{
158 paramsMap.clear();
159
160 // Check if codec context is freeable, if yes free it.
161 if (codecContext != NULL) {
162#if LIBAVCODEC_VERSION_MAJOR < 61
163 // See https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavcodec/avcodec.h#L2381-L2384
165#endif
168 }
169}
170
172{
173 yCTrace(FFMPEGMONITOR, "setparam");
174 return false;
175}
176
178{
179 yCTrace(FFMPEGMONITOR, "getparam");
180 return false;
181}
182
184{
185 if (senderSide) {
186 // If sender side
187 yCTrace(FFMPEGMONITOR, "accept - sender");
188 // Try to cast the Thing into an Image
189 Image* img = thing.cast_as< Image >();
190 // If cast fails, try to cast the Thing into a Bottle
191 if(img == nullptr) {
192 Bottle* bt = thing.cast_as<Bottle>();
193 // If cast fails, return error
194 if (bt == nullptr) {
195 yCError(FFMPEGMONITOR, "Expected type Image or Bottle in sender side, but got wrong data type!");
196 return false;
197 }
198 }
199 }
200 else {
201 // If receiver side
202 yCTrace(FFMPEGMONITOR, "accept - receiver");
203 // Try to cast the Thing into a Bottle
204 Bottle* bt = thing.cast_as<Bottle>();
205 // If cast fails, return error
206 if(bt == nullptr){
207 yCError(FFMPEGMONITOR, "Expected type Bottle in receiver side, but got wrong data type!");
208 return false;
209 }
210 }
211 return true;
212}
213
215{
216 double now = yarp::os::Time::now();
217 const double printInterval = 5.0;
218
219 if (statisticsCounter < 0)
220 {
221 previousFrameTime = now;
224 }
225 else
226 {
227 size_t outputData{0};
228 inputBottle.toBinary(&outputData);
229 double dt = now - previousFrameTime;
230 double bandwidth = outputData * 8 / dt /1000;
235
236 }
238 {
241 std::stringstream bandwidthString, lagString;
242 bandwidthString << std::fixed << std::setprecision(2) << bandwidthRunningAverage;
243 lagString << std::fixed << std::setprecision(3) << lagRunningAverage * 1000;
244 yCInfo(FFMPEGMONITOR, "Statistics: current bandwidth %s kb/s, codec computational time %s ms",
245 bandwidthString.str().c_str(), lagString.str().c_str());
246 }
247}
248
250{
251 double startTime = yarp::os::Time::now();
252 if (senderSide) {
253 bool success = true;
254 yCTrace(FFMPEGMONITOR, "update - sender");
255 // Cast Thing into an Image
256 Image* img = thing.cast_as< Image >();
257
258 if (img == nullptr) {
259 Bottle* bot = thing.cast_as<Bottle>();
261 {
262 yCError(FFMPEGMONITOR, "The input type is a Bottle, but it cannot be copied to an Image");
263 success = false;
264 }
265 img = &imageBottleBuffer;
266 }
267
268 // Allocate memory for packet
270 if (packet == NULL) {
271 yCError(FFMPEGMONITOR, "Error in packet allocation");
272 success = false;
273 }
274
275 // Call compress function
276 if (success && compress(img, packet) != 0) {
277 yCError(FFMPEGMONITOR, "Error in compression");
278 success = false;
279 }
280
281 // Insert compressed image into a Bottle to be sent
282 data.clear();
283
284 int successCode = success ? 1 : 0;
286 data.addInt32(img->width());
287 data.addInt32(img->height());
288 data.addInt32(img->getPixelCode());
289 data.addInt32(img->getPixelSize());
290
291 if (success) { // If compression was successful, insert also compressed data
292 // Packet
293 Value p(packet, sizeof(*packet));
294 data.add(p);
295 // Packet data
296 Value d(packet->data, packet->size);
297 data.add(d);
298 // Buffer size
299 data.addInt32(packet->buf->size);
300 // Buffer data
301 Value bd(packet->buf->data, packet->buf->size);
302 data.add(bd);
303
304 // Side data elements
305 for (int i = 0; i < packet->side_data_elems; i++) {
306 data.addInt32(packet->side_data[i].size);
307 data.addInt32(packet->side_data[i].type);
308 Value sd(packet->side_data[i].data, packet->side_data[i].size);
309 data.add(sd);
310 }
311 }
312
313 if (printStatistics)
314 {
316 }
317
319 // Free the memory allocated for the packet
321 }
322 else {
323
324 yCTrace(FFMPEGMONITOR, "update - receiver");
325 // Cast the Thin as a Bottle
327 // Fill the final image with zeros
328 imageOut.zero();
329 // Extract decompression data from the Bottle
330 int width = compressedBottle->get(1).asInt32();
331 int height = compressedBottle->get(2).asInt32();
332 int pixelCode = compressedBottle->get(3).asInt32();
333 int pixelSize = compressedBottle->get(4).asInt32();
334 // Set information into final image
335
337 {
340 imageOut.resize(width, height);
341 }
342 else
343 {
344 yCError(FFMPEGMONITOR, "Invalid input pixel code");
345 }
346
347 // Check if compression was successful
348 if (compressedBottle->get(0).asInt32() == 1) {
349 bool success = true;
350 // Get compressed image from Bottle
351 AVPacket* tmp = (AVPacket*) compressedBottle->get(5).asBlob();
352 // Allocate memory for packet
354 // Set all packet parameters
355 packet->dts = tmp->dts;
356 packet->duration = tmp->duration;
357 packet->flags = tmp->flags;
358 packet->pos = tmp->pos;
359 packet->pts = tmp->pts;
360 packet->side_data_elems = 0;
361 packet->stream_index = tmp->stream_index;
362 packet->size = tmp->size;
363 // Image data
364 packet->data = (uint8_t *) compressedBottle->get(6).asBlob();
365 // Buffer data
366 packet->buf = av_buffer_create((uint8_t *) compressedBottle->get(8).asBlob(),
367 compressedBottle->get(7).asInt32(), av_buffer_default_free,
368 nullptr, AV_BUFFER_FLAG_READONLY);
369
370 // Packet side data
371 for (int i = 0; i < tmp->side_data_elems; i++) {
372
374 (AVPacketSideDataType) compressedBottle->get(10).asInt32(), // Type
375 (uint8_t *) compressedBottle->get(11).asBlob(), // Data
376 compressedBottle->get(9).asInt32()); // Size
377 if (ret < 0) {
378 success = false;
379 break;
380 }
381 }
382
383 // Call to decompress function
384 if (success && decompress(packet, width, height, pixelCode) != 0) {
385 yCError(FFMPEGMONITOR, "Error in decompression");
386 }
387
388 if (printStatistics)
389 {
391 }
392
393 // Free memory allocated for side data and packet
394 av_freep(&packet->side_data);
396
397 }
398
400
401 }
402 return th;
403}
404
406
407 yCTrace(FFMPEGMONITOR, "compress");
410
411 // Get width and height
412 int w = img->width();
413 int h = img->height();
414
415 // Allocate video frame for original frames
417 if (startFrame == NULL) {
418 yCError(FFMPEGMONITOR, "Cannot allocate starting frame!");
419 return -1;
420 }
421
422 // Allocate a video frame for end frame
424 if (endFrame == NULL) {
425 yCError(FFMPEGMONITOR, "Cannot allocate end frame!");
427 return -1;
428 }
429
430 // Allocate space into start frame to contain data
431 int success = av_image_alloc(startFrame->data, startFrame->linesize,
432 w, h,
434
435 if (success < 0) {
436 yCError(FFMPEGMONITOR, "Cannot allocate starting frame buffer!");
439 return -1;
440 }
441
442 // Set Image data into AVFrame
443 startFrame->linesize[0] = img->getRowSize();
444 // Free old pointer (because we will use the buffer contained into img)
445 av_freep(&startFrame->data[0]);
446 startFrame->data[0] = img->getRawImage();
447 startFrame->height = h;
448 startFrame->width = w;
450
451 // Allocate memory for end frame data
452 success = av_image_alloc(endFrame->data, endFrame->linesize,
453 w, h, pixelFormat, 16);
454
455 if (success < 0) {
456 yCError(FFMPEGMONITOR, "Cannot allocate end frame buffer!");
459 return -1;
460 }
461
462 // Set end frame parameters
463 endFrame->height = h;
464 endFrame->width = w;
465 endFrame->format = pixelFormat;
466
467 {
468 std::lock_guard<std::mutex> lock(instances_mutex);
469
470 // Convert the image from start format into end format
471 static struct SwsContext *img_convert_ctx;
472
473 // Allocate context for conversion
476 w, h,
479 NULL, NULL, NULL);
480 if (img_convert_ctx == NULL) {
481 yCError(FFMPEGMONITOR, "Cannot initialize pixel format conversion context!");
482 av_freep(&endFrame->data[0]);
485 return -1;
486 }
487
488 // Perform conversion
489 int ret = sws_scale(img_convert_ctx, startFrame->data, startFrame->linesize, 0,
490 h, endFrame->data, endFrame->linesize);
491
492 if (ret < 0) {
493 yCError(FFMPEGMONITOR, "Could not convert pixel format!");
495 av_freep(&endFrame->data[0]);
498 return -1;
499 }
500
501 if (firstTime) {
502 // If this is the first compression
503
504 // Set codec context parameters
505 codecContext->width = w;
506 codecContext->height = h;
507 codecContext->pix_fmt = pixelFormat;
508
509 // Open codec
511 if (ret < 0) {
512 yCError(FFMPEGMONITOR, "Could not open codec");
514 av_freep(&endFrame->data[0]);
517 return -1;
518 }
519 firstTime = false;
520 }
521
522 // Set presentation timestamp
523#if LIBAVCODEC_VERSION_MAJOR >= 61
524 // See https://github.com/FFmpeg/FFmpeg/commit/6b6f7db81932f94876ff4bcfd2da0582b8ab897e
525 endFrame->pts = codecContext->frame_num;
526#else
527 endFrame->pts = codecContext->frame_number;
528#endif
529
530 // Send image frame to codec
532 if (ret < 0) {
533 yCError(FFMPEGMONITOR, "Error sending a frame for encoding");
535 av_freep(&endFrame->data[0]);
538 return -1;
539 }
540
541 // Receive compressed data into packet
544 av_freep(&endFrame->data[0]);
547
548
549 if (ret == AVERROR(EAGAIN)) {
550 // Not enough data
551 yCError(FFMPEGMONITOR, "Error EAGAIN");
552 return -1;
553 } else if (ret == AVERROR_EOF) {
554 // End of file reached
555 yCError(FFMPEGMONITOR, "Error EOF");
556 return -1;
557 } else if (ret < 0) {
558 yCError(FFMPEGMONITOR, "Error during encoding");
559 return -1;
560 }
561 }
562
563 return 0;
564}
565
567
568 yCTrace(FFMPEGMONITOR, "decompress");
571
572 if (firstTime) {
573 // If this is the first decompression
574
575 // Set codec context parameters
576 codecContext->width = w;
577 codecContext->height = h;
578 codecContext->pix_fmt = pixelFormat;
579
580 // Open codec
582 if (ret < 0) {
583 yCError(FFMPEGMONITOR, "Could not open codec");
584 return -1;
585 }
586 firstTime = false;
587 }
588
589 // Allocate video frame
591 if (startFrame == NULL) {
592 yCError(FFMPEGMONITOR, "Could not allocate start frame!");
593 return -1;
594 }
595
596 // Send compressed packet to codec
598 if (ret < 0) {
599 yCError(FFMPEGMONITOR, "Error sending a frame for decoding");
601 return -1;
602 }
603
604 // Receive decompressed image into an AVFrame
606 if (ret == AVERROR(EAGAIN)) {
607 // No enough data
608 yCError(FFMPEGMONITOR, "Error EAGAIN");
610 return -1;
611 }
612 else if (ret == AVERROR_EOF) {
613 // End of file reached
614 yCError(FFMPEGMONITOR, "Error EOF");
616 return -1;
617 }
618 else if (ret < 0) {
619 yCError(FFMPEGMONITOR, "Error during decoding");
621 return -1;
622 }
623
624 // Allocate a video frame for end frame
626 if (endFrame == NULL) {
627 yCError(FFMPEGMONITOR, "Could not allocate start frame!");
629 return -1;
630 }
631
632 // Allocate memory into end frame to contain data
633 int success = av_image_alloc(endFrame->data, endFrame->linesize,
634 w, h,
636
637 if (success < 0) {
638 yCError(FFMPEGMONITOR, "Error allocating end frame buffer!");
641 return -1;
642 }
643
644 // Set end frame parameters
645 endFrame->height = h;
646 endFrame->width = w;
648
649 {
650 std::lock_guard<std::mutex> lock(instances_mutex);
651
652 // Convert the image into RGB format
653 static struct SwsContext *img_convert_ctx;
654
655 // Allocate conversion context
658 w, h,
661 NULL, NULL, NULL);
662 if (img_convert_ctx == NULL) {
663 yCError(FFMPEGMONITOR, "Cannot initialize the pixel format conversion context!");
664 av_freep(&endFrame->data[0]);
667 return -1;
668 }
669
670 // Perform conversion
671 ret = sws_scale(img_convert_ctx, startFrame->data, startFrame->linesize, 0,
672 h, endFrame->data, endFrame->linesize);
673
674 if (ret < 0) {
675 yCError(FFMPEGMONITOR, "Could not convert pixel format!");
676 av_freep(&endFrame->data[0]);
680 return -1;
681 }
682
683 // Copy decompressed data from end frame to imageOut
685
686 // Free allocated memory
687 av_freep(&endFrame->data[0]);
691 }
692
693 return 0;
694}
695
697{
698
699 // Set default pixel format
701
702 bool customEnc = false;
703 bool customDec = false;
704
705 // checks for encoder/decoders
707 {
708 yCError(FFMPEGMONITOR, "`decoder` parameter is not allowed on sender side");
709 return false;
710 }
712 {
713 yCError(FFMPEGMONITOR, "`encoder` parameter is not allowed on receiver side");
714 return false;
715 }
716
718 {
719 std::string paramValue = inputoptions.find(FFMPEGPORTMONITOR_CL_ENCODER_KEY).asString();
720
722 if (!codecOut)
723 {
724 yCError(FFMPEGMONITOR, "Can't find encoder %s", paramValue.c_str());
725 codecOut = nullptr;
726 return false;
727 }
728 customEnc = true;
729 }
730
731 // parse for custom decoder
733 {
734 std::string paramValue = inputoptions.find(FFMPEGPORTMONITOR_CL_DECODER_KEY).asString();
735
737 if (!codecOut)
738 {
739 yCError(FFMPEGMONITOR, "Can't find decoder %s", paramValue.c_str());
740 codecOut = nullptr;
741 return false;
742 }
743 customDec = true;
744 }
745
746 //extra options: pixel format
748 {
750 pixelFormatOut = static_cast<AVPixelFormat>(std::atoi(paramValue.c_str()));
751 }
752
753 //extra options: frame rate
755 {
756 std::string paramValue = inputoptions.find(FFMPEGPORTMONITOR_CL_FRAME_RATE_KEY).asString();
757 frameRate = std::atoi(paramValue.c_str());
758 }
759
760 // extra options: statistics printing
762 {
764 printStatistics = std::atoi(paramValue.c_str());
765 }
766
767 // Iterate through all properties and save unknown parameters to paramsMap
769 std::string inputoptionsStr = inputoptions.toString();
771
772 for (size_t i = 0; i < propertyBottle.size(); i++)
773 {
774 Value& element = propertyBottle.get(i);
775 if (!element.isList()) { continue; }
776
777 Bottle* entry = element.asList();
778 if (entry->size() < 2) { continue; }
779
780 std::string key = entry->get(0).asString();
781
782 // Skip known parameters
788 key == "type" ||
789 key == "filename" ||
790 key == "source" ||
791 key == "destination" ||
792 key == "sender_side" ||
793 key == "receiver_side" ||
794 key == "carrier")
795 { continue;}
796
797
798 // Add unknown parameter to params map
799 std::string value = entry->get(1).toString();
800 paramsMap[key] = value;
801 }
802
803 if (!customEnc && senderSide==true)
804 {
805 yCWarning(FFMPEGMONITOR, "No encoder specified, using default codec (mpeg2video).");
806
807 // Set default codec
810 if (!codecOut) {
811 yCError(FFMPEGMONITOR, "Can't find default codec (mpeg2video).");
812 return false;
813 }
814 }
815 if (!customDec && senderSide==false)
816 {
817 yCWarning(FFMPEGMONITOR, "No decoder specified, using default codec (mpeg2video).");
818
819 // Set default codec
822 if (!codecOut) {
823 yCError(FFMPEGMONITOR, "Can't find default codec (mpeg2video).");
824 return false;
825 }
826 }
827
828 return true;
829}
830
832
833 // Iterate over all saved parameters
834 for (auto const& x : paramsMap) {
835
836 // Get key and value
837 std::string key = x.first;
838 std::string value = x.second;
839
840 // Try to set this pair (key, value) into codec context (global parameters).
841 int globalError = av_opt_set(codecContext, key.c_str(), value.c_str(), 0);
842 // Try to set this pair (key, value) into codec context -> priv data (parameters that are specific for a codec).
843 int privError = av_opt_set(codecContext->priv_data, key.c_str(), value.c_str(), 0);
844
845 // If the param exists, but the value is out of range
847 yCError(FFMPEGMONITOR, "Parameter out of range: %s", key.c_str());
848 return -1;
849 }
850 // If the param exists, but the value is invalid
851 else if (globalError == AVERROR(EINVAL) || privError == AVERROR(EINVAL)) {
852 yCError(FFMPEGMONITOR, "Invalid value for parameter: %s", key.c_str());
853 return -1;
854 }
855 // If the param doesn't exists (we check only in sender side because some parameters doesn't exist in the decoders)
857 yCError(FFMPEGMONITOR, "Parameter not found: %s", key.c_str());
858 return -1;
859 }
860
861 }
862 return 0;
863}
@ VOCAB_PIXEL_INVALID
Definition Image.h:41
void updateStatistics(yarp::os::Bottle &inputBottle, double currentLag)
Print some network statistics.
yarp::sig::FlexImage imageOut
The final decompressed image that will be sent to the original destination.
int statisticsCounter
Utility counter for printing statistics.
int compress(yarp::sig::Image *img, AVPacket *pkt)
This function performs all the compression actions on the incoming Image and saves the resulting comp...
AVPixelFormat pixelFormat
Ffmpeg pixel format.
bool accept(yarp::os::Things &thing) override
This function is used by the port monitor to decide if an incoming packet can be accepted (it tries t...
int setCommandLineParams()
This function iterates over the attribute paramsMap and sets all the specified parameters into the at...
bool firstTime
Boolean variable used to check if the current call to the "compression" (or "decompression") function...
yarp::sig::Image imageBottleBuffer
The final decompressed image that will be sent to the original destination.
yarp::os::Things & update(yarp::os::Things &thing) override
This function is the one that manipulates the incoming packet.
yarp::os::Bottle data
The bottle that is filled with compressed image and all the information needed for decompression (it ...
const AVCodec * codec
Ffmpeg structure containing all codec information needed for compression / decompression.
double lagRunningAverage
Variable storing the current lag for statistics.
double previousFrameTime
Seconds since epoch of the previous frame;.
yarp::os::Things th
The object returned by the "update" function; it can be a yarp::os::Bottle (sender side) or a yarp::s...
bool printStatistics
Boolean variable used to check whether the bandwidth statistics should be printed.
bool senderSide
Boolean variable that tells if the current execution is in sender side or not.
bool create(const yarp::os::Property &options) override
This function is called when the object is created and it is used to initialize all its attributes.
bool setparam(const yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
bool getparam(yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
int decompress(AVPacket *pkt, int w, int h, int pixelCode)
This function decompresses the incoming AVPacket passed as parameter and saves decompressed data into...
double previousStatisticPrintTime
Utility variable to store the time in which the last time the statistics have been printed.
std::map< std::string, std::string > paramsMap
Structure that maps every parameter inserted from command line into its value (both as strings).
void destroy(void) override
This function is called when the execution is terminated and the object is destroyed.
bool parsePropertyParams(yarp::os::Property inputoptions, const AVCodec *&codecOut, AVPixelFormat &pixelFormatOut, int &frameRate)
This function parses the command line parameters from a string containing the entire command used to ...
AVCodecContext * codecContext
Ffmpeg structure containing all codec context information needed for compression / decompression.
double bandwidthRunningAverage
Variable storing the current bandwidth average for statistics.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
Definition Bottle.cpp:315
void clear()
Empties the bottle of any objects it contains.
Definition Bottle.cpp:121
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition Bottle.cpp:140
A mini-server for performing network communication in the background.
static LogCallback printCallback()
Get current print callback.
Definition Log.cpp:892
static LogType minimumPrintLevel()
Get current minimum print level.
Definition Log.cpp:852
@ LogTypeReserved
Definition Log.h:98
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
A class for storing options and configuration information.
Definition Property.h:33
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Base class for generic things.
Definition Things.h:18
T * cast_as()
Definition Things.h:53
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
Definition Things.cpp:26
A single value (typically within a Bottle).
Definition Value.h:44
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:192
void setPixelCode(int imgPixelCode)
Definition Image.h:364
void setPixelSize(size_t imgPixelSize)
Definition Image.h:369
Base class for storing images.
Definition Image.h:79
size_t width() const
Gets width of image in pixels.
Definition Image.h:171
size_t getRowSize() const
Size of the underlying image buffer rows.
Definition Image.h:197
unsigned char * getRawImage() const
Access to the internal image buffer.
Definition Image.cpp:462
virtual size_t getPixelSize() const
Gets pixel size in memory in bytes.
Definition Image.cpp:370
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
Definition Image.cpp:387
void zero()
Set all pixels to 0.
Definition Image.cpp:380
size_t height() const
Gets height of image in pixels.
Definition Image.h:177
virtual int getPixelCode() const
Gets pixel type identifier.
Definition Image.cpp:375
File containing constans used in FfmpegPortmonitor.cpp.
static std::map< int, int > FFMPEGPORTMONITOR_PIXELMAP
This structure maps YARP pixel format codec into Ffmpeg pixel format codes.
Definition constants.h:84
static const std::string FFMPEGPORTMONITOR_CL_PIXEL_FORMAT_KEY
This string is the "key" value for the pixel format parameter.
Definition constants.h:56
static const std::string FFMPEGPORTMONITOR_CL_FRAME_RATE_KEY
This string is the "key" value for the frame rate parameter.
Definition constants.h:62
static const std::string FFMPEGPORTMONITOR_CL_DECODER_KEY
This string is the "key" value for the custom decoder parameter.
Definition constants.h:50
static const std::string FFMPEGPORTMONITOR_CL_PRINT_STATISTICS_KEY
This string is the "key" value to enable the print statistics.
Definition constants.h:68
static AVPixelFormat FFMPEGPORTMONITOR_DEFAULT_PIXEL_FORMAT
Default pixel format to be used within ffmpeg.
Definition constants.h:96
static const std::string FFMPEGPORTMONITOR_CL_ENCODER_KEY
This string is the "key" value for the custom encoder parameter.
Definition constants.h:44
static std::mutex instances_mutex
Header file of FfmpegPortmonitor: a port monitor for video compression/decompression.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13