Tag Parser: ivf/ivfstream.cpp Source File

Tag Parser 12.5.3 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
ivfstream.cpp
Go to the documentation of this file.
1#include "./ivfstream.h"
2
3#include "../mp4/mp4ids.h"
4
5#include "../exceptions.h"
6
7#include <c++utilities/conversion/stringbuilder.h>
8#include <c++utilities/conversion/stringconversion.h>
9
10#include <string>
11
12using namespace std;
13using namespace CppUtilities;
14
15namespace TagParser {
16
22
23 void IvfStream::internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress)
24{
25 CPP_UTILITIES_UNUSED(progress)
26
27 static const string context("parsing IVF header");
28 if (!m_istream) {
29 throw NoDataFoundException();
30 }
31
32 // check signature and version
33 if (m_reader.readUInt32BE() != 0x444B4946u) {
34 diag.emplace_back(DiagLevel::Critical, "Signature not \"DKIF\".", context);
35 throw InvalidDataException();
36 }
37 const auto version = m_reader.readUInt16LE();
38 m_version = version;
39 if (version != 0) {
40 diag.emplace_back(DiagLevel::Warning, argsToString("Version ", version, " is not supported."), context);
41 }
42
43 // read remaining header
44 m_headerLength = m_reader.readUInt16LE();
45 const auto formatId = m_reader.readUInt32BE();
46 m_formatId = interpretIntegerAsString(formatId);
47 m_pixelSize.setWidth(m_reader.readUInt16LE());
48 m_pixelSize.setHeight(m_reader.readUInt16LE());
49 m_fps = m_reader.readUInt32LE();
50 m_timeScale = m_reader.readUInt32LE();
51 m_sampleCount = m_reader.readUInt32LE();
52
53 // compute further values
54 m_format = FourccIds::fourccToMediaFormat(formatId);
55 m_duration = TimeSpan::fromSeconds(static_cast<double>(m_sampleCount) / m_fps);
56
57 // skip unused bytes
58 m_istream->seekg(4, ios_base::cur);
59}
60
61 void IvfStream::readFrame(Diagnostics &diag)
62{
63 m_frames.emplace_back();
64 m_frames.back().parseHeader(m_reader, diag);
65}
66
67} // namespace TagParser
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::AbstractTrack::m_sampleCount
std::uint64_t m_sampleCount
Definition abstracttrack.h:221
TagParser::AbstractTrack::m_version
double m_version
Definition abstracttrack.h:202
TagParser::AbstractTrack::version
double version() const
Returns the version/level of the track if known; otherwise returns 0.
Definition abstracttrack.h:341
TagParser::AbstractTrack::m_formatId
std::string m_formatId
Definition abstracttrack.h:199
TagParser::AbstractTrack::m_pixelSize
Size m_pixelSize
Definition abstracttrack.h:223
TagParser::AbstractTrack::m_duration
CppUtilities::TimeSpan m_duration
Definition abstracttrack.h:207
TagParser::AbstractTrack::formatId
const std::string & formatId() const
Returns the format/codec ID.
Definition abstracttrack.h:370
TagParser::AbstractTrack::m_reader
CppUtilities::BinaryReader m_reader
Definition abstracttrack.h:194
TagParser::AbstractTrack::m_timeScale
std::uint32_t m_timeScale
Definition abstracttrack.h:231
TagParser::AbstractTrack::m_fps
std::uint32_t m_fps
Definition abstracttrack.h:228
TagParser::AbstractTrack::m_format
MediaFormat m_format
Definition abstracttrack.h:198
TagParser::AbstractTrack::m_istream
std::istream * m_istream
Definition abstracttrack.h:192
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::InvalidDataException
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
Definition exceptions.h:25
TagParser::IvfStream::readFrame
void readFrame(Diagnostics &diag)
Definition ivfstream.cpp:61
TagParser::IvfStream::internalParseHeader
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Definition ivfstream.cpp:23
TagParser::NoDataFoundException
The exception that is thrown when the data to be parsed holds no parsable information (e....
Definition exceptions.h:18
exceptions.h
ivfstream.h
mp4ids.h
CppUtilities
Definition abstractcontainer.h:16
TagParser::FourccIds::fourccToMediaFormat
TAG_PARSER_EXPORT MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
Definition mp4ids.cpp:51
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::DiagLevel::Warning
@ Warning
Definition diagnostics.h:20
TagParser::DiagLevel::Critical
@ Critical
Definition diagnostics.h:21