Tag Parser
6.2.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Implementation of Media::AbstractTrack for the MP4 container. More...
#include <mp4track.h>
Public Member Functions | |
Mp4Track (Mp4Atom &trakAtom) | |
Constructs a new track for the specified trakAtom. More... | |
~Mp4Track () | |
Destroys the track. More... | |
TrackType | type () const |
Returns the type of the track if known; otherwise returns TrackType::Unspecified. More... | |
Mp4Atom & | trakAtom () |
Returns the trak atom for the current instance. More... | |
const std::vector< uint32 > & | sampleSizes () const |
Returns the sample size table for the track. More... | |
unsigned int | chunkOffsetSize () const |
Returns the size of a single chunk offset denotation within the stco atom. More... | |
uint32 | chunkCount () const |
Returns the number of chunks denoted by the stco atom. More... | |
uint32 | sampleToChunkEntryCount () const |
Returns the number of "sample to chunk" entries within the stsc atom. More... | |
const Mpeg4ElementaryStreamInfo * | mpeg4ElementaryStreamInfo () const |
Returns information about the MPEG-4 elementary stream. More... | |
const AvcConfiguration * | avcConfiguration () const |
Returns the AVC configuration. More... | |
std::vector< uint64 > | readChunkOffsets () |
Reads the chunk offsets from the stco atom. More... | |
std::vector< std::tuple< uint32, uint32, uint32 > > | readSampleToChunkTable () |
Reads the sample to chunk table. More... | |
std::vector< uint64 > | readChunkSizes () |
Reads the chunk sizes from the stsz (sample sizes) and stsc (samples per chunk) atom. More... | |
void | makeTrack () |
Makes the track entry ("trak"-atom) for the track. More... | |
uint64 | requiredSize () const |
Returns the number of bytes written when calling makeTrack(). More... | |
void | makeTrackHeader () |
Makes the track header (tkhd atom) for the track. More... | |
void | makeMedia () |
Makes the media information (mdia atom) for the track. More... | |
void | makeMediaInfo () |
Makes a media information (minf atom) for the track. More... | |
void | makeSampleTable () |
Makes the sample table (stbl atom) for the track. More... | |
void | updateChunkOffsets (const std::vector< int64 > &oldMdatOffsets, const std::vector< int64 > &newMdatOffsets) |
Updates the chunk offsets of the track. More... | |
void | updateChunkOffsets (const std::vector< uint64 > &chunkOffsets) |
Updates the chunk offsets of the track. More... | |
void | updateChunkOffset (uint32 chunkIndex, uint64 offset) |
Updates a particular chunk offset. More... | |
![]() | |
virtual | ~AbstractTrack () |
Destroys the track. More... | |
std::istream & | inputStream () |
Returns the associated input stream. More... | |
void | setInputStream (std::istream &stream) |
Assigns an other input stream. More... | |
std::ostream & | outputStream () |
Returns the associated input stream. More... | |
void | setOutputStream (std::ostream &stream) |
Assigns an other output stream. More... | |
IoUtilities::BinaryReader & | reader () |
Returns a binary reader for the associated stream. More... | |
IoUtilities::BinaryWriter & | writer () |
Returns a binary writer for the associated stream. More... | |
uint64 | startOffset () const |
Returns the start offset of the track in the associated stream. 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... | |
const char * | formatName () const |
Returns the format of the track as C-style string if known; otherwise returns the format abbreviation or an empty string. More... | |
const char * | formatAbbreviation () const |
Returns the a more or less common abbreviation for the format of the track as C-style string 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... | |
const char * | mediaTypeName () const |
Returns the string representation of the media type of the track. More... | |
uint64 | size () const |
Returns the size in bytes if known; otherwise returns 0. More... | |
uint32 | trackNumber () const |
Returns the track number if known; otherwise returns 0. More... | |
uint64 | id () const |
Returns the track ID if known; otherwise returns 0. More... | |
const std::string | name () const |
Returns the track name if known; otherwise returns an empty string. More... | |
const ChronoUtilities::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 ChronoUtilities::DateTime & | creationTime () const |
Returns the creation time if known; otherwise returns a DateTime of zero ticks. More... | |
const ChronoUtilities::DateTime & | modificationTime () const |
Returns the time of the last modification if known; otherwise returns a DateTime of zero ticks. More... | |
const std::string & | language () const |
Returns the language of the track if known; otherwise returns an empty string. More... | |
uint32 | samplingFrequency () const |
Returns the number of samples per second if known; otherwise returns 0. More... | |
uint32 | extensionSamplingFrequency () const |
Returns the number of samples per second if known; otherwise returns 0. More... | |
uint16 | bitsPerSample () const |
Returns the number of bits per sample; otherwise returns 0. More... | |
uint16 | channelCount () const |
Returns the number of channels if known; otherwise returns 0. More... | |
byte | channelConfig () const |
Returns the channel configuration. More... | |
const char * | channelConfigString () const |
Returns a string with the channel configuration if available; otherwise returns nullptr. More... | |
byte | extensionChannelConfig () const |
Returns the extension channel configuration if available; otherwise returns nullptr. More... | |
const char * | extensionChannelConfigString () const |
Returns a string with the extension channel configuration if available; otherwise returns nullptr. More... | |
uint64 | sampleCount () const |
Returns the number of samples 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... | |
uint16 | depth () const |
Returns the bit depth if known; otherwise returns 0. More... | |
uint32 | fps () const |
Returns the number of frames per second if known; otherwise returns 0. More... | |
const char * | 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 denoted as interlaced; otherwise returns false. More... | |
uint32 | timeScale () const |
Returns the time scale if known; otherwise returns 0. More... | |
bool | isEnabled () const |
Returns true if the track is denoted as enabled; otherwise returns false. More... | |
bool | isDefault () const |
Returns true if the track is denoted as default; otherwise returns false. More... | |
bool | isForced () const |
Returns true if the track is denoted as forced; otherwise returns false. More... | |
bool | hasLacing () const |
Returns true if the track has lacing; otherwise returns false. More... | |
bool | isEncrypted () const |
Returns true if the track is denoted as encrypted; otherwise returns false. More... | |
uint32 | 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... | |
void | parseHeader () |
Parses technical information about the track from the header. More... | |
bool | isHeaderValid () const |
Returns an indication whether the track header is valid. More... | |
![]() | |
const NotificationList & | notifications () const |
Returns notifications for the current object. More... | |
bool | hasNotifications () const |
Returns an indication whether there are notifications for the current object. More... | |
bool | hasCriticalNotifications () const |
Returns an indication whether there are critical notifications for the current object. More... | |
NotificationType | worstNotificationType () const |
Returns the worst notification type. More... | |
const std::string & | currentStatus () const |
Returns a status information for the current object. More... | |
double | currentPercentage () const |
Returns the progress percentage of the current object. More... | |
size_t | registerCallback (CallbackFunction callback) |
Registers a callback function. More... | |
void | unregisterCallback (size_t id) |
Unregisters a previously registered callback function whith the specified id. More... | |
void | unregisterAllCallbacks () |
Unregisters all callback functions. More... | |
void | forwardStatusUpdateCalls (StatusProvider *other=nullptr) |
Forwards all status updates calls to the specified statusProvider. More... | |
StatusProvider * | usedProvider () |
Returns the provider which callback functions will be called when the status or the percentage is updated. More... | |
void | tryToAbort () |
Commands the object to abort the current operation. More... | |
bool | isAborted () const |
Returns an indication whether the current operation should be aborted. More... | |
void | invalidateStatus () |
Invalidates the current status. More... | |
void | invalidateNotifications () |
Invalidates the object's notifications. More... | |
void | updateStatus (const std::string &status) |
This method is meant to be called by the derived class to report updated status information. More... | |
void | updateStatus (const std::string &status, double percentage) |
This method is meant to be called by the derived class to report updated status information. More... | |
void | updatePercentage (double percentage) |
This method is meant to be called by the derived class to report updated progress percentage only. More... | |
void | addNotification (const Notification ¬ification) |
This protected method is meant to be called by the derived class to add a notification. More... | |
void | addNotification (NotificationType type, const std::string &message, const std::string &context) |
This protected method is meant to be called by the derived class to add a notification of the specified type, message and context. More... | |
void | addNotifications (const StatusProvider &from) |
This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More... | |
void | addNotifications (const std::string &higherContext, const StatusProvider &from) |
This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More... | |
void | addNotifications (const NotificationList ¬ifications) |
This protected method is meant to be called by the derived class to add the specified notifications. More... | |
Static Public Member Functions | |
static std::unique_ptr< Mpeg4ElementaryStreamInfo > | parseMpeg4ElementaryStreamInfo (StatusProvider &statusProvider, IoUtilities::BinaryReader &reader, Mp4Atom *esDescAtom) |
Reads the MPEG-4 elementary stream descriptor for the track. More... | |
static std::unique_ptr< Mpeg4AudioSpecificConfig > | parseAudioSpecificConfig (StatusProvider &statusProvider, std::istream &stream, uint64 startOffset, uint64 size) |
Parses the audio specific configuration for the track. More... | |
static std::unique_ptr< Mpeg4VideoSpecificConfig > | parseVideoSpecificConfig (StatusProvider &statusProvider, IoUtilities::BinaryReader &reader, uint64 startOffset, uint64 size) |
Parses the video specific configuration for the track. More... | |
static void | addInfo (const AvcConfiguration &avcConfig, AbstractTrack &track) |
Adds the information from the specified avcConfig to the specified track. More... | |
Protected Member Functions | |
void | internalParseHeader () |
This method is internally called to parse header information. More... | |
![]() | |
AbstractTrack (std::istream &inputStream, std::ostream &outputStream, uint64 startOffset) | |
Constructs a new track. More... | |
AbstractTrack (std::iostream &stream, uint64 startOffset) | |
Constructs a new track. More... | |
![]() | |
StatusProvider () | |
Constructs a new StatusProvider. More... | |
Implementation of Media::AbstractTrack for the MP4 container.
Definition at line 119 of file mp4track.h.
Media::Mp4Track::Mp4Track | ( | Mp4Atom & | trakAtom | ) |
Constructs a new track for the specified trakAtom.
"trak"-atoms are stored in the top-level atom "move". Each "trak"-atom holds header information for one track in the MP4 file.
Definition at line 90 of file mp4track.cpp.
Media::Mp4Track::~Mp4Track | ( | ) |
Destroys the track.
Definition at line 114 of file mp4track.cpp.
|
static |
Adds the information from the specified avcConfig to the specified track.
Definition at line 889 of file mp4track.cpp.
|
inline |
Returns the AVC configuration.
Definition at line 254 of file mp4track.h.
|
inline |
Returns the number of chunks denoted by the stco atom.
Definition at line 223 of file mp4track.h.
|
inline |
Returns the size of a single chunk offset denotation within the stco atom.
Valid values are 4 and 8 bytes.
Definition at line 215 of file mp4track.h.
|
protectedvirtual |
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 | Media::Failure or a derived exception when a parsing error occurs. |
Implements Media::AbstractTrack.
Definition at line 1183 of file mp4track.cpp.
void Media::Mp4Track::makeMedia | ( | ) |
Makes the media information (mdia atom) for the track.
The data is written to the assigned output stream at the current position.
Definition at line 1010 of file mp4track.cpp.
void Media::Mp4Track::makeMediaInfo | ( | ) |
Makes a media information (minf atom) for the track.
The data is written to the assigned output stream at the current position.
Definition at line 1070 of file mp4track.cpp.
void Media::Mp4Track::makeSampleTable | ( | ) |
Makes the sample table (stbl atom) for the track.
The data is written to the assigned output stream at the current position.
Definition at line 1125 of file mp4track.cpp.
void Media::Mp4Track::makeTrack | ( | ) |
Makes the track entry ("trak"-atom) for the track.
The data is written to the assigned output stream at the current position.
Definition at line 926 of file mp4track.cpp.
void Media::Mp4Track::makeTrackHeader | ( | ) |
Makes the track header (tkhd atom) for the track.
The data is written to the assigned output stream at the current position.
Definition at line 963 of file mp4track.cpp.
|
inline |
Returns information about the MPEG-4 elementary stream.
Definition at line 243 of file mp4track.h.
|
static |
Parses the audio specific configuration for the track.
Definition at line 542 of file mp4track.cpp.
|
static |
Reads the MPEG-4 elementary stream descriptor for the track.
Definition at line 457 of file mp4track.cpp.
|
static |
Parses the video specific configuration for the track.
Definition at line 691 of file mp4track.cpp.
vector< uint64 > Media::Mp4Track::readChunkOffsets | ( | ) |
Reads the chunk offsets from the stco atom.
Throws | InvalidDataException when
|
Throws | std::ios_base::failure when an IO error occurs. |
Definition at line 133 of file mp4track.cpp.
vector< uint64 > Media::Mp4Track::readChunkSizes | ( | ) |
Reads the chunk sizes from the stsz (sample sizes) and stsc (samples per chunk) atom.
Throws | InvalidDataException when
|
Throws | std::ios_base::failure when an IO error occurs. |
Definition at line 407 of file mp4track.cpp.
vector< tuple< uint32, uint32, uint32 > > Media::Mp4Track::readSampleToChunkTable | ( | ) |
Reads the sample to chunk table.
Definition at line 358 of file mp4track.cpp.
uint64 Media::Mp4Track::requiredSize | ( | ) | const |
Returns the number of bytes written when calling makeTrack().
Definition at line 954 of file mp4track.cpp.
|
inline |
Returns the sample size table for the track.
Definition at line 205 of file mp4track.h.
|
inline |
Returns the number of "sample to chunk" entries within the stsc atom.
Definition at line 231 of file mp4track.h.
|
inline |
Returns the trak atom for the current instance.
Definition at line 193 of file mp4track.h.
|
virtual |
Returns the type of the track if known; otherwise returns TrackType::Unspecified.
Reimplemented from Media::AbstractTrack.
Definition at line 117 of file mp4track.cpp.
void Media::Mp4Track::updateChunkOffset | ( | uint32 | chunkIndex, |
uint64 | offset | ||
) |
Updates a particular chunk offset.
chunkIndex | Specifies the index of the chunk offset to be updated. |
offset | Specifies the new chunk offset. |
Throws | InvalidDataException when
|
Definition at line 868 of file mp4track.cpp.
void Media::Mp4Track::updateChunkOffsets | ( | const std::vector< int64 > & | oldMdatOffsets, |
const std::vector< int64 > & | newMdatOffsets | ||
) |
Updates the chunk offsets of the track.
This is necessary when the "mdat"-atom (which contains the actual chunk data) is moved.
oldMdatOffsets | Specifies a vector holding the old offsets of the "mdat"-atoms. |
newMdatOffsets | Specifies a vector holding the new offsets of the "mdat"-atoms. |
Throws | InvalidDataException when
|
Throws | std::ios_base::failure when an IO error occurs. |
Definition at line 767 of file mp4track.cpp.
void Media::Mp4Track::updateChunkOffsets | ( | const std::vector< uint64 > & | chunkOffsets | ) |
Updates the chunk offsets of the track.
This is necessary when the "mdat"-atom (which contains the actual chunk data) is moved.
chunkOffsets | Specifies the new chunk offset table. |
Throws | InvalidDataException when
|
Definition at line 832 of file mp4track.cpp.