servicemp3.cpp: more simple/flexible streaming detection
[enigma2.git] / lib / base / rawfile.h
index bb39dc6e82a0363797fa4b0a156145cf7268887b..7b736a33afc258db8f938fdba140451092c2dd33 100644 (file)
@@ -2,39 +2,9 @@
 #define __lib_base_rawfile_h
 
 #include <string>
-#include <lib/base/object.h>
+#include <lib/base/itssource.h>
 
-class iDataSource: public iObject
-{
-public:
-       virtual off_t lseek(off_t offset, int whence)=0;
-       virtual ssize_t read(void *buf, size_t count)=0; /* NOTE: you must be able to handle short reads! */
-       virtual off_t length()=0;
-       virtual off_t position()=0;
-       virtual int valid()=0;
-       virtual eSingleLock &getLock()=0;
-       virtual bool is_shared()=0;
-};
-
-class iDataSourcePositionRestorer
-{
-       ePtr<iDataSource> &m_source;
-       off_t m_position;
-public:
-       iDataSourcePositionRestorer(ePtr<iDataSource> &source)
-               :m_source(source)
-       {
-               if (m_source->is_shared())
-                       m_position = m_source->position();
-       }
-       ~iDataSourcePositionRestorer()
-       {
-               if (m_source->is_shared())
-                       m_source->lseek(m_position, SEEK_SET);
-       }
-};
-
-class eRawFile: public iDataSource
+class eRawFile: public iTsSource
 {
        DECLARE_REF(eRawFile);
        eSingleLock m_lock;
@@ -43,14 +13,13 @@ public:
        ~eRawFile();
        int open(const char *filename, int cached = 0);
        void setfd(int fd);
-       off_t lseek(off_t offset, int whence);
        int close();
-       ssize_t read(void *buf, size_t count); /* NOTE: you must be able to handle short reads! */
+
+       // iTsSource
+       off_t lseek(off_t offset, int whence);
+       ssize_t read(off_t offset, void *buf, size_t count);
        off_t length();
-       off_t position();
        int valid();
-       eSingleLock &getLock();
-       bool is_shared() { return ref.count > 1; }
 private:
        int m_fd;     /* for uncached */
        FILE *m_file; /* for cached */
@@ -61,6 +30,8 @@ private:
        void scan();
        int m_current_file;
        int switchOffset(off_t off);
+
+       off_t lseek_internal(off_t offset, int whence);
        FILE *openFileCached(int nr);
        int openFileUncached(int nr);
 };