mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 21:14:23 -04:00
Split Ogg packets larger than 64kb into multiple pages
The implementation is not very efficient, but the current Ogg code makes it hard to write it properly. :( Patch by Marc Halbruegge BUG:171957 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1019459 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
@ -13,6 +13,7 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/riff/aiff
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/trueaudio
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/vorbis
|
||||
)
|
||||
|
||||
SET(test_runner_SRCS
|
||||
@ -31,6 +32,7 @@ SET(test_runner_SRCS
|
||||
test_xiphcomment.cpp
|
||||
test_aiff.cpp
|
||||
test_riff.cpp
|
||||
test_ogg.cpp
|
||||
)
|
||||
IF(WITH_MP4)
|
||||
SET(test_runner_SRCS ${test_runner_SRCS} test_mp4.cpp)
|
||||
|
@ -6,6 +6,7 @@ INCLUDES = \
|
||||
-I$(top_srcdir)/taglib/mpeg/id3v1 \
|
||||
-I$(top_srcdir)/taglib/mpeg/id3v2 \
|
||||
-I$(top_srcdir)/taglib/ogg \
|
||||
-I$(top_srcdir)/taglib/ogg/vorbis \
|
||||
-I$(top_srcdir)/taglib/riff \
|
||||
-I$(top_srcdir)/taglib/riff/aiff \
|
||||
-I$(top_srcdir)/taglib/mpeg/id3v2/frames
|
||||
@ -24,7 +25,8 @@ test_runner_SOURCES = \
|
||||
test_id3v2.cpp \
|
||||
test_xiphcomment.cpp \
|
||||
test_riff.cpp \
|
||||
test_aiff.cpp
|
||||
test_aiff.cpp \
|
||||
test_ogg.cpp
|
||||
|
||||
if build_tests
|
||||
TESTS = test_runner
|
||||
|
58
tests/test_ogg.cpp
Normal file
58
tests/test_ogg.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <oggfile.h>
|
||||
#include <vorbisfile.h>
|
||||
#include <oggpageheader.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
||||
class TestOGG : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestOGG);
|
||||
CPPUNIT_TEST(testSimple);
|
||||
CPPUNIT_TEST(testSplitPackets);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testSimple()
|
||||
{
|
||||
string newname = copyFile("empty", ".ogg");
|
||||
|
||||
Vorbis::File *f = new Vorbis::File(newname.c_str());
|
||||
f->tag()->setArtist("The Artist");
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new Vorbis::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
|
||||
delete f;
|
||||
|
||||
deleteFile(newname);
|
||||
}
|
||||
|
||||
void testSplitPackets()
|
||||
{
|
||||
string newname = copyFile("empty", ".ogg");
|
||||
|
||||
Vorbis::File *f = new Vorbis::File(newname.c_str());
|
||||
f->tag()->addField("test", ByteVector(128 * 1024, 'x') + ByteVector(1, '\0'));
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new Vorbis::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(19, f->lastPageHeader()->pageSequenceNumber());
|
||||
delete f;
|
||||
|
||||
deleteFile(newname);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG);
|
Reference in New Issue
Block a user