PiImageStreamer
Loading...
Searching...
No Matches
SWE4211RPi::AbstractImageTransmitter Class Referenceabstract

#include <AbstractImageTransmitter.h>

Inheritance diagram for SWE4211RPi::AbstractImageTransmitter:

Public Member Functions

virtual int streamImage (cv::Mat *image)=0
 
void setDestinationMachine (const char *machineName)
 
int getConnectionNumber ()
 

Protected Member Functions

std::string getDestinationMachine ()
 

Protected Attributes

int myPort = 9000
 
int sockfd = 0
 
char * destinationMachineName = nullptr
 
std::mutex destinationMutex
 
int imageCount = 0
 
std::atomic< int > connectionNumber {0}
 

Detailed Description

This is the abstract base class for all image transmitters.

Member Function Documentation

◆ getConnectionNumber()

int SWE4211RPi::AbstractImageTransmitter::getConnectionNumber ( )

This method will return the number of connections that have been made. A change in this value indicates that a new connection has started.

Returns
The count of connections made so far. It will be 0 if no connection has been made.
Here is the caller graph for this function:

◆ getDestinationMachine()

std::string SWE4211RPi::AbstractImageTransmitter::getDestinationMachine ( )
protected

This method will return a copy of the destination machine name, taken while holding the mutex. Because it is a copy, it remains valid even if the destination is changed while it is in use.

Returns
The destination machine name, or an empty string if none has been set.
Here is the caller graph for this function:

◆ setDestinationMachine()

void SWE4211RPi::AbstractImageTransmitter::setDestinationMachine ( const char *  machineName)

This method will update the destination machine name for the stream. If a new destination is given (i.e. not an empty name, which indicates a disconnect), a new connection has started, so the image count is reset and the connection number is incremented.

Parameters
machineNameThis is the name of the destination. An empty string stops the stream.

This method will update the destination machine name for the stream. If a new destination is given (i.e. not an empty name, which indicates a disconnect), a new connection has started, so the image count is reset and the connection number is incremented.

Parameters
machineNameThis is the name of the destination.
  1. Lock the mutex so that the name cannot be read by another thread while it is being replaced.

  2. Free the old name, then allocate space for and copy in the new name.

  3. If the new name is a real destination (i.e. longer than 1 char), reset the image count and increment the connection number.
Here is the caller graph for this function:

◆ streamImage()

virtual int SWE4211RPi::AbstractImageTransmitter::streamImage ( cv::Mat *  image)
pure virtual

This method will stream via udp the image to the remote device.

Parameters
imageThis is the image that is to be sent.
Returns
The return will be 0 if successful or -1 if there is a failure.

Implemented in SWE4211RPi::CompressedImageTransmitter.

Here is the caller graph for this function:

Member Data Documentation

◆ connectionNumber

std::atomic<int> SWE4211RPi::AbstractImageTransmitter::connectionNumber {0}
protected

This is a count of the connections that have been made. It increments each time a new (non-empty) destination machine is set, so that other classes can detect that a new connection has started streaming.

◆ destinationMachineName

char* SWE4211RPi::AbstractImageTransmitter::destinationMachineName = nullptr
protected

This is a c style string representing the destination machine's name (or IP address). An empty string means there is no destination. It must only be accessed while holding destinationMutex, except in the constructor and destructor.

◆ destinationMutex

std::mutex SWE4211RPi::AbstractImageTransmitter::destinationMutex
protected

This mutex protects destinationMachineName, which is changed by setDestinationMachine() on one thread while it may be read by streamImage() on another.

◆ imageCount

int SWE4211RPi::AbstractImageTransmitter::imageCount = 0
protected

This is a count of the images that are streamed. The first image streamed will be 0 and it will increment each time a new image is streamed. It is reset to 0 each time a new connection is made.

◆ myPort

int SWE4211RPi::AbstractImageTransmitter::myPort = 9000
protected

This is the UDP port that the images are to be sent to. It defaults to 9000, but is normally set by the derived class's constructor.

◆ sockfd

int SWE4211RPi::AbstractImageTransmitter::sockfd = 0
protected

This is the socket file descriptor that is used to send the datagrams.


The documentation for this class was generated from the following files: