Commit Graph

552 Commits

Author SHA1 Message Date
b4fe04f8e0 tests: fix compilation on MSYS2
Something about a deleted operator<<.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-12-13 06:24:39 +01:00
8a42e552aa Use private implementations for MP4::Atom, MP4::Atoms 2023-12-11 06:35:08 +01:00
491322d1ba Tolerate trailing garbage in M4A files (#1186)
If an M4A file contains trailing garbage (e.g. an APE tag at the
end of the file), it was considered invalid since [e21640b].
It is important to make sure that atoms which affect modifications
written by TagLib are valid, otherwise the file might be damaged.
However, in cases where invalid atoms do not affect modifications
(which are only done inside the root level "moov" and "moof"
containers), they can be safely ignored.

This commit allows trailing garbage in M4A files as it is also
accepted in MP3, WAV and DSF files.
2023-12-08 15:58:01 +01:00
8b3f1a459e Fix issues reported by CppCheck
Many shadowFunction, some useStlAlgorithm, and others.

cppcheck --enable=all --inline-suppr \
  --suppress=noExplicitConstructor --suppress=unusedFunction \
  --suppress=missingIncludeSystem --project=compile_commands.json
2023-12-07 05:00:00 +01:00
131918333b Fix issues reported by Clang Static Analyzer
Some deadcode.DeadStores.

On Debian 12:
CXXFLAGS=-I/usr/include/x86_64-linux-gnu/c++/12 \
cmake -DCMAKE_C_COMPILER=/usr/share/clang/scan-build-14/libexec/ccc-analyzer \
    -DCMAKE_CXX_COMPILER=/usr/share/clang/scan-build-14/libexec/c++-analyzer \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
    -DENABLE_CCACHE=ON -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON \
    -DCMAKE_BUILD_TYPE=Debug ../taglib
scan-build make
2023-12-07 05:00:00 +01:00
51d63ab285 Detach list when setAutoDelete() is called
When calling setAutoDelete() on the implicitly shared copy of a list,
also auto-deletion of the original container was modified because
it was not detached. On the other hand, detach() was called by some
methods getting an Iterator parameter, which can lead to modification
of other implicitly shared copies but not the object is was called on.
This happens when the method is called on a not-already-detached
container, which is normally not the case because the container is
detached when the iterator is taken (e.g. calling begin()).
In such methods detach() cannot be called, and the client must
make sure that the iterator is taken after making an implicit copy.
This will NOT work:

List<int> l1 = { 1 };
auto it = l1.begin();
List<int> l2 = l1;
l1.erase(it);

This will modify both l1 and l2. The second and the third lines
must be swapped so that l1.begin() will detach l1 from l2.
2023-12-02 08:03:14 +01:00
3f11e0ae2f TestId3v2FrameFactory: Fix memory leak
The frames in a frameList() copy were not deleted because it had the
autoDelete property active. However, removed frames cannot be auto
deleted. Using setAutoDelete() affects the source of the copy, which has
to be investigated further.
2023-12-01 07:55:55 +01:00
bd06012b02 Implement property interface for RIFF Info 2023-12-01 07:55:55 +01:00
9233ff1f5d Support OWNER property for MP4
OWNER ownr
2023-12-01 07:55:55 +01:00
88219f2493 Support additional properties for ASF
ARTISTWEBPAGE WM/AuthorURL
ENCODING WM/EncodingSettings
INITIALKEY WM/InitialKey
ORIGINALALBUM WM/OriginalAlbumTitle
ORIGINALARTIST WM/OriginalArtist
ORIGINALFILENAME WM/OriginalFilename
ORIGINALLYRICIST WM/OriginalLyricist
2023-12-01 07:55:55 +01:00
9df243ef74 Separate multiple values in basic tag with " / " instead of " " 2023-12-01 06:22:35 +01:00
56382e8cd4 Return tag union for tag() of WAV file 2023-12-01 06:22:35 +01:00
8bb8fc5fe6 Remove null byte removal for table of contents frame 2023-12-01 06:22:35 +01:00
3d67b139e4 Fix extensibility of ID3v2 FrameFactory
Because the main extension point of FrameFactory was using a protected
Frame subclass, it was not really possible to implement a custom frame
factory. Existing Frame subclasses also show that access to the frame
header might be needed when implementing a Frame subclass.
2023-11-23 16:41:46 +01:00
c083d7ce15 Clients can control supported MP4 atoms using an ItemFactory (#1175) 2023-11-23 16:39:57 +01:00
2f4c76b52a MP4: Get duration from mvhd if not present in mdhd (#1165) (#1168) 2023-11-05 14:40:37 +01:00
dfa33bec08 Fix crash with invalid WAV files (#1163) (#1164)
With specially crafted WAV files having the "id3 " chunk as the
only valid chunk, when trying to write the tags, the existing
"id3 " chunk is removed, and then vector::front() is called on
the now empty chunks vector.
Now it is checked if the vector is empty to avoid the crash.
2023-11-05 14:40:18 +01:00
3869aa189f Raw AAC (ADTS) support (#508)
Detect ADTS MPEG header to use it also for AAC.

The test file empty1s.aac was generated using
ffmpeg -f lavfi -i anullsrc=r=11025:cl=mono -t 1 -acodec aac empty1s.aac

---------

Co-authored-by: Nick Shaforostov <mshaforostov@airmusictech.com>
Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-11-03 05:17:39 +01:00
a7c0b53f7a C bindings: taglib_file_new_iostream() to access file from memory (#987)
A ByteVectorStream can be created/freed from C using
taglib_memory_iostream_new()/taglib_iostream_free().
2023-10-27 09:46:54 +02:00
0db487bf61 Remove deprecated FileRef::create() method
In order to achieve this, the TagLib_File type of the C bindings is now
a FileRef and no longer a File. The support for the .oga extension has been
ported to FileRef(), so that taglib_file_new() should still behave the
same, but additionally also support content based file type detection.
2023-10-27 09:46:54 +02:00
8d98ebf24b Provide properties methods on FileRef, make FileRef non-virtual
Use of FileRef::file() is discouraged, but was necessary to access the
properties. It was also not clear whether to access the properties via
tag() or file(). With the property methods on FileRef, it should become
the "simple usage" interface it was meant to be.
As the destructor was the only virtual method on FileRef, it is now made
non-virtual. Probably, it is not useful as a virtual base class.
2023-10-27 09:46:54 +02:00
11f94903d0 DSDIFF: Add tests for ID3 in PROP and DIIN chunks 2023-10-23 06:06:05 +02:00
6b5f28d56d DSDIFF: Fix adding and removing DIIN chunks
Also modernize and simplify code, fix formatting, support
ID3v2FrameFactory, fix updating the internal chunk bookkeeping
after file modifications, stripping ID3 and DIIN tags.
2023-10-23 06:06:05 +02:00
19cceab211 DSDIFF support, add tests, fix formatting 2023-10-23 06:06:05 +02:00
182edcd3f9 Add unit tests for C bindings 2023-10-21 06:19:55 +02:00
1d213b8b98 List: Add Sort Functions (#1160) 2023-10-18 07:54:22 +02:00
b40b834b1b Add ByteVector conversion functions, tests 2023-10-15 08:29:58 +02:00
6be03b7ae1 Unified interface for complex properties like pictures (#94)
Provides a dynamic interface for properties which cannot be represented
with simple strings, e.g. pictures. The keys of such properties can
be queried using `complexPropertyKeys()`, which could return for example
["PICTURE"]. The property can then be read using
`complexProperties("PICTURE")`, which will return a list of variant maps
containing the picture data and attributes. Adding a picture is as
easy as

    t->setComplexProperties("PICTURE", {
      {
        {"data", data},
        {"pictureType", "Front Cover"},
        {"mimeType", "image/jpeg"}
      }
    });
2023-10-14 09:01:59 +02:00
75d4252480 Variant type as container for complex properties 2023-10-14 09:01:59 +02:00
2e3a66cc31 Fix memory leak in testParsePodcastFrame() 2023-10-07 09:18:22 +02:00
21b08c0dcb List: Support Braced List Initialization (#1154)
* List: support braced list initialization

* Use swap for assignment

---------

Co-authored-by: complexlogic <complexlogic@users.noreply.github.com>
2023-10-07 07:27:29 +02:00
8a800b8c38 Map: Support Braced List Initialization (#1153)
* Map: support braced list initialization

* Use swap assignment

---------

Co-authored-by: complexlogic <complexlogic@users.noreply.github.com>
2023-10-07 07:27:14 +02:00
c332aa04f2 Add simple runtime version check API (#970)
How to use:

  #include <tversionnumber.h>

  if (TagLib::runtimeVersion() >= TagLib::VersionNumber(1, 11, 1)) {
    // running v1.11.1 or higher
  }

  if (TagLib::runtimeVersion() >= TagLib::VersionNumber(1, 12)) {
    // running v1.12 or higher
  }

---------

Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-10-06 14:15:30 +02:00
c13a42021a Do not scan full MPEG file for ID3v2 tag in Fast read style (#968) (#1151)
This is based on the patch used by VLC, but the full scan is only
skipped when the read style is explicitly set to Fast.
https://code.videolan.org/videolan/vlc/-/blob/master/contrib/src/taglib/0001-Implement-ID3v2-readStyle-avoid-worst-case.patch
2023-09-30 14:25:52 +02:00
eaf7ff8b94 DSF: Support frame factory, ID3v2.3, allow trailing garbage
Additionally test coverage and formatting are improved.
2023-09-26 16:23:03 +02:00
39d1d68237 DSD Stream File (DSF) support 2023-09-26 16:23:03 +02:00
97a74ca3d8 clang: fix -Wextra-semi warnings (#1134)
Achieved by adding do/while to mandate a semicolon.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-16 08:23:45 +02:00
7646184d6b unused includes (#1133)
* unused includes

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* Use consistent order of includes

Always include in the following order:
- Own header files
- Standard header files
- System header files
- Project header files (toolkit first)

Exceptions:
- cppunit/extensions/HelperMacros.h must be included after
  header files declaring stream operators
- config.h must be included before its definitions are used

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-09-16 08:22:36 +02:00
524b588a1e manual range loop conversions (#1126)
* manual range loop conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* Restore const containers where non const temporaries are iterated

* Use std::as_const() instead of const container copies where possible

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-09-06 20:58:13 +02:00
ecf1d4fa53 clang: fix documentation (#1111)
* Use [[deprecated]] always

Simplifies the code. Codebase is C++17 anyways.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang: fix documentation

Found with Wdocumentation

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* add deprecated to length() and fix usages

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-03 15:14:05 +02:00
f2d0e664e7 Add ending namespace comments (#1108)
Found with google-readability-namespace-comments

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-07 20:44:11 -05:00
185bb7042e Use unique_ptr for d-pointers (#1095)
* clang-tidy: make deleted members public

One oversight of modernize-use-equals-delete is that the C++11 way of
doing this is to make it public, which makes the warning still trigger.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: add missing deleted functions

Found with cppcoreguidelines-special-member-functions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* unique_ptr conversions

unique_ptr is a safer and cleaner way to handle d pointers.

Also added missing = default.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-07 15:08:40 -05:00
843a8aac80 Replace RefCounter with shared_ptr (#1100)
* clang-tidy: replace RefCounter with shared_ptr

The latter is C++11.

Found with clang-analyzer-webkit.NoUncountedMemberChecker

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* remove trefcounter

It is now unused.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-07 08:40:24 -05:00
965260e3cb Add a note about how I generated list of classes 2023-07-30 06:55:23 +02:00
f903e1ad71 Add checks for the expected sizes of all public classes
This ensures that d-pointers exist where they're expected, and that
classes are virtual that we expect to be virtual, as well as ensuring
that we get a failure if the class size changes when it shouldn't.

This also fixes the issues that were discovered by adding these tests.
2023-07-30 06:31:48 +02:00
c54c924333 Use static_cast instead of C-style casts 2023-07-22 07:09:58 +02:00
cc7d23cdf5 Consistently use quote form when including our own headers 2023-07-22 07:09:58 +02:00
2a1fb27735 clang-tidy: Replace C headers with C++ alternatives
run-clang-tidy -header-filter='.*' -checks='-*,modernize-deprecated-headers'

Fixed manually as automatic fix would shuffle headers around.
2023-07-22 07:09:58 +02:00
c2c9e8989c clang-tidy: Use auto where it improves the readability
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-auto' \
-config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
-fix

Manually fixed some wrong `const auto` replacements and verified
that all types are deduced correctly.
2023-07-22 07:09:58 +02:00
abc6c31890 clang-tidy: Use nullptr instead of 0
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix
2023-07-22 07:09:58 +02:00