A subclass of QFile which reads and writes MPEG transport stream packets instead of raw data.
More...
A subclass of QFile which reads and writes MPEG transport stream packets instead of raw data.
◆ TsFileType
Describe the packet format inside a TS file.
Enumerator |
---|
AutoDetect | Automatically detect on input, same as TsFile on output.
|
TsFile | Standard MPEG-2 Transport Stream file, 188 bytes per TS packet.
|
M2tsFile | M2TS file (BluRay and some IP-TV), 4-byte timestamp followed by 188-byte TS packet.
|
◆ QtsTsFile() [1/2]
QtsTsFile::QtsTsFile |
( |
QObject * |
parent = 0 | ) |
|
|
explicit |
Constructor.
- Parameters
-
[in] | parent | Optional parent object. |
◆ QtsTsFile() [2/2]
Constructor.
- Parameters
-
[in] | name | File name. |
[in] | type | TS packet format. |
[in] | parent | Optional parent object. |
◆ open()
bool QtsTsFile::open |
( |
OpenMode |
mode = ReadOnly | ) |
|
|
virtual |
Open the file.
Reimplemented from QIODevice.
- Parameters
-
[in] | mode | The mode into which the file shall been open. |
- Returns
- True on success, false on error.
◆ read()
int QtsTsFile::read |
( |
QtsTsPacket * |
buffer, |
|
|
int |
maxPacketCount = 1 |
|
) |
| |
Read as many TS packets as possible from the file.
- Parameters
-
[out] | buffer | Buffer receiving the TS packets. |
[in] | maxPacketCount | Size in buffer in number of TS packets. |
- Returns
- Number of TS packets actually read or negative on error.
◆ write()
bool QtsTsFile::write |
( |
const QtsTsPacket * |
buffer, |
|
|
int |
packetCount = 1 |
|
) |
| |
Write TS packets to the file.
- Parameters
-
[in] | buffer | Buffer containing the TS packets to write. If the file format is M2tsFile, a zero 4-byte timestamp is inserted before each packet. |
[in] | packetCount | Number of TS packets to write from buffer. |
- Returns
- True on success, false on error.
◆ writeWithTimeStamp()
bool QtsTsFile::writeWithTimeStamp |
( |
quint32 |
timeStamp, |
|
|
const QtsTsPacket * |
packet |
|
) |
| |
Write one TS packet with timestamp to the file.
- Parameters
-
[in] | packet | TS packet to write. |
[in] | timeStamp | Time stamp to write (will be converted to big endian before writing). Ignored if the file format is not M2tsFile. |
- Returns
- True on success, false on error.
◆ tsFileType()
Get the TS packet format.
If initially set to AutoDetect on an input file, the returned value will be either TsFile or M2tsFile after reading the first packet.
- Returns
- The TS packet format.
◆ setTsFileType()
void QtsTsFile::setTsFileType |
( |
const TsFileType & |
tsFileType | ) |
|
Set the TS packet format.
Must be called before open().
- Returns
- The TS packet format.
◆ autoDetectFileFormat()
bool QtsTsFile::autoDetectFileFormat |
( |
| ) |
|
|
private |
Read enough packets in _inBuffer to determine the packet size.
- Returns
- True on success, false on error. When true is returned, it is guaranteed that _tsFileType is no longer AutoDetect.
◆ fillBuffer()
bool QtsTsFile::fillBuffer |
( |
int |
size | ) |
|
|
private |
Make sure that the internal input buffer contains at least a given number of bytes.
Read input file if necessary.
- Parameters
-
size | Requested byte count in buffer. |
- Returns
- False on read error. When true, the target number of bytes may not be reached if no data is currently available from the file.
◆ writeRawData()
bool QtsTsFile::writeRawData |
( |
const void * |
data, |
|
|
int |
size |
|
) |
| |
|
private |
Write raw data to the file.
- Parameters
-
[in] | data | Address of data to write. |
[in] | size | Number of bytes to write from data. |
- Returns
- True on success, false on error.
◆ _tsFileType
◆ _inBuffer
Buffer for partially read packets or initial auto-detection.
The documentation for this class was generated from the following files: