本文整理汇总了C++中mp4::File::tag方法的典型用法代码示例。如果您正苦于以下问题:C++ File::tag方法的具体用法?C++ File::tag怎么用?C++ File::tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mp4::File
的用法示例。
在下文中一共展示了File::tag方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCovrWrite
void testCovrWrite()
{
ScopedFileCopy copy("has-tags", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->contains("covr"));
MP4::CoverArtList l = f->tag()->item("covr").toCoverArtList();
l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
f->tag()->setItem("covr", l);
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->contains("covr"));
l = f->tag()->item("covr").toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[2].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l[2].data().size());
delete f;
}
示例2: copy
void test64BitAtom()
{
ScopedFileCopy copy("64bit", ".mp4");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemMap()["cpil"].toBool());
MP4::Atoms *atoms = new MP4::Atoms(f);
MP4::Atom *moov = atoms->atoms[0];
CPPUNIT_ASSERT_EQUAL(long(77), moov->length);
f->tag()->setItem("pgap", true);
f->save();
delete atoms;
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->item("cpil").toBool());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->item("pgap").toBool());
atoms = new MP4::Atoms(f);
moov = atoms->atoms[0];
// original size + 'pgap' size + padding
CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
delete atoms;
delete f;
}
示例3: testCovrWrite
void testCovrWrite()
{
string filename = copyFile("has-tags", ".m4a");
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
f->tag()->itemListMap()["covr"] = l;
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
l = f->tag()->itemListMap()["covr"].toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[2].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l[2].data().size());
delete f;
deleteFile(filename);
}
示例4: copyFile
void test64BitAtom()
{
string filename = copyFile("64bit", ".mp4");
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["cpil"].toBool());
MP4::Atoms *atoms = new MP4::Atoms(f);
MP4::Atom *moov = atoms->atoms[0];
CPPUNIT_ASSERT_EQUAL(long(77), moov->length);
f->tag()->itemListMap()["pgap"] = true;
f->save();
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["pgap"].toBool());
atoms = new MP4::Atoms(f);
moov = atoms->atoms[0];
// original size + 'pgap' size + padding
CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
deleteFile(filename);
}
示例5: testCovrRead
void testCovrRead()
{
MP4::File *f = new MP4::File("data/has-tags.m4a");
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
}
示例6:
void testCovrRead2()
{
MP4::File *f = new MP4::File(TEST_FILE_PATH_C("covr-junk.m4a"));
CPPUNIT_ASSERT(f->tag()->contains("covr"));
MP4::CoverArtList l = f->tag()->item("covr").toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
delete f;
}
示例7: testFreeForm
void testFreeForm()
{
ScopedFileCopy copy("has-tags", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("----:com.apple.iTunes:iTunNORM"));
f->tag()->itemListMap()["----:org.kde.TagLib:Foo"] = StringList("Bar");
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("----:org.kde.TagLib:Foo"));
CPPUNIT_ASSERT_EQUAL(String("Bar"), f->tag()->itemListMap()["----:org.kde.TagLib:Foo"].toStringList()[0]);
f->save();
delete f;
}
示例8: testUpdateStco
void testUpdateStco()
{
string filename = copyFile("no-tags", ".3g2");
MP4::File *f = new MP4::File(filename.c_str());
f->tag()->setArtist(ByteVector(3000, 'x'));
ByteVectorList data1;
{
MP4::Atoms a(f);
MP4::Atom *stco = a.find("moov")->findall("stco", true)[0];
f->seek(stco->offset + 12);
ByteVector data = f->readBlock(stco->length - 12);
unsigned int count = data.mid(0, 4).toUInt();
int pos = 4;
while (count--) {
unsigned int offset = data.mid(pos, 4).toUInt();
f->seek(offset);
data1.append(f->readBlock(20));
pos += 4;
}
}
f->save();
delete f;
f = new MP4::File(filename.c_str());
{
MP4::Atoms a(f);
MP4::Atom *stco = a.find("moov")->findall("stco", true)[0];
f->seek(stco->offset + 12);
ByteVector data = f->readBlock(stco->length - 12);
unsigned int count = data.mid(0, 4).toUInt();
int pos = 4, i = 0;
while (count--) {
unsigned int offset = data.mid(pos, 4).toUInt();
f->seek(offset);
CPPUNIT_ASSERT_EQUAL(data1[i], f->readBlock(20));
pos += 4;
i++;
}
}
delete f;
deleteFile(filename);
}
示例9: testSaveExisingWhenIlstIsLast
void testSaveExisingWhenIlstIsLast()
{
ScopedFileCopy copy("ilst-is-last", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
f->tag()->setComment("foo");
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
CPPUNIT_ASSERT_EQUAL(String("foo"), f->tag()->comment());
}
示例10: testGnre
void testGnre()
{
MP4::File *f = new MP4::File(TEST_FILE_PATH_C("gnre.m4a"));
CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
delete f;
}
示例11: testGnre
void testGnre()
{
MP4::File *f = new MP4::File("data/gnre.m4a");
CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
}