TSDuck v3.38-3675
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::MPEPacket Class Reference

Representation of a packet for MPE (Multi-Protocol Encapsulation). More...

#include <tsMPEPacket.h>

Public Member Functions

 MPEPacket ()=default
 Default constructor.
 
 MPEPacket (ByteBlockPtr datagram, ShareMode mode, const MACAddress &mac=MACAddress(), PID pid=PID_NULL)
 Constructor from a full datagram (including network headers).
 
 MPEPacket (const MPEPacket &other, ShareMode mode)
 Copy constructor.
 
 MPEPacket (const Section &section)
 Constructor from a DSM-CC MPE section.
 
 MPEPacket (MPEPacket &&other) noexcept
 Move constructor.
 
void clear ()
 Clear content.
 
MPEPacketcopy (const MPEPacket &other)
 Duplication.
 
MPEPacketcopy (const Section &section)
 Copy content from a DSM-CC MPE section.
 
void createSection (Section &section) const
 Create a DSM-CC MPE section containing the MPE packet.
 
const uint8_t * datagram () const
 Access to the binary content of the complete network datagram.
 
size_t datagramSize () const
 Size of the binary content of the complete network datagram.
 
IPv4Address destinationIPAddress () const
 Get the destination IP address.
 
MACAddress destinationMACAddress () const
 Get the destination MAC address.
 
IPv4SocketAddress destinationSocket () const
 Get the destination socket address.
 
uint16_t destinationUDPPort () const
 Get the destination UDP port.
 
bool isValid () const
 Check if the packet has valid content.
 
MPEPacketoperator= (const MPEPacket &other)
 Assignment operator.
 
MPEPacketoperator= (MPEPacket &&other) noexcept
 Move assignment operator.
 
void setDestinationIPAddress (const IPv4Address &ip)
 Set the destination IP address.
 
void setDestinationMACAddress (const MACAddress &mac)
 Set the destination MAC address.
 
void setDestinationSocket (const IPv4SocketAddress &sock)
 Set the destination socket address.
 
void setDestinationUDPPort (uint16_t port)
 Set the destination UDP port.
 
void setSourceIPAddress (const IPv4Address &ip)
 Set the source IP address.
 
void setSourcePID (PID pid)
 Set the source PID.
 
void setSourceSocket (const IPv4SocketAddress &sock)
 Set the source socket address.
 
void setSourceUDPPort (uint16_t port)
 Set the source UDP port.
 
bool setUDPMessage (const uint8_t *data, size_t size)
 Replace the binary content of the UDP message.
 
IPv4Address sourceIPAddress () const
 Get the source IP address.
 
PID sourcePID () const
 Get the source PID.
 
IPv4SocketAddress sourceSocket () const
 Get the source socket address.
 
uint16_t sourceUDPPort () const
 Get the source UDP port.
 
const uint8_t * udpMessage () const
 Access to the binary content of the UDP message.
 
size_t udpMessageSize () const
 Size of the binary content of the UDP message.
 

Detailed Description

Representation of a packet for MPE (Multi-Protocol Encapsulation).

This implementation has the following restrictions:

  • The encapsulated datagrams can be UDP/IP only.
  • LLC/SNAP encapsulation is not supported.
  • The datagran and address scrambling is not supported.
  • Each datagram shall fit into one section.
See also
ETSI EN 301 192, section 7.1.

Constructor & Destructor Documentation

◆ MPEPacket() [1/5]

ts::MPEPacket::MPEPacket ( )
default

Default constructor.

Section is initially marked invalid.

◆ MPEPacket() [2/5]

ts::MPEPacket::MPEPacket ( const MPEPacket other,
ShareMode  mode 
)

Copy constructor.

Parameters
[in]otherAnother instance to copy.
[in]modeThe datagram contents are either shared (ShareMode::SHARE) between the two instances or duplicated (ts::ShareMode::COPY).

◆ MPEPacket() [3/5]

ts::MPEPacket::MPEPacket ( MPEPacket &&  other)
noexcept

Move constructor.

Parameters
[in,out]otherAnother instance to move.

◆ MPEPacket() [4/5]

ts::MPEPacket::MPEPacket ( ByteBlockPtr  datagram,
ShareMode  mode,
const MACAddress mac = MACAddress(),
PID  pid = PID_NULL 
)

Constructor from a full datagram (including network headers).

Parameters
[in]datagramSmart pointer to the complete datagram content. The datagram typically includes the IP and UDP headers. The datagram is analyzed and marked invalid if no valid UDP/IP header is found.
[in]modeThe datagram contents are either shared (ShareMode::SHARE) between the two instances or duplicated (ShareMode::COPY).
[in]macDestination MAC address. If unspecified and the destination IP address is multicast, the corresponding MAC address is used.
[in]pidPID from which the DSM-CC section was read.

◆ MPEPacket() [5/5]

ts::MPEPacket::MPEPacket ( const Section section)

Constructor from a DSM-CC MPE section.

Parameters
[in]sectionA binary DSM-CC MPE section.

Member Function Documentation

◆ clear()

void ts::MPEPacket::clear ( )

Clear content.

Becomes invalid.

◆ operator=() [1/2]

MPEPacket & ts::MPEPacket::operator= ( const MPEPacket other)

