Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
TagParser::FlacStream Class Reference

Implementation of TagParser::AbstractTrack for raw FLAC streams. More...

#include <flacstream.h>

Inheritance diagram for TagParser::FlacStream:
[legend]
Collaboration diagram for TagParser::FlacStream:
[legend]

Public Member Functions

 FlacStream (MediaFileInfo &mediaFileInfo, std::uint64_t startOffset)
 Constructs a new track for the specified mediaFileInfo at the specified startOffset.
 
 ~FlacStream () override
 
TrackType type () const override
 Returns the type of the track if known; otherwise returns TrackType::Unspecified.
 
VorbisCommentvorbisComment () const
 Returns the Vorbis comment if one is present in the stream.
 
VorbisCommentcreateVorbisComment ()
 Creates a new Vorbis comment for the stream.
 
bool removeVorbisComment ()
 Removes the assigned Vorbis comment if one is assigned; does nothing otherwise.
 
std::uint32_t paddingSize () const
 Returns the padding size.
 
std::uint32_t streamOffset () const
 Returns the start offset of the actual FLAC frames.
 
std::streamoff makeHeader (std::ostream &stream, Diagnostics &diag)
 Writes the FLAC metadata header to the specified outputStream.
 
- Public Member Functions inherited from TagParser::AbstractTrack
virtual ~AbstractTrack ()
 Destroys the track.
 
std::istream & inputStream ()
 Returns the associated input stream.
 
void setInputStream (std::istream &stream)
 Assigns another input stream.
 
std::ostream & outputStream ()
 Returns the associated output stream.
 
void setOutputStream (std::ostream &stream)
 Assigns another output stream.
 
CppUtilities::BinaryReader & reader ()
 Returns a binary reader for the associated stream.
 
CppUtilities::BinaryWriter & writer ()
 Returns a binary writer for the associated stream.
 
std::uint64_t startOffset () const
 Returns the start offset of the track in the associated stream.
 
TrackFlags flags () const
 Returns flags (various boolean properties) of this track.
 
MediaFormat format () const
 Returns the format of the track if known; otherwise returns MediaFormat::Unknown.
 
double version () const
 Returns the version/level of the track if known; otherwise returns 0.
 
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.
 
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.
 
const std::string & formatId () const
 Returns the format/codec ID.
 
MediaType mediaType () const
 Returns the media type if known; otherwise returns MediaType::Other.
 
std::string_view mediaTypeName () const
 Returns the string representation of the media type of the track.
 
std::uint64_t size () const
 Returns the size in bytes if known; otherwise returns 0.
 
void setSize (std::uint64_t size)
 Sets the size in bytes.
 
std::uint32_t trackNumber () const
 Returns the track number if known; otherwise returns 0.
 
void setTrackNumber (std::uint32_t trackNumber)
 Sets the track number.
 
std::uint64_t id () const
 Returns the track ID if known; otherwise returns 0.
 
void setId (std::uint64_t id)
 Sets the track ID.
 
const std::string name () const
 Returns the track name if known; otherwise returns an empty string.
 
void setName (std::string_view name)
 Sets the name.
 
const CppUtilities::TimeSpan & duration () const
 Returns the duration if known; otherwise returns a TimeSpan of zero ticks.
 
double bitrate () const
 Returns the average bitrate in kbit/s if known; otherwise returns zero.
 
double maxBitrate () const
 Returns the maximum bitrate in kbit/s if known; otherwise returns zero.
 
const CppUtilities::DateTime & creationTime () const
 Returns the creation time if known; otherwise returns a DateTime of zero ticks.
 
const CppUtilities::DateTime & modificationTime () const
 Returns the time of the last modification if known; otherwise returns a DateTime of zero ticks.
 
const Localelocale () const
 Returns the locale of the track if known; otherwise returns an empty locale.
 
void setLocale (const Locale &locale)
 Sets the locale of the track.
 
std::uint32_t samplingFrequency () const
 Returns the number of samples per second if known; otherwise returns 0.
 
std::uint32_t extensionSamplingFrequency () const
 Returns the number of samples per second if known; otherwise returns 0.
 
std::uint16_t bitsPerSample () const
 Returns the number of bits per sample; otherwise returns 0.
 
std::uint16_t channelCount () const
 Returns the number of channels if known; otherwise returns 0.
 
