From 2d48ae784ea6828e8626c32c848f64232d8f35c0 Mon Sep 17 00:00:00 2001 From: geronimo Date: Fri, 13 Jul 2012 04:26:40 +0200 Subject: initial import --- libs/fsScan/.dep.inc | 5 + libs/fsScan/Makefile | 128 ++++++++++++++++ libs/fsScan/fsScan.cbp | 73 +++++++++ libs/fsScan/fsScan.depend | 1 + libs/fsScan/fsScan.layout | 14 ++ libs/fsScan/fsScan.layout.save | 14 ++ libs/fsScan/include/AbstractMedia.h | 84 +++++++++++ libs/fsScan/include/AbstractMultiFileMovie.h | 48 ++++++ libs/fsScan/include/Audio.h | 43 ++++++ libs/fsScan/include/DVDImage.h | 45 ++++++ libs/fsScan/include/FilesystemScanner.h | 59 ++++++++ libs/fsScan/include/LegacyVdrRecording.h | 42 ++++++ libs/fsScan/include/MediaFactory.h | 49 ++++++ libs/fsScan/include/Movie.h | 43 ++++++ libs/fsScan/include/Picture.h | 43 ++++++ libs/fsScan/include/VdrRecording.h | 42 ++++++ libs/fsScan/nbproject/Makefile-Debug.mk | 139 +++++++++++++++++ libs/fsScan/nbproject/Makefile-Release.mk | 139 +++++++++++++++++ libs/fsScan/nbproject/Makefile-impl.mk | 133 +++++++++++++++++ libs/fsScan/nbproject/Makefile-variables.mk | 35 +++++ libs/fsScan/nbproject/Package-Debug.bash | 75 ++++++++++ libs/fsScan/nbproject/Package-Release.bash | 75 ++++++++++ libs/fsScan/nbproject/configurations.xml | 97 ++++++++++++ .../fsScan/nbproject/private/Makefile-variables.mk | 7 + libs/fsScan/nbproject/private/configurations.xml | 72 +++++++++ libs/fsScan/nbproject/private/private.xml | 8 + libs/fsScan/nbproject/project.xml | 25 ++++ libs/fsScan/src/AbstractMedia.cc | 92 ++++++++++++ libs/fsScan/src/AbstractMultiFileMovie.cc | 111 ++++++++++++++ libs/fsScan/src/Audio.cc | 65 ++++++++ libs/fsScan/src/DVDImage.cc | 100 +++++++++++++ libs/fsScan/src/FilesystemScanner.cc | 166 +++++++++++++++++++++ libs/fsScan/src/LegacyVdrRecording.cc | 91 +++++++++++ libs/fsScan/src/MediaFactory.cc | 137 +++++++++++++++++ libs/fsScan/src/Movie.cc | 61 ++++++++ libs/fsScan/src/Picture.cc | 69 +++++++++ libs/fsScan/src/VdrRecording.cc | 91 +++++++++++ libs/fsScan/summary.txt | 1 + 38 files changed, 2522 insertions(+) create mode 100644 libs/fsScan/.dep.inc create mode 100644 libs/fsScan/Makefile create mode 100644 libs/fsScan/fsScan.cbp create mode 100644 libs/fsScan/fsScan.depend create mode 100644 libs/fsScan/fsScan.layout create mode 100644 libs/fsScan/fsScan.layout.save create mode 100644 libs/fsScan/include/AbstractMedia.h create mode 100644 libs/fsScan/include/AbstractMultiFileMovie.h create mode 100644 libs/fsScan/include/Audio.h create mode 100644 libs/fsScan/include/DVDImage.h create mode 100644 libs/fsScan/include/FilesystemScanner.h create mode 100644 libs/fsScan/include/LegacyVdrRecording.h create mode 100644 libs/fsScan/include/MediaFactory.h create mode 100644 libs/fsScan/include/Movie.h create mode 100644 libs/fsScan/include/Picture.h create mode 100644 libs/fsScan/include/VdrRecording.h create mode 100644 libs/fsScan/nbproject/Makefile-Debug.mk create mode 100644 libs/fsScan/nbproject/Makefile-Release.mk create mode 100644 libs/fsScan/nbproject/Makefile-impl.mk create mode 100644 libs/fsScan/nbproject/Makefile-variables.mk create mode 100644 libs/fsScan/nbproject/Package-Debug.bash create mode 100644 libs/fsScan/nbproject/Package-Release.bash create mode 100644 libs/fsScan/nbproject/configurations.xml create mode 100644 libs/fsScan/nbproject/private/Makefile-variables.mk create mode 100644 libs/fsScan/nbproject/private/configurations.xml create mode 100644 libs/fsScan/nbproject/private/private.xml create mode 100644 libs/fsScan/nbproject/project.xml create mode 100644 libs/fsScan/src/AbstractMedia.cc create mode 100644 libs/fsScan/src/AbstractMultiFileMovie.cc create mode 100644 libs/fsScan/src/Audio.cc create mode 100644 libs/fsScan/src/DVDImage.cc create mode 100644 libs/fsScan/src/FilesystemScanner.cc create mode 100644 libs/fsScan/src/LegacyVdrRecording.cc create mode 100644 libs/fsScan/src/MediaFactory.cc create mode 100644 libs/fsScan/src/Movie.cc create mode 100644 libs/fsScan/src/Picture.cc create mode 100644 libs/fsScan/src/VdrRecording.cc create mode 100644 libs/fsScan/summary.txt (limited to 'libs/fsScan') diff --git a/libs/fsScan/.dep.inc b/libs/fsScan/.dep.inc new file mode 100644 index 0000000..4560e55 --- /dev/null +++ b/libs/fsScan/.dep.inc @@ -0,0 +1,5 @@ +# This code depends on make tool being used +DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES})) +ifneq (${DEPFILES},) +include ${DEPFILES} +endif diff --git a/libs/fsScan/Makefile b/libs/fsScan/Makefile new file mode 100644 index 0000000..ec9de69 --- /dev/null +++ b/libs/fsScan/Makefile @@ -0,0 +1,128 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_PLATFORM_${CONF} platform name (current configuration) +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# build tests +build-tests: .build-tests-post + +.build-tests-pre: +# Add your pre 'build-tests' code here... + +.build-tests-post: .build-tests-impl +# Add your post 'build-tests' code here... + + +# run tests +test: .test-post + +.test-pre: +# Add your pre 'test' code here... + +.test-post: .test-impl +# Add your post 'test' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/libs/fsScan/fsScan.cbp b/libs/fsScan/fsScan.cbp new file mode 100644 index 0000000..bef32fe --- /dev/null +++ b/libs/fsScan/fsScan.cbp @@ -0,0 +1,73 @@ + + + + + + diff --git a/libs/fsScan/fsScan.depend b/libs/fsScan/fsScan.depend new file mode 100644 index 0000000..c4ac310 --- /dev/null +++ b/libs/fsScan/fsScan.depend @@ -0,0 +1 @@ +# depslib dependency file v1.0 diff --git a/libs/fsScan/fsScan.layout b/libs/fsScan/fsScan.layout new file mode 100644 index 0000000..f1a8eb2 --- /dev/null +++ b/libs/fsScan/fsScan.layout @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/libs/fsScan/fsScan.layout.save b/libs/fsScan/fsScan.layout.save new file mode 100644 index 0000000..f1a8eb2 --- /dev/null +++ b/libs/fsScan/fsScan.layout.save @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/libs/fsScan/include/AbstractMedia.h b/libs/fsScan/include/AbstractMedia.h new file mode 100644 index 0000000..4b8fedd --- /dev/null +++ b/libs/fsScan/include/AbstractMedia.h @@ -0,0 +1,84 @@ +/** + * ======================== legal notice ====================== + * + * File: AbstractMedia.h + * Created: 2. Juli 2012, 14:33 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef ABSTRACTMEDIA_H +#define ABSTRACTMEDIA_H + +#include +#include +#include + +typedef struct { + const char *extension; + const char *mimeType; +} SupportedExtension; + +class cAbstractMedia { +public: + typedef enum { + Invalid, + Audio, + Movie, + DVDImage, + LegacyVdrRecording, + VdrRecording, + Picture, + Unknown + } SupportedMediaType; + + virtual ~cAbstractMedia(); + + virtual void Refresh(void); + ///< will be called right before start streaming, so this call is used to + ///< determine the real size, number of files, etc. + virtual size_t ReadChunk(char *buf, size_t bufSize); + ///< used to hide the differences between single- and multi-file media. + + SupportedMediaType MediaType(void) const { return mediaType; } + const char *LogicalPath(void) const { return logicalPath; } + const char *RealPath(void) const { return realPath; } + const char *Name(void) const { return name; } + const char *MimeType(void) const { return mimeType; } + time_t LastModified(void) const { return lastModified; } + void SetLastModified(time_t when) { lastModified = when; } + size_t Size(void) const { return size; } + void SetSize(size_t Size) { size = Size; } + static const char *MediaType2Text(int Type); + +protected: + cAbstractMedia(SupportedMediaType Type, const char *Name, const char *Logical, const char *Path, const char *Mime); + int fd; + +private: + SupportedMediaType mediaType; + char *logicalPath; + char *realPath; + char *name; + char *mimeType; + time_t lastModified; + size_t size; + }; + +#endif /* ABSTRACTMEDIA_H */ + diff --git a/libs/fsScan/include/AbstractMultiFileMovie.h b/libs/fsScan/include/AbstractMultiFileMovie.h new file mode 100644 index 0000000..e3bd520 --- /dev/null +++ b/libs/fsScan/include/AbstractMultiFileMovie.h @@ -0,0 +1,48 @@ +/** + * ======================== legal notice ====================== + * + * File: AbstractMultiFileMovie.h + * Created: 3. Juli 2012, 07:39 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef ABSTRACTMULTIFILEMOVIE_H +#define ABSTRACTMULTIFILEMOVIE_H + +#include + +class cAbstractMultiFileMovie : public cMovie { +public: + virtual ~cAbstractMultiFileMovie(); + + virtual size_t ReadChunk(char *buf, size_t bufSize); + + virtual const char *FirstFile(void) = 0; + virtual const char *NextFile(void) = 0; + +protected: + cAbstractMultiFileMovie(const char *Name, const char *Logical, const char *Path, const char *Mime, SupportedMediaType Type); + int movieFiles; + int curFileNo; + char *fileNameBuf; // this class does not need it, but all subclasses do ... + size_t bufSize; + }; + +#endif /* ABSTRACTMULTIFILEMOVIE_H */ + diff --git a/libs/fsScan/include/Audio.h b/libs/fsScan/include/Audio.h new file mode 100644 index 0000000..d1a784a --- /dev/null +++ b/libs/fsScan/include/Audio.h @@ -0,0 +1,43 @@ +/** + * ======================== legal notice ====================== + * + * File: Audio.h + * Created: 2. Juli 2012, 15:00 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef AUDIO_H +#define AUDIO_H + +#include + +class cAudio : public cAbstractMedia { +public: + cAudio(const char *Name, const char *Logical, const char *Path, const char *Mime); + virtual ~cAudio(); + +private: + static const char *ContentType(const char *Extension); + static SupportedExtension knownExtensions[]; + friend class cMediaFactory; + friend class FScanTest; + }; + +#endif /* AUDIO_H */ + diff --git a/libs/fsScan/include/DVDImage.h b/libs/fsScan/include/DVDImage.h new file mode 100644 index 0000000..e773e72 --- /dev/null +++ b/libs/fsScan/include/DVDImage.h @@ -0,0 +1,45 @@ +/** + * ======================== legal notice ====================== + * + * File: DVDImage.h + * Created: 3. Juli 2012, 08:34 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef DVDIMAGE_H +#define DVDIMAGE_H + +#include + +class cDVDImage : public cAbstractMultiFileMovie { +public: + cDVDImage(const char *Name, const char *Logical, const char *Path); + virtual ~cDVDImage(); + + virtual void Refresh(void); + + virtual const char *FirstFile(void); + virtual const char *NextFile(void); + +private: + int mainMovie; + }; + +#endif /* DVDIMAGE_H */ + diff --git a/libs/fsScan/include/FilesystemScanner.h b/libs/fsScan/include/FilesystemScanner.h new file mode 100644 index 0000000..7a188ce --- /dev/null +++ b/libs/fsScan/include/FilesystemScanner.h @@ -0,0 +1,59 @@ +/** + * ======================== legal notice ====================== + * + * File: FilesystemScanner.h + * Created: 2. Juli 2012, 13:58 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef FILESYSTEMSCANNER_H +#define FILESYSTEMSCANNER_H + +#include +#include +#include + +class cAbstractMedia; +class cFilesystemScanner { +public: + cFilesystemScanner(); + virtual ~cFilesystemScanner(); + + cManagedVector &MediaPool(void) { return pool; } + std::map &Categories(void) { return categories; } + cAbstractMedia *FindMedia(const char *LogicalPath); + void Refresh(void); + + void SetBaseDirectory(const char *dir); + void SetMediaFactory(cMediaFactory *factory); + +protected: + void parseDir(const char *dir, cManagedVector &result); + +private: + char *baseDirectory; + size_t fileBufSize; + struct dirent *dirEntryBuf; + cManagedVector pool; + std::map categories; + cMediaFactory *mediaFactory; + }; + +#endif /* FILESYSTEMSCANNER_H */ + diff --git a/libs/fsScan/include/LegacyVdrRecording.h b/libs/fsScan/include/LegacyVdrRecording.h new file mode 100644 index 0000000..147e6fc --- /dev/null +++ b/libs/fsScan/include/LegacyVdrRecording.h @@ -0,0 +1,42 @@ +/** + * ======================== legal notice ====================== + * + * File: LegacyVdrRecording.h + * Created: 3. Juli 2012, 08:16 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef LEGACYVDRRECORDING_H +#define LEGACYVDRRECORDING_H + +#include + +class cLegacyVdrRecording : public cAbstractMultiFileMovie { +public: + cLegacyVdrRecording(const char *Name, const char *Logical, const char *Path); + virtual ~cLegacyVdrRecording(); + + virtual void Refresh(void); + + virtual const char *FirstFile(void); + virtual const char *NextFile(void); + }; + +#endif /* LEGACYVDRRECORDING_H */ + diff --git a/libs/fsScan/include/MediaFactory.h b/libs/fsScan/include/MediaFactory.h new file mode 100644 index 0000000..b9b5391 --- /dev/null +++ b/libs/fsScan/include/MediaFactory.h @@ -0,0 +1,49 @@ +/** + * ======================== legal notice ====================== + * + * File: MediaFactory.h + * Created: 2. Juli 2012, 15:43 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef MEDIAFACTORY_H +#define MEDIAFACTORY_H + +#include +#include + +class cAbstractMedia; +class cMediaFactory { +public: + cMediaFactory(const char *BaseDirectory); + virtual ~cMediaFactory(); + + cAbstractMedia *CreateMedia(const char *FileOrDirname, struct stat *st); + + const char *BaseDirectory(void) const { return baseDirectory; } + void SetBaseDirectory(const char *dir); + +private: + char *baseDirectory; + char *scratch; + size_t scratchSize; + }; + +#endif /* MEDIAFACTORY_H */ + diff --git a/libs/fsScan/include/Movie.h b/libs/fsScan/include/Movie.h new file mode 100644 index 0000000..af8b437 --- /dev/null +++ b/libs/fsScan/include/Movie.h @@ -0,0 +1,43 @@ +/** + * ======================== legal notice ====================== + * + * File: Movie.h + * Created: 2. Juli 2012, 15:12 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef MOVIE_H +#define MOVIE_H + +#include + +class cMovie : public cAbstractMedia { +public: + cMovie(const char *Name, const char *Logical, const char *Path, const char *Mime, SupportedMediaType Type = cAbstractMedia::Movie); + virtual ~cMovie(); + +private: + static const char *ContentType(const char *Extension); + static SupportedExtension knownExtensions[]; + friend class cMediaFactory; + friend class FScanTest; + }; + +#endif /* MOVIE_H */ + diff --git a/libs/fsScan/include/Picture.h b/libs/fsScan/include/Picture.h new file mode 100644 index 0000000..a911a71 --- /dev/null +++ b/libs/fsScan/include/Picture.h @@ -0,0 +1,43 @@ +/** + * ======================== legal notice ====================== + * + * File: Picture.h + * Created: 2. Juli 2012, 15:18 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef PICTURE_H +#define PICTURE_H + +#include + +class cPicture : public cAbstractMedia { +public: + cPicture(const char *Name, const char *Logical, const char *Path, const char *Mime); + virtual ~cPicture(); + +private: + static const char *ContentType(const char *Extension); + static SupportedExtension knownExtensions[]; + friend class cMediaFactory; + friend class FScanTest; + }; + +#endif /* PICTURE_H */ + diff --git a/libs/fsScan/include/VdrRecording.h b/libs/fsScan/include/VdrRecording.h new file mode 100644 index 0000000..2e3904b --- /dev/null +++ b/libs/fsScan/include/VdrRecording.h @@ -0,0 +1,42 @@ +/** + * ======================== legal notice ====================== + * + * File: VdrRecording.h + * Created: 3. Juli 2012, 08:30 + * Author: Geronimo + * 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 + * + * -------------------------------------------------------------- + */ +#ifndef VDRRECORDING_H +#define VDRRECORDING_H + +#include + +class cVdrRecording : public cAbstractMultiFileMovie { +public: + cVdrRecording(const char *Name, const char *Logical, const char *Path); + virtual ~cVdrRecording(); + + virtual void Refresh(void); + + virtual const char *FirstFile(void); + virtual const char *NextFile(void); + }; + +#endif /* VDRRECORDING_H */ + diff --git a/libs/fsScan/nbproject/Makefile-Debug.mk b/libs/fsScan/nbproject/Makefile-Debug.mk new file mode 100644 index 0000000..f2cf866 --- /dev/null +++ b/libs/fsScan/nbproject/Makefile-Debug.mk @@ -0,0 +1,139 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/src/Picture.o \ + ${OBJECTDIR}/src/Audio.o \ + ${OBJECTDIR}/src/DVDImage.o \ + ${OBJECTDIR}/src/VdrRecording.o \ + ${OBJECTDIR}/src/LegacyVdrRecording.o \ + ${OBJECTDIR}/src/MediaFactory.o \ + ${OBJECTDIR}/src/FilesystemScanner.o \ + ${OBJECTDIR}/src/AbstractMultiFileMovie.o \ + ${OBJECTDIR}/src/AbstractMedia.o \ + ${OBJECTDIR}/src/Movie.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi +CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a ${OBJECTFILES} + $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +${OBJECTDIR}/src/Picture.o: nbproject/Makefile-${CND_CONF}.mk src/Picture.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Picture.o src/Picture.cc + +${OBJECTDIR}/src/Audio.o: nbproject/Makefile-${CND_CONF}.mk src/Audio.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Audio.o src/Audio.cc + +${OBJECTDIR}/src/DVDImage.o: nbproject/Makefile-${CND_CONF}.mk src/DVDImage.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/DVDImage.o src/DVDImage.cc + +${OBJECTDIR}/src/VdrRecording.o: nbproject/Makefile-${CND_CONF}.mk src/VdrRecording.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/VdrRecording.o src/VdrRecording.cc + +${OBJECTDIR}/src/LegacyVdrRecording.o: nbproject/Makefile-${CND_CONF}.mk src/LegacyVdrRecording.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LegacyVdrRecording.o src/LegacyVdrRecording.cc + +${OBJECTDIR}/src/MediaFactory.o: nbproject/Makefile-${CND_CONF}.mk src/MediaFactory.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/MediaFactory.o src/MediaFactory.cc + +${OBJECTDIR}/src/FilesystemScanner.o: nbproject/Makefile-${CND_CONF}.mk src/FilesystemScanner.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FilesystemScanner.o src/FilesystemScanner.cc + +${OBJECTDIR}/src/AbstractMultiFileMovie.o: nbproject/Makefile-${CND_CONF}.mk src/AbstractMultiFileMovie.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMultiFileMovie.o src/AbstractMultiFileMovie.cc + +${OBJECTDIR}/src/AbstractMedia.o: nbproject/Makefile-${CND_CONF}.mk src/AbstractMedia.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMedia.o src/AbstractMedia.cc + +${OBJECTDIR}/src/Movie.o: nbproject/Makefile-${CND_CONF}.mk src/Movie.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Movie.o src/Movie.cc + +# Subprojects +.build-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +# Subprojects +.clean-subprojects: + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff --git a/libs/fsScan/nbproject/Makefile-Release.mk b/libs/fsScan/nbproject/Makefile-Release.mk new file mode 100644 index 0000000..17f8aff --- /dev/null +++ b/libs/fsScan/nbproject/Makefile-Release.mk @@ -0,0 +1,139 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/src/Picture.o \ + ${OBJECTDIR}/src/Audio.o \ + ${OBJECTDIR}/src/DVDImage.o \ + ${OBJECTDIR}/src/VdrRecording.o \ + ${OBJECTDIR}/src/LegacyVdrRecording.o \ + ${OBJECTDIR}/src/MediaFactory.o \ + ${OBJECTDIR}/src/FilesystemScanner.o \ + ${OBJECTDIR}/src/AbstractMultiFileMovie.o \ + ${OBJECTDIR}/src/AbstractMedia.o \ + ${OBJECTDIR}/src/Movie.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS= +CXXFLAGS= + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a ${OBJECTFILES} + $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +${OBJECTDIR}/src/Picture.o: nbproject/Makefile-${CND_CONF}.mk src/Picture.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Picture.o src/Picture.cc + +${OBJECTDIR}/src/Audio.o: nbproject/Makefile-${CND_CONF}.mk src/Audio.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Audio.o src/Audio.cc + +${OBJECTDIR}/src/DVDImage.o: nbproject/Makefile-${CND_CONF}.mk src/DVDImage.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/DVDImage.o src/DVDImage.cc + +${OBJECTDIR}/src/VdrRecording.o: nbproject/Makefile-${CND_CONF}.mk src/VdrRecording.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/VdrRecording.o src/VdrRecording.cc + +${OBJECTDIR}/src/LegacyVdrRecording.o: nbproject/Makefile-${CND_CONF}.mk src/LegacyVdrRecording.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LegacyVdrRecording.o src/LegacyVdrRecording.cc + +${OBJECTDIR}/src/MediaFactory.o: nbproject/Makefile-${CND_CONF}.mk src/MediaFactory.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/MediaFactory.o src/MediaFactory.cc + +${OBJECTDIR}/src/FilesystemScanner.o: nbproject/Makefile-${CND_CONF}.mk src/FilesystemScanner.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FilesystemScanner.o src/FilesystemScanner.cc + +${OBJECTDIR}/src/AbstractMultiFileMovie.o: nbproject/Makefile-${CND_CONF}.mk src/AbstractMultiFileMovie.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMultiFileMovie.o src/AbstractMultiFileMovie.cc + +${OBJECTDIR}/src/AbstractMedia.o: nbproject/Makefile-${CND_CONF}.mk src/AbstractMedia.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMedia.o src/AbstractMedia.cc + +${OBJECTDIR}/src/Movie.o: nbproject/Makefile-${CND_CONF}.mk src/Movie.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Movie.o src/Movie.cc + +# Subprojects +.build-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a + +# Subprojects +.clean-subprojects: + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff --git a/libs/fsScan/nbproject/Makefile-impl.mk b/libs/fsScan/nbproject/Makefile-impl.mk new file mode 100644 index 0000000..1d398f7 --- /dev/null +++ b/libs/fsScan/nbproject/Makefile-impl.mk @@ -0,0 +1,133 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=fsScan + +# Active Configuration +DEFAULTCONF=Debug +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=Debug Release + + +# build +.build-impl: .build-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf + + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ + done + +# all +.all-impl: .all-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ + done + +# build tests +.build-tests-impl: .build-impl .build-tests-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf + +# run tests +.test-impl: .build-tests-impl .test-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf + +# dependency checking support +.depcheck-impl: + @echo "# This code depends on make tool being used" >.dep.inc + @if [ -n "${MAKE_VERSION}" ]; then \ + echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ + echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ + echo "include \$${DEPFILES}" >>.dep.inc; \ + echo "endif" >>.dep.inc; \ + else \ + echo ".KEEP_STATE:" >>.dep.inc; \ + echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ + fi + +# configuration validation +.validate-impl: + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + echo ""; \ + echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ + echo "See 'make help' for details."; \ + echo "Current directory: " `pwd`; \ + echo ""; \ + fi + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + exit 1; \ + fi + + +# help +.help-impl: .help-pre + @echo "This makefile supports the following configurations:" + @echo " ${ALLCONFS}" + @echo "" + @echo "and the following targets:" + @echo " build (default target)" + @echo " clean" + @echo " clobber" + @echo " all" + @echo " help" + @echo "" + @echo "Makefile Usage:" + @echo " make [CONF=] [SUB=no] build" + @echo " make [CONF=] [SUB=no] clean" + @echo " make [SUB=no] clobber" + @echo " make [SUB=no] all" + @echo " make help" + @echo "" + @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," + @echo " also clean subprojects." + @echo "Target 'clobber' will remove all built files from all configurations and," + @echo " unless 'SUB=no', also from subprojects." + @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'help' prints this message." + @echo "" + diff --git a/libs/fsScan/nbproject/Makefile-variables.mk b/libs/fsScan/nbproject/Makefile-variables.mk new file mode 100644 index 0000000..e22487e --- /dev/null +++ b/libs/fsScan/nbproject/Makefile-variables.mk @@ -0,0 +1,35 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +CND_BUILDDIR=build +CND_DISTDIR=dist +# Debug configuration +CND_PLATFORM_Debug=GNU-Linux-x86 +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux-x86 +CND_ARTIFACT_NAME_Debug=libfsscan.a +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/libfsscan.a +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package +CND_PACKAGE_NAME_Debug=fsScan.tar +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/fsScan.tar +# Release configuration +CND_PLATFORM_Release=GNU-Linux-x86 +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux-x86 +CND_ARTIFACT_NAME_Release=libfsscan.a +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux-x86/libfsscan.a +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package +CND_PACKAGE_NAME_Release=fsScan.tar +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/fsScan.tar +# +# include compiler specific variables +# +# dmake command +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ + (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) +# +# gmake command +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) +# +include nbproject/private/Makefile-variables.mk diff --git a/libs/fsScan/nbproject/Package-Debug.bash b/libs/fsScan/nbproject/Package-Debug.bash new file mode 100644 index 0000000..2a9c453 --- /dev/null +++ b/libs/fsScan/nbproject/Package-Debug.bash @@ -0,0 +1,75 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a +OUTPUT_BASENAME=libfsscan.a +PACKAGE_TOP_DIR=fsScan/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/fsScan/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fsScan.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fsScan.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff --git a/libs/fsScan/nbproject/Package-Release.bash b/libs/fsScan/nbproject/Package-Release.bash new file mode 100644 index 0000000..d996196 --- /dev/null +++ b/libs/fsScan/nbproject/Package-Release.bash @@ -0,0 +1,75 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a +OUTPUT_BASENAME=libfsscan.a +PACKAGE_TOP_DIR=fsScan/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/fsScan/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fsScan.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fsScan.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff --git a/libs/fsScan/nbproject/configurations.xml b/libs/fsScan/nbproject/configurations.xml new file mode 100644 index 0000000..a2338c7 --- /dev/null +++ b/libs/fsScan/nbproject/configurations.xml @@ -0,0 +1,97 @@ + + + + + include/AbstractMedia.h + include/AbstractMultiFileMovie.h + include/Audio.h + include/DVDImage.h + include/FilesystemScanner.h + include/LegacyVdrRecording.h + include/MediaFactory.h + include/Movie.h + include/Picture.h + include/VdrRecording.h + + + + + src/AbstractMedia.cc + src/AbstractMultiFileMovie.cc + src/Audio.cc + src/DVDImage.cc + src/FilesystemScanner.cc + src/LegacyVdrRecording.cc + src/MediaFactory.cc + src/Movie.cc + src/Picture.cc + src/VdrRecording.cc + + + + + Makefile + + + Makefile + + + + LOCAL_SOURCES + default + + + + + include + ../networking/include + ../util/include + ../vdr/include + + -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi + + _GNU_SOURCE=1 + _REENTRANT + + 2 + + + + + + + + LOCAL_SOURCES + default + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + + diff --git a/libs/fsScan/nbproject/private/Makefile-variables.mk b/libs/fsScan/nbproject/private/Makefile-variables.mk new file mode 100644 index 0000000..a64183e --- /dev/null +++ b/libs/fsScan/nbproject/private/Makefile-variables.mk @@ -0,0 +1,7 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +# Debug configuration +# Release configuration diff --git a/libs/fsScan/nbproject/private/configurations.xml b/libs/fsScan/nbproject/private/configurations.xml new file mode 100644 index 0000000..fa15dc7 --- /dev/null +++ b/libs/fsScan/nbproject/private/configurations.xml @@ -0,0 +1,72 @@ + + + Makefile + + + + localhost + 2 + + + + + + + + + + + + + + + gdb + + + + "${OUTPUT_PATH}" + + "${OUTPUT_PATH}" + + true + 0 + 0 + + + + + + + localhost + 2 + + + + + + + + + + + + + + + gdb + + + + "${OUTPUT_PATH}" + + "${OUTPUT_PATH}" + + true + 0 + 0 + + + + + + diff --git a/libs/fsScan/nbproject/private/private.xml b/libs/fsScan/nbproject/private/private.xml new file mode 100644 index 0000000..5ee2703 --- /dev/null +++ b/libs/fsScan/nbproject/private/private.xml @@ -0,0 +1,8 @@ + + + + 3 + 0 + + + diff --git a/libs/fsScan/nbproject/project.xml b/libs/fsScan/nbproject/project.xml new file mode 100644 index 0000000..a104f65 --- /dev/null +++ b/libs/fsScan/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.cnd.makeproject + + + fsScan + + cc + h + UTF-8 + + + + + Debug + 3 + + + Release + 3 + + + + + diff --git a/libs/fsScan/src/AbstractMedia.cc b/libs/fsScan/src/AbstractMedia.cc new file mode 100644 index 0000000..3a3556b --- /dev/null +++ b/libs/fsScan/src/AbstractMedia.cc @@ -0,0 +1,92 @@ +/** + * ======================== legal notice ====================== + * + * File: AbstractMedia.cc + * Created: 2. Juli 2012, 14:33 + * Author: Geronimo + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +cAbstractMedia::cAbstractMedia(cAbstractMedia::SupportedMediaType Type, const char *Name, const char *Logical, const char *Path, const char *Mime) + : fd(-1) + , mediaType(Type) + , logicalPath(Logical ? strdup(Logical) : NULL) + , realPath(Path ? strdup(Path) : NULL) + , name(Name ? strdup(Name) : NULL) + , mimeType(Mime ? strdup(Mime) : NULL) + , lastModified(0) + , size(0) +{ +} + +cAbstractMedia::~cAbstractMedia() +{ + free(logicalPath); + free(realPath); + free(name); + free(mimeType); +} + +void cAbstractMedia::Refresh(void) +{ +} + +size_t cAbstractMedia::ReadChunk(char* Buf, size_t bufSize) +{ + long rv = 0; + + if (fd < 1) { // fp stays open between various calls + fd = open(RealPath(), O_RDONLY | O_LARGEFILE); + if (fd < 1) { + esyslog("could not open requested path %s - Error #%d", RealPath(), errno); + return 0; + } + } + isyslog("have filehandle #%d (%s)", fd, RealPath()); + if ((rv = read(fd, Buf, bufSize)) < 0) + esyslog("ERROR: failed to read from file %s #%d", RealPath(), errno); + else + isyslog("read %u bytes from file", rv); + if (rv < (long) bufSize) { // most probabely end of file + close(fd); + } + return rv; +} + +const char *cAbstractMedia::MediaType2Text(int Type) +{ + switch(Type) { + case Audio: return TO_STRING(Audio); + case Movie: return TO_STRING(Movie); + case DVDImage: return TO_STRING(DVDImage); + case LegacyVdrRecording: return TO_STRING(LegacyVdrRecording); + case VdrRecording: return TO_STRING(VdrRecording); + case Picture: return TO_STRING(Picture); + default: return TO_STRING(Invalid); + } +} \ No newline at end of file diff --git a/libs/fsScan/src/AbstractMultiFileMovie.cc b/libs/fsScan/src/AbstractMultiFileMovie.cc new file mode 100644 index 0000000..bcbd115 --- /dev/null +++ b/libs/fsScan/src/AbstractMultiFileMovie.cc @@ -0,0 +1,111 @@ +/** + * ======================== legal notice ====================== + * + * File: AbstractMultiFileMovie.cc + * Created: 3. Juli 2012, 07:39 + * Author: Geronimo + * 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 +#include +#include +#include +#include +#include + +cAbstractMultiFileMovie::cAbstractMultiFileMovie(const char *Name, const char *Logical, const char *Path, const char *Mime, SupportedMediaType Type) + : cMovie(Name, Logical, Path, Mime, Type) + , movieFiles(0) + , curFileNo(0) + , fileNameBuf(NULL) + , bufSize(0) +{ +} + +cAbstractMultiFileMovie::~cAbstractMultiFileMovie() +{ + free(fileNameBuf); +} + +size_t cAbstractMultiFileMovie::ReadChunk(char* Buf, size_t bufSize) +{ + long rv = 0; + + if (fd < 1) { + fd = open(FirstFile(), O_RDONLY | O_LARGEFILE); + if (fd < 1) { + esyslog("could not open requested path %s - Error #%d", FirstFile(), errno); + return 0; + } + } + isyslog("have filehandle #%d (%s)", fd, FirstFile()); + rv = read(fd, Buf, bufSize); + + if (rv < (long) bufSize) { + const char *nextFilename = NextFile(); + + if (nextFilename) { + close(fd); + fd = open(nextFilename, O_RDONLY | O_LARGEFILE); + if (fd < 1) { + esyslog("could not open requested path %s - Error #%d", nextFilename, errno); + return 0; + } + isyslog("have filehandle #%d (%s)", fd, nextFilename); + rv = read(fd, Buf, bufSize); + } + if (rv < (long) bufSize) { + close(fd); + fd = -1; + } + } + return rv; +} + +//int cAbstractMultiFileMovie::ReadBlah(char* buf, size_t bufSize) +//{ +// size_t bytesRead = 0; +// +// if (!fp) { +// if (!(fp = f open(FirstFile(), "r"))) { +// //TODO: add some verbose error message? +// return 0; +// } +// } +// +// bytesRead = f read(buf, sizeof(char), bufSize, fp); +// +// if (bytesRead < bufSize) { +// const char *nextFilename = NextFile(); +// +// if (nextFilename) { +// f close(fp); +// if (!(fp = f open(nextFilename, "r"))) { +// //TODO: be verbose +// return 0; +// } +// bytesRead += f read(buf + bytesRead, sizeof(char), bufSize - bytesRead, fp); +// } +// if (bytesRead < bufSize) { +// f close(fp); +// fp = NULL; +// } +// } +// return bytesRead; +//} diff --git a/libs/fsScan/src/Audio.cc b/libs/fsScan/src/Audio.cc new file mode 100644 index 0000000..25521dc --- /dev/null +++ b/libs/fsScan/src/Audio.cc @@ -0,0 +1,65 @@ +/** + * ======================== legal notice ====================== + * + * File: Audio.cc + * Created: 2. Juli 2012, 15:00 + * Author: Geronimo + * 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 +#include +#include + +SupportedExtension cAudio::knownExtensions[] = { + { "aac", "audio/aac" }, + { "aif", "audio/x-aiff" }, + { "aiff", "audio/x-aiff" }, + { "aifc", "audio/x-aiff" }, + { "au", "audio/x-au" }, + { "fla", "audio/flac" }, + { "flac", "audio/flac" }, + { "oga", "audio/ogg" }, + { "ogg", "audio/ogg" }, + { "mka", "audio/x-matroska" }, + { "mp3", "audio/mpeg" }, + { "mp4", "audio/x-mpeg4" }, + { "m4a", "audio/x-m4" }, + { "mpg", "audio/mpeg" }, + { "mpp", "audio/x-musepack" }, + { "ram", "audio/x-realaudio" }, + { NULL, NULL } +}; + +cAudio::cAudio(const char *Name, const char *Logical, const char *Path, const char *Mime) + : cAbstractMedia(Audio, Name, Logical, Path, Mime) +{ +} + +cAudio::~cAudio() +{ +} + +const char *cAudio::ContentType(const char* Extension) +{ + for (SupportedExtension *p = knownExtensions; p && p->extension; ++p) { + if (!strcasecmp(p->extension, Extension)) return p->mimeType; + } + return NULL; +} + diff --git a/libs/fsScan/src/DVDImage.cc b/libs/fsScan/src/DVDImage.cc new file mode 100644 index 0000000..5ffb170 --- /dev/null +++ b/libs/fsScan/src/DVDImage.cc @@ -0,0 +1,100 @@ +/** + * ======================== legal notice ====================== + * + * File: DVDImage.cc + * Created: 3. Juli 2012, 08:34 + * Author: Geronimo + * 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 +#include +#include +#include +#define FILE_MASK "VIDEO_TS/VTS_%02d_%d.VOB" + +cDVDImage::cDVDImage(const char *Name, const char *Logical, const char *Path) + : cAbstractMultiFileMovie(Name, Logical, Path, "video/mpeg", DVDImage) +{ +} + +cDVDImage::~cDVDImage() +{ +} + +void cDVDImage::Refresh(void) +{ + struct stat stBuf; + size_t maxSize = 0; + size_t total = 0; + time_t lastMod = 0; + + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) { + //TODO: some error message? + return; + } + strcpy(fileNameBuf, RealPath()); + } + movieFiles = 0; + mainMovie = 0; + + for (int movie = 1; movie < 100; ++movie) { + total = 0; + for (int fileNo = 1;; ++fileNo) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, movie, fileNo); + if (stat(fileNameBuf, &stBuf) < 0) { + movieFiles = fileNo - 1; + break; + } + total += stBuf.st_size; + if (stBuf.st_mtime > lastMod) lastMod = stBuf.st_mtime; + } + if (total > maxSize) { + maxSize = total; + mainMovie = movie; + } + } + SetSize(total); + SetLastModified(lastMod); +} + +const char *cDVDImage::FirstFile(void) +{ + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) { + //TODO: some error message? + return NULL; + } + strcpy(fileNameBuf, RealPath()); + } + curFileNo = 1; + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, mainMovie, curFileNo); + + return fileNameBuf; +} + +const char *cDVDImage::NextFile(void) +{ + if (++curFileNo < movieFiles) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, mainMovie, curFileNo); + + return fileNameBuf; + } + return NULL; +} diff --git a/libs/fsScan/src/FilesystemScanner.cc b/libs/fsScan/src/FilesystemScanner.cc new file mode 100644 index 0000000..8377691 --- /dev/null +++ b/libs/fsScan/src/FilesystemScanner.cc @@ -0,0 +1,166 @@ +/** + * ======================== legal notice ====================== + * + * File: FilesystemScanner.cc + * Created: 2. Juli 2012, 13:58 + * Author: Geronimo + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void freeMediaCallback(void *elem) +{ + delete (cAbstractMedia *)elem; +} + +cFilesystemScanner::cFilesystemScanner() + : baseDirectory(NULL) + , fileBufSize(512) + , dirEntryBuf(NULL) + , pool(freeMediaCallback) + , mediaFactory(NULL) +{ +} + +cFilesystemScanner::~cFilesystemScanner() +{ + FREE(dirEntryBuf); + FREE(baseDirectory); + pool.clear(); + if (mediaFactory) delete mediaFactory; +} + +void cFilesystemScanner::SetBaseDirectory(const char* dir) +{ + FREE(baseDirectory); + baseDirectory = strdup(dir); + if (mediaFactory) mediaFactory->SetBaseDirectory(dir); +} + +void cFilesystemScanner::SetMediaFactory(cMediaFactory* factory) +{ + if ((mediaFactory = factory)) { + FREE(baseDirectory); + baseDirectory = strdup(mediaFactory->BaseDirectory()); + } +} + +// return true if a should be ordered before b +bool defaultMediaSortOrder(void *a, void *b) +{ + if (!a && !b) return true; + if (!a && b) return false; + if (a && !b) return true; + cAbstractMedia *m0 = (cAbstractMedia *)a; + cAbstractMedia *m1 = (cAbstractMedia *)b; + bool rv = (m0->MediaType() - m1->MediaType()) < 0; + + if (!rv) rv = strcmp(m0->Name(), m1->Name()); + + return rv; +} + +void cFilesystemScanner::Refresh() +{ + if (!mediaFactory) return; + pool.clear(); + categories.clear(); + dirEntryBuf = (struct dirent *)malloc(sizeof(struct dirent)); + if (!dirEntryBuf) { + esyslog("ERROR: out of memory!"); + return; + } + parseDir(baseDirectory, pool); + FREE(dirEntryBuf); +#ifdef REDNOSE + pool.sort(defaultMediaSortOrder); +#else + pool.sort(NULL); +#endif + cAbstractMedia::SupportedMediaType ot = cAbstractMedia::Invalid; + cAbstractMedia *m; + + for (size_t i=0; i < pool.size(); ++i) { + m = (cAbstractMedia *) pool[i]; + if (m->MediaType() != ot) { + ot = m->MediaType(); + categories[ot] = i; + } + } +} + +void cFilesystemScanner::parseDir(const char* dirName, cManagedVector &result) +{ + if (!mediaFactory) return; + DIR *dir = opendir(dirName); + cAbstractMedia *media; + char *pathBuf = (char *)malloc(fileBufSize); + struct dirent *dirEntry; + struct stat statBuf; + + if (!dir) return; + if (!pathBuf) { + closedir(dir); + return; + } + if (fileBufSize < strlen(dirName) + 128) { + fileBufSize += 256; + pathBuf = (char *)realloc(pathBuf, fileBufSize); + } + while (!readdir_r(dir, dirEntryBuf, &dirEntry) && dirEntry) { + if (*dirEntry->d_name == '.') continue; // don't bother with hidden stuff + strcpy(pathBuf, dirName); + strcat(pathBuf, "/"); + strcat(pathBuf, dirEntry->d_name); + if (stat(pathBuf, &statBuf) < 0) return; + if ((media = mediaFactory->CreateMedia(pathBuf, &statBuf))) { + result.push_back(media); + isyslog("found media %s - %s", media->MimeType(), media->LogicalPath()); + continue; + } + if ((statBuf.st_mode & S_IFMT) == S_IFDIR) parseDir(pathBuf, result); + } + closedir(dir); + FREE(pathBuf); +} + +cAbstractMedia *cFilesystemScanner::FindMedia(const char* LogicalPath) +{ + cAbstractMedia *rv = NULL, *tmp; + + for (size_t i=0; i < pool.size(); ++i) { + tmp = (cAbstractMedia *) pool[i]; + if (!strcmp(tmp->LogicalPath(), LogicalPath)) { + rv = tmp; + break; + } + } + return rv; +} \ No newline at end of file diff --git a/libs/fsScan/src/LegacyVdrRecording.cc b/libs/fsScan/src/LegacyVdrRecording.cc new file mode 100644 index 0000000..ea2ed35 --- /dev/null +++ b/libs/fsScan/src/LegacyVdrRecording.cc @@ -0,0 +1,91 @@ +/** + * ======================== legal notice ====================== + * + * File: LegacyVdrRecording.cc + * Created: 3. Juli 2012, 08:16 + * Author: Geronimo + * 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 +#include +#include +#include +#define FILE_MASK "/%03d.vdr" + +cLegacyVdrRecording::cLegacyVdrRecording(const char *Name, const char *Logical, const char *Path) + : cAbstractMultiFileMovie(Name, Logical, Path, "video/mpeg", LegacyVdrRecording) +{ +} + +cLegacyVdrRecording::~cLegacyVdrRecording() +{ +} + +void cLegacyVdrRecording::Refresh(void) +{ + struct stat stBuf; + size_t total = 0; + time_t lastMod = 0; + + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) { + //TODO: some error message? + return; + } + strcpy(fileNameBuf, RealPath()); + } + movieFiles = 0; + + for (int fileNo = 1;; ++fileNo) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, fileNo); + if (stat(fileNameBuf, &stBuf) < 0) { + movieFiles = fileNo - 1; + break; + } + total += stBuf.st_size; + if (stBuf.st_mtime > lastMod) lastMod = stBuf.st_mtime; + } + SetSize(total); + SetLastModified(lastMod); +} + +const char *cLegacyVdrRecording::FirstFile(void) +{ + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) { + //TODO: some error message? + return NULL; + } + strcpy(fileNameBuf, RealPath()); + } + curFileNo = 1; + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo); + + return fileNameBuf; +} + +const char *cLegacyVdrRecording::NextFile(void) +{ + if (++curFileNo < movieFiles) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo); + + return fileNameBuf; + } + return NULL; +} diff --git a/libs/fsScan/src/MediaFactory.cc b/libs/fsScan/src/MediaFactory.cc new file mode 100644 index 0000000..a94fbb1 --- /dev/null +++ b/libs/fsScan/src/MediaFactory.cc @@ -0,0 +1,137 @@ +/** + * ======================== legal notice ====================== + * + * File: MediaFactory.cc + * Created: 2. Juli 2012, 15:43 + * Author: Geronimo + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +cMediaFactory::cMediaFactory(const char *BaseDirectory) + : baseDirectory(BaseDirectory ? strdup(BaseDirectory) : NULL) + , scratch(NULL) + , scratchSize(1024) +{ + if (baseDirectory && *(baseDirectory + strlen(baseDirectory) - 1) == '/') + *(baseDirectory + strlen(baseDirectory) - 1) = 0; + scratch = (char *)malloc(scratchSize); +} + +cMediaFactory::~cMediaFactory() +{ + free(scratch); + free(baseDirectory); +} + +void cMediaFactory::SetBaseDirectory(const char* dir) +{ + if (baseDirectory == dir) return; + char *tmp = baseDirectory; + baseDirectory = NULL; + free(tmp); + if (dir) { + baseDirectory = strdup(dir); + if (*(baseDirectory + strlen(baseDirectory) - 1) == '/') + *(baseDirectory + strlen(baseDirectory) - 1) = 0; + } +} + +cAbstractMedia *cMediaFactory::CreateMedia(const char* FileOrDirname, struct stat *st) +{ + const char *name = rindex(FileOrDirname, '/') + 1; + const char *logical = FileOrDirname + strlen(baseDirectory); + const char *mimeType = NULL; + cAbstractMedia *rv = NULL; + +// printf("CreateMedia(%s) ... name=[%s], logical=[%s]\n", FileOrDirname, name, logical); + if ((st->st_mode & S_IFMT) == S_IFDIR) { + static const char *addons[] = { "/001.vdr", "/00001.ts", "/VIDEO_TS/VIDEO_TS.IFO", "/video_ts/VIDEO_TS.IFO", "/video_ts/video_ts.ifo", NULL }; + struct stat stBuf; + int n=0; + + if (scratchSize < (strlen(FileOrDirname) + 32)) { + scratchSize += 128; + scratch = (char *)realloc(scratch, scratchSize); + } + if (!scratch) return NULL; + + for (const char **pa = addons; pa && *pa; ++pa, ++n) { + strcpy(scratch, FileOrDirname); + strcat(scratch, *pa); + + if (stat(scratch, &stBuf) < 0) continue; + + if ((stBuf.st_mode & S_IFMT) == S_IFREG) { + if (n < 2) { + char *tmp = rindex(scratch, '/'); // filename + char *p = tmp; + + *p = ')'; + *(p + 2) = 0; + tmp = rindex(scratch, '/'); // ts-directory + + for (; p > tmp; --p) *(p + 1) = *p; // shift it up one position + *(p + 1) = '('; // start of ts-directory + *tmp = ' '; // add separator + tmp = rindex(scratch, '/'); // name of vdr recording + if (tmp) name = tmp + 1; + } + switch (n) { + case 0: rv = new cLegacyVdrRecording(name, logical, FileOrDirname); break; + case 1: rv = new cVdrRecording(name, logical, FileOrDirname); break; + default: rv = new cDVDImage(name, logical, FileOrDirname); break; + } + rv->SetLastModified(st->st_mtime); + } + } + } + else if ((st->st_mode & S_IFMT) == S_IFREG) { + const char *extension = rindex(FileOrDirname, '.'); + + if (!extension) return NULL; + ++extension; + + mimeType = cMovie::ContentType(extension); + if (mimeType) rv = new cMovie(name, logical, FileOrDirname, mimeType); + else { + mimeType = cAudio::ContentType(extension); + if (mimeType) rv = new cAudio(name, logical, FileOrDirname, mimeType); + else { + mimeType = cPicture::ContentType(extension); + if (mimeType) rv = new cPicture(name, logical, FileOrDirname, mimeType); + } + } + if (rv) { + rv->SetLastModified(st->st_mtime); + rv->SetSize(st->st_size); + } + } + return rv; +} \ No newline at end of file diff --git a/libs/fsScan/src/Movie.cc b/libs/fsScan/src/Movie.cc new file mode 100644 index 0000000..a558f81 --- /dev/null +++ b/libs/fsScan/src/Movie.cc @@ -0,0 +1,61 @@ +/** + * ======================== legal notice ====================== + * + * File: Movie.cc + * Created: 2. Juli 2012, 15:12 + * Author: Geronimo + * 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 +#include +#include + +SupportedExtension cMovie::knownExtensions[] = { + { "asd", "video/x-ms-asf" }, + { "asf", "video/x-ms-asf" }, + { "avi", "video/x-msvideo" }, + { "dv", "video/x-dv" }, + { "flv", "video/x-flv" }, + { "gl", "video/x-gl" }, + { "iso", "application/x-iso9660-image" }, + { "ogv", "video/ogg" }, + { "mkv", "video/x-matroska" }, + { "mov", "video/quicktime" }, + { "mpeg", "video/mpeg" }, + { "swf", "application/x-shockwave-flash" }, + { NULL, NULL } +}; + +cMovie::cMovie(const char *Name, const char *Logical, const char *Path, const char *Mime, SupportedMediaType Type) + : cAbstractMedia(Type, Name, Logical, Path, Mime) +{ +} + +cMovie::~cMovie() +{ +} + +const char *cMovie::ContentType(const char* Extension) +{ + for (SupportedExtension *p = knownExtensions; p && p->extension; ++p) { + if (!strcasecmp(p->extension, Extension)) return p->mimeType; + } + return NULL; +} + diff --git a/libs/fsScan/src/Picture.cc b/libs/fsScan/src/Picture.cc new file mode 100644 index 0000000..3c44ce6 --- /dev/null +++ b/libs/fsScan/src/Picture.cc @@ -0,0 +1,69 @@ +/** + * ======================== legal notice ====================== + * + * File: Picture.cc + * Created: 2. Juli 2012, 15:18 + * Author: Geronimo + * 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 +#include +#include + +SupportedExtension cPicture::knownExtensions[] = { + { "bmp", "image/x-windows-bmp" }, + { "gif", "image/gif" }, + { "jff", "image/jpeg" }, + { "jfif", "image/jpeg" }, + { "jif", "image/jpeg" }, + { "jp2", "image/jp2" }, + { "jpe", "image/jpeg" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "jpm", "image/jpm" }, + { "jpx", "image/jpx" }, + { "pbm", "image/x-portable-bitmap" }, + { "pct", "image/x-pict" }, + { "pcx", "image/x-pcx" }, + { "png", "image/png" }, + { "pnm", "image/x-portable-anymap" }, + { "ppm", "image/x-portable-pixmap" }, + { "qti", "image/quicktime" }, + { "ras", "image/x-cmu-raster" }, + { "rgb", "image/x-rgb" }, + { NULL, NULL } +}; + +cPicture::cPicture(const char *Name, const char *Logical, const char *Path, const char *Mime) +: cAbstractMedia(Picture, Name, Logical, Path, Mime) +{ +} + +cPicture::~cPicture() +{ +} + +const char *cPicture::ContentType(const char* Extension) +{ + for (SupportedExtension *p = knownExtensions; p && p->extension; ++p) { + if (!strcasecmp(p->extension, Extension)) return p->mimeType; + } + return NULL; +} + diff --git a/libs/fsScan/src/VdrRecording.cc b/libs/fsScan/src/VdrRecording.cc new file mode 100644 index 0000000..f706477 --- /dev/null +++ b/libs/fsScan/src/VdrRecording.cc @@ -0,0 +1,91 @@ +/** + * ======================== legal notice ====================== + * + * File: VdrRecording.cc + * Created: 3. Juli 2012, 08:30 + * Author: Geronimo + * 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 +#include +#include +#include +#define FILE_MASK "/%05d.ts" + +cVdrRecording::cVdrRecording(const char *Name, const char *Logical, const char *Path) + : cAbstractMultiFileMovie(Name, Logical, Path, "video/mpeg", VdrRecording) +{ +} + +cVdrRecording::~cVdrRecording() +{ +} + +void cVdrRecording::Refresh(void) +{ + struct stat stBuf; + size_t total = 0; + time_t lastMod = 0; + + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) { + //TODO: some error message? + return; + } + strcpy(fileNameBuf, RealPath()); + } + movieFiles = 0; + + for (int fileNo = 1;; ++fileNo) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, fileNo); + if (stat(fileNameBuf, &stBuf) < 0) { + movieFiles = fileNo - 1; + break; + } + total += stBuf.st_size; + if (stBuf.st_mtime > lastMod) lastMod = stBuf.st_mtime; + } + SetSize(total); + SetLastModified(lastMod); +} + +const char *cVdrRecording::FirstFile(void) +{ + if (!fileNameBuf) { + if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 16))) { + //TODO: some error message? + return NULL; + } + strcpy(fileNameBuf, RealPath()); + } + curFileNo = 1; + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo); + + return fileNameBuf; +} + +const char *cVdrRecording::NextFile(void) +{ + if (++curFileNo < movieFiles) { + sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo); + + return fileNameBuf; + } + return NULL; +} diff --git a/libs/fsScan/summary.txt b/libs/fsScan/summary.txt new file mode 100644 index 0000000..0247690 --- /dev/null +++ b/libs/fsScan/summary.txt @@ -0,0 +1 @@ +libfsScan: mediatypes and filesystem scanning -- cgit v1.2.3