YARP
Yet Another Robot Platform
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 int getParamsFromCommandLine(std::string carrierString, AVCodecID &codecId);
100
107
108 public:
114
120
126
132
137 std::string codecName;
138
143 const AVCodec *codec;
144
149 AVCodecContext *codecContext = NULL;
150
156
161 std::map<std::string, std::string> paramsMap;
162};
163
164#endif
image_compression_ffmpeg: This portmonitor uses Ffmpeg to compress and decompress video streams with ...
int getParamsFromCommandLine(std::string carrierString, AVCodecID &codecId)
This function parses the command line parameters from a string containing the entire command used to ...
yarp::sig::FlexImage imageOut
The final decompressed image that will be sent to the original destination.
int compress(yarp::sig::Image *img, AVPacket *pkt)
This function performs all the compression actions on the incoming Image and saves the resulting comp...
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...
std::string codecName
The string containing codec name.
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.
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 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...
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.
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:411
Base class for storing images.
Definition: Image.h:79