Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adds Raw UDP streaming support.
To test change rtp to udp in IPTVChannel::Tune().
- Loading branch information
1 parent
cfe2a50
commit 3b3b172
Showing
9 changed files
with
223 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* -*- Mode: c++ -*- | ||
* PacketBuffer | ||
* Copyright (c) 2012 Digital Nirvana, Inc. | ||
* Distributed as part of MythTV under GPL v2 and later. | ||
*/ | ||
|
||
// POSIX headers | ||
#include <stdlib.h> // for random | ||
|
||
// MythTV headers | ||
#include "packetbuffer.h" | ||
#include "compat.h" // for random on windows | ||
|
||
PacketBuffer::PacketBuffer(unsigned int bitrate) : | ||
m_bitrate(bitrate), | ||
m_next_empty_packet_key(0ULL) | ||
{ | ||
while (!m_next_empty_packet_key) | ||
{ | ||
m_next_empty_packet_key = | ||
(random() << 24) ^ (random() << 16) ^ | ||
(random() << 8) ^ random(); | ||
} | ||
} | ||
|
||
bool PacketBuffer::HasAvailablePacket(void) const | ||
{ | ||
return !m_available_packets.empty(); | ||
} | ||
|
||
UDPPacket PacketBuffer::PopDataPacket(void) | ||
{ | ||
if (m_available_packets.empty()) | ||
return UDPPacket(0); | ||
|
||
UDPPacket packet(m_available_packets.front()); | ||
m_available_packets.pop_front(); | ||
|
||
return packet; | ||
} | ||
|
||
UDPPacket PacketBuffer::GetEmptyPacket(void) | ||
{ | ||
QMap<uint64_t, UDPPacket>::iterator it = m_empty_packets.begin(); | ||
if (it == m_empty_packets.end()) | ||
{ | ||
return UDPPacket(m_next_empty_packet_key++); | ||
} | ||
|
||
UDPPacket packet(*it); | ||
m_empty_packets.erase(it); | ||
|
||
return packet; | ||
} | ||
|
||
void PacketBuffer::FreePacket(const UDPPacket &packet) | ||
{ | ||
uint64_t top = packet.GetKey() & (0xFFFFFFFFULL<<32); | ||
if (top == (m_next_empty_packet_key & (0xFFFFFFFFULL<<32))) | ||
m_empty_packets[packet.GetKey()] = packet; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* -*- Mode: c++ -*- | ||
* PacketBuffer | ||
* Copyright (c) 2012 Digital Nirvana, Inc. | ||
* Distributed as part of MythTV under GPL v2 and later. | ||
*/ | ||
|
||
#ifndef _PACKET_BUFFER_H_ | ||
#define _PACKET_BUFFER_H_ | ||
|
||
#include <QList> | ||
#include <QMap> | ||
|
||
#include "udppacket.h" | ||
|
||
class PacketBuffer | ||
{ | ||
public: | ||
PacketBuffer(unsigned int bitrate); | ||
virtual ~PacketBuffer() { } | ||
|
||
virtual void PushDataPacket(const UDPPacket&) = 0; | ||
|
||
virtual void PushFECPacket(const UDPPacket&, unsigned int) = 0; | ||
|
||
/// \brief Returns true if there are ordered packets ready for processing. | ||
bool HasAvailablePacket(void) const; | ||
|
||
/// \brief Fetches a data packet for processing. | ||
/// Call FreePacket() when done with the packet. | ||
UDPPacket PopDataPacket(void); | ||
|
||
/// Gets a packet for use in PushDataPacket/PushFECPacket. | ||
UDPPacket GetEmptyPacket(void); | ||
|
||
/** \brief 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. | ||
*/ | ||
void FreePacket(const UDPPacket &); | ||
|
||
protected: | ||
uint m_bitrate; | ||
|
||
/// Packets key to use for next empty packet | ||
uint64_t m_next_empty_packet_key; | ||
|
||
/// Packets ready for reuse | ||
QMap<uint64_t, UDPPacket> m_empty_packets; | ||
|
||
/// Ordered list of available packets | ||
QList<UDPPacket> m_available_packets; | ||
}; | ||
|
||
#endif // _PACKET_BUFFER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.