1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
// =================================================================================================
// Copyright Adobe
// Copyright 2020 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================
#ifndef __WAVE_Handler_hpp__
#define __WAVE_Handler_hpp__ 1
#include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header.
#include "public/include/XMP_Const.h"
#include "XMPFiles/source/FormatSupport/IFF/ChunkController.h"
#include "XMPFiles/source/FormatSupport/IFF/IChunkBehavior.h"
#include "XMPFiles/source/FormatSupport/IFF/IChunkData.h"
#include "source/Endian.h"
#include "XMPFiles/source/FormatSupport/IFF/ChunkPath.h"
#include "XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.h"
#include "XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.h"
#include "XMPFiles/source/FormatSupport/WAVE/CartMetadata.h"
#include "XMPFiles/source/FormatSupport/WAVE/DISPMetadata.h"
#include "XMPFiles/source/FormatSupport/WAVE/INFOMetadata.h"
#include "source/XIO.hpp"
#include "XMPFiles/source/XMPFiles_Impl.hpp"
using namespace IFF_RIFF;
// =================================================================================================
/// \file WAV_Handler.hpp
/// \brief File format handler for AIFF.
// =================================================================================================
/**
* Contructor for the handler.
*/
extern XMPFileHandler * WAVE_MetaHandlerCTor ( XMPFiles * parent );
/**
* Checks the format of the file, see common code.
*/
extern bool WAVE_CheckFormat ( XMP_FileFormat format,
XMP_StringPtr filePath,
XMP_IO* fileRef,
XMPFiles * parent );
/** WAVE does not need kXMPFiles_CanRewrite as we can always use UpdateFile to either do
* in-place update or append to the file. */
static const XMP_OptionBits kWAVE_HandlerFlags = (kXMPFiles_CanInjectXMP |
kXMPFiles_CanExpand |
kXMPFiles_PrefersInPlace |
kXMPFiles_CanReconcile |
kXMPFiles_ReturnsRawPacket |
kXMPFiles_AllowsSafeUpdate |
kXMPFiles_CanNotifyProgress
);
/**
* Main class for the the WAVE file handler.
*/
class WAVE_MetaHandler : public XMPFileHandler
{
public:
WAVE_MetaHandler ( XMPFiles* parent );
~WAVE_MetaHandler();
void CacheFileData();
void ProcessXMP();
void UpdateFile ( bool doSafeUpdate );
void WriteTempFile ( XMP_IO* tempRef );
/**
* Checks if the first 4 bytes of the given buffer are either type RIFF or RF64
* @param buffer a byte buffer that must contain at least 4 bytes and point to the correct byte
* @return Either kChunk_RIFF, kChunk_RF64 0 if no type could be determined
*/
static XMP_Uns32 whatRIFFFormat( XMP_Uns8* buffer );
private:
/**
* Updates/creates/deletes a given legacy chunk depending on the given new legacy value
* If the Chunk exists and is not empty, it is updated. If it is empty the
* Chunk is removed from the tree. If the Chunk does not exist but a value is given, it is created
* and initialized with that value
*
* @param chunk OUT pointer to the legacy chunk
* @param chunkID Id of the Chunk if it needs to be created
* @param chunkType Type of the Chunk if it needs to be created
* @param legacyData the new legacy metadata object (can be empty)
*/
void updateLegacyChunk( IChunkData **chunk, XMP_Uns32 chunkID, XMP_Uns32 chunkType, IMetadata &legacyData );
/** private standard Ctor, not to be used */
WAVE_MetaHandler (): mChunkController(NULL), mChunkBehavior(NULL),
mINFOMeta(), mBEXTMeta(), mCartMeta(), mDISPMeta(),
mXMPChunk(NULL), mINFOChunk(NULL),
mBEXTChunk(NULL), mCartChunk(NULL), mDISPChunk(NULL) {};
// ----- MEMBERS ----- //
/** Controls the parsing and writing of the passed stream. */
ChunkController *mChunkController;
/** Represents the rules how chunks are added, removed or rearranged */
IChunkBehavior *mChunkBehavior;
/** container for Legacy metadata */
INFOMetadata mINFOMeta;
BEXTMetadata mBEXTMeta;
CartMetadata mCartMeta;
DISPMetadata mDISPMeta;
iXMLMetadata miXMLMeta;
// cr8r is not yet required for WAVE
// Cr8rMetadata mCr8rMeta;
/** pointer to the XMP chunk */
IChunkData *mXMPChunk;
/** pointer to legacy chunks */
IChunkData *mINFOChunk;
IChunkData *mBEXTChunk;
IChunkData *mCartChunk;
IChunkData *mDISPChunk;
IChunkData *miXMLChunk;
// cr8r is not yet required for WAVE
// IChunkData *mCr8rChunk;
// ----- CONSTANTS ----- //
/** Chunk path identifier of interest in WAVE */
static const ChunkIdentifier kRIFFXMP[2];
static const ChunkIdentifier kRIFFInfo[2];
static const ChunkIdentifier kRIFFDisp[2];
static const ChunkIdentifier kRIFFBext[2];
static const ChunkIdentifier kRIFFCart[2];
static const ChunkIdentifier kRIFFiXML[2];
// cr8r is not yet required for WAVE
// static const ChunkIdentifier kWAVECr8r[2];
/** Chunk path identifier of interest in RF64 */
static const ChunkIdentifier kRF64XMP[2];
static const ChunkIdentifier kRF64Info[2];
static const ChunkIdentifier kRF64Disp[2];
static const ChunkIdentifier kRF64Bext[2];
static const ChunkIdentifier kRF64Cart[2];
static const ChunkIdentifier kRF64iXML[2];
// cr8r is not yet required for WAVE
// static const ChunkIdentifier kRF64Cr8r[2];
/** Path to XMP chunk */
ChunkPath mWAVEXMPChunkPath;
/** Path to INFO chunk */
ChunkPath mWAVEInfoChunkPath;
/** Path to DISP chunk */
ChunkPath mWAVEDispChunkPath;
/** Path to BEXT chunk */
ChunkPath mWAVEBextChunkPath;
/** Path to cart chunk */
ChunkPath mWAVECartChunkPath;
/** Path to IXML chunk */
ChunkPath mWAVEiXMLChunkPath;
//cr8r is not yet required for WAVE
///** Path to Cr8r chunk */
//const ChunkPath mWAVECr8rChunkPath;
}; // WAVE_MetaHandler
// =================================================================================================
#endif /* __WAVE_Handler_hpp__ */
|