image_compression_ffmpeg
: This portmonitor uses Ffmpeg to compress and decompress video streams with a specified codec.
More...
Public Member Functions | |
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. | |
void | destroy (void) override |
This function is called when the execution is terminated and the object is destroyed. | |
bool | setparam (const yarp::os::Property ¶ms) override |
This will be called when the portmonitor carrier parameters are set via YARP admin port. | |
bool | getparam (yarp::os::Property ¶ms) override |
This will be called when the portmonitor carrier parameters are requested via YARP admin port. | |
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 to cast it to the right type). | |
yarp::os::Things & | update (yarp::os::Things &thing) override |
This function is the one that manipulates the incoming packet. | |
![]() | |
virtual | ~MonitorObject () |
virtual void | trig () |
This will be called when one of the peer connections to the same import port receives data. | |
virtual yarp::os::Things & | updateReply (yarp::os::Things &thing) |
The updateReply makes it possible to modify a reply from a port when the portmonitor object is attached to a two-ways connection (e.g., RPC). | |
Public Attributes | |
yarp::os::Things | th |
The object returned by the "update" function; it can be a yarp::os::Bottle (sender side) or a yarp::sig::Image (receiver side). | |
yarp::os::Bottle | data |
The bottle that is filled with compressed image and all the information needed for decompression (it will be sent from sender to receiver). | |
yarp::sig::FlexImage | imageOut |
The final decompressed image that will be sent to the original destination. | |
yarp::sig::Image | imageBottleBuffer |
The final decompressed image that will be sent to the original destination. | |
bool | senderSide |
Boolean variable that tells if the current execution is in sender side or not. | |
const AVCodec * | codec |
Ffmpeg structure containing all codec information needed for compression / decompression. | |
AVCodecContext * | codecContext = NULL |
Ffmpeg structure containing all codec context information needed for compression / decompression. | |
AVPixelFormat | pixelFormat {AV_PIX_FMT_YUV420P} |
Ffmpeg pixel format. | |
bool | firstTime |
Boolean variable used to check if the current call to the "compression" (or "decompression") function is the first one or not. | |
bool | printStatistics |
Boolean variable used to check whether the bandwidth statistics should be printed. | |
double | previousFrameTime |
Seconds since epoch of the previous frame;. | |
double | bandwidthRunningAverage |
Variable storing the current bandwidth average for statistics. | |
double | lagRunningAverage |
Variable storing the current lag for statistics. | |
int | statisticsCounter |
Utility counter for printing statistics. | |
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). | |
Protected Member Functions | |
int | compress (yarp::sig::Image *img, AVPacket *pkt) |
This function performs all the compression actions on the incoming Image and saves the resulting compressed data into the AVPacket passed as parameter. | |
int | decompress (AVPacket *pkt, int w, int h, int pixelCode) |
This function decompresses the incoming AVPacket passed as parameter and saves decompressed data into the attribute imageOut (yarp::sig::FlexImage). | |
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 execute the program and saves the parameters into the attribute paramsMap (std::map<std::string, std::string>). | |
int | setCommandLineParams () |
This function iterates over the attribute paramsMap and sets all the specified parameters into the attribute codecContext. | |
void | updateStatistics (yarp::os::Bottle &inputBottle, double currentLag) |
Print some network statistics. | |
image_compression_ffmpeg
: This portmonitor uses Ffmpeg to compress and decompress video streams with a specified codec.
Definition at line 33 of file ffmpegPortmonitor.h.
|
overridevirtual |
This function is used by the port monitor to decide if an incoming packet can be accepted (it tries to cast it to the right type).
The accepted packets are then handled by the function "update"; the others are discarded.
thing | The incoming packet; must be a yarp::sig::Image in sender side, must be a yarp::sig::Bottle in receiver side. |
Reimplemented from yarp::os::MonitorObject.
Definition at line 193 of file ffmpegPortmonitor.cpp.
|
protected |
This function performs all the compression actions on the incoming Image and saves the resulting compressed data into the AVPacket passed as parameter.
img | The incoming image. |
pkt | The packet containing all the compressed data. |
Definition at line 415 of file ffmpegPortmonitor.cpp.
|
overridevirtual |
This function is called when the object is created and it is used to initialize all its attributes.
It is called both on sender and receiver side, and it performs different initializations basing on side check.
options | Parameters passed to the object to initialize it (e.g. command line parameters). |
Reimplemented from yarp::os::MonitorObject.
Definition at line 68 of file ffmpegPortmonitor.cpp.
This function decompresses the incoming AVPacket passed as parameter and saves decompressed data into the attribute imageOut (yarp::sig::FlexImage).
pkt | The incoming packet containing all the compressed data. |
w | The width of the image (in pixels). |
h | The height of the image (in pixels). |
pixelCode | The YARP pixel format code of the image. |
Definition at line 576 of file ffmpegPortmonitor.cpp.
This function is called when the execution is terminated and the object is destroyed.
It frees the memory allocated during the "create" function.
Reimplemented from yarp::os::MonitorObject.
Definition at line 166 of file ffmpegPortmonitor.cpp.
|
overridevirtual |
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
params | The Property |
Reimplemented from yarp::os::MonitorObject.
Definition at line 187 of file ffmpegPortmonitor.cpp.
|
protected |
This function parses the command line parameters from a string containing the entire command used to execute the program and saves the parameters into the attribute paramsMap (std::map<std::string, std::string>).
carrierString | The entire command used to execute the program. |
codecId | The codec for video compression / decompression. |
Definition at line 707 of file ffmpegPortmonitor.cpp.
|
protected |
This function iterates over the attribute paramsMap and sets all the specified parameters into the attribute codecContext.
Definition at line 894 of file ffmpegPortmonitor.cpp.
|
overridevirtual |
This will be called when the portmonitor carrier parameters are set via YARP admin port.
params | The Property |
Reimplemented from yarp::os::MonitorObject.
Definition at line 181 of file ffmpegPortmonitor.cpp.
|
overridevirtual |
This function is the one that manipulates the incoming packet.
In sender side, it takes the Image and sends it to the "compress" function. Then it fills a Bottle containing the compressed Image and all the information needed for decompression. In receiver side, it takes the incoming Bottle and unpacks it; then it sends all compressed data to the "decompress" function; it finally creates a new Image object filled with decompressed data.
thing | The incoming packet; it is a yarp::sig::Image in sender side, a yarp::sig::Bottle in receiver side. |
Reimplemented from yarp::os::MonitorObject.
Definition at line 259 of file ffmpegPortmonitor.cpp.
|
protected |
Print some network statistics.
Definition at line 224 of file ffmpegPortmonitor.cpp.
double FfmpegMonitorObject::bandwidthRunningAverage |
Variable storing the current bandwidth average for statistics.
Definition at line 182 of file ffmpegPortmonitor.h.
const AVCodec* FfmpegMonitorObject::codec |
Ffmpeg structure containing all codec information needed for compression / decompression.
Definition at line 148 of file ffmpegPortmonitor.h.
AVCodecContext* FfmpegMonitorObject::codecContext = NULL |
Ffmpeg structure containing all codec context information needed for compression / decompression.
Definition at line 154 of file ffmpegPortmonitor.h.
yarp::os::Bottle FfmpegMonitorObject::data |
The bottle that is filled with compressed image and all the information needed for decompression (it will be sent from sender to receiver).
Definition at line 124 of file ffmpegPortmonitor.h.
bool FfmpegMonitorObject::firstTime |
Boolean variable used to check if the current call to the "compression" (or "decompression") function is the first one or not.
Definition at line 166 of file ffmpegPortmonitor.h.
yarp::sig::Image FfmpegMonitorObject::imageBottleBuffer |
The final decompressed image that will be sent to the original destination.
Definition at line 136 of file ffmpegPortmonitor.h.
yarp::sig::FlexImage FfmpegMonitorObject::imageOut |
The final decompressed image that will be sent to the original destination.
Definition at line 130 of file ffmpegPortmonitor.h.
double FfmpegMonitorObject::lagRunningAverage |
Variable storing the current lag for statistics.
Definition at line 187 of file ffmpegPortmonitor.h.
std::map<std::string, std::string> FfmpegMonitorObject::paramsMap |
Structure that maps every parameter inserted from command line into its value (both as strings).
Definition at line 203 of file ffmpegPortmonitor.h.
AVPixelFormat FfmpegMonitorObject::pixelFormat {AV_PIX_FMT_YUV420P} |
Ffmpeg pixel format.
Definition at line 160 of file ffmpegPortmonitor.h.
double FfmpegMonitorObject::previousFrameTime |
Seconds since epoch of the previous frame;.
Definition at line 177 of file ffmpegPortmonitor.h.
double FfmpegMonitorObject::previousStatisticPrintTime |
Utility variable to store the time in which the last time the statistics have been printed.
Definition at line 197 of file ffmpegPortmonitor.h.
bool FfmpegMonitorObject::printStatistics |
Boolean variable used to check whether the bandwidth statistics should be printed.
Definition at line 172 of file ffmpegPortmonitor.h.
bool FfmpegMonitorObject::senderSide |
Boolean variable that tells if the current execution is in sender side or not.
Definition at line 142 of file ffmpegPortmonitor.h.
int FfmpegMonitorObject::statisticsCounter |
Utility counter for printing statistics.
Definition at line 192 of file ffmpegPortmonitor.h.
yarp::os::Things FfmpegMonitorObject::th |
The object returned by the "update" function; it can be a yarp::os::Bottle (sender side) or a yarp::sig::Image (receiver side).
Definition at line 118 of file ffmpegPortmonitor.h.