diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ea44e54..f60afad9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ include(ConfigureChecks.cmake) option(WITH_APE "Build with APE, MPC, WavPack" ON) option(WITH_ASF "Build with ASF" ON) option(WITH_DSF "Build with DSF" ON) +option(WITH_MATROSKA "Build with Matroska" ON) option(WITH_MOD "Build with Tracker modules" ON) option(WITH_MP4 "Build with MP4" ON) option(WITH_RIFF "Build with AIFF, RIFF, WAV" ON) @@ -197,6 +198,9 @@ endif() if(WITH_DSF) set(TAGLIB_WITH_DSF TRUE) endif() +if(WITH_MATROSKA) + set(TAGLIB_WITH_MATROSKA TRUE) +endif() if(WITH_MOD) set(TAGLIB_WITH_MOD TRUE) endif() diff --git a/INSTALL.md b/INSTALL.md index beb4bf43..af9a7652 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -63,6 +63,7 @@ and ID3 tags cannot be disabled. The following CMake options are available: | `WITH_APE` | Build with APE, MPC, WavPack (default ON) | | `WITH_ASF` | Build with ASF (default ON) | | `WITH_DSF` | Build with DSF (default ON) | +| `WITH_MATROSKA` | Build with Matroska (default ON) | | `WITH_MOD` | Build with Tracker modules (default ON) | | `WITH_MP4` | Build with MP4 (default ON) | | `WITH_RIFF` | Build with AIFF, RIFF, WAV (default ON) | diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 777797ca..d5862407 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -39,15 +39,17 @@ target_link_libraries(framelist tag) add_executable(strip-id3v1 strip-id3v1.cpp) target_link_libraries(strip-id3v1 tag) -########### next target ############### +if(WITH_MATROSKA) + ########### next target ############### -add_executable(matroskareader matroskareader.cpp) -target_link_libraries(matroskareader tag) + add_executable(matroskareader matroskareader.cpp) + target_link_libraries(matroskareader tag) -########### next target ############### + ########### next target ############### -add_executable(matroskawriter matroskawriter.cpp) -target_link_libraries(matroskawriter tag) + add_executable(matroskawriter matroskawriter.cpp) + target_link_libraries(matroskawriter tag) +endif() install(TARGETS tagreader tagreader_c tagwriter framelist strip-id3v1 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index 73f3f4a1..20fd4331 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -5,8 +5,6 @@ set(tag_HDR_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2 ${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2/frames ${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v1 - ${CMAKE_CURRENT_SOURCE_DIR}/matroska - ${CMAKE_CURRENT_SOURCE_DIR}/matroska/ebml ) if(WITH_ASF) set(tag_HDR_DIRS ${tag_HDR_DIRS} @@ -66,9 +64,15 @@ if(WITH_SHORTEN) ${CMAKE_CURRENT_SOURCE_DIR}/shorten ) endif() +if(WITH_MATROSKA) + set(tag_HDR_DIRS ${tag_HDR_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/matroska + ${CMAKE_CURRENT_SOURCE_DIR}/matroska/ebml + ) +endif() include_directories(${tag_HDR_DIRS}) -set(tag_PUBLIC_HDRS +set(tag_HDRS tag.h fileref.h audioproperties.h @@ -92,12 +96,6 @@ set(tag_PUBLIC_HDRS toolkit/tpropertymap.h toolkit/tdebuglistener.h toolkit/tversionnumber.h - matroska/matroskaattachedfile.h - matroska/matroskaattachments.h - matroska/matroskafile.h - matroska/matroskatag.h - matroska/matroskasimpletag.h - matroska/matroskaelement.h mpeg/mpegfile.h mpeg/mpegproperties.h mpeg/mpegheader.h @@ -228,49 +226,32 @@ if(WITH_SHORTEN) shorten/shortentag.h ) endif() - -set(tag_PRIVATE_HDRS - matroska/matroskaseekhead.h - matroska/matroskasegment.h - matroska/ebml/ebmlbinaryelement.h - matroska/ebml/ebmlelement.h - matroska/ebml/ebmlmasterelement.h - matroska/ebml/ebmlmkattachments.h - matroska/ebml/ebmlmkseekhead.h - matroska/ebml/ebmlmksegment.h - matroska/ebml/ebmlmktags.h - matroska/ebml/ebmlstringelement.h - matroska/ebml/ebmluintelement.h - matroska/ebml/ebmlutils.h - matroska/ebml/ebmlvoidelement.h -) - -set(tag_HDRS ${tag_PUBLIC_HDRS} ${tag_PRIVATE_HDRS}) - -set(matroska_SRCS - matroska/matroskaattachedfile.cpp - matroska/matroskaattachments.cpp - matroska/matroskaelement.cpp - matroska/matroskafile.cpp - matroska/matroskaseekhead.cpp - matroska/matroskasegment.cpp - matroska/matroskasimpletag.cpp - matroska/matroskatag.cpp -) - -set(ebml_SRCS - matroska/ebml/ebmlbinaryelement.cpp - matroska/ebml/ebmlelement.cpp - matroska/ebml/ebmlmasterelement.cpp - matroska/ebml/ebmlmkattachments.cpp - matroska/ebml/ebmlmkseekhead.cpp - matroska/ebml/ebmlmksegment.cpp - matroska/ebml/ebmlmktags.cpp - matroska/ebml/ebmlstringelement.cpp - matroska/ebml/ebmluintelement.cpp - matroska/ebml/ebmlutils.cpp - matroska/ebml/ebmlvoidelement.cpp -) +if(WITH_MATROSKA) + set(tag_HDRS ${tag_HDRS} + matroska/matroskafile.h + matroska/matroskatag.h + matroska/matroskasimpletag.h + matroska/matroskaattachedfile.h + matroska/matroskaattachments.h + matroska/matroskafile.h + matroska/matroskatag.h + matroska/matroskasimpletag.h + matroska/matroskaelement.h + matroska/matroskaseekhead.h + matroska/matroskasegment.h + matroska/ebml/ebmlbinaryelement.h + matroska/ebml/ebmlelement.h + matroska/ebml/ebmlmasterelement.h + matroska/ebml/ebmlmkattachments.h + matroska/ebml/ebmlmkseekhead.h + matroska/ebml/ebmlmksegment.h + matroska/ebml/ebmlmktags.h + matroska/ebml/ebmlstringelement.h + matroska/ebml/ebmluintelement.h + matroska/ebml/ebmlutils.h + matroska/ebml/ebmlvoidelement.h + ) +endif() set(mpeg_SRCS mpeg/mpegfile.cpp @@ -461,6 +442,33 @@ if(WITH_SHORTEN) ) endif() +if(WITH_MATROSKA) + set(matroska_SRCS + matroska/matroskaattachedfile.cpp + matroska/matroskaattachments.cpp + matroska/matroskaelement.cpp + matroska/matroskafile.cpp + matroska/matroskaseekhead.cpp + matroska/matroskasegment.cpp + matroska/matroskasimpletag.cpp + matroska/matroskatag.cpp + ) + + set(ebml_SRCS + matroska/ebml/ebmlbinaryelement.cpp + matroska/ebml/ebmlelement.cpp + matroska/ebml/ebmlmasterelement.cpp + matroska/ebml/ebmlmkattachments.cpp + matroska/ebml/ebmlmkseekhead.cpp + matroska/ebml/ebmlmksegment.cpp + matroska/ebml/ebmlmktags.cpp + matroska/ebml/ebmlstringelement.cpp + matroska/ebml/ebmluintelement.cpp + matroska/ebml/ebmlutils.cpp + matroska/ebml/ebmlvoidelement.cpp + ) +endif() + set(toolkit_SRCS toolkit/tstring.cpp toolkit/tstringlist.cpp @@ -480,11 +488,11 @@ set(toolkit_SRCS ) set(tag_LIB_SRCS - ${matroska_SRCS} ${ebml_SRCS} ${mpeg_SRCS} ${id3v1_SRCS} ${id3v2_SRCS} ${frames_SRCS} ${ogg_SRCS} + ${mpeg_SRCS} ${id3v1_SRCS} ${id3v2_SRCS} ${frames_SRCS} ${ogg_SRCS} ${vorbis_SRCS} ${oggflacs_SRCS} ${mpc_SRCS} ${ape_SRCS} ${toolkit_SRCS} ${flacs_SRCS} ${wavpack_SRCS} ${speex_SRCS} ${trueaudio_SRCS} ${riff_SRCS} ${aiff_SRCS} ${wav_SRCS} ${asf_SRCS} ${mp4_SRCS} ${mod_SRCS} ${s3m_SRCS} ${it_SRCS} ${xm_SRCS} ${opus_SRCS} - ${dsf_SRCS} ${dsdiff_SRCS} ${shorten_SRCS} + ${dsf_SRCS} ${dsdiff_SRCS} ${shorten_SRCS} ${matroska_SRCS} ${ebml_SRCS} tag.cpp tagunion.cpp fileref.cpp @@ -509,13 +517,8 @@ set_target_properties(tag PROPERTIES SOVERSION ${TAGLIB_SOVERSION_MAJOR} INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR} DEFINE_SYMBOL MAKE_TAGLIB_LIB -<<<<<<< HEAD INTERFACE_LINK_LIBRARIES "${ZLIB_INTERFACE_LINK_LIBRARIES}" PUBLIC_HEADER "${tag_HDRS}" -======= - LINK_INTERFACE_LIBRARIES "" - PUBLIC_HEADER "${tag_PUBLIC_HDRS}" ->>>>>>> 770c1012 (Initial matroska support) ) if(NOT BUILD_SHARED_LIBS) target_compile_definitions(tag PUBLIC TAGLIB_STATIC) diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 17ecc8b4..701f30a7 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -38,7 +38,6 @@ #include "tstringlist.h" #include "tvariant.h" #include "tdebug.h" -#include "matroskafile.h" #include "mpegfile.h" #ifdef TAGLIB_WITH_RIFF #include "aifffile.h" @@ -78,6 +77,9 @@ #ifdef TAGLIB_WITH_SHORTEN #include "shortenfile.h" #endif +#ifdef TAGLIB_WITH_MATROSKA +#include "matroskafile.h" +#endif using namespace TagLib; @@ -221,8 +223,10 @@ namespace else if(ext == "SHN") file = new Shorten::File(stream, readAudioProperties, audioPropertiesStyle); #endif +#ifdef TAGLIB_WITH_MATROSKA else if(ext == "MKA" || ext == "MKV" || ext == "WEBM") file = new Matroska::File(stream, readAudioProperties); +#endif // if file is not valid, leave it to content-based detection. diff --git a/taglib/matroska/ebml/ebmluintelement.cpp b/taglib/matroska/ebml/ebmluintelement.cpp index 716b770b..c49dd9f7 100644 --- a/taglib/matroska/ebml/ebmluintelement.cpp +++ b/taglib/matroska/ebml/ebmluintelement.cpp @@ -59,11 +59,10 @@ ByteVector EBML::UIntElement::render() ByteVector buffer = renderId(); buffer.append(renderVINT(dataSize, 0)); - unsigned long long value = this->value; - - static const auto byteOrder = Utils::systemByteOrder(); - if(byteOrder == Utils::LittleEndian) - value = Utils::byteSwap((unsigned long long) value); + uint64_t value = this->value; + static const auto byteOrder = Utils::systemByteOrder(); + if (byteOrder == Utils::LittleEndian) + value = Utils::byteSwap(value); buffer.append(ByteVector((char*) &value + (sizeof(value) - dataSize), dataSize)); return buffer; diff --git a/taglib/matroska/ebml/ebmlutils.cpp b/taglib/matroska/ebml/ebmlutils.cpp index cc898aef..cd41667c 100644 --- a/taglib/matroska/ebml/ebmlutils.cpp +++ b/taglib/matroska/ebml/ebmlutils.cpp @@ -97,14 +97,14 @@ ByteVector EBML::renderVINT(uint64_t number, int minSizeLength) int numBytes = std::max(minSizeLength, minSize(number)); number |= (1ULL << (numBytes * 7)); static const auto byteOrder = Utils::systemByteOrder(); - if(byteOrder == Utils::LittleEndian) - number = Utils::byteSwap(static_cast(number)); - return ByteVector((char*) &number + (sizeof(number) - numBytes), numBytes); + if (byteOrder == Utils::LittleEndian) + number = Utils::byteSwap(number); + return ByteVector((char*) &number + (sizeof(number) - numBytes), numBytes); } unsigned long long EBML::randomUID() { - static std::random_device device; + static std::random_device device; static std::mt19937 generator(device()); static std::uniform_int_distribution distribution; return distribution(generator); diff --git a/taglib/matroska/matroskaelement.h b/taglib/matroska/matroskaelement.h index 9eef6f03..d8697931 100644 --- a/taglib/matroska/matroskaelement.h +++ b/taglib/matroska/matroskaelement.h @@ -24,6 +24,7 @@ #include #include "taglib_export.h" +#include "taglib.h" #include "tutils.h" #include "tbytevector.h" #include "tlist.h" @@ -76,4 +77,4 @@ namespace TagLib { } #endif -#endif \ No newline at end of file +#endif diff --git a/taglib/taglib_config.h.cmake b/taglib/taglib_config.h.cmake index 7a3a02c4..06e51756 100644 --- a/taglib/taglib_config.h.cmake +++ b/taglib/taglib_config.h.cmake @@ -6,6 +6,7 @@ #cmakedefine TAGLIB_WITH_APE 1 #cmakedefine TAGLIB_WITH_ASF 1 #cmakedefine TAGLIB_WITH_DSF 1 +#cmakedefine TAGLIB_WITH_MATROSKA 1 #cmakedefine TAGLIB_WITH_MOD 1 #cmakedefine TAGLIB_WITH_MP4 1 #cmakedefine TAGLIB_WITH_RIFF 1