ifw-rtmstools 3.0.0
|
The RtmsReceiver class. More...
#include <rtmsReceiver.hpp>
Public Member Functions | |
RtmsReceiver (std::string address, int port, std::string net_if, int width, int height, int bpp, const int rcv_buf_factor=3) | |
virtual | ~RtmsReceiver () |
int | GetSize () const |
Get image size in bytes. | |
int | GetWidth () const |
int | GetHeight () const |
void | ReceivePacket (const boost::system::error_code &error, size_t bytes_transferred) |
Callback to process RTMS packets. | |
virtual void | HandleLeaderPacket () |
Invoked to handle a MUDPI/RTMS Leader Packet. | |
virtual void | HandlePayloadPacket (mudpiif::mudpiPacketJumbo &packet) |
Invoked to handle a MUDPI/RTMS Payload Packet. | |
virtual void | HandleTrailerPacket () |
Invoked to handle a MUDPI/RTMS Trailer Packet. | |
virtual void | HandleLostPackets () |
Handle the case where packets are lost. | |
virtual void | HandleWrongFrameId () |
Handle the case where a wrong frame ID is received. | |
virtual void | Wait () |
Wait for incoming network data (for asynchroneous use) | |
void | StartReceiver () |
Network configuration. | |
void | StopReceiver () |
int32_t | GetCurrentSampleId () const |
Public Attributes | |
std::string | m_address |
int | m_port |
std::string | m_net_if |
int | m_width |
int | m_height |
int | m_bpp |
long unsigned int | m_prev_frames_expected |
long unsigned int | m_prev_frames_received |
bool | m_execute |
int | m_rcv_buf_factor {3} |
double | m_last_lost_packets_log {0.0} |
double | m_last_diff_sample_id_log {0.0} |
int32_t | m_current_sample_id {-1} |
unsigned int | m_sample {0} |
bool | m_io_service_running {false} |
boost::asio::io_service | m_io_service |
boost::asio::ip::udp::socket | m_socket {m_io_service} |
boost::array< char, PACKET_SIZE > | m_recv_buffer |
boost::asio::ip::udp::endpoint | m_remote_endpoint |
struct timeval m_start | m_end |
int | m_num_frames = 0 |
log4cplus::Logger | m_logger |
The RtmsReceiver class.
This structure is used to receive RTMS packages and assembly back the image when the last packet is received. If any packet is lost, the complete frame will be discarded. It uses BOOST asio library for handling the UDP networking.
By default the class has an asynchroneous behaviour.
ifw::rtmstools::RtmsReceiver::RtmsReceiver | ( | std::string | address, |
int | port, | ||
std::string | net_if, | ||
int | width, | ||
int | height, | ||
int | bpp, | ||
const int | rcv_buf_factor = 3 ) |
|
virtual |
int32_t ifw::rtmstools::RtmsReceiver::GetCurrentSampleId | ( | ) | const |
int ifw::rtmstools::RtmsReceiver::GetHeight | ( | ) | const |
int ifw::rtmstools::RtmsReceiver::GetSize | ( | ) | const |
Get image size in bytes.
int ifw::rtmstools::RtmsReceiver::GetWidth | ( | ) | const |
|
virtual |
Invoked to handle a MUDPI/RTMS Leader Packet.
Reimplemented in ifw::rtmstools::Rtms2DdtReceiver, and ifw::rtmstools::RtmsReceiverTool.
|
virtual |
Handle the case where packets are lost.
Reimplemented in ifw::rtmstools::Rtms2DdtReceiver, and ifw::rtmstools::RtmsReceiverTool.
|
virtual |
Invoked to handle a MUDPI/RTMS Payload Packet.
Reimplemented in ifw::rtmstools::Rtms2DdtReceiver, and ifw::rtmstools::RtmsReceiverTool.
|
virtual |
Invoked to handle a MUDPI/RTMS Trailer Packet.
Reimplemented in ifw::rtmstools::Rtms2DdtReceiver, and ifw::rtmstools::RtmsReceiverTool.
|
virtual |
Handle the case where a wrong frame ID is received.
void ifw::rtmstools::RtmsReceiver::ReceivePacket | ( | const boost::system::error_code & | error, |
size_t | bytes_transferred ) |
Callback to process RTMS packets.
This methods process the incoming data and retrieves the information for the RTMS packets. When the trailer packet is received succesfully, this method will create a new image object and push it to the queue. It triggers the notification by updating the new_image flag.
void ifw::rtmstools::RtmsReceiver::StartReceiver | ( | ) |
Network configuration.
This method configures boost asio to listen for incoming packets. At the end, it calls the Wait method.
void ifw::rtmstools::RtmsReceiver::StopReceiver | ( | ) |
|
virtual |
Wait for incoming network data (for asynchroneous use)
It can be used to receive data asynchronosly from boost asio. The method invokes the ReceivePacket callback function when data is available.
std::string ifw::rtmstools::RtmsReceiver::m_address |
int ifw::rtmstools::RtmsReceiver::m_bpp |
int32_t ifw::rtmstools::RtmsReceiver::m_current_sample_id {-1} |
struct timeval m_start ifw::rtmstools::RtmsReceiver::m_end |
bool ifw::rtmstools::RtmsReceiver::m_execute |
int ifw::rtmstools::RtmsReceiver::m_height |
boost::asio::io_service ifw::rtmstools::RtmsReceiver::m_io_service |
bool ifw::rtmstools::RtmsReceiver::m_io_service_running {false} |
double ifw::rtmstools::RtmsReceiver::m_last_diff_sample_id_log {0.0} |
double ifw::rtmstools::RtmsReceiver::m_last_lost_packets_log {0.0} |
log4cplus::Logger ifw::rtmstools::RtmsReceiver::m_logger |
std::string ifw::rtmstools::RtmsReceiver::m_net_if |
int ifw::rtmstools::RtmsReceiver::m_num_frames = 0 |
int ifw::rtmstools::RtmsReceiver::m_port |
long unsigned int ifw::rtmstools::RtmsReceiver::m_prev_frames_expected |
long unsigned int ifw::rtmstools::RtmsReceiver::m_prev_frames_received |
int ifw::rtmstools::RtmsReceiver::m_rcv_buf_factor {3} |
boost::array<char, PACKET_SIZE> ifw::rtmstools::RtmsReceiver::m_recv_buffer |
boost::asio::ip::udp::endpoint ifw::rtmstools::RtmsReceiver::m_remote_endpoint |
unsigned int ifw::rtmstools::RtmsReceiver::m_sample {0} |
boost::asio::ip::udp::socket ifw::rtmstools::RtmsReceiver::m_socket {m_io_service} |
int ifw::rtmstools::RtmsReceiver::m_width |