YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ffmpegPortmonitor.h
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
14#ifndef YARP_FFMPEG_CARRIER_FFMPEGPORTMONITOR_H
15#define YARP_FFMPEG_CARRIER_FFMPEGPORTMONITOR_H
16
17// YARP imports
18#include <yarp/os/Bottle.h>
19#include <yarp/os/Things.h>
20#include <yarp/sig/Image.h>
22
23// Ffmpeg imports
24extern "C" {
25 #include <libavcodec/avcodec.h>
26}
27
34{
35 public:
43 bool create(const yarp::os::Property& options) override;
44
49 void destroy(void) override;
50
51 bool setparam(const yarp::os::Property& params) override;
52 bool getparam(yarp::os::Property& params) override;
53
61 bool accept(yarp::os::Things& thing) override;
62
70
71 protected:
79 int compress(yarp::sig::Image* img, AVPacket* pkt);
80
90 int decompress(AVPacket* pkt, int w, int h, int pixelCode);
91
99 bool getParamsFromCommandLine(std::string carrierString, const AVCodec *&codecOut, AVPixelFormat &pixelFormatOut, int &frameRate);
100
107
111 void updateStatistics(yarp::os::Bottle &inputBottle, double currentLag);
112
113 public:
119
125
131
137
143
148 const AVCodec *codec;
149
154 AVCodecContext *codecContext = NULL;
155
160 AVPixelFormat pixelFormat{AV_PIX_FMT_YUV420P};
161
167
173
178
183
188
193
198
203 std::map<std::string, std::string> paramsMap;
204};
205
206#endif
image_compression_ffmpeg: This portmonitor uses Ffmpeg to compress and decompress video streams with ...
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 getParamsFromCommandLine(std::string carrierString, const AVCodec *&codecOut, AVPixelFormat &pixelFormatOut, int &frameRate)
This function parses the command line parameters from a string containing the entire command used to ...
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.
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:64
A class for storing options and configuration information.
Definition Property.h:33
Base class for generic things.
Definition Things.h:18
Image class with user control of representation details.
Definition Image.h:374
Base class for storing images.
Definition Image.h:79