Exiv2
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
31 namespace Exiv2 {
32 
33 // *****************************************************************************
34 // class definitions
35 
36  // Add MKV to the supported image formats
37  namespace ImageType {
38  const int mkv = 21;
39  }
40 
41  // Todo: Should be hidden
45  struct EXIV2LIB_DEPRECATED MatroskaTags {
46  uint64_t val_;
47  const char* label_;
48 
50  bool operator==(uint64_t key) const { return val_ == key; }
51  }; // struct TagDetails
52 
56  class EXIV2LIB_DEPRECATED_EXPORT MatroskaVideo : public Image {
57  public:
59 
60 
73 
75 
76  void readMetadata();
77  void writeMetadata();
79 
81 
82  std::string mimeType() const;
84 
85  protected:
95  uint32_t findBlockSize(byte b);
100  void decodeBlock();
107  void contentManagement(const MatroskaTags* mt, const byte* buf, long size);
112  void aspectRatio();
113 
114  private:
116 
117  MatroskaVideo(const MatroskaVideo& rhs);
120  MatroskaVideo& operator=(const MatroskaVideo& rhs);
122 
123  private:
125  bool continueTraversing_;
127  uint64_t height_, width_;
128 
129  }; // class MatroskaVideo
130 
131 // *****************************************************************************
132 // template, inline and free functions
133 
134  // These could be static private functions on Image subclasses but then
135  // ImageFactory needs to be made a friend.
141  EXIV2LIB_DEPRECATED_EXPORT Image::AutoPtr newMkvInstance(BasicIo::AutoPtr io, bool create);
142 
144  EXIV2LIB_DEPRECATED_EXPORT bool isMkvType(BasicIo& iIo, bool advance);
145 
146 } // namespace Exiv2
147 
148 #endif // #ifndef MATROSKAVIDEO_HPP_
Exiv2::newMkvInstance
EXIV2LIB_DEPRECATED_EXPORT Image::AutoPtr newMkvInstance(BasicIo::AutoPtr io, bool create)
Create a new MatroskaVideo instance and return an auto-pointer to it. Caller owns the returned object...
Exiv2::MatroskaTags::label_
const char * label_
Translation of the tag value.
Definition: matroskavideo.hpp:47
Exiv2::MatroskaVideo
Class to access Matroska video files.
Definition: matroskavideo.hpp:56
Exiv2::MatroskaTags::val_
uint64_t val_
Tag value.
Definition: matroskavideo.hpp:46
Exiv2::MatroskaVideo::MatroskaVideo
MatroskaVideo(BasicIo::AutoPtr io)
Constructor for a Matroska video. Since the constructor can not return a result, callers should check...
Exiv2::MatroskaVideo::contentManagement
void contentManagement(const MatroskaTags *mt, const byte *buf, long size)
Interpret tag information, and save it in the respective XMP container.
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:316
Exiv2::MatroskaVideo::mimeType
std::string mimeType() const
Return the MIME type of the image.
Exiv2::MatroskaVideo::findBlockSize
uint32_t findBlockSize(byte b)
Function used to calulate the size of a block. This information is only stored in one byte....
Exiv2::isMkvType
EXIV2LIB_DEPRECATED_EXPORT bool isMkvType(BasicIo &iIo, bool advance)
Check if the file iIo is a Matroska Video.
Exiv2::MatroskaVideo::aspectRatio
void aspectRatio()
Calculates Aspect Ratio of a video, and stores it in the respective XMP container.
Exiv2::find
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition: types.hpp:497
Exiv2::ImageType::mkv
const int mkv
Treating mkv as an image type>
Definition: matroskavideo.hpp:38
Exiv2::MatroskaVideo::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::getFloat
EXIV2API float getFloat(const byte *buf, ByteOrder byteOrder)
Read a 4 byte single precision floating point value (IEEE 754 binary32) from the data buffer.
Definition: types.cpp:342
EXV_WARNING
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
Exiv2::MatroskaTags::operator==
bool operator==(uint64_t key) const
Comparison operator for use with the find template.
Definition: matroskavideo.hpp:50
Exiv2::MatroskaVideo::writeMetadata
void writeMetadata()
Write metadata back to the image.
Exiv2::Internal
Contains internal objects which are not published and are not part of the libexiv2 API.
Definition: slice.hpp:31
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:81
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
Exiv2::getDouble
EXIV2API double getDouble(const byte *buf, ByteOrder byteOrder)
Read an 8 byte double precision floating point value (IEEE 754 binary64) from the data buffer.
Definition: types.cpp:356
Exiv2::MatroskaTags
Helper structure for the Matroska tags lookup table.
Definition: matroskavideo.hpp:45
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
Exiv2::MatroskaVideo::decodeBlock
void decodeBlock()
Check for a valid tag and decode the block at the current IO position. Calls contentManagement() or s...
error.hpp
Error class for exceptions, log message class.