summaryrefslogtreecommitdiff
path: root/libs/fsScan/src/AbstractMultiFileMovie.cc
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
committergeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
commit774e09eef2d7761814e6f19fb462eb0fdc74f2d7 (patch)
treeca0c4e06afdb99139c7953a8dd5576a3bcd15e23 /libs/fsScan/src/AbstractMultiFileMovie.cc
parentab7186c6c116629983dc506c4b53794026518455 (diff)
downloadcmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.gz
cmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.bz2
worked out different file class and improved media handling
Diffstat (limited to 'libs/fsScan/src/AbstractMultiFileMovie.cc')
-rw-r--r--libs/fsScan/src/AbstractMultiFileMovie.cc89
1 files changed, 40 insertions, 49 deletions
diff --git a/libs/fsScan/src/AbstractMultiFileMovie.cc b/libs/fsScan/src/AbstractMultiFileMovie.cc
index 823130e..a5de060 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>
@@ -29,45 +29,57 @@
#include <errno.h>
#include <unistd.h>
-cAbstractMultiFileMovie::cAbstractMultiFileMovie(const char *Name, const char *Logical, const char *Path, const char *Mime, SupportedMediaType Type)
- : cMovie(Name, Logical, Path, Mime, Type)
+cAbstractMultiFileMovie::cAbstractMultiFileMovie(const cFile &File, const char *Mime, SupportedMediaType Type)
+ : cMovie(File, Mime, Type)
, movieFiles(0)
, curFileNo(0)
- , fileNameBuf(NULL)
+ , buf(NULL)
, bufSize(0)
+ , name(NULL)
{
}
cAbstractMultiFileMovie::~cAbstractMultiFileMovie()
{
- free(fileNameBuf);
+ free(name);
+ free(buf);
+}
+
+bool cAbstractMultiFileMovie::checkBuffer()
+{
+ if (!buf && bufSize) {
+ buf = (char *) malloc(bufSize);
+ }
+ return buf != NULL;
}
size_t cAbstractMultiFileMovie::ReadChunk(char* Buf, size_t bufSize)
{
long rv = 0;
+ const char *path = NULL;
if (fd < 1) {
- fd = open(FirstFile(), O_RDONLY | O_LARGEFILE);
+ path = FirstFile();
+ fd = open(path, O_RDONLY | O_LARGEFILE);
if (fd < 1) {
- esyslog("could not open requested path %s - Error #%d", FirstFile(), errno);
+ esyslog("could not open requested path %s - Error #%d", path, errno);
return 0;
}
}
- isyslog("have filehandle #%d (%s)", fd, FirstFile());
+ isyslog("have filehandle #%d (%s)", fd, path);
rv = read(fd, Buf, bufSize);
if (rv < (long) bufSize) {
- const char *nextFilename = NextFile();
+ path = NextFile();
- if (nextFilename) {
+ if (path) {
close(fd);
- fd = open(nextFilename, O_RDONLY | O_LARGEFILE);
+ fd = open(path, O_RDONLY | O_LARGEFILE);
if (fd < 1) {
- esyslog("could not open requested path %s - Error #%d", nextFilename, errno);
+ esyslog("could not open requested path %s - Error #%d", path, errno);
return 0;
}
- isyslog("have filehandle #%d (%s)", fd, nextFilename);
+ isyslog("have filehandle #%d (%s)", fd, path);
rv = read(fd, Buf, bufSize);
}
if (rv < (long) bufSize) {
@@ -78,34 +90,13 @@ size_t cAbstractMultiFileMovie::ReadChunk(char* Buf, size_t bufSize)
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;
-//}
+void cAbstractMultiFileMovie::SetName(char* Name)
+///< Name must have already been allocated from heap!
+{
+ name = Name;
+}
+
+void cAbstractMultiFileMovie::SetSize(size_t Size)
+{
+ size = Size;
+} \ No newline at end of file