std::uint8_t channelConfig () const
 Returns the channel configuration.
 
std::string_view channelConfigString () const
 Returns a string with the channel configuration if available; otherwise returns nullptr.
 
std::uint8_t extensionChannelConfig () const
 Returns the extension channel configuration if available; otherwise returns nullptr.
 
std::string_view extensionChannelConfigString () const
 Returns a string with the extension channel configuration if available; otherwise returns nullptr.
 
std::uint64_t sampleCount () const
 Returns the number of samples/frames if known; otherwise returns 0.
 
int quality () const
 Returns the quality if known; otherwise returns 0.
 
const SizepixelSize () const
 Returns the size of the encoded video frames if known; otherwise returns a zero size.
 
const SizedisplaySize () const
 Returns the size of the video frames to display if known; otherwise returns a zero size.
 
const Sizeresolution () const
 Returns the resolution if known; otherwise returns a zero size.
 
const std::string & compressorName () const
 Returns the compressor name if known; otherwise returns an empty string.
 
void setCompressorName (std::string_view compressorName)
 Returns the compressor name if known; otherwise returns an empty string.
 
std::uint16_t depth () const
 Returns the bit depth if known; otherwise returns 0.
 
std::uint32_t fps () const
 Returns the number of frames per second if known; otherwise returns 0.
 
std::string_view chromaFormat () const
 Returns the chroma subsampling format if known; otherwise returns nullptr.
 
const AspectRatiopixelAspectRatio () const
 Returns the pixel aspect ratio (PAR).
 
bool isInterlaced () const
 Returns true if the video is interlaced; otherwise returns false.
 
std::uint32_t timeScale () const
 Returns the time scale if known; otherwise returns 0.
 
bool isEnabled () const
 Returns true if the track is marked as enabled; otherwise returns false.
 
void setEnabled (bool enabled)
 Sets whether the track is enabled.
 
bool isDefault () const
 Returns true if the track is marked as default; otherwise returns false.
 
void setDefault (bool isDefault)
 Sets whether the track is a default track.
 
bool isForced () const
 Returns true if the track is marked as forced; otherwise returns false.
 
void setForced (bool forced)
 Sets whether the track is forced.
 
bool hasLacing () const
 Returns true if the track has lacing; otherwise returns false.
 
bool isEncrypted () const
 Returns true if the track is marked as encrypted; otherwise returns false.
 
std::uint32_t colorSpace () const
 Returns the color space if known; otherwise returns 0.
 
const Margincropping () const
 Returns the cropping if known; otherwise returns zero margins.
 
std::string label () const
 Returns a label for the track.
 
std::string description () const
 Returns a description about the track.
 
std::string shortDescription () const
 Returns a short description about the track.
 
void parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses technical information about the track from the header.
 
bool isHeaderValid () const
 Returns an indication whether the track header is valid.
 

Static Public Member Functions

static void makePadding (std::ostream &stream, std::uint32_t size, bool isLast, Diagnostics &diag)
 Writes padding of the specified size to the specified stream.
 

Protected Member Functions

void internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) override
 This method is internally called to parse header information.
 
- Protected Member Functions inherited from TagParser::AbstractTrack
 AbstractTrack (std::istream &inputStream, std::ostream &outputStream, std::uint64_t startOffset)
 Constructs a new track.
 
 AbstractTrack (std::iostream &stream, std::uint64_t startOffset)
 Constructs a new track.
 

Additional Inherited Members

- Protected Attributes inherited from TagParser::AbstractTrack
std::istream * m_istream
 
std::ostream * m_ostream
 
CppUtilities::BinaryReader m_reader
 
CppUtilities::BinaryWriter m_writer
 
std::uint64_t m_startOffset
 
TrackFlags m_flags
 
MediaFormat m_format
 
std::string m_formatId
 
std::string m_formatName
 
MediaType m_mediaType
 
double m_version
 
std::uint64_t m_size
 
std::uint32_t m_trackNumber
 
std::uint64_t m_id
 
std::string m_name
 
CppUtilities::TimeSpan m_duration
 
double m_bitrate
 
double m_maxBitrate
 
CppUtilities::DateTime m_creationTime
 
CppUtilities::DateTime m_modificationTime
 
Locale m_locale
 
std::uint32_t m_samplingFrequency
 
