thumbnailer-1.1+14.04.20140401.1/ 0000755 0000153 0177776 00000000000 12316641155 016421 5 ustar pbuser nogroup 0000000 0000000 thumbnailer-1.1+14.04.20140401.1/tools/ 0000755 0000153 0177776 00000000000 12316641155 017561 5 ustar pbuser nogroup 0000000 0000000 thumbnailer-1.1+14.04.20140401.1/tools/scaler.cpp 0000644 0000153 0177776 00000002157 12316640575 021550 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
#include
int main(int argc, char **argv) {
ImageScaler sc;
try {
std::string ifilename(argv[1]);
std::string ofilename(argv[2]);
sc.scale(ifilename, ofilename, TN_SIZE_LARGE, ifilename);
} catch(std::runtime_error &e) {
printf("Failed: %s\n", e.what());
return 1;
}
return 0;
}
thumbnailer-1.1+14.04.20140401.1/tools/lastfmtest.cpp 0000644 0000153 0177776 00000001737 12316640575 022470 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
#include
using namespace std;
int main(int /*argc*/, char **/*argv*/) {
LastFMDownloader dl;
dl.download("The Prodigy", "Music for the Jilted Generation", "image.jpg");
return 0;
}
thumbnailer-1.1+14.04.20140401.1/tools/imdump.cpp 0000644 0000153 0177776 00000002057 12316640575 021571 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
#include
int main(int argc, char **argv) {
gst_init(&argc, &argv);
AudioImageExtractor ae;
try {
ae.extract(argv[1], argv[2]);
} catch(std::runtime_error &e) {
printf("Failed: %s\n", e.what());
return 1;
}
return 0;
}
thumbnailer-1.1+14.04.20140401.1/tools/CMakeLists.txt 0000644 0000153 0177776 00000000720 12316640575 022325 0 ustar pbuser nogroup 0000000 0000000 #add_executable(imdump imdump.cpp)
#target_link_libraries(imdump thumbnailer ${GST_DEPS_LDFLAGS})
add_executable(scaler scaler.cpp ../src/imagescaler.cpp)
target_link_libraries(scaler ${IMG_DEPS_LDFLAGS})
add_executable(cachetool cachetool.cpp)
target_link_libraries(cachetool thumbnailer)
add_executable(lastfmtest lastfmtest.cpp ../src/lastfmdownloader.cpp ../src/soupdownloader.cpp)
target_link_libraries(lastfmtest ${SOUP_DEPS_LDFLAGS} ${XML_DEPS_LDFLAGS})
thumbnailer-1.1+14.04.20140401.1/tools/cachetool.cpp 0000644 0000153 0177776 00000002276 12316640575 022242 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
#include
int main(int argc, char **argv) {
Thumbnailer t;
if(argc != 2) {
printf("%s \n", argv[0]);
return 1;
}
std::string ifilename(argv[1]);
std::string ofilename = t.get_thumbnail(ifilename, TN_SIZE_LARGE);
if(ofilename.empty())
printf("Thumbnail could not be generated.\n");
else
printf("Thumbnail file is %s.\n", ofilename.c_str());
return 0;
}
thumbnailer-1.1+14.04.20140401.1/cmake/ 0000755 0000153 0177776 00000000000 12316641155 017501 5 ustar pbuser nogroup 0000000 0000000 thumbnailer-1.1+14.04.20140401.1/cmake/coverage.cmake 0000644 0000153 0177776 00000003230 12316640575 022301 0 ustar pbuser nogroup 0000000 0000000 if (CMAKE_BUILD_TYPE MATCHES coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
if (NOT GCOVR_EXECUTABLE)
message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
else ()
message(STATUS "Gcovr found, can generate XML coverage info.")
add_custom_target (coverage-xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
--object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
endif()
find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
if (NOT LCOV_EXECUTABLE)
message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
else ()
if(NOT GENHTML_EXECUTABLE)
message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
else()
message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
add_custom_target (coverage-html
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
)
endif()
endif()
endif()
thumbnailer-1.1+14.04.20140401.1/tests/ 0000755 0000153 0177776 00000000000 12316641155 017563 5 ustar pbuser nogroup 0000000 0000000 thumbnailer-1.1+14.04.20140401.1/tests/unique_gobj.cpp 0000644 0000153 0177776 00000012135 12316640575 022605 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
using namespace std;
TEST(Unique_gobj, trivial) {
unique_gobj basic(gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480));
ASSERT_TRUE(bool(basic));
ASSERT_TRUE(gdk_pixbuf_get_width(basic.get()) == 640);
ASSERT_TRUE(gdk_pixbuf_get_height(basic.get()) == 480);
}
TEST(Unique_gobj, compare) {
GdkPixbuf *pb1 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
GdkPixbuf *pb2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
if(pb1 > pb2) {
std::swap(pb1, pb2);
}
ASSERT_TRUE(pb1 < pb2);
unique_gobj u1(pb1);
unique_gobj u2(pb2);
ASSERT_TRUE(!(u1 == nullptr));
ASSERT_TRUE(u1 != nullptr);
ASSERT_TRUE(u1 != u2);
ASSERT_TRUE(!(u1 == u2));
ASSERT_TRUE(u1 < u2);
ASSERT_TRUE(!(u2 < u1));
ASSERT_TRUE(!(u1 == u2));
ASSERT_TRUE(!(u2 == u1));
ASSERT_TRUE(u1 <= u2);
ASSERT_TRUE(!(u2 <= u1));
}
// This is its own thing due to need to avoid double release.
TEST(Unique_gobj, equality) {
GdkPixbuf *pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
unique_gobj u1(pb);
g_object_ref(G_OBJECT(pb));
unique_gobj u2(pb);
ASSERT_TRUE(u1 == u2);
ASSERT_TRUE(u2 == u1);
ASSERT_TRUE(!(u1 != u2));
ASSERT_TRUE(!(u2 != u1));
}
TEST(Unique_gobj, release) {
GdkPixbuf *pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
unique_gobj u(pb);
ASSERT_TRUE(u != nullptr);
ASSERT_TRUE(u.get() != nullptr);
ASSERT_TRUE(pb == u.release());
ASSERT_TRUE(!u);
ASSERT_TRUE(u.get() == nullptr);
g_object_unref(pb);
}
void sub_func(GdkPixbuf *pb) {
ASSERT_TRUE(G_OBJECT(pb)->ref_count == 2);
unique_gobj u(pb);
ASSERT_TRUE(G_OBJECT(pb)->ref_count == 2);
// Now it dies and refcount is reduced.
}
TEST(Unique_gobj, refcount) {
GdkPixbuf *pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
ASSERT_TRUE(G_OBJECT(pb)->ref_count == 1);
g_object_ref(G_OBJECT(pb));
sub_func(pb);
ASSERT_TRUE(G_OBJECT(pb)->ref_count == 1);
g_object_unref(G_OBJECT(pb));
}
TEST(Unique_gobj, swap) {
GdkPixbuf *pb1 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
GdkPixbuf *pb2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
unique_gobj u1(pb1);
unique_gobj u2(pb2);
u1.swap(u2);
ASSERT_TRUE(u1.get() == pb2);
ASSERT_TRUE(u2.get() == pb1);
std::swap(u1, u2);
ASSERT_TRUE(u1.get() == pb1);
ASSERT_TRUE(u2.get() == pb2);
}
TEST(Unique_gobj, floating) {
GdkPixbuf *pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
bool got_exception = false;
g_object_force_floating(G_OBJECT(pb));
try {
unique_gobj u(pb);
} catch(const invalid_argument &c) {
got_exception = true;
}
g_object_unref(G_OBJECT(pb));
ASSERT_TRUE(got_exception);
}
TEST(Unique_gobj, move) {
GdkPixbuf *pb1 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
GdkPixbuf *pb2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
g_object_ref(G_OBJECT(pb1));
unique_gobj u1(pb1);
unique_gobj u2(pb2);
u1 = std::move(u2);
ASSERT_TRUE(u1.get() == pb2);
ASSERT_TRUE(!u2);
ASSERT_TRUE(G_OBJECT(pb1)->ref_count == 1);
g_object_unref(G_OBJECT(pb1));
}
TEST(Unique_gobj, null) {
GdkPixbuf *pb1 = NULL;
GdkPixbuf *pb3 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
unique_gobj u1(pb1);
unique_gobj u2(nullptr);
unique_gobj u3(pb3);
ASSERT_TRUE(!u1);
ASSERT_TRUE(!u2);
u3 = nullptr;
ASSERT_TRUE(!u3);
}
TEST(Unique_gobj, reset) {
GdkPixbuf *pb1 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
GdkPixbuf *pb2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 640, 480);
unique_gobj u(pb1);
u.reset(pb2);
ASSERT_TRUE(u.get() == pb2);
u.reset(nullptr);
ASSERT_TRUE(!u);
}
TEST(Unique_gobj, sizeoftest) {
ASSERT_TRUE(sizeof(GdkPixbuf*) == sizeof(unique_gobj));
}
TEST(Unique_gobj, deleter) {
unique_gobj u1;
ASSERT_TRUE(u1.get_deleter() == g_object_unref);
}
int main(int argc, char **argv) {
g_type_init(); // Still needed in precise.
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
thumbnailer-1.1+14.04.20140401.1/tests/testsetup.h.in 0000644 0000153 0177776 00000000125 12316640575 022404 0 ustar pbuser nogroup 0000000 0000000 #ifndef TESTSETUP_H
#define TESTSETUP_H
#define TESTDATADIR "@TESTDATADIR@"
#endif
thumbnailer-1.1+14.04.20140401.1/tests/mediaartcachetest.cpp 0000644 0000153 0177776 00000010254 12316640575 023750 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013-2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Jussi Pakkanen
*/
#include
#include
#include
#include
#include
#include
#include "../include/internal/mediaartcache.h"
using namespace std;
namespace mediascanner {
TEST(MediaArtCacheTest, BasicFunctionality) {
MediaArtCache mac;
mac.clear();
string artist = "Some Guy";
string album = "Muzak";
const int datasize = 3;
char data[datasize] = {'a', 'b', 'c'};
char indata[datasize];
FILE *f;
ASSERT_FALSE(mac.has_art(artist, album));
mac.add_art(artist, album, data, datasize);
ASSERT_TRUE(mac.has_art(artist, album));
f = fopen(mac.get_art_file(artist, album).c_str(), "r");
ASSERT_TRUE(f);
ASSERT_EQ(fread(indata, 1, datasize, f), datasize);
fclose(f);
ASSERT_EQ(memcmp(indata, data, datasize), 0);
mac.clear();
assert(!mac.has_art(artist, album));
}
TEST(MediaArtCacheTest, Swapped) {
string artist1("foo");
string album1("bar");
string artist2(album1);
string album2(artist1);
const int datasize = 4;
char data1[datasize] = {'a', 'b', 'c', 'd'};
char data2[datasize] = {'d', 'c', 'b', 'e'};
char indata[datasize];
MediaArtCache mac;
FILE *f;
mac.clear();
ASSERT_FALSE(mac.has_art(artist1, album1));
ASSERT_FALSE(mac.has_art(artist2, album2));
mac.add_art(artist1, album1, data1, datasize);
ASSERT_TRUE(mac.has_art(artist1, album1));
ASSERT_FALSE(mac.has_art(artist2, album2));
mac.clear();
mac.add_art(artist2, album2, data2, datasize);
ASSERT_FALSE(mac.has_art(artist1, album1));
ASSERT_TRUE(mac.has_art(artist2, album2));
mac.add_art(artist1, album1, data1, datasize);
f = fopen(mac.get_art_file(artist1, album1).c_str(), "r");
ASSERT_TRUE(f);
ASSERT_EQ(fread(indata, 1, datasize, f), datasize);
fclose(f);
ASSERT_EQ(memcmp(indata, data1, datasize), 0);
f = fopen(mac.get_art_file(artist2, album2).c_str(), "r");
ASSERT_TRUE(f);
ASSERT_EQ(fread(indata, 1, datasize, f), datasize);
fclose(f);
ASSERT_EQ(memcmp(indata, data2, datasize), 0);
}
static int count_files(const string &dir) {
DIR *d = opendir(dir.c_str());
int count = 0;
if(!d) {
string s = "Something went wrong.";
throw s;
}
struct dirent *entry, *de;
entry = (dirent*)malloc(sizeof(dirent) + NAME_MAX);
while(readdir_r(d, entry, &de) == 0 && de) {
string basename = entry->d_name;
if (basename == "." || basename == "..")
continue;
count++;
}
closedir(d);
free(entry);
return count;
}
TEST(MediaArtCacheTest, Prune) {
MediaArtCache mac;
mac.clear();
const int max_files = MediaArtCache::MAX_SIZE;
string cache_dir = mac.get_cache_dir();
char arr[] = {'a', 'b', 'c'};
ASSERT_EQ(count_files(cache_dir), 0);
for(int i=0; i