Skip to content

Commit 4546c00

Browse files
committed
Compile time configuration WITH_MATROSKA
1 parent f948436 commit 4546c00

9 files changed

Lines changed: 91 additions & 76 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ include(ConfigureChecks.cmake)
100100
option(WITH_APE "Build with APE, MPC, WavPack" ON)
101101
option(WITH_ASF "Build with ASF" ON)
102102
option(WITH_DSF "Build with DSF" ON)
103+
option(WITH_MATROSKA "Build with Matroska" ON)
103104
option(WITH_MOD "Build with Tracker modules" ON)
104105
option(WITH_MP4 "Build with MP4" ON)
105106
option(WITH_RIFF "Build with AIFF, RIFF, WAV" ON)
@@ -197,6 +198,9 @@ endif()
197198
if(WITH_DSF)
198199
set(TAGLIB_WITH_DSF TRUE)
199200
endif()
201+
if(WITH_MATROSKA)
202+
set(TAGLIB_WITH_MATROSKA TRUE)
203+
endif()
200204
if(WITH_MOD)
201205
set(TAGLIB_WITH_MOD TRUE)
202206
endif()

INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and ID3 tags cannot be disabled. The following CMake options are available:
6363
| `WITH_APE` | Build with APE, MPC, WavPack (default ON) |
6464
| `WITH_ASF` | Build with ASF (default ON) |
6565
| `WITH_DSF` | Build with DSF (default ON) |
66+
| `WITH_MATROSKA` | Build with Matroska (default ON) |
6667
| `WITH_MOD` | Build with Tracker modules (default ON) |
6768
| `WITH_MP4` | Build with MP4 (default ON) |
6869
| `WITH_RIFF` | Build with AIFF, RIFF, WAV (default ON) |

examples/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ target_link_libraries(framelist tag)
3939
add_executable(strip-id3v1 strip-id3v1.cpp)
4040
target_link_libraries(strip-id3v1 tag)
4141

42-
########### next target ###############
42+
if(WITH_MATROSKA)
43+
########### next target ###############
4344

44-
add_executable(matroskareader matroskareader.cpp)
45-
target_link_libraries(matroskareader tag)
45+
add_executable(matroskareader matroskareader.cpp)
46+
target_link_libraries(matroskareader tag)
4647

47-
########### next target ###############
48+
########### next target ###############
4849

49-
add_executable(matroskawriter matroskawriter.cpp)
50-
target_link_libraries(matroskawriter tag)
50+
add_executable(matroskawriter matroskawriter.cpp)
51+
target_link_libraries(matroskawriter tag)
52+
endif()
5153

