Tag Parser 10.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
The AbstractTrack class parses and stores technical information about video, audio and other kinds of media tracks. More...
#include <abstracttrack.h>
Public Member Functions | |
virtual | ~AbstractTrack () |
Destroys the track. More... | |
virtual TrackType | type () const |
Returns the type of the track if known; otherwise returns TrackType::Unspecified. More... | |
std::istream & | inputStream () |
Returns the associated input stream. More... | |
void | setInputStream (std::istream &stream) |
Assigns another input stream. More... | |
std::ostream & | outputStream () |
Returns the associated output stream. More... | |
void | setOutputStream (std::ostream &stream) |
Assigns another output stream. More... | |
CppUtilities::BinaryReader & | reader () |
Returns a binary reader for the associated stream. More... | |
CppUtilities::BinaryWriter & | writer () |
Returns a binary writer for the associated stream. More... | |
std::uint64_t | startOffset () const |
Returns the start offset of the track in the associated stream. More... | |
TrackFlags | flags () const |
Returns flags (various boolean properties) of this track. More... | |
MediaFormat | format () const |
Returns the format of the track if known; otherwise returns MediaFormat::Unknown. More... | |
double | version () const |
Returns the version/level of the track if known; otherwise returns 0. More... | |
std::string_view | formatName () const |
Returns the format of the track as C-style string if known; otherwise returns the format abbreviation or an empty string. More... | |
std::string_view | formatAbbreviation () const |
Returns the a more or less common abbreviation for the format of the track if known; otherwise returns an empty string. More... | |
const std::string & | formatId () const |
Returns the format/codec ID. More... | |
MediaType | mediaType () const |
Returns the media type if known; otherwise returns MediaType::Other. More... | |
std::string_view | mediaTypeName () const |
Returns the string representation of the media type of the track. More... | |
std::uint64_t | size () const |
Returns the size in bytes if known; otherwise returns 0. More... | |
std::uint32_t | trackNumber () const |
Returns the track number if known; otherwise returns 0. More... | |
void | setTrackNumber (std::uint32_t trackNumber) |
Sets the track number. More... | |
std::uint64_t | id () const |
Returns the track ID if known; otherwise returns 0. More... | |
void | setId (std::uint64_t id) |
Sets the track ID. More... | |
const std::string | name () const |
Returns the track name if known; otherwise returns an empty string. More... | |
void | setName (std::string_view name) |
Sets the name. More... | |
const CppUtilities::TimeSpan & | duration () const |
Returns the duration if known; otherwise returns a TimeSpan of zero ticks. More... | |
double | bitrate () const |
Returns the average bitrate in kbit/s if known; otherwise returns zero. More... | |
double | maxBitrate () const |
Returns the maximum bitrate in kbit/s if known; otherwise returns zero. More... | |
const CppUtilities::DateTime & | creationTime () const |
Returns the creation time if known; otherwise returns a DateTime of zero ticks. More... | |
const CppUtilities::DateTime & | modificationTime () const |
Returns the time of the last modification if known; otherwise returns a DateTime of zero ticks. More... | |
const Locale & | locale () const |
Returns the locale of the track if known; otherwise returns an empty locale. More... | |
void | setLocale (const Locale &locale) |
Sets the locale of the track. More... | |
std::uint32_t | samplingFrequency () const |
Returns the number of samples per second if known; otherwise returns 0. More... | |
std::uint32_t | extensionSamplingFrequency () const |
Returns the number of samples per second if known; otherwise returns 0. More... | |
std::uint16_t | bitsPerSample () const |
Returns the number of bits per sample; otherwise returns 0. More... | |
std::uint16_t | channelCount () const |
Returns the number of channels if known; otherwise returns 0. More... | |
std::uint8_t | channelConfig () const |
Returns the channel configuration. More... | |
std::string_view | channelConfigString () const |
Returns a string with the channel configuration if available; otherwise returns nullptr. More... | |
std::uint8_t | extensionChannelConfig () const |
Returns the extension channel configuration if available; otherwise returns nullptr. More... | |
std::string_view | extensionChannelConfigString () const |
Returns a string with the extension channel configuration if available; otherwise returns nullptr. More... | |
std::uint64_t | sampleCount () const |
Returns the number of samples/frames if known; otherwise returns 0. More... | |
int | quality () const |
Returns the quality if known; otherwise returns 0. More... | |
const Size & | pixelSize () const |
Returns the size of the encoded video frames if known; otherwise returns a zero size. More... | |
const Size & | displaySize () const |
Returns the size of the video frames to display if known; otherwise returns a zero size. More... | |
const Size & | resolution () const |
Returns the resolution if known; otherwise returns a zero size. More... | |
const std::string & | compressorName () const |
Returns the compressor name if known; otherwise returns an empty string. More... | |
void | setCompressorName (std::string_view compressorName) |
Returns the compressor name if known; otherwise returns an empty string. More... | |
std::uint16_t | depth () const |
Returns the bit depth if known; otherwise returns 0. More... | |
std::uint32_t | fps () const |
Returns the number of frames per second if known; otherwise returns 0. More... | |
std::string_view | chromaFormat () const |
Returns the chroma subsampling format if known; otherwise returns nullptr. More... | |
const AspectRatio & | pixelAspectRatio () const |
Returns the pixel aspect ratio (PAR). More... | |
bool | isInterlaced () const |
Returns true if the video is interlaced; otherwise returns false. More... | |
std::uint32_t | timeScale () const |
Returns the time scale if known; otherwise returns 0. More... | |
bool | isEnabled () const |
Returns true if the track is marked as enabled; otherwise returns false. More... | |
void | setEnabled (bool enabled) |
Sets whether the track is enabled. More... | |
bool | isDefault () const |
Returns true if the track is marked as default; otherwise returns false. More... | |
void | setDefault (bool isDefault) |
Sets whether the track is a default track. More... | |
bool | isForced () const |
Returns true if the track is marked as forced; otherwise returns false. More... | |
void | setForced (bool forced) |
Sets whether the track is forced. More... | |
bool | hasLacing () const |
Returns true if the track has lacing; otherwise returns false. More... | |
bool | isEncrypted () const |
Returns true if the track is marked as encrypted; otherwise returns false. More... | |
std::uint32_t | colorSpace () const |
Returns the color space if known; otherwise returns 0. More... | |
const Margin & | cropping () const |
Returns the cropping if known; otherwise returns zero margins. More... | |
std::string | label () const |
Returns a label for the track. More... | |
std::string | description () const |
Returns a description about the track. More... | |
std::string | shortDescription () const |
Returns a short description about the track. More... | |
void | parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses technical information about the track from the header. More... | |
bool | isHeaderValid () const |
Returns an indication whether the track header is valid. More... | |
Protected Member Functions | |
AbstractTrack (std::istream &inputStream, std::ostream &outputStream, std::uint64_t startOffset) | |
Constructs a new track. More... | |
AbstractTrack (std::iostream &stream, std::uint64_t startOffset) | |
Constructs a new track. More... | |
virtual void | internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress)=0 |
This method is internally called to parse header information. More... | |
Friends | |
class | MpegAudioFrameStream |
class | WaveAudioStream |
class | Mp4Track |
The AbstractTrack class parses and stores technical information about video, audio and other kinds of media tracks.
The tag class only provides the interface and common functionality. It is meant to be subclassed.
Definition at line 65 of file abstracttrack.h.
|
virtual |
Destroys the track.
Definition at line 76 of file abstracttrack.cpp.
|
protected |
Constructs a new track.
inputStream | Specifies the stream the track will read from to perform particular operations such as reading header information. |
outputStream | Specifies the stream the track will write to to perform particular operations such as updating or making header information. |
startOffset | The start offset of the track in the specified stream. |
Definition at line 30 of file abstracttrack.cpp.
|
protected |
Constructs a new track.
stream | Specifies the stream the track will read from or write to to perform particular operations such as reading header information. |
startOffset | The start offset of the track in the specified stream. |
Definition at line 68 of file abstracttrack.cpp.
|
inline |
Returns the average bitrate in kbit/s if known; otherwise returns zero.
Definition at line 410 of file abstracttrack.h.
|
inline |
Returns the number of bits per sample; otherwise returns 0.
Definition at line 478 of file abstracttrack.h.
|
inline |
Returns the channel configuration.
This is the MPEG-4 channel config for MPEG-4 audio.
Definition at line 499 of file abstracttrack.h.
std::string_view TagParser::AbstractTrack::channelConfigString | ( | ) | const |
Returns a string with the channel configuration if available; otherwise returns nullptr.
Definition at line 83 of file abstracttrack.cpp.
|
inline |
Returns the number of channels if known; otherwise returns 0.
This value only makes sense for audio tracks.
Definition at line 488 of file abstracttrack.h.
|
inline |
Returns the chroma subsampling format if known; otherwise returns nullptr.
This value only makes sense for video tracks.
Definition at line 592 of file abstracttrack.h.
|
inline |
Returns the color space if known; otherwise returns 0.
Definition at line 695 of file abstracttrack.h.
|
inline |
Returns the compressor name if known; otherwise returns an empty string.
Definition at line 555 of file abstracttrack.h.
|
inline |
Returns the creation time if known; otherwise returns a DateTime of zero ticks.
Definition at line 426 of file abstracttrack.h.
|
inline |
Returns the cropping if known; otherwise returns zero margins.
Definition at line 703 of file abstracttrack.h.
|
inline |
Returns the bit depth if known; otherwise returns 0.
Definition at line 572 of file abstracttrack.h.
string TagParser::AbstractTrack::description | ( | ) | const |
Returns a description about the track.
The description contains the abbreviated format and further information depending on the media type (eg. display size in case of video, language in case of audio/text). It is intended to be joined with descriptions of other tracks to get a short technical description about the file.
Examples (exact format might change in the future!):
Definition at line 204 of file abstracttrack.cpp.
|
inline |
Returns the size of the video frames to display if known; otherwise returns a zero size.
This value only makes sense for video tracks.
Definition at line 537 of file abstracttrack.h.
|
inline |
Returns the duration if known; otherwise returns a TimeSpan of zero ticks.
Definition at line 402 of file abstracttrack.h.
std::uint8_t TagParser::AbstractTrack::extensionChannelConfig | ( | ) | const |
Returns the extension channel configuration if available; otherwise returns nullptr.
Definition at line 99 of file abstracttrack.cpp.
std::string_view TagParser::AbstractTrack::extensionChannelConfigString | ( | ) | const |
Returns a string with the extension channel configuration if available; otherwise returns nullptr.
Definition at line 107 of file abstracttrack.cpp.
|
inline |
Returns the number of samples per second if known; otherwise returns 0.
Definition at line 470 of file abstracttrack.h.
|
inline |
Returns flags (various boolean properties) of this track.
Definition at line 273 of file abstracttrack.h.
|
inline |
Returns the format of the track if known; otherwise returns MediaFormat::Unknown.
Definition at line 281 of file abstracttrack.h.
|
inline |
Returns the a more or less common abbreviation for the format of the track if known; otherwise returns an empty string.
Definition at line 309 of file abstracttrack.h.
|
inline |
Returns the format/codec ID.
This is usually the raw format identifier extracted from the container) if known; otherwise returns an empty string.
Definition at line 319 of file abstracttrack.h.
|
inline |
Returns the format of the track as C-style string if known; otherwise returns the format abbreviation or an empty string.
Definition at line 300 of file abstracttrack.h.
|
inline |
Returns the number of frames per second if known; otherwise returns 0.
This value only makes sense for video tracks.
Definition at line 582 of file abstracttrack.h.
|
inline |
Returns true if the track has lacing; otherwise returns false.
Definition at line 679 of file abstracttrack.h.
|
inline |
Returns the track ID if known; otherwise returns 0.
Definition at line 368 of file abstracttrack.h.
|
inline |
Returns the associated input stream.
Definition at line 196 of file abstracttrack.h.
|
protectedpure virtual |
This method is internally called to parse header information.
It needs to be implemented when subclassing this class.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Implemented in TagParser::AdtsStream, TagParser::FlacStream, TagParser::IvfStream, TagParser::MatroskaTrack, TagParser::Mp4Track, TagParser::MpegAudioFrameStream, TagParser::OggStream, and TagParser::WaveAudioStream.
|
inline |
Returns true if the track is marked as default; otherwise returns false.
Definition at line 645 of file abstracttrack.h.
|
inline |
Returns true if the track is marked as enabled; otherwise returns false.
Definition at line 628 of file abstracttrack.h.
|
inline |
Returns true if the track is marked as encrypted; otherwise returns false.
Definition at line 687 of file abstracttrack.h.
|
inline |
Returns true if the track is marked as forced; otherwise returns false.
Definition at line 662 of file abstracttrack.h.
|
inline |
Returns an indication whether the track header is valid.
Definition at line 711 of file abstracttrack.h.
|
inline |
Returns true if the video is interlaced; otherwise returns false.
This value only makes sense for video tracks.
Definition at line 610 of file abstracttrack.h.
string TagParser::AbstractTrack::label | ( | ) | const |
Returns a label for the track.
The label contains the ID, type, name and language of the track. It is intended to be used in a menu for selecting a track from the file.
Definition at line 123 of file abstracttrack.cpp.
|
inline |
Returns the locale of the track if known; otherwise returns an empty locale.
The format of the locale depends on the particular format/implementation.
Definition at line 444 of file abstracttrack.h.
|
inline |
Returns the maximum bitrate in kbit/s if known; otherwise returns zero.
Definition at line 418 of file abstracttrack.h.
|
inline |
Returns the media type if known; otherwise returns MediaType::Other.
Definition at line 327 of file abstracttrack.h.
|
inline |
Returns the string representation of the media type of the track.
Definition at line 335 of file abstracttrack.h.
|
inline |
Returns the time of the last modification if known; otherwise returns a DateTime of zero ticks.
Definition at line 434 of file abstracttrack.h.
|
inline |
Returns the track name if known; otherwise returns an empty string.
Definition at line 385 of file abstracttrack.h.
|
inline |
Returns the associated output stream.
Definition at line 215 of file abstracttrack.h.
void TagParser::AbstractTrack::parseHeader | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses technical information about the track from the header.
The information will be read from the associated stream. The stream and the start offset of the track have been specified when constructing the Track.
The parsed information can be accessed using the corresponding methods.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Definition at line 235 of file abstracttrack.cpp.
|
inline |
Returns the pixel aspect ratio (PAR).
Definition at line 600 of file abstracttrack.h.
|
inline |
Returns the size of the encoded video frames if known; otherwise returns a zero size.
This value only makes sense for video tracks.
Definition at line 527 of file abstracttrack.h.
|
inline |
Returns the quality if known; otherwise returns 0.
The scale depends on the format.
Definition at line 517 of file abstracttrack.h.
|
inline |
Returns a binary reader for the associated stream.
Definition at line 237 of file abstracttrack.h.
|
inline |
Returns the resolution if known; otherwise returns a zero size.
This value only makes sense for video tracks.
Definition at line 547 of file abstracttrack.h.
|
inline |
Returns the number of samples/frames if known; otherwise returns 0.
Definition at line 507 of file abstracttrack.h.
|
inline |
Returns the number of samples per second if known; otherwise returns 0.
Definition at line 461 of file abstracttrack.h.
|
inline |
Returns the compressor name if known; otherwise returns an empty string.
Definition at line 564 of file abstracttrack.h.
|
inline |
Sets whether the track is a default track.
Definition at line 654 of file abstracttrack.h.
|
inline |
Sets whether the track is enabled.
Definition at line 637 of file abstracttrack.h.
|
inline |
Sets whether the track is forced.
Definition at line 671 of file abstracttrack.h.
|
inline |
Sets the track ID.
Definition at line 377 of file abstracttrack.h.
|
inline |
Assigns another input stream.
The track will read from the stream to perform particular operations such as reading header information.
Definition at line 207 of file abstracttrack.h.
|
inline |
Sets the locale of the track.
Definition at line 453 of file abstracttrack.h.
|
inline |
Sets the name.
Definition at line 394 of file abstracttrack.h.
|
inline |
Assigns another output stream.
The track will write to the stream to perform particular operations such as updating or making header information.
Definition at line 226 of file abstracttrack.h.
|
inline |
Sets the track number.
Definition at line 360 of file abstracttrack.h.
string TagParser::AbstractTrack::shortDescription | ( | ) | const |
Returns a short description about the track.
See description() for details.
Examples (exact format might change in the future!):
Definition at line 218 of file abstracttrack.cpp.
|
inline |
Returns the size in bytes if known; otherwise returns 0.
Definition at line 343 of file abstracttrack.h.
|
inline |
Returns the start offset of the track in the associated stream.
Definition at line 264 of file abstracttrack.h.
|
inline |
Returns the time scale if known; otherwise returns 0.
The time scale depends on the format.
Definition at line 620 of file abstracttrack.h.
|
inline |
Returns the track number if known; otherwise returns 0.
Definition at line 351 of file abstracttrack.h.
|
inlinevirtual |
Returns the type of the track if known; otherwise returns TrackType::Unspecified.
Reimplemented in TagParser::AdtsStream, TagParser::FlacStream, TagParser::IvfStream, TagParser::MatroskaTrack, TagParser::Mp4Track, TagParser::MpegAudioFrameStream, TagParser::OggStream, and TagParser::WaveAudioStream.
Definition at line 256 of file abstracttrack.h.
|
inline |
Returns the version/level of the track if known; otherwise returns 0.
Definition at line 289 of file abstracttrack.h.
|
inline |
Returns a binary writer for the associated stream.
Definition at line 248 of file abstracttrack.h.
|
friend |
Definition at line 68 of file abstracttrack.h.
|
friend |
Definition at line 66 of file abstracttrack.h.
|
friend |
Definition at line 67 of file abstracttrack.h.
|
protected |
Definition at line 162 of file abstracttrack.h.
|
protected |
Definition at line 169 of file abstracttrack.h.
|
protected |
Definition at line 170 of file abstracttrack.h.
|
protected |
Definition at line 172 of file abstracttrack.h.
|
protected |
Definition at line 171 of file abstracttrack.h.
|
protected |
Definition at line 183 of file abstracttrack.h.
|
protected |
Definition at line 174 of file abstracttrack.h.
|
protected |
Definition at line 186 of file abstracttrack.h.
|
protected |
Definition at line 180 of file abstracttrack.h.
|
protected |
Definition at line 164 of file abstracttrack.h.
|
protected |
Definition at line 187 of file abstracttrack.h.
|
protected |
Definition at line 181 of file abstracttrack.h.
|
protected |
Definition at line 178 of file abstracttrack.h.
|
protected |
Definition at line 161 of file abstracttrack.h.
|
protected |
Definition at line 173 of file abstracttrack.h.
|
protected |
Definition at line 168 of file abstracttrack.h.
|
protected |
Definition at line 151 of file abstracttrack.h.
|
protected |
Definition at line 152 of file abstracttrack.h.
|
protected |
Definition at line 153 of file abstracttrack.h.
|
protected |
Definition at line 154 of file abstracttrack.h.
|
protected |
Definition at line 182 of file abstracttrack.h.
|
protected |
Definition at line 159 of file abstracttrack.h.
|
protected |
Definition at line 146 of file abstracttrack.h.
|
protected |
Definition at line 166 of file abstracttrack.h.
|
protected |
Definition at line 163 of file abstracttrack.h.
|
protected |
Definition at line 155 of file abstracttrack.h.
|
protected |
Definition at line 165 of file abstracttrack.h.
|
protected |
Definition at line 160 of file abstracttrack.h.
|
protected |
Definition at line 147 of file abstracttrack.h.
|
protected |
Definition at line 184 of file abstracttrack.h.
|
protected |
Definition at line 177 of file abstracttrack.h.
|
protected |
Definition at line 176 of file abstracttrack.h.
|
protected |
Definition at line 148 of file abstracttrack.h.
|
protected |
Definition at line 179 of file abstracttrack.h.
|
protected |
Definition at line 175 of file abstracttrack.h.
|
protected |
Definition at line 167 of file abstracttrack.h.
|
protected |
Definition at line 157 of file abstracttrack.h.
|
protected |
Definition at line 150 of file abstracttrack.h.
|
protected |
Definition at line 185 of file abstracttrack.h.
|
protected |
Definition at line 158 of file abstracttrack.h.
|
protected |
Definition at line 156 of file abstracttrack.h.
|
protected |
Definition at line 149 of file abstracttrack.h.