Transport stream file input with a seekable buffer.
More...
|
| TSFileInputBuffered (size_t buffer_size) |
| Constructor. More...
|
|
virtual | ~TSFileInputBuffered () |
| Destructor.
|
|
void | abortRead () |
| Abort any currenly read operation in progress. More...
|
|
bool | canSeek (PacketCounter position) const |
| Check if we can seek to the specified absolute position. More...
|
|
bool | close (Report &report) |
| Close the file. More...
|
|
size_t | getBackwardSeekableCount () const |
| Get the backward seekable distance inside the buffer. More...
|
|
size_t | getBufferedCount () const |
| Get the number of TS packets in the buffer. More...
|
|
size_t | getBufferFreeSize () const |
| Get the size of the free space in the buffer. More...
|
|
size_t | getBufferSize () const |
| Get the buffer size. More...
|
|
int | getErrorSeverityLevel () const |
| Get the severity level for error reporting. More...
|
|
UString | getFileName () const |
| Get the file name. More...
|
|
size_t | getForwardSeekableCount () const |
| Get the forward seekable distance inside the buffer. More...
|
|
PacketCounter | getPacketCount () const |
| Get the number of read packets. More...
|
|
bool | isOpen () const |
| Check if the file is open. More...
|
|
bool | open (const UString &filename, uint64_t start_offset, Report &report) |
| Open the file in rewindable mode. More...
|
|
bool | open (const UString &filename, size_t repeat_count, uint64_t start_offset, Report &report) |
| Open the file. More...
|
|
size_t | read (TSPacket *buffer, size_t max_packets, Report &report) |
| Read TS packets. More...
|
|
bool | seek (PacketCounter position, Report &report) |
| Seek to the specified absolute position, if it is inside the buffer. More...
|
|
bool | seekBackward (size_t packet_count, Report &report) |
| Seek the file backward the specified number of packets. More...
|
|
bool | seekForward (size_t packet_count, Report &report) |
| Seek the file forward the specified number of packets. More...
|
|
bool | setBufferSize (size_t buffer_size, Report &report) |
| Set the buffer size. More...
|
|
void | setErrorSeverityLevel (int level) |
| Set the severity level for error reporting. More...
|
|
Transport stream file input with a seekable buffer.
This variant of TSFileInput allows to seek back and forth to some extent without doing I/O's and can work on non-seekable files (pipes for instance).
◆ TSFileInputBuffered()
ts::TSFileInputBuffered::TSFileInputBuffered |
( |
size_t |
buffer_size | ) |
|
Constructor.
- Parameters
-
[in] | buffer_size | Size of the seekable buffer in number of TS packets. |
◆ setBufferSize()
bool ts::TSFileInputBuffered::setBufferSize |
( |
size_t |
buffer_size, |
|
|
Report & |
report |
|
) |
| |
Set the buffer size.
Can be done only when the file is closed.
- Parameters
-
[in] | buffer_size | Size of the seekable buffer in number of TS packets. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ getBufferSize()
size_t ts::TSFileInputBuffered::getBufferSize |
( |
| ) |
const |
|
inline |
Get the buffer size.
- Returns
- The buffer size in number of TS packets.
◆ getBufferFreeSize()
size_t ts::TSFileInputBuffered::getBufferFreeSize |
( |
| ) |
const |
|
inline |
Get the size of the free space in the buffer.
- Returns
- The number of free TS packets in the buffer.
◆ getBufferedCount()
size_t ts::TSFileInputBuffered::getBufferedCount |
( |
| ) |
const |
|
inline |
Get the number of TS packets in the buffer.
- Returns
- The number of TS packets in the buffer.
◆ open() [1/2]
bool ts::TSFileInputBuffered::open |
( |
const UString & |
filename, |
|
|
size_t |
repeat_count, |
|
|
uint64_t |
start_offset, |
|
|
Report & |
report |
|
) |
| |
Open the file.
Override TSFileInput::open(). There is no rewindable version.
- Parameters
-
[in] | filename | File name. If empty, use standard input. Must be a regular file is repeat_count is not 1 or if start_offset is not zero. |
[in] | repeat_count | Reading packets loops back after end of file until all repeat are done. If zero, infinitely repeat. |
[in] | start_offset | Offset in bytes from the beginning of the file where to start reading packets at each iteration. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ read()
size_t ts::TSFileInputBuffered::read |
( |
TSPacket * |
buffer, |
|
|
size_t |
max_packets, |
|
|
Report & |
report |
|
) |
| |
Read TS packets.
If the file file was opened with a repeat_count different from 1, reading packets transparently loops back at end if file.
- Parameters
-
[out] | buffer | Address of reception packet buffer. |
[in] | max_packets | Size of buffer in packets. |
[in,out] | report | Where to report errors. |
- Returns
- The actual number of read packets. Returning zero means error or end of file repetition.
◆ getBackwardSeekableCount()
size_t ts::TSFileInputBuffered::getBackwardSeekableCount |
( |
| ) |
const |
|
inline |
Get the backward seekable distance inside the buffer.
This is the minimum guaranteed seekable distance.
- Returns
- The buffer size from the highest previously read packet or the beginning of file, whichever comes first.
◆ getForwardSeekableCount()
size_t ts::TSFileInputBuffered::getForwardSeekableCount |
( |
| ) |
const |
|
inline |
Get the forward seekable distance inside the buffer.
This is the minimum guaranteed seekable distance.
- Returns
- The highest previously read packet index, before backward seek.
◆ seekBackward()
bool ts::TSFileInputBuffered::seekBackward |
( |
size_t |
packet_count, |
|
|
Report & |
report |
|
) |
| |
Seek the file backward the specified number of packets.
- Parameters
-
[in] | packet_count | The number of packets to seek backward from the current position. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ seekForward()
bool ts::TSFileInputBuffered::seekForward |
( |
size_t |
packet_count, |
|
|
Report & |
report |
|
) |
| |
Seek the file forward the specified number of packets.
- Parameters
-
[in] | packet_count | The number of packets to seek forward from the current position. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ getPacketCount()
Get the number of read packets.
- Returns
- The number of read packets.
◆ canSeek()
bool ts::TSFileInputBuffered::canSeek |
( |
PacketCounter |
position | ) |
const |
Check if we can seek to the specified absolute position.
- Parameters
-
[in] | position | Absolute packet index in the file. |
- Returns
- True if the specified position is inside the buffer.
◆ seek()
Seek to the specified absolute position, if it is inside the buffer.
- Parameters
-
[in] | position | Absolute packet index in the file. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ open() [2/2]
bool ts::TSFileInput::open |
( |
const UString & |
filename, |
|
|
uint64_t |
start_offset, |
|
|
Report & |
report |
|
) |
| |
|
inherited |
Open the file in rewindable mode.
The file must be a rewindable file, eg. not a pipe. There is no repeat count, rewind must be done explicitly.
- Parameters
-
[in] | filename | File name. If empty, use standard input. |
[in] | start_offset | Offset in bytes from the beginning of the file where to start reading packets. |
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
- See also
- rewind()
-
seek()
◆ isOpen()
bool ts::TSFileInput::isOpen |
( |
| ) |
const |
|
inlineinherited |
Check if the file is open.
- Returns
- True if the file is open.
◆ getErrorSeverityLevel()
int ts::TSFileInput::getErrorSeverityLevel |
( |
| ) |
const |
|
inlineinherited |
Get the severity level for error reporting.
- Returns
- The severity level for error reporting.
◆ setErrorSeverityLevel()
void ts::TSFileInput::setErrorSeverityLevel |
( |
int |
level | ) |
|
|
inlineinherited |
Set the severity level for error reporting.
- Parameters
-
[in] | level | The severity level for error reporting. The default is Error. |
◆ getFileName()
UString ts::TSFileInput::getFileName |
( |
| ) |
const |
|
inlineinherited |
Get the file name.
- Returns
- The file name.
◆ close()
bool ts::TSFileInput::close |
( |
Report & |
report | ) |
|
|
inherited |
Close the file.
- Parameters
-
[in,out] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ abortRead()
void ts::TSFileInput::abortRead |
( |
| ) |
|
|
inherited |
Abort any currenly read operation in progress.
The file is left in a broken state and can be only closed.
◆ MIN_BUFFER_SIZE
const size_t ts::TSFileInputBuffered::MIN_BUFFER_SIZE = 16 |
|
static |
Minimum buffer size.
Used to minimize buffer_size in constructor and setBufferSize().
The documentation for this class was generated from the following file: