diff options
Diffstat (limited to 'libs/fsScan/src')
-rw-r--r-- | libs/fsScan/src/AbstractMedia.cc | 17 | ||||
-rw-r--r-- | libs/fsScan/src/AbstractMultiFileMovie.cc | 12 | ||||
-rw-r--r-- | libs/fsScan/src/Audio.cc | 19 | ||||
-rw-r--r-- | libs/fsScan/src/DVDImage.cc | 12 | ||||
-rw-r--r-- | libs/fsScan/src/FSMediaScanner.cc (renamed from libs/fsScan/src/FilesystemScanner.cc) | 26 | ||||
-rw-r--r-- | libs/fsScan/src/File.cc | 181 | ||||
-rw-r--r-- | libs/fsScan/src/FileRepresentation.cc | 132 | ||||
-rw-r--r-- | libs/fsScan/src/FileSystem.cc | 132 | ||||
-rw-r--r-- | libs/fsScan/src/LegacyVdrRecording.cc | 12 | ||||
-rw-r--r-- | libs/fsScan/src/MediaFactory.cc | 40 | ||||
-rw-r--r-- | libs/fsScan/src/Movie.cc | 18 | ||||
-rw-r--r-- | libs/fsScan/src/Picture.cc | 12 | ||||
-rw-r--r-- | libs/fsScan/src/VdrRecording.cc | 12 |
13 files changed, 106 insertions, 519 deletions
diff --git a/libs/fsScan/src/AbstractMedia.cc b/libs/fsScan/src/AbstractMedia.cc index 27ad751..924f01a 100644 --- a/libs/fsScan/src/AbstractMedia.cc +++ b/libs/fsScan/src/AbstractMedia.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMedia.cc * Created: 2. Juli 2012, 14 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <AbstractMedia.h> @@ -112,6 +112,11 @@ const char *cAbstractMedia::MediaType2Text(int Type) } } +bool cAbstractMedia::NeedsFurtherScan(void) const +{ + return false; +} + const char *cAbstractMedia::AbsolutePath(void) const { return keyPath.AbsolutePath(); diff --git a/libs/fsScan/src/AbstractMultiFileMovie.cc b/libs/fsScan/src/AbstractMultiFileMovie.cc index d20da87..f679511 100644 --- a/libs/fsScan/src/AbstractMultiFileMovie.cc +++ b/libs/fsScan/src/AbstractMultiFileMovie.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMultiFileMovie.cc * Created: 3. Juli 2012, 07 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <AbstractMultiFileMovie.h> diff --git a/libs/fsScan/src/Audio.cc b/libs/fsScan/src/Audio.cc index 8933c36..6c90fbc 100644 --- a/libs/fsScan/src/Audio.cc +++ b/libs/fsScan/src/Audio.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Audio.cc * Created: 2. Juli 2012, 15 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <Audio.h> @@ -40,7 +40,7 @@ SupportedExtension cAudio::knownExtensions[] = { { "mp3", "audio/mpeg" }, { "mp4", "audio/x-mpeg4" }, { "m4a", "audio/x-m4" }, - { "mpg", "audio/mpeg" }, +// { "mpg", "audio/mpeg" }, { "mpp", "audio/x-musepack" }, { "ram", "audio/x-realaudio" }, { NULL, NULL } @@ -63,3 +63,8 @@ const char *cAudio::ContentType(const char* Extension) return NULL; } +bool cAudio::NeedsFurtherScan(void) const +{ +//TODO: common meta data: artist, title + return true; +} diff --git a/libs/fsScan/src/DVDImage.cc b/libs/fsScan/src/DVDImage.cc index 8c789b4..0d23ae1 100644 --- a/libs/fsScan/src/DVDImage.cc +++ b/libs/fsScan/src/DVDImage.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: DVDImage.cc * Created: 3. Juli 2012, 08 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <DVDImage.h> diff --git a/libs/fsScan/src/FilesystemScanner.cc b/libs/fsScan/src/FSMediaScanner.cc index cbe4b95..f4ac14e 100644 --- a/libs/fsScan/src/FilesystemScanner.cc +++ b/libs/fsScan/src/FSMediaScanner.cc @@ -1,28 +1,28 @@ /** * ======================== legal notice ====================== - * - * File: FilesystemScanner.cc + * + * File: FSMediaScanner.cc * Created: 2. Juli 2012, 13 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ -#include <FilesystemScanner.h> +#include <FSMediaScanner.h> #include <AbstractMedia.h> #include <Logging.h> #include <stddef.h> @@ -40,20 +40,20 @@ void freeMediaCallback(void *elem) delete (cAbstractMedia *)elem; } -cFilesystemScanner::cFilesystemScanner() +cFSMediaScanner::cFSMediaScanner() : fileBufSize(512) , pool(freeMediaCallback) , mediaFactory(NULL) { } -cFilesystemScanner::~cFilesystemScanner() +cFSMediaScanner::~cFSMediaScanner() { pool.clear(); if (mediaFactory) delete mediaFactory; } -void cFilesystemScanner::SetMediaFactory(cMediaFactory* factory) +void cFSMediaScanner::SetMediaFactory(cMediaFactory* factory) { mediaFactory = factory; } @@ -76,7 +76,7 @@ bool defaultMediaSortOrder(void *a, void *b) return rv; } -void cFilesystemScanner::Refresh() +void cFSMediaScanner::Refresh() { if (!mediaFactory) return; pool.clear(); @@ -96,7 +96,7 @@ void cFilesystemScanner::Refresh() } } -cAbstractMedia *cFilesystemScanner::FindMedia(const char *Path) +cAbstractMedia *cFSMediaScanner::FindMedia(const char *Path) { cAbstractMedia *rv = NULL, *tmp; diff --git a/libs/fsScan/src/File.cc b/libs/fsScan/src/File.cc deleted file mode 100644 index 477c5c8..0000000 --- a/libs/fsScan/src/File.cc +++ /dev/null @@ -1,181 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: File.cc - * Created: 21. Juli 2012, 12 - * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include <File.h> -#include <FileSystem.h> -#include <FileRepresentation.h> -#include <StringBuilder.h> -#include <sys/stat.h> -#include <sys/dir.h> - -cFileSystem *cFile::fs = NULL; -static mode_t ReadMask = S_IRUSR | S_IRGRP | S_IROTH; -static mode_t WriteMask = S_IWUSR | S_IWGRP | S_IWOTH; -static mode_t ExecMask = S_IXUSR | S_IXGRP | S_IXOTH; - - -cFile::cFile(const char *Path) - : rep(NULL) -{ - if (!fs) fs = new cFileSystem(); - if (!Path) { - Path = getcwd(NULL, 0); - rep = fs->representationOfFile(Path); - free((char *) Path); - } - else rep = fs->representationOfFile(Path); -} - -cFile::cFile(const cFile &other) - : rep(other.rep) -{ - if (!fs) fs = new cFileSystem(); -} - -cFile::cFile(const cFile& Parent, const char* RelativePath) - : rep(NULL) -{ - if (!fs) fs = new cFileSystem(); - rep = fs->representationOfFile(Parent, RelativePath); -} - -cFile::cFile(const cFileRepresentation *fr) - : rep(fr) -{ - if (!fs) fs = new cFileSystem(); -} - -cFile::~cFile() -{ -} - -cFile &cFile::operator =(const cFile &other) -{ - rep = other.rep; - return *this; -} - -const char *cFile::AbsolutePath(void) const -{ - if (rep) return rep->Path(); - return NULL; -} - -bool cFile::Exists(void) const -{ - if (rep) return rep->exists; - return false; -} - -bool cFile::IsDirectory(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFDIR; - return false; -} - -bool cFile::IsFile(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFREG; - return false; -} - -bool cFile::IsSymbolic(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFLNK; - return false; -} - -bool cFile::CanRead(void) const -{ - if (rep) return rep->mode & ReadMask; - return false; -} - -bool cFile::CanWrite(void) const -{ - if (rep) return rep->mode & WriteMask; - return false; -} - -bool cFile::CanExecute(void) const -{ - if (rep) return rep->mode & ExecMask; - return false; -} - -off64_t cFile::Size(void) const -{ - if (rep) return rep->size; - return 0; -} - -ulong cFile::LastModified(void) const -{ - if (rep) return rep->lastModified; - return 0; -} - -cFile *cFile::Parent(void) const -{ - if (rep) return new cFile(rep->getParent()); - return NULL; -} - -const char *cFile::Name(void) const -{ - if (rep) return rep->name; - return NULL; -} - -void cFile::Cleanup(void) -{ - if (fs) { - delete fs; - fs = NULL; - } -} - -void cFile::VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque) -{ - if (!Exists() || !IsDirectory()) return; - struct dirent entryBuffer, *pE; - DIR *dir = opendir(AbsolutePath()); - - while (!readdir_r(dir, &entryBuffer, &pE) && pE) { - if (*(pE->d_name) == '.') continue; // don't bother with hidden stuff - cb(opaque, this, pE->d_name); - } - closedir(dir); -} - -char *cFile::toURI() const -{ - if (rep) return rep->toURI(); - return NULL; -} - -void cFile::SetVirtualRoot(bool isRoot) -{ - if (rep) ((cFileRepresentation *)rep)->SetVirtualRoot(isRoot); -} diff --git a/libs/fsScan/src/FileRepresentation.cc b/libs/fsScan/src/FileRepresentation.cc deleted file mode 100644 index 81599a3..0000000 --- a/libs/fsScan/src/FileRepresentation.cc +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileRepresentation.cc - * Created: 21. Juli 2012, 12 - * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include <FileRepresentation.h> -#include <FileSystem.h> -#include <StringBuilder.h> -#include <Url.h> -#include <Codec.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> -#include <stdlib.h> -#include <iostream> -#include <stack> - -cFileRepresentation::cFileRepresentation(const char *Name) - : exists(false) - , isRoot(true) - , isVirtualRoot(true) - , mode(0) - , size(0) - , lastModified(0) - , name(NULL) - , path(NULL) - , parent(NULL) -{ - struct stat st; - - if (!stat(Name, &st)) { - name = strdup(Name); - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::cFileRepresentation(const cFileRepresentation *Parent, const char *Name) - : exists(false) - , isRoot(false) - , isVirtualRoot(false) - , mode(0) - , size(0) - , lastModified(0) - , name(strdup(Name)) - , path(NULL) - , parent(Parent) -{ - struct stat st; - - if (!stat(Path(), &st)) { - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::~cFileRepresentation() -{ - free(name); - free(path); -} - -const char *cFileRepresentation::Path() const -{ - if (!path) { - cStringBuilder sb; - - if (parent) sb.Append(parent->Path()); - sb.Append(cFileSystem::PathSeparator).Append(name); - path = sb.toString(); - } - return path; -} - -void cFileRepresentation::SetVirtualRoot(bool isRoot) -{ - isVirtualRoot = isRoot; -} - -char *cFileRepresentation::toURI() const -{ - cStringBuilder *sb = new cStringBuilder(); - const cFileRepresentation *f = this; - std::stack<const cFileRepresentation *> rev; - cURLEncoder *enc = cUrl::Encoder(); - char *tmp, *chk, *rv; - size_t stackSize; - - while (!f->isVirtualRoot) { - rev.push(f); - stackSize = rev.size(); - f = f->parent; - } - - for (;;) { - f = rev.top(); - rev.pop(); - chk = f->name + strlen(f->name) - 1; - if (*chk != cFileSystem::PathSeparator) sb->Append(cFileSystem::PathSeparator); - tmp = enc->Encode(f->name); - sb->Append(tmp); - free(tmp); - if (rev.empty()) break; - } - rv = sb->toString(); - delete sb; - - return rv; -} diff --git a/libs/fsScan/src/FileSystem.cc b/libs/fsScan/src/FileSystem.cc deleted file mode 100644 index 3891c97..0000000 --- a/libs/fsScan/src/FileSystem.cc +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileSystem.cc - * Created: 21. Juli 2012, 12 - * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include <FileSystem.h> -#include <FileRepresentation.h> -#include <File.h> -#include <StringBuilder.h> -#include <iostream> -#include <stdlib.h> -#include <string.h> - -char cFileSystem::PathSeparator = '/'; -char cFileSystem::RootPath[4] = { PathSeparator, 0, 0, 0 }; - -cFileSystem::cFileSystem() -{ -} - -cFileSystem::~cFileSystem() -{ - std::tr1::unordered_map<std::string, cFileRepresentation *>::iterator it = fileCache.begin(); - - while (it != fileCache.end()) { - if (it->second) delete it->second; - ++it; - } -} - -cFileRepresentation *cFileSystem::cacheEntry(const char* Path) -{ - if (fileCache.empty()) return NULL; - std::tr1::unordered_map<std::string, cFileRepresentation *>::iterator it = fileCache.find(Path); - - if (it != fileCache.end()) return it->second; - return NULL; -} - -cFileRepresentation *cFileSystem::representationOfFile(const cFile &Parent, const char* Path) -{ - cFileRepresentation *parentRep = (cFileRepresentation *) Parent.rep; - cFileRepresentation *tmp = NULL; - cStringBuilder *sb = new cStringBuilder(Parent.AbsolutePath()); - char *scratch = strdup(Path); - char *last = scratch + strlen(Path); - char *start = *scratch == PathSeparator ? scratch + 1 : scratch; - char *end = strchr(scratch, PathSeparator); - char *path; - - while (start < last) { - end = strchr(start, PathSeparator); - if (!end) end = start + strlen(start); - *end = 0; - sb->Append(PathSeparator).Append(start); - path = sb->toString(); - tmp = cacheEntry(path); - if (!tmp) { - tmp = new cFileRepresentation(parentRep, start); - fileCache[path] = tmp; - } - parentRep = tmp; - free(path); - start = end + 1; - } - free(scratch); - delete sb; - - if (tmp) return tmp; - return NULL; -} - -cFileRepresentation *cFileSystem::representationOfFile(const char* Path) -{ - cFileRepresentation *rv = cacheEntry(Path); - - if (!rv) { - cFileRepresentation *tmp = NULL; - char *scratch = strdup(Path); - char *p; - - for (p = strrchr(scratch, PathSeparator); !rv && p; p = strrchr(scratch, PathSeparator)) { - if (p > scratch) *p = 0; - else { - if (!(rv = cacheEntry(RootPath))) { - *p = 0; - tmp = new cFileRepresentation(RootPath); - fileCache[RootPath] = tmp; - break; - } - } - if ((tmp = cacheEntry(scratch))) break; - } - - if (tmp) { - cFileRepresentation *parent = tmp; - size_t poolSize = fileCache.size(); - const char *last = scratch + strlen(Path); - - for (p = scratch + strlen(scratch) + 1; p < last; p += strlen(p) + 1) { - if (!*(p - 1)) *(p - 1) = PathSeparator; - tmp = new cFileRepresentation(parent, p); - fileCache[scratch] = tmp; - poolSize = fileCache.size(); - parent = tmp; - } - rv = parent; - } - free(scratch); - } - return rv; -} - diff --git a/libs/fsScan/src/LegacyVdrRecording.cc b/libs/fsScan/src/LegacyVdrRecording.cc index 731d0f3..5ee635c 100644 --- a/libs/fsScan/src/LegacyVdrRecording.cc +++ b/libs/fsScan/src/LegacyVdrRecording.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: LegacyVdrRecording.cc * Created: 3. Juli 2012, 08 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <LegacyVdrRecording.h> diff --git a/libs/fsScan/src/MediaFactory.cc b/libs/fsScan/src/MediaFactory.cc index 22b9044..4dec763 100644 --- a/libs/fsScan/src/MediaFactory.cc +++ b/libs/fsScan/src/MediaFactory.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: MediaFactory.cc * Created: 2. Juli 2012, 15 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <MediaFactory.h> @@ -29,6 +29,7 @@ #include <LegacyVdrRecording.h> #include <VdrRecording.h> #include <DVDImage.h> +#include <ServerConfig.h> #include <StringBuilder.h> #include <Logging.h> #include <File.h> @@ -36,8 +37,9 @@ #include <stdlib.h> #include <string.h> -cMediaFactory::cMediaFactory(const cFile &BaseDirectory) - : baseDirectory(BaseDirectory) +cMediaFactory::cMediaFactory(const cServerConfig &sc) + : config(sc) + , baseDirectory(sc.DocumentRoot()) , scratch(NULL) , scratchSize(1024) { @@ -61,7 +63,14 @@ void cMediaFactory::SetBaseDirectory(const cFile &dir) int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) { if (!opaque) return -1; - cManagedVector *pool = (cManagedVector *) opaque; + cMediaFactory *mf = (cMediaFactory *) opaque; + + return mf->CreateMedia(Parent, Name); +} + +int cMediaFactory::CreateMedia(const cFile *Parent, const char *Name) +{ +// cManagedVector *pool = (cManagedVector *) opaque; cFile *curFile = new cFile(*Parent, Name); const char *mimeType = NULL; cAbstractMedia *rv = NULL; @@ -93,7 +102,7 @@ int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) } delete tmp; } - if (!rv) curFile->VisitFiles(createMedia, opaque); + if (!rv) curFile->VisitFiles(createMedia, this); } else { const char *extension = strrchr(Name, '.'); @@ -117,7 +126,8 @@ int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) } delete curFile; if (rv) { - pool->push_back(rv); + if (config.WantExtendedScan() && rv->NeedsFurtherScan()) Scan4MetaData(rv); + mediaPool->push_back(rv); return 0; } return -1; @@ -128,5 +138,11 @@ void cMediaFactory::Scan4Media(cManagedVector& pool) if (!baseDirectory.Exists() || !baseDirectory.IsDirectory()) return; baseDirectory.SetVirtualRoot(); - baseDirectory.VisitFiles(createMedia, &pool); + mediaPool = &pool; + baseDirectory.VisitFiles(createMedia, this); +} + +void cMediaFactory::Scan4MetaData(cAbstractMedia* media) +{ + //TODO: } diff --git a/libs/fsScan/src/Movie.cc b/libs/fsScan/src/Movie.cc index 759ff3d..a63ff19 100644 --- a/libs/fsScan/src/Movie.cc +++ b/libs/fsScan/src/Movie.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Movie.cc * Created: 2. Juli 2012, 15 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <Movie.h> @@ -37,6 +37,7 @@ SupportedExtension cMovie::knownExtensions[] = { { "ogv", "video/ogg" }, { "mkv", "video/x-matroska" }, { "mov", "video/quicktime" }, + { "mpg", "video/mpeg" }, { "mpeg", "video/mpeg" }, { "swf", "application/x-shockwave-flash" }, { NULL, NULL } @@ -59,3 +60,8 @@ const char *cMovie::ContentType(const char* Extension) return NULL; } +bool cMovie::NeedsFurtherScan(void) const +{ +//TODO: common meta data: width, height, interlaced + return true; +} diff --git a/libs/fsScan/src/Picture.cc b/libs/fsScan/src/Picture.cc index 566c44c..19a02a1 100644 --- a/libs/fsScan/src/Picture.cc +++ b/libs/fsScan/src/Picture.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Picture.cc * Created: 2. Juli 2012, 15 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <Picture.h> diff --git a/libs/fsScan/src/VdrRecording.cc b/libs/fsScan/src/VdrRecording.cc index 4fb61fa..03abccf 100644 --- a/libs/fsScan/src/VdrRecording.cc +++ b/libs/fsScan/src/VdrRecording.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: VdrRecording.cc * Created: 3. Juli 2012, 08 * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include <VdrRecording.h> |