MediaX v1.0.0rc7 [7e6cb74]
Video streaming for military vehicles
Loading...
Searching...
No Matches
mediax::rtp::uncompressed::RtpUncompressedDepayloader Class Reference

Manage an RTP stream. More...

#include <rtp_uncompressed_depayloader.h>

Inheritance diagram for mediax::rtp::uncompressed::RtpUncompressedDepayloader:
Inheritance graph
Collaboration diagram for mediax::rtp::uncompressed::RtpUncompressedDepayloader:
Collaboration graph

Public Member Functions

 RtpUncompressedDepayloader ()
 The supported colour spaces.
 
 ~RtpUncompressedDepayloader (void) final=default
 Destroy the Rtp Stream object.
 
 RtpUncompressedDepayloader (RtpUncompressedDepayloader &&other)=delete
 Construct a new Rtpvraw Depayloader object (Deleted)
 
void SetStreamInfo (const ::mediax::rtp::StreamInformation &stream_information) final
 Configure at RTP input stream and dont wait for the SAP/SDP announcement.
 
bool Open () final
 Open the RTP stream.
 
void Start () final
 Start the stream recieve thread, can be quickly re-started without having to re-open the UDP port.
 
void Stop () final
 Stop the stream recieve thread, can be quickly re-started without having to re-open the UDP port.
 
void Close () final
 Close the RTP stream.
 
bool Receive (::mediax::rtp::RtpFrameData *data, int32_t timeout=0) final
 Recieve a frame or timeout.
 
void Callback (::mediax::rtp::RtpFrameData frame) const final
 The callback function for the RTP stream.
 
- Public Member Functions inherited from mediax::rtp::RtpDepayloader
 RtpDepayloader ()
 Construct a new Rtp Depayloader object.
 
virtual ~RtpDepayloader ()=default
 Destroy the Rtp Stream object.
 
 RtpDepayloader (RtpDepayloader const &)=delete
 Construct a new Rtp Payloader object.
 
RtpDepayloaderoperator= (RtpDepayloader const &)=delete
 Construct a new Rtp Payloader object.
 
void RegisterCallback (const ::mediax::rtp::RtpCallback &callback)
 Register a callback for our session_name.
 
virtual bool Receive (mediax::rtp::RtpFrameData *data, int32_t timeout=0)=0
 Recieve a frame or timeout.
 
void SetSessionName (std::string_view name)
 Set the Session Name attribute.
 
std::string GetSessionName ()
 Get the Session Name attribute.
 
::mediax::rtp::ColourspaceType GetColourSpace ()
 Get the Colour Space object of the incoming stream.
 
void SetHeight (uint32_t height)
 Set the Height attribute.
 
uint32_t GetHeight () const
 Get the Height object of the incoming stream.
 
void SetWidth (uint32_t width)
 Set the Width attribute.
 
uint32_t GetWidth () const
 Get the Width object of the incoming stream.
 
void SetFramerate (uint32_t framerate)
 Set the Frame Rate object.
 
uint32_t GetFrameRate () const
 Get the Frame Rate of the incoming stream.
 
std::string GetIpAddress () const
 Get the Ip Address of the incoming stream.
 
void SetIpAddress (std::string_view ip_address)
 Set the Ip Address attribute.
 
void SetPort (uint32_t port)
 Set the Port object.
 
uint32_t GetPort () const
 Get the Port of the incoming stream.
 
void SetColourSpace (::mediax::rtp::ColourspaceType colourspace)
 Set the Colour Space object.
 
bool SettingsValid () const
 Check if the settings are valid. All stream information was set.
 
::mediax::rtp::ColourspaceType GetColourSpace () const
 Get the Colour Space object.
 
bool IsMulticast (std::string_view ip_address) const
 Check if the IP address is a multicast address.
 
bool CallbackRegistered () const
 Check is a callback is registered.
 
void UnregisterCallback ()
 Unregister the callback.
 
::mediax::rtp::RtpPortTypeGetStream ()
 Get the Port Type object.
 
::mediax::rtp::RtpCallback GetCallback () const
 Get the Callback object.
 
std::vector< uint8_t > & GetBuffer ()
 Get the Buffer object.
 
uint32_t GetBufferSize () const
 Get the Buffer Size object.
 
void SetBufferSize (uint32_t size)
 Set the Buffer Size object.
 
::mediax::rtp::StreamState GetState () const
 Get the State object.
 

Private Member Functions

void UpdateHeader (::mediax::rtp::RtpHeaderData *packet, int line, int last, int32_t timestamp, int32_t source) const
 Populate the RTP header.
 
bool WaitForFrame (uint8_t **cpu, int32_t timeout)
 Wait for a frame or timeout.
 
bool ReadRtpHeader (RtpUncompressedDepayloader *stream, ::mediax::rtp::RtpPacket *packet)
 Read in a RTP packet and decode header.
 
bool ReceiveLines (::mediax::rtp::RtpPacket *packet, bool *last_scan_line, int *last_packet)
 Receive video lines.
 

Static Private Member Functions

static void TransmitThread (RtpUncompressedDepayloader *stream)
 Transmit RTP data to the network using a separate thread.
 
static void ReceiveThread (RtpUncompressedDepayloader *stream)
 Recieve RTP data to the network using a separate thread.
 
