diff options
| author | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-10-14 19:17:01 +0000 |
|---|---|---|
| committer | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-10-14 19:17:01 +0000 |
| commit | 3bd78c6d82eb92eb76f6a4acde6a7e411356b127 (patch) | |
| tree | 58089be0031b2bc1dd0ceb7cc22aea8f3e67aec9 | |
| parent | a9aae4109f4cfaf333c1c9b9f1379d7deb1fc583 (diff) | |
| download | vdr-plugin-muggle-3bd78c6d82eb92eb76f6a4acde6a7e411356b127.tar.gz vdr-plugin-muggle-3bd78c6d82eb92eb76f6a4acde6a7e411356b127.tar.bz2 | |
Fixed few bugs and added initial GD coverart code.
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@888 e10066b5-e1e2-0310-b819-94efdf66514b
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | mg_image_provider.c | 69 | ||||
| -rw-r--r-- | mg_image_provider.h | 4 | ||||
| -rw-r--r-- | mg_item_gd.c | 61 | ||||
| -rw-r--r-- | mg_tools.c | 2 | ||||
| -rw-r--r-- | vdr_setup.c | 13 |
6 files changed, 78 insertions, 81 deletions
@@ -14,13 +14,13 @@ PLUGIN = muggle #if you want ogg / flac support, define HAVE_VORBISFILE and/or HAVE_FLAC #in $VDRDIR/Make.config like this: -#HAVE_VORBISFILE=1 -#HAVE_FLAC=1 -#HAVE_SNDFILE=1 +HAVE_VORBISFILE=1 +HAVE_FLAC=1 +HAVE_SNDFILE=1 #if you do not want to compile in code for embedded mysql, #define this: -#HAVE_ONLY_SERVER=1 +HAVE_ONLY_SERVER=1 #define what database you want to use. Default is mysql. HAVE_SQLITE #removes mysql support and adds SQLite support @@ -35,7 +35,7 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ pri ### The C++ compiler and options: CXX ?= g++-3.3 -CXXFLAGS ?= -fPIC -O0 -Wall -Woverloaded-virtual -Wno-deprecated -g +CXXFLAGS ?= -fPIC -O0 -Wall -Woverloaded-virtual -Wno-deprecated -g ### The directory environment: diff --git a/mg_image_provider.c b/mg_image_provider.c index c2500e7..2a94c89 100644 --- a/mg_image_provider.c +++ b/mg_image_provider.c @@ -16,6 +16,8 @@ #include <dirent.h> #include <libgen.h> #include <sys/types.h> +#include <unistd.h> +#include <fts.h> using namespace std; @@ -129,6 +131,48 @@ mgImageProvider* mgImageProvider::Create( ) return new mgImageProvider(); } +bool mgImageProvider::extractImagesFromDatabase( mgItemGd *item ) +{ + /* GD entry looks like: img0x00004810-00.jpg + and may reside in $ToplevelDir/[0-9]{2}/ + + Then, all img0x00004810-??.jpg are possible matches, but not + files such as img0x00004810-00-s200.jpg which are optimized + for a different resoluition. + + Thanks to viking (from vdrportal.de) for help with this + */ + string file = item->getImagePath(); + bool result = false; + + FTS *fts; + FTSENT *ftsent; + + char *dir[2]; + dir[0] = the_setup.ToplevelDir; + dir[1] = NULL; + + fts = fts_open( dir, FTS_LOGICAL, 0); + if (fts) + { + while( (ftsent = fts_read(fts)) != NULL ) + { + if( ftsent->fts_info & FTS_F ) + { + if( !strcmp( ftsent->fts_name, file.c_str() ) ) + { + cout << "Found image:" << ftsent->fts_path << endl; + m_image_list.push_back( ftsent->fts_path ); + + result = true; + } + } + } + fts_close(fts); + } + return result; +} + void mgImageProvider::updateFromItemDirectory( mgItemGd *item ) { // no images in tags, find images in the directory of the file itself @@ -164,17 +208,24 @@ bool mgImageProvider::updateItem( mgItemGd *item ) { // do not try to acquire new images when we are playing back a separate directory deleteTemporaryImages(); - // check whether the item has cover images in tags? - string dir = extractImagesFromTag( filename ); + // check whether the item has cover images defined in the database ? + bool has_db_images = extractImagesFromDatabase( item ); - if( dir == "" ) + if( !has_db_images ) { - updateFromItemDirectory( item ); - } - else - { - fillImageList( dir ); - } + // no. check whether the item has cover images defined in tags ? + string dir = extractImagesFromTag( filename ); + + if( dir == "" ) + { + // no. use anything from the directory + updateFromItemDirectory( item ); + } + else + { + fillImageList( dir ); + } + } // start a thread to convert all images in 'dir' into .mpg format in the background Start(); diff --git a/mg_image_provider.h b/mg_image_provider.h index be6893a..c1e834b 100644 --- a/mg_image_provider.h +++ b/mg_image_provider.h @@ -54,6 +54,10 @@ class mgImageProvider : public cThread */ void fillImageList( std::string dir ); + /*! \brief update images according to GD scheme from database entry + */ + bool extractImagesFromDatabase( mgItemGd *item ); + /*! \brief find images for an item */ void updateFromItemDirectory( mgItemGd *item ); diff --git a/mg_item_gd.c b/mg_item_gd.c index f89044d..4244447 100644 --- a/mg_item_gd.c +++ b/mg_item_gd.c @@ -221,66 +221,7 @@ mgItemGd::getSourceFile(bool AbsolutePath,bool Silent) const string mgItemGd::getImagePath(bool AbsolutePath) const { - string result; - if (AbsolutePath) - { - result = getImagePath(false); - if (!result.empty()) - result = string(the_setup.ToplevelDir) + result; - return result; - } - if (!m_coverimg.empty()) - { - result = m_coverimg; - if (!readable(result)) - { - analyze_failure(result); - m_coverimg=""; - } - else - return result; - } - result = getSourceFile(false,true); - const char* jpg = ".jpg"; - string::size_type dot = result.rfind('.'); - if (dot==string::npos) - result += jpg; - else - result.replace(dot,999,jpg); - if (readable(result)) - return result; -#ifdef DIAS - while (true) - { - m_covercount++; - result = getSourceFile(false,true); - dot = result.rfind('.'); - if (dot==string::npos) - result += '.' + m_covercount + jpg; - else - result.replace(dot,999,'.' + m_covercount + jpg); - if (readable(result)) - return result; - if (m_covercount == 1) - break; - m_covercount = 0; - } -#endif - result = getSourceFile(false,true); - while (true) - { - string::size_type slash = result.rfind('/'); - if (slash == string::npos) - { - if (readable("cover.jpg")) - return "cover.jpg"; - break; - } - result.replace(slash,999,""); - if (readable(result+"/cover.jpg")) - return result+"/cover.jpg"; - } - return ""; + return m_coverimg; } mgItemGd::mgItemGd (char **row) @@ -183,7 +183,7 @@ bool samedir( const char *d1, const char *d2 ) #ifdef PATH_MAX path_max = PATH_MAX; #else - path_max = pathconf (path, _PC_PATH_MAX); + path_max = pathconf ( "/", _PC_PATH_MAX ); if (path_max <= 0) { path_max = 4096; diff --git a/vdr_setup.c b/vdr_setup.c index be39bb9..4608eaa 100644 --- a/vdr_setup.c +++ b/vdr_setup.c @@ -36,22 +36,23 @@ mgMenuSetup::mgMenuSetup () // Audio stuff Add (new cMenuEditBoolItem (tr ("Initial loop mode"),&the_setup.InitLoopMode, - tr("on"), tr("off") ) ); + tr("off"), tr("on") ) ); Add (new cMenuEditBoolItem (tr ("Initial shuffle mode"), &the_setup.InitShuffleMode, - tr("on"), tr("off") ) ); + tr("off"), tr("on") ) ); Add (new cMenuEditBoolItem (tr ("Audio mode"), &the_setup.AudioMode, - tr ("Round"), tr ("Dither"))); + tr ("Dither"), tr ("Round"))); Add (new cMenuEditBoolItem (tr ("Use 48kHz mode only"), &the_setup.Only48kHz, - tr("yes"), tr("no") ) ); + tr("no"), tr("yes") ) ); Add (new cMenuEditIntItem (tr ("Normalizer level"), &the_setup.TargetLevel, 0, MAX_TARGET_LEVEL)); + Add (new cMenuEditIntItem (tr ("Limiter level"), &the_setup.LimiterLevel, MIN_LIMITER_LEVEL, 100)); @@ -71,12 +72,12 @@ mgMenuSetup::mgMenuSetup () the_setup.ImageCacheDir, MAX_PATH, chars_allowed ) ); Add (new cMenuEditBoolItem (tr ("Use DVB still picture"), &the_setup.UseDeviceStillPicture, - tr("yes"), tr("no") ) ); + tr("no"), tr("yes") ) ); // Synchronization Add (new cMenuEditBoolItem (tr ("Delete stale references"), &the_setup.DeleteStaleReferences, - tr("yes"), tr("no") )); + tr("no"), tr("yes") )); mgAction *a = actGenerate(actSync); const char *mn = a->MenuName(); |