5254
install(TARGETS tagreader tagreader_c tagwriter framelist strip-id3v1
5355
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

taglib/CMakeLists.txt

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ set(tag_HDR_DIRS
55
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2
66
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2/frames
77
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v1
8-
${CMAKE_CURRENT_SOURCE_DIR}/matroska
9-
${CMAKE_CURRENT_SOURCE_DIR}/matroska/ebml
108
)
119
if(WITH_ASF)
1210
set(tag_HDR_DIRS ${tag_HDR_DIRS}
@@ -66,9 +64,15 @@ if(WITH_SHORTEN)
6664
${CMAKE_CURRENT_SOURCE_DIR}/shorten
6765
)
6866
endif()
67+
if(WITH_MATROSKA)
68+
set(tag_HDR_DIRS ${tag_HDR_DIRS}
69+
${CMAKE_CURRENT_SOURCE_DIR}/matroska
70+
${CMAKE_CURRENT_SOURCE_DIR}/matroska/ebml
71+
)
72+
endif()
6973
include_directories(${tag_HDR_DIRS})
7074

71-
set(tag_PUBLIC_HDRS
75+
set(tag_HDRS
7276
tag.h
7377
fileref.h
7478
audioproperties.h
@@ -92,12 +96,6 @@ set(tag_PUBLIC_HDRS
9296
toolkit/tpropertymap.h
9397
toolkit/tdebuglistener.h
9498
toolkit/tversionnumber.h
95-
matroska/matroskaattachedfile.h
96-
matroska/matroskaattachments.h
97-
matroska/matroskafile.h
98-
matroska/matroskatag.h
99-
matroska/matroskasimpletag.h
100-
matroska/matroskaelement.h
10199
mpeg/mpegfile.h
102100
mpeg/mpegproperties.h
103101
mpeg/mpegheader.h
@@ -228,49 +226,32 @@ if(WITH_SHORTEN)
228226
shorten/shortentag.h
229227
)
230228
endif()
231-
232-
set(tag_PRIVATE_HDRS
233-
matroska/matroskaseekhead.h
234-
matroska/matroskasegment.h
235-
matroska/ebml/ebmlbinaryelement.h
236-
matroska/ebml/ebmlelement.h
237-
matroska/ebml/ebmlmasterelement.h
238-
matroska/ebml/ebmlmkattachments.h
239-
matroska/ebml/ebmlmkseekhead.h
240-
matroska/ebml/ebmlmksegment.h
241-
matroska/ebml/ebmlmktags.h
242-
matroska/ebml/ebmlstringelement.h
243-
matroska/ebml/ebmluintelement.h
244-
matroska/ebml/ebmlutils.h
245-
matroska/ebml/ebmlvoidelement.h
246-
)
247-
248-
set(tag_HDRS ${tag_PUBLIC_HDRS} ${tag_PRIVATE_HDRS})
249-
250-
set(matroska_SRCS
251-
matroska/matroskaattachedfile.cpp
252-
matroska/matroskaattachments.cpp
253-
matroska/matroskaelement.cpp
254-
matroska/matroskafile.cpp
255-
matroska/matroskaseekhead.cpp
256-
matroska/matroskasegment.cpp
257-
matroska/matroskasimpletag.cpp
258-
matroska/matroskatag.cpp
259-
)
260-
261-
set(ebml_SRCS
262-
matroska/ebml/ebmlbinaryelement.cpp
263-
matroska/ebml/ebmlelement.cpp
264-
matroska/ebml/ebmlmasterelement.cpp
265-
matroska/ebml/ebmlmkattachments.cpp
266-
matroska/ebml/ebmlmkseekhead.cpp
267-
matroska/ebml/ebmlmksegment.cpp
268-
matroska/ebml/ebmlmktags.cpp
269-
matroska/ebml/ebmlstringelement.cpp
270-
matroska/ebml/ebmluintelement.cpp
271-
matroska/ebml/ebmlutils.cpp
272-
matroska/ebml/ebmlvoidelement.cpp
273-
)
229+
if(WITH_MATROSKA)
230+
set(tag_HDRS ${tag_HDRS}
231+
matroska/matroskafile.h
232+
matroska/matroskatag.h
233+
matroska/matroskasimpletag.h
234+
matroska/matroskaattachedfile.h
235+
matroska/matroskaattachments.h
236+
matroska/matroskafile.h
237+
matroska/matroskatag.h
238+
matroska/matroskasimpletag.h
239+
matroska/matroskaelement.h
240+
matroska/matroskaseekhead.h
241+
matroska/matroskasegment.h
242+
matroska/ebml/ebmlbinaryelement.h
243+
matroska/ebml/ebmlelement.h
244+
matroska/ebml/ebmlmasterelement.h
245+
matroska/ebml/ebmlmkattachments.h
246+
matroska/ebml/ebmlmkseekhead.h
247+
matroska/ebml/ebmlmksegment.h
248+
matroska/ebml/ebmlmktags.h
249+
matroska/ebml/ebmlstringelement.h
250+
matroska/ebml/ebmluintelement.h
251+
matroska/ebml/ebmlutils.h
252+
matroska/ebml/ebmlvoidelement.h
253+
)
254+
endif()
274255

275256
set(mpeg_SRCS
276257
mpeg/mpegfile.cpp
@@ -461,6 +442,33 @@ if(WITH_SHORTEN)
461442
)
462443
endif()
463444

445+
if(WITH_MATROSKA)
446+
set(matroska_SRCS
447+
matroska/matroskaattachedfile.cpp
448+
matroska/matroskaattachments.cpp
449+
matroska/matroskaelement.cpp
450+
matroska/matroskafile.cpp
451+
matroska/matroskaseekhead.cpp
452+
matroska/matroskasegment.cpp
453+
matroska/matroskasimpletag.cpp
454+
matroska/matroskatag.cpp
455+
)
456+
457+
set(ebml_SRCS
458+
matroska/ebml/ebmlbinaryelement.cpp
459+
matroska/ebml/ebmlelement.cpp
460+
matroska/ebml/ebmlmasterelement.cpp
461+
matroska/ebml/ebmlmkattachments.cpp
462+
matroska/ebml/ebmlmkseekhead.cpp
463+
matroska/ebml/ebmlmksegment.cpp
464+
matroska/ebml/ebmlmktags.cpp
465+
matroska/ebml/ebmlstringelement.cpp
466+
matroska/ebml/ebmluintelement.cpp
467+
matroska/ebml/ebmlutils.cpp
468+
matroska/ebml/ebmlvoidelement.cpp
469+
)
470+
endif()
471+
464472
set(toolkit_SRCS
465473
toolkit/tstring.cpp
466474
toolkit/tstringlist.cpp
@@ -480,11 +488,11 @@ set(toolkit_SRCS
480488
)
481489

482490
set(tag_LIB_SRCS
483-
${matroska_SRCS} ${ebml_SRCS} ${mpeg_SRCS} ${id3v1_SRCS} ${id3v2_SRCS} ${frames_SRCS} ${ogg_SRCS}
491+
${mpeg_SRCS} ${id3v1_SRCS} ${id3v2_SRCS} ${frames_SRCS} ${ogg_SRCS}
484492
${vorbis_SRCS} ${oggflacs_SRCS} ${mpc_SRCS} ${ape_SRCS} ${toolkit_SRCS} ${flacs_SRCS}
485493
${wavpack_SRCS} ${speex_SRCS} ${trueaudio_SRCS} ${riff_SRCS} ${aiff_SRCS} ${wav_SRCS}
486494
${asf_SRCS} ${mp4_SRCS} ${mod_SRCS} ${s3m_SRCS} ${it_SRCS} ${xm_SRCS} ${opus_SRCS}
487-
${dsf_SRCS} ${dsdiff_SRCS} ${shorten_SRCS}
495+
${dsf_SRCS} ${dsdiff_SRCS} ${shorten_SRCS} ${matroska_SRCS} ${ebml_SRCS}
488496
tag.cpp
489497
tagunion.cpp
490498
fileref.cpp
@@ -509,13 +517,8 @@ set_target_properties(tag PROPERTIES
509517
SOVERSION ${TAGLIB_SOVERSION_MAJOR}
510518
INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR}
511519
DEFINE_SYMBOL MAKE_TAGLIB_LIB
512-
<<<<<<< HEAD
513520
INTERFACE_LINK_LIBRARIES "${ZLIB_INTERFACE_LINK_LIBRARIES}"
514521
PUBLIC_HEADER "${tag_HDRS}"
515-
=======
516-
LINK_INTERFACE_LIBRARIES ""
517-
PUBLIC_HEADER "${tag_PUBLIC_HDRS}"
518-
>>>>>>> 770c1012 (Initial matroska support)
519522
)
520523
if(NOT BUILD_SHARED_LIBS)
521524
target_compile_definitions(tag PUBLIC TAGLIB_STATIC)

taglib/fileref.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "tstringlist.h"
3939
#include "tvariant.h"
4040
#include "tdebug.h"
41-
#include "matroskafile.h"
4241
#include "mpegfile.h"
4342
#ifdef TAGLIB_WITH_RIFF
4443
#include "aifffile.h"
@@ -78,6 +77,9 @@
7877
#ifdef TAGLIB_WITH_SHORTEN
7978
#include "shortenfile.h"
8079
#endif
80+
#ifdef TAGLIB_WITH_MATROSKA
81+
#include "matroskafile.h"
82+
#endif
8183

8284
using namespace TagLib;
8385

@@ -221,8 +223,10 @@ namespace
221223
else if(ext == "SHN")
222224
file = new Shorten::File(stream, readAudioProperties, audioPropertiesStyle);
223225
#endif
226+
#ifdef TAGLIB_WITH_MATROSKA
224227
else if(ext == "MKA" || ext == "MKV" || ext == "WEBM")
225228
file = new Matroska::File(stream, readAudioProperties);
229+
#endif
226230

227231
// if file is not valid, leave it to content-based detection.
228232

taglib/matroska/ebml/ebmluintelement.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ ByteVector EBML::UIntElement::render()
5959

6060
ByteVector buffer = renderId();
6161
buffer.append(renderVINT(dataSize, 0));
62-
unsigned long long value = this->value;
63-
64-
static const auto byteOrder = Utils::systemByteOrder();
65-
if(byteOrder == Utils::LittleEndian)
66-
value = Utils::byteSwap((unsigned long long) value);
62+
uint64_t value = this->value;
63+
static const auto byteOrder = Utils::systemByteOrder();
64+
if (byteOrder == Utils::LittleEndian)
65+
value = Utils::byteSwap(value);
6766

6867
buffer.append(ByteVector((char*) &value + (sizeof(value) - dataSize), dataSize));
6968
return buffer;

taglib/matroska/ebml/ebmlutils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ ByteVector EBML::renderVINT(uint64_t number, int minSizeLength)
9797
int numBytes = std::max(minSizeLength, minSize(number));
9898
number |= (1ULL << (numBytes * 7));
9999
static const auto byteOrder = Utils::systemByteOrder();
100-
if(byteOrder == Utils::LittleEndian)
101-
number = Utils::byteSwap(static_cast<unsigned long long>(number));
102-
return ByteVector((char*) &number + (sizeof(number) - numBytes), numBytes);
100+
if (byteOrder == Utils::LittleEndian)
101+
number = Utils::byteSwap(number);
102+
return ByteVector((char*) &number + (sizeof(number) - numBytes), numBytes);
103103
}
104104

105105
unsigned long long EBML::randomUID()
106106
{
107-
static std::random_device device;
107+
static std::random_device device;
108108
static std::mt19937 generator(device());
109109
static std::uniform_int_distribution<unsigned long long> distribution;
110110
return distribution(generator);

taglib/matroska/matroskaelement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <memory>
2626
#include "taglib_export.h"
27+
#include "taglib.h"
2728
#include "tutils.h"
2829
#include "tbytevector.h"
2930
#include "tlist.h"
@@ -76,4 +77,4 @@ namespace TagLib {
7677
}
7778

7879
#endif
79-
#endif
80+
#endif

taglib/taglib_config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#cmakedefine TAGLIB_WITH_APE 1
77
#cmakedefine TAGLIB_WITH_ASF 1
88
#cmakedefine TAGLIB_WITH_DSF 1
9+
#cmakedefine TAGLIB_WITH_MATROSKA 1
910
#cmakedefine TAGLIB_WITH_MOD 1
1011
#cmakedefine TAGLIB_WITH_MP4 1
1112
#cmakedefine TAGLIB_WITH_RIFF 1

0 commit comments

Comments
 (0)