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. More... | |
void | destroy (void) override |
This function is called when the execution is terminated and the object is destroyed. More... | |
bool | setparam (const yarp::os::Property ¶ms) override |
This will be called when the portmonitor carrier parameters are set via YARP admin port. More... | |
bool | getparam (yarp::os::Property ¶ms) override |
This will be called when the portmonitor carrier parameters are requested via YARP admin port. More... | |
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). More... | |
yarp::os::Things & | update (yarp::os::Things &thing) override |
This function is the one that manipulates the incoming packet. More... | |
![]() | |
virtual | ~MonitorObject () |
virtual bool | create (const yarp::os::Property &options) |
This will be called when the dll is properly loaded by the portmonitor carrier. More... | |
virtual void | destroy () |
This will be called when the portmonitor object destroyes. More... | |
virtual bool | setparam (const yarp::os::Property ¶ms) |
This will be called when the portmonitor carrier parameters are set via YARP admin port. More... | |
virtual bool | getparam (yarp::os::Property ¶ms) |
This will be called when the portmonitor carrier parameters are requested via YARP admin port. More... | |
virtual void | trig () |
This will be called when one of the peer connections to the same import port receives data. More... | |
virtual bool | accept (yarp::os::Things &thing) |
This will be called when the data reach the portmonitor object. More... | |
virtual yarp::os::Things & | update (yarp::os::Things &thing) |
After data get accpeted in the accept() callback, an instance of that is given to the update function where the data can be accessed and modified. More... | |
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). More... | |
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). More... | |
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). More... | |
yarp::sig::FlexImage | imageOut |
The final decompressed image that will be sent to the original destination. More... | |
bool | senderSide |
Boolean variable that tells if the current execution is in sender side or not. More... | |
std::string | codecName |
The string containing codec name. More... | |
const AVCodec * | codec |
Ffmpeg structure containing all codec information needed for compression / decompression. More... | |
AVCodecContext * | codecContext = NULL |
Ffmpeg structure containing all codec context information needed for compression / decompression. More... | |
bool | firstTime |
Boolean variable used to check if the current call to the "compression" (or "decompression") function is the first one or not. More... | |
std::map< std::string, std::string > | paramsMap |
Structure that maps every parameter inserted from command line into its value (both as strings). More... | |
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. More... | |
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). More... | |
int | getParamsFromCommandLine (std::string carrierString, AVCodecID &codecId) |
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>). More... | |
int | setCommandLineParams () |
This function iterates over the attribute paramsMap and sets all the specified parameters into the attribute codecContext. More... | |
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 141 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 293 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 66 of file ffmpegPortmonitor.cpp.
|
protected |
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 445 of file ffmpegPortmonitor.cpp.
|
overridevirtual |
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 117 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 135 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 572 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 629 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 129 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 168 of file ffmpegPortmonitor.cpp.
const AVCodec* FfmpegMonitorObject::codec |
Ffmpeg structure containing all codec information needed for compression / decompression.
Definition at line 143 of file ffmpegPortmonitor.h.
AVCodecContext* FfmpegMonitorObject::codecContext = NULL |
Ffmpeg structure containing all codec context information needed for compression / decompression.
Definition at line 149 of file ffmpegPortmonitor.h.
std::string FfmpegMonitorObject::codecName |
The string containing codec name.
Definition at line 137 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 119 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 155 of file ffmpegPortmonitor.h.
yarp::sig::FlexImage FfmpegMonitorObject::imageOut |
The final decompressed image that will be sent to the original destination.
Definition at line 125 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 161 of file ffmpegPortmonitor.h.
bool FfmpegMonitorObject::senderSide |
Boolean variable that tells if the current execution is in sender side or not.
Definition at line 131 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 113 of file ffmpegPortmonitor.h.