static int32_t GenerateTimestamp90kHz ()
 Get a 90Htz timestamp.
 

Private Attributes

std::atomic< bool > new_rx_frame_ = false
 The incremental sequence numer for transmitting RTP packets, atomic.
 
bool rx_thread_running_ = true
 Flag indicating the thread is running.
 
::mediax::rtp::TxData arg_tx
 Transmit arguments used by the thread.
 
pthread_mutex_t mutex_
 thread mutex
 
std::array< uint8_t, ::mediax::rtp::kMaxUdpDataudpdata
 UDP data buffer.
 
std::thread rx_thread_
 Arguments sent to thread.
 
uint32_t sequence_number_ = 0
 The current sequence number.
 

Detailed Description

Manage an RTP stream.

Constructor & Destructor Documentation

◆ RtpUncompressedDepayloader() [1/2]

mediax::rtp::uncompressed::RtpUncompressedDepayloader::RtpUncompressedDepayloader ( )

The supported colour spaces.

Construct a new Rtp Stream object

Parameters
heightin pixels of the RTP stream
widthin pixels of the RTP stream

◆ RtpUncompressedDepayloader() [2/2]

mediax::rtp::uncompressed::RtpUncompressedDepayloader::RtpUncompressedDepayloader ( RtpUncompressedDepayloader &&  other)
delete

Construct a new Rtpvraw Depayloader object (Deleted)

Parameters
other

Member Function Documentation

◆ Callback()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::Callback ( ::mediax::rtp::RtpFrameData  frame) const
finalvirtual

The callback function for the RTP stream.

Parameters
frame

Implements mediax::rtp::RtpDepayloader.

◆ Close()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::Close ( )
finalvirtual

Close the RTP stream.

Reimplemented from mediax::rtp::RtpDepayloader.

◆ GenerateTimestamp90kHz()

static int32_t mediax::rtp::uncompressed::RtpUncompressedDepayloader::GenerateTimestamp90kHz ( )
staticprivate

Get a 90Htz timestamp.

Returns
int32_t The current time stamp

◆ Open()

bool mediax::rtp::uncompressed::RtpUncompressedDepayloader::Open ( )
finalvirtual

Open the RTP stream.

Returns
true
false

Reimplemented from mediax::rtp::RtpDepayloader.

◆ ReadRtpHeader()

bool mediax::rtp::uncompressed::RtpUncompressedDepayloader::ReadRtpHeader ( RtpUncompressedDepayloader stream,
::mediax::rtp::RtpPacket packet 
)
private

Read in a RTP packet and decode header.

Returns
true
false

◆ Receive()

bool mediax::rtp::uncompressed::RtpUncompressedDepayloader::Receive ( ::mediax::rtp::RtpFrameData data,
int32_t  timeout = 0 
)
final

Recieve a frame or timeout.

Parameters
datathe fame buffer in CPU memory.
timeoutzero will wait forever or a timeout in milliseconds
Returns
true when frame available and false when no frame was received in the timeout

◆ ReceiveLines()

bool mediax::rtp::uncompressed::RtpUncompressedDepayloader::ReceiveLines ( ::mediax::rtp::RtpPacket packet,
bool *  last_scan_line,
int *  last_packet 
)
private

Receive video lines.

Returns
true if frame complete
false if frame incomplete

◆ ReceiveThread()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::ReceiveThread ( RtpUncompressedDepayloader stream)
staticprivate

Recieve RTP data to the network using a separate thread.

Parameters
streamthis object

◆ SetStreamInfo()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::SetStreamInfo ( const ::mediax::rtp::StreamInformation stream_information)
finalvirtual

Configure at RTP input stream and dont wait for the SAP/SDP announcement.

Parameters
stream_informationThe stream information

Implements mediax::rtp::RtpDepayloader.

◆ Start()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::Start ( )
finalvirtual

Start the stream recieve thread, can be quickly re-started without having to re-open the UDP port.

This can cause bandwidth issues if multiple UDP multicast streams are open. If bandwidth is an issue then its better to close the stream before switching to a new stream

Reimplemented from mediax::rtp::RtpDepayloader.

◆ Stop()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::Stop ( )
finalvirtual

Stop the stream recieve thread, can be quickly re-started without having to re-open the UDP port.

Reimplemented from mediax::rtp::RtpDepayloader.

◆ TransmitThread()

static void mediax::rtp::uncompressed::RtpUncompressedDepayloader::TransmitThread ( RtpUncompressedDepayloader stream)
staticprivate

Transmit RTP data to the network using a separate thread.

Parameters
streamthis object

◆ UpdateHeader()

void mediax::rtp::uncompressed::RtpUncompressedDepayloader::UpdateHeader ( ::mediax::rtp::RtpHeaderData packet,
int  line,
int  last,
int32_t  timestamp,
int32_t  source 
) const
private

Populate the RTP header.

Parameters
packetthe RTP header
linethe line number
lasttrue if last line
timestampthe timestamp
sourcethe source id

◆ WaitForFrame()

bool mediax::rtp::uncompressed::RtpUncompressedDepayloader::WaitForFrame ( uint8_t **  cpu,
int32_t  timeout 
)
private

Wait for a frame or timeout.

Parameters
cpu
timeout
Returns
true
false

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