MythTV  master
Public Member Functions | Protected Attributes | List of all members
PacketBuffer Class Referenceabstract

#include <libmythtv/recorders/rtp/packetbuffer.h>

Inheritance diagram for PacketBuffer:
[legend]
Collaboration diagram for PacketBuffer:
[legend]

Public Member Functions

 PacketBuffer (unsigned int bitrate)
 
virtual ~PacketBuffer ()=default
 
virtual void PushDataPacket (const UDPPacket &)=0
 
virtual void PushFECPacket (const UDPPacket &, unsigned int)=0
 
bool HasAvailablePacket (void) const
 Returns true if there are ordered packets ready for processing. More...
 
UDPPacket PopDataPacket (void)
 Fetches a data packet for processing. More...
 
UDPPacket GetEmptyPacket (void)
 Gets a packet for use in PushDataPacket/PushFECPacket. More...
 
void FreePacket (const UDPPacket &packet)
 Frees an RTPDataPacket returned by PopDataPacket. More...
 

Protected Attributes

uint m_bitrate
 
uint64_t m_next_empty_packet_key
 Packets key to use for next empty packet. More...
 
QMap< uint64_t, UDPPacketm_empty_packets
 Packets ready for reuse. More...
 
QList< UDPPacketm_available_packets
 Ordered list of available packets. More...
 

Detailed Description

Definition at line 15 of file packetbuffer.h.

Constructor & Destructor Documentation

◆ PacketBuffer()

PacketBuffer::PacketBuffer ( unsigned int  bitrate)
explicit

Definition at line 13 of file packetbuffer.cpp.

◆ ~PacketBuffer()

virtual PacketBuffer::~PacketBuffer ( )
virtualdefault

Member Function Documentation

◆ PushDataPacket()

virtual void PacketBuffer::PushDataPacket ( const UDPPacket )
pure virtual

◆ PushFECPacket()

virtual void PacketBuffer::PushFECPacket ( const UDPPacket ,
unsigned int   
)
pure virtual

◆ HasAvailablePacket()

bool PacketBuffer::HasAvailablePacket ( void  ) const

Returns true if there are ordered packets ready for processing.

Definition at line 19 of file packetbuffer.cpp.

Referenced by IPTVStreamHandlerWriteHelper::timerEvent().

◆ PopDataPacket()

UDPPacket PacketBuffer::PopDataPacket ( void  )

Fetches a data packet for processing.

Call FreePacket() when done with the packet.

Definition at line 24 of file packetbuffer.cpp.

Referenced by IPTVStreamHandlerWriteHelper::timerEvent().

◆ GetEmptyPacket()

UDPPacket PacketBuffer::GetEmptyPacket ( void  )

Gets a packet for use in PushDataPacket/PushFECPacket.

Definition at line 35 of file packetbuffer.cpp.

Referenced by IPTVStreamHandlerReadHelper::ReadPending().

◆ FreePacket()

void PacketBuffer::FreePacket ( const UDPPacket packet)

Frees an RTPDataPacket returned by PopDataPacket.

Note
Since we return UDPPackets and not pointers to packets we don't leak if this isn't called, but by preventing the reference count on the QByteArrays from going to 0 we can reuse the byte array and avoid mallocs.

Definition at line 49 of file packetbuffer.cpp.

Referenced by UDPPacketBuffer::PushFECPacket(), RTPPacketBuffer::PushFECPacket(), and IPTVStreamHandlerWriteHelper::timerEvent().

Member Data Documentation

◆ m_bitrate

uint PacketBuffer::m_bitrate
protected

Definition at line 44 of file packetbuffer.h.

◆ m_next_empty_packet_key

uint64_t PacketBuffer::m_next_empty_packet_key
protected

Packets key to use for next empty packet.

The upper 32 bits are random and the lower 32 bits are incremented from 0.

Definition at line 49 of file packetbuffer.h.

Referenced by FreePacket(), and GetEmptyPacket().

◆ m_empty_packets

QMap<uint64_t, UDPPacket> PacketBuffer::m_empty_packets
protected

Packets ready for reuse.

Definition at line 52 of file packetbuffer.h.

Referenced by FreePacket(), and GetEmptyPacket().

◆ m_available_packets

QList<UDPPacket> PacketBuffer::m_available_packets
protected

Ordered list of available packets.

Definition at line 55 of file packetbuffer.h.

Referenced by HasAvailablePacket(), PopDataPacket(), UDPPacketBuffer::PushDataPacket(), and RTPPacketBuffer::PushDataPacket().


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