std::uint32_t m_extensionSamplingFrequency
 
std::uint16_t m_bitsPerSample
 
std::uint32_t m_bytesPerSecond
 
std::uint16_t m_channelCount
 
std::uint8_t m_channelConfig
 
std::uint8_t m_extensionChannelConfig
 
std::uint16_t m_chunkSize
 
std::uint64_t m_sampleCount
 
int m_quality
 
Size m_pixelSize
 
Size m_displaySize
 
Size m_resolution
 
std::string m_compressorName
 
std::uint16_t m_depth
 
std::uint32_t m_fps
 
std::string_view m_chromaFormat
 
AspectRatio m_pixelAspectRatio
 
std::uint32_t m_timeScale
 
std::uint32_t m_colorSpace
 
Margin m_cropping
 
FieldOrder m_fieldOrder
 
StereoMode m_stereoMode
 
AlphaMode m_alphaMode
 
DisplayUnit m_displayUnit
 
AspectRatioType m_aspectRatioType
 
std::unique_ptr< AbstractTrackPrivatem_p
 

Detailed Description

Implementation of TagParser::AbstractTrack for raw FLAC streams.

Constructor & Destructor Documentation

◆ FlacStream()

TagParser::FlacStream::FlacStream ( MediaFileInfo & mediaFileInfo,
std::uint64_t startOffset )

Constructs a new track for the specified mediaFileInfo at the specified startOffset.

The stream of the mediaFileInfo instance is used as input stream.

Definition at line 31 of file flacstream.cpp.

◆ ~FlacStream()

TagParser::FlacStream::~FlacStream ( )
inlineoverride

Definition at line 39 of file flacstream.h.

Member Function Documentation

◆ createVorbisComment()

VorbisComment * TagParser::FlacStream::createVorbisComment ( )

Creates a new Vorbis comment for the stream.

Remarks
Just returns the current Vorbis comment if already present.

Definition at line 44 of file flacstream.cpp.

◆ internalParseHeader()

void TagParser::FlacStream::internalParseHeader ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

This method is internally called to parse header information.

It needs to be implemented when subclassing this class.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsTagParser::Failure or a derived exception when a parsing error occurs.

Implements TagParser::AbstractTrack.

Definition at line 65 of file flacstream.cpp.

◆ makeHeader()

std::streamoff TagParser::FlacStream::makeHeader ( std::ostream & stream,
Diagnostics & diag )

Writes the FLAC metadata header to the specified outputStream.

This basically copies all "METADATA_BLOCK_HEADER" of the current stream to the specified outputStream, except:

  • Vorbis comment is updated.
  • "METADATA_BLOCK_PICTURE" are updated.
  • Padding is skipped
Returns
Returns the start offset of the last "METADATA_BLOCK_HEADER" within outputStream.

Definition at line 181 of file flacstream.cpp.

◆ makePadding()

void TagParser::FlacStream::makePadding ( std::ostream & stream,
std::uint32_t size,
bool isLast,
Diagnostics & diag )
static

Writes padding of the specified size to the specified stream.

Remarks
Size must be at least 4 bytes.

Definition at line 303 of file flacstream.cpp.

◆ paddingSize()

std::uint32_t TagParser::FlacStream::paddingSize ( ) const
inline

Returns the padding size.

Definition at line 59 of file flacstream.h.

◆ removeVorbisComment()

bool TagParser::FlacStream::removeVorbisComment ( )

Removes the assigned Vorbis comment if one is assigned; does nothing otherwise.

Returns
Returns whether there were a Vorbis comment assigned.

Definition at line 56 of file flacstream.cpp.

◆ streamOffset()

std::uint32_t TagParser::FlacStream::streamOffset ( ) const
inline

Returns the start offset of the actual FLAC frames.

Remarks
This equals the size of the metadata header blocks.

Definition at line 68 of file flacstream.h.

◆ type()

TrackType TagParser::FlacStream::type ( ) const
inlineoverridevirtual

Returns the type of the track if known; otherwise returns TrackType::Unspecified.

Reimplemented from TagParser::AbstractTrack.

Definition at line 43 of file flacstream.h.

◆ vorbisComment()

VorbisComment * TagParser::FlacStream::vorbisComment ( ) const
inline

Returns the Vorbis comment if one is present in the stream.

Definition at line 51 of file flacstream.h.


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