Torc
0.1
|
#include <torcsegmentedringbuffer.h>
Signals | |
void | InitSegmentReady (void) |
void | SegmentReady (int Segment) |
void | SegmentRemoved (int Segment) |
Public Member Functions | |
TorcSegmentedRingBuffer (int Size, int MaxSegments) | |
~TorcSegmentedRingBuffer () | |
int | GetSize (void) |
Return the size of the buffer (NOT the number of segments). More... | |
int | GetHead (void) |
Return the number of the segment at the head of the queue (the newest). More... | |
int | GetSegmentsAvail (int &TailRef) |
Return the number of available segments. More... | |
int | Write (QByteArray *Data, int Size) |
int | Write (const uint8_t *Data, int Size) |
Write data to the current segment. More... | |
int | FinishSegment (bool Init) |
Finish the current segment and start a new one. More... | |
int | ReadSegment (uint8_t *Data, int Max, int SegmentRef, int Offset=0) |
Copy Max bytes of a segment identified by SegmentRef into the memory pointed to at Dst. More... | |
int | ReadSegment (QIODevice *Dst, int SegmentRef) |
Copy the segment identified by SegmentRef to the IODevice specified by Dst. More... | |
QByteArray | GetSegment (int SegmentRef) |
Return a copy of the segment identified by SegmentRef. More... | |
QByteArray | GetInitSegment (void) |
Return a copy of the MP4 'init' segment. More... | |
void | SaveInitSegment (void) |
Save the MP4 'init' segment. More... | |
Protected Member Functions | |
int | GetBytesFree (void) |
Return the number of free bytes available for writing. More... | |
Protected Attributes | |
int | m_size |
QByteArray | m_data |
int | m_readPosition |
int | m_writePosition |
int | m_currentSize |
int | m_currentStartPosition |
QReadWriteLock | m_segmentsLock |
QQueue< QPair< int, int > > | m_segments |
QQueue< int > | m_segmentRefs |
int | m_segmentCounter |
int | m_maxSegments |
QByteArray | m_initSegment |
A circular buffer customised for storing segmented media data - principally fragmented MP4 files but should work with other formats such as transport streams (TS).
The owner is responsible for ensuring the total buffer size is appropriate for the use case (i.e. media type/bitrate and buffering required).
Definition at line 10 of file torcsegmentedringbuffer.h.
|
explicit |
Definition at line 35 of file torcsegmentedringbuffer.cpp.
TorcSegmentedRingBuffer::~TorcSegmentedRingBuffer | ( | ) |
Definition at line 52 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::FinishSegment | ( | bool | Init | ) |
Finish the current segment and start a new one.
The buffer's owner is responsible for indicating that the segment is finished.
Init | Indicates that this is an MP4 'init' segment that should be saved separately. |
Definition at line 110 of file torcsegmentedringbuffer.cpp.
|
inlineprotected |
Return the number of free bytes available for writing.
Definition at line 60 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::GetHead | ( | void | ) |
Return the number of the segment at the head of the queue (the newest).
Definition at line 78 of file torcsegmentedringbuffer.cpp.
QByteArray TorcSegmentedRingBuffer::GetInitSegment | ( | void | ) |
Return a copy of the MP4 'init' segment.
Definition at line 287 of file torcsegmentedringbuffer.cpp.
QByteArray TorcSegmentedRingBuffer::GetSegment | ( | int | SegmentRef | ) |
Return a copy of the segment identified by SegmentRef.
Definition at line 267 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::GetSegmentsAvail | ( | int & | TailRef | ) |
Return the number of available segments.
If the buffer is not empty, TailRef will be set to the value of the oldest segment.
Definition at line 92 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::GetSize | ( | void | ) |
Return the size of the buffer (NOT the number of segments).
Definition at line 72 of file torcsegmentedringbuffer.cpp.
|
signal |
int TorcSegmentedRingBuffer::ReadSegment | ( | uint8_t * | Dst, |
int | Max, | ||
int | SegmentRef, | ||
int | Offset = 0 |
||
) |
Copy Max bytes of a segment identified by SegmentRef into the memory pointed to at Dst.
If returned value == MAX, try again with offset
Definition at line 185 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::ReadSegment | ( | QIODevice * | Dst, |
int | SegmentRef | ||
) |
Copy the segment identified by SegmentRef to the IODevice specified by Dst.
Definition at line 214 of file torcsegmentedringbuffer.cpp.
void TorcSegmentedRingBuffer::SaveInitSegment | ( | void | ) |
Save the MP4 'init' segment.
Definition at line 233 of file torcsegmentedringbuffer.cpp.
|
signal |
|
signal |
int TorcSegmentedRingBuffer::Write | ( | QByteArray * | Data, |
int | Size | ||
) |
Definition at line 172 of file torcsegmentedringbuffer.cpp.
int TorcSegmentedRingBuffer::Write | ( | const uint8_t * | Data, |
int | Size | ||
) |
Write data to the current segment.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 137 of file torcsegmentedringbuffer.cpp.
|
protected |
Definition at line 43 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 44 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 40 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 50 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 49 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 41 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 48 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 47 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 46 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 45 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 39 of file torcsegmentedringbuffer.h.
|
protected |
Definition at line 42 of file torcsegmentedringbuffer.h.