Exiv2
Loading...
Searching...
No Matches
matroskavideo.hpp
1// ***************************************************************** -*- C++ -*-
2/*
3 * Copyright (C) 2004-2021 Exiv2 authors
4 * This program is part of the Exiv2 distribution.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19 */
20#ifndef MATROSKAVIDEO_HPP_
21#define MATROSKAVIDEO_HPP_
22
23// *****************************************************************************
24#include "exiv2lib_export.h"
25
26// included header files
27#include "image.hpp"
28
29// *****************************************************************************
30// namespace extensions
31namespace Exiv2 {
32
37// *****************************************************************************
38// class definitions
39namespace Internal {
40
41enum matroskaTypeEnum : char {
42 String = 's',
43 Integer = 'i',
44 UInteger = 'u',
45 Date = 'd',
46 InternalField = 'n',
47 Boolean = 'o',
48 Binary = 'b',
49 Master = 'm',
50 Float = 'f',
51 Utf8 = '8',
52 UndefinedType = 'z',
53};
54
55enum matroskaProcessEnum : char {
56 Process = 'p',
57 Skip = 's',
58 Composite = 'c',
59 Undefined = 'u',
60};
61
63 uint64_t _id;
64 std::string _label;
65 matroskaTypeEnum _type;
66 matroskaProcessEnum _process;
67
68 MatroskaTag(uint64_t id, std::string label, matroskaTypeEnum type, matroskaProcessEnum process) :
69 _id(id), _label(std::move(label)), _type(type), _process(process) {
70 }
71
72 MatroskaTag(uint64_t id, std::string label) :
73 _id(id),
74 _label(std::move(label)),
75 _type(matroskaTypeEnum::UndefinedType),
76 _process(matroskaProcessEnum::Undefined) {
77 }
78
79 bool operator==(uint64_t id) const {
80 return id == _id;
81 }
82
83 [[nodiscard]] bool isSkipped() const {
84 return _process == Skip;
85 }
86 [[nodiscard]] bool isComposite() const {
87 return _process == Composite;
88 }
89 void dump(std::ostream& os) const {
90 os << " MatroskaTag "
91 << " id: [0x" << std::hex << _id << "] label:[" << _label << "] type:[" << _type << "] process :[" << _process
92 << "]\n";
93 }
94};
95} // namespace Internal
96
100class EXIV2API MatroskaVideo : public Image {
101 public:
103
104
117
119
120 void readMetadata() override;
121 void writeMetadata() override;
123
125
126 [[nodiscard]] std::string mimeType() const override;
128
129 protected:
139 [[nodiscard]] static uint32_t findBlockSize(byte b);
144 void decodeBlock();
152 void decodeInternalTags(const Internal::MatroskaTag* tag, const byte* buf);
153 void decodeStringTags(const Internal::MatroskaTag* tag, const byte* buf);
154 void decodeIntegerTags(const Internal::MatroskaTag* tag, const byte* buf);
155 void decodeBooleanTags(const Internal::MatroskaTag* tag, const byte* buf);
156 void decodeDateTags(const Internal::MatroskaTag* tag, const byte* buf, size_t size);
157 void decodeFloatTags(const Internal::MatroskaTag* tag, const byte* buf);
158
159 private:
161 bool continueTraversing_{};
163 uint64_t height_{};
164 uint64_t width_{};
165 uint32_t track_count_{};
166 double time_code_scale_ = 1.0;
167 uint64_t stream_{};
168
169 static constexpr double bytesMB = 1048576;
170
171}; // class MatroskaVideo
172
173// *****************************************************************************
174// template, inline and free functions
175
176// These could be static private functions on Image subclasses but then
177// ImageFactory needs to be made a friend.
183EXIV2API Image::UniquePtr newMkvInstance(BasicIo::UniquePtr io, bool create);
184
186EXIV2API bool isMkvType(BasicIo& iIo, bool advance);
187
188} // namespace Exiv2
189
190#endif // #ifndef MATROSKAVIDEO_HPP_
An interface for simple binary IO.
Definition basicio.hpp:35
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:50
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition image.hpp:53
Class to access Matroska video files.
Definition matroskavideo.hpp:100
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
EXIV2API Image::UniquePtr newMkvInstance(BasicIo::UniquePtr io, bool create)
Create a new MatroskaVideo instance and return an auto-pointer to it. Caller owns the returned object...
Definition matroskavideo.cpp:922
EXIV2API bool isMkvType(BasicIo &iIo, bool advance)
Check if the file iIo is a Matroska Video.
Definition matroskavideo.cpp:930
Definition matroskavideo.hpp:62
List of TIFF compression to MIME type mappings.
Definition tiffimage.cpp:47