TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TSFileInput Class Reference

Transport Stream file input. More...

Inheritance diagram for ts::TSFileInput:
Collaboration diagram for ts::TSFileInput:

Public Member Functions

 TSFileInput ()
 Default constructor.
 
virtual ~TSFileInput ()
 Destructor.
 
void abortRead ()
 Abort any currenly read operation in progress. More...
 
bool close (Report &report)
 Close the file. More...
 
int getErrorSeverityLevel () const
 Get the severity level for error reporting. More...
 
UString getFileName () const
 Get the file name. 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, size_t repeat_count, uint64_t start_offset, Report &report)
 Open the file. More...
 
bool open (const UString &filename, uint64_t start_offset, Report &report)
 Open the file in rewindable mode. More...
 
size_t read (TSPacket *buffer, size_t max_packets, Report &report)
 Read TS packets. More...
 
bool rewind (Report &report)
 Rewind the file. More...
 
bool seek (PacketCounter packet_index, Report &report)
 Seek the file at a specified packet index. More...
 
void setErrorSeverityLevel (int level)
 Set the severity level for error reporting. More...
 

Protected Attributes

UString _filename
 Input file name.
 
PacketCounter _total_packets
 Total read packets.
 

Detailed Description

Transport Stream file input.

Member Function Documentation

◆ open() [1/2]

bool ts::TSFileInput::open ( const UString filename,
size_t  repeat_count,
uint64_t  start_offset,
Report report 
)

Open the file.

Parameters
[in]filenameFile 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_countReading packets loops back after end of file until all repeat are done. If zero, infinitely repeat.
[in]start_offsetOffset in bytes from the beginning of the file where to start reading packets at each iteration.
[in,out]reportWhere 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 
)

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]filenameFile name. If empty, use standard input.
[in]start_offsetOffset in bytes from the beginning of the file where to start reading packets.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.
See also
rewind()
seek()

◆ isOpen()

bool ts::TSFileInput::isOpen ( ) const
inline

Check if the file is open.

Returns
True if the file is open.

◆ getErrorSeverityLevel()

int ts::TSFileInput::getErrorSeverityLevel ( ) const
inline

Get the severity level for error reporting.

Returns
The severity level for error reporting.

◆ setErrorSeverityLevel()

void ts::TSFileInput::setErrorSeverityLevel ( int  level)
inline

Set the severity level for error reporting.

Parameters
[in]levelThe severity level for error reporting. The default is Error.

◆ getFileName()

UString ts::TSFileInput::getFileName ( ) const
inline

Get the file name.

Returns
The file name.

◆ close()

bool ts::TSFileInput::close ( Report report)

Close the file.

Parameters
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ read()

size_t ts::TSFileInput::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]bufferAddress of reception packet buffer.
[in]max_packetsSize of buffer in packets.
[in,out]reportWhere to report errors.
Returns
The actual number of read packets. Returning zero means error or end of file repetition.

◆ abortRead()

void ts::TSFileInput::abortRead ( )

Abort any currenly read operation in progress.

The file is left in a broken state and can be only closed.

◆ rewind()

bool ts::TSFileInput::rewind ( Report report)
inline

Rewind the file.

The file must have been opened in rewindable mode. If the file file was opened with a start_offset different from 0, rewinding the file means restarting at this start_offset.

Parameters
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ seek()

bool ts::TSFileInput::seek ( PacketCounter  packet_index,
Report report 
)

Seek the file at a specified packet index.

The file must have been opened in rewindable mode.

Parameters
[in]packet_indexSeek the file to this specified packet index (plus the previously specified start_offset).
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ getPacketCount()

PacketCounter ts::TSFileInput::getPacketCount ( ) const
inline

Get the number of read packets.

Returns
The number of read packets.

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