Assignment operator.

The contents are referenced, and thus shared between the two objects.

Parameters
[in]otherOther instance to assign to this object.
Returns
A reference to this object.

◆ operator=() [2/2]

MPEPacket & ts::MPEPacket::operator= ( MPEPacket &&  other)
noexcept

Move assignment operator.

Parameters
[in,out]otherOther instance to move into this object.
Returns
A reference to this object.

◆ copy() [1/2]

MPEPacket & ts::MPEPacket::copy ( const MPEPacket other)

Duplication.

Similar to assignment but the objects are duplicated.

Parameters
[in]otherOther instance to duplicate into this object.
Returns
A reference to this object.

◆ copy() [2/2]

MPEPacket & ts::MPEPacket::copy ( const Section section)

Copy content from a DSM-CC MPE section.

Parameters
[in]sectionA binary DSM-CC MPE section.
Returns
A reference to this object.

◆ createSection()

void ts::MPEPacket::createSection ( Section section) const

Create a DSM-CC MPE section containing the MPE packet.

Parameters
[out]sectionA binary DSM-CC MPE section to create.

◆ isValid()

bool ts::MPEPacket::isValid ( ) const
inline

Check if the packet has valid content.

Returns
True if the packet has valid content.

◆ sourcePID()

PID ts::MPEPacket::sourcePID ( ) const
inline

Get the source PID.

Returns
The source PID.

◆ setSourcePID()

void ts::MPEPacket::setSourcePID ( PID  pid)
inline

Set the source PID.

Parameters
[in]pidThe source PID.

◆ destinationMACAddress()

MACAddress ts::MPEPacket::destinationMACAddress ( ) const
inline

Get the destination MAC address.

Returns
The destination MAC address.

◆ setDestinationMACAddress()

void ts::MPEPacket::setDestinationMACAddress ( const MACAddress mac)
inline

Set the destination MAC address.

Parameters
[in]macThe destination MAC address.

◆ sourceIPAddress()

IPv4Address ts::MPEPacket::sourceIPAddress ( ) const

Get the source IP address.

Returns
The source IP address.

◆ setSourceIPAddress()

void ts::MPEPacket::setSourceIPAddress ( const IPv4Address ip)

Set the source IP address.

Parameters
[in]ipThe source IP address.

◆ destinationIPAddress()

IPv4Address ts::MPEPacket::destinationIPAddress ( ) const

Get the destination IP address.

Returns
The destination IP address.

◆ setDestinationIPAddress()

void ts::MPEPacket::setDestinationIPAddress ( const IPv4Address ip)

Set the destination IP address.

Parameters
[in]ipThe destination IP address.

◆ sourceUDPPort()

uint16_t ts::MPEPacket::sourceUDPPort ( ) const

Get the source UDP port.

Returns
The source UDP port.

◆ setSourceUDPPort()

void ts::MPEPacket::setSourceUDPPort ( uint16_t  port)

Set the source UDP port.

Parameters
[in]portThe source UDP port.

◆ destinationUDPPort()

uint16_t ts::MPEPacket::destinationUDPPort ( ) const

Get the destination UDP port.

Returns
The destination UDP port.

◆ setDestinationUDPPort()

void ts::MPEPacket::setDestinationUDPPort ( uint16_t  port)

Set the destination UDP port.

Parameters
[in]portThe destination UDP port.

◆ sourceSocket()

IPv4SocketAddress ts::MPEPacket::sourceSocket ( ) const

Get the source socket address.

Returns
The source socket address.

◆ setSourceSocket()

void ts::MPEPacket::setSourceSocket ( const IPv4SocketAddress sock)

Set the source socket address.

Parameters
[in]sockThe source socket address.

◆ destinationSocket()

IPv4SocketAddress ts::MPEPacket::destinationSocket ( ) const

Get the destination socket address.

Returns
The destination socket address.

◆ setDestinationSocket()

void ts::MPEPacket::setDestinationSocket ( const IPv4SocketAddress sock)

Set the destination socket address.

Parameters
[in]sockThe destination socket address.

◆ udpMessage()

const uint8_t * ts::MPEPacket::udpMessage ( ) const

Access to the binary content of the UDP message.

Do not modify content.

Returns
Address of the binary content of the UDP message payload. May be invalidated after modification in section.

◆ udpMessageSize()

size_t ts::MPEPacket::udpMessageSize ( ) const

Size of the binary content of the UDP message.

Returns
Size of the binary content of the UDP message.

◆ datagram()

const uint8_t * ts::MPEPacket::datagram ( ) const
inline

Access to the binary content of the complete network datagram.

Do not modify content.

Returns
Address of the binary content of the complete network datagram. May be invalidated after modification in section.

◆ datagramSize()

size_t ts::MPEPacket::datagramSize ( ) const
inline

Size of the binary content of the complete network datagram.

Returns
Size of the binary content of the complete network datagram.

◆ setUDPMessage()

bool ts::MPEPacket::setUDPMessage ( const uint8_t *  data,
size_t  size 
)

Replace the binary content of the UDP message.

Parameters
[in]dataAddress of the binary content of the UDP message payload.
[in]sizeSize of the binary content of the UDP message. May be invalidated after modification in section.
Returns
True on success, false on invalid parameters.

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