[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / filesystem / MythFile.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://www.xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include "IFile.h"
23 #include "ILiveTV.h"
24 #include "MythSession.h"
25 #include "XBDateTime.h"
26 #include "video/VideoInfoTag.h"
27 #include <queue>
28
29 extern "C" {
30 #include "cmyth/include/cmyth/cmyth.h"
31 }
32
33 class DllLibCMyth;
34
35 namespace XFILE
36 {
37
38
39 class CMythFile
40   : public  IFile
41   ,         ILiveTVInterface
42   ,         IRecordable
43   , private CMythSession::IEventListener
44 {
45 public:
46   CMythFile();
47   virtual ~CMythFile();
48   virtual bool          Open(const CURL& url);
49   virtual int64_t       Seek(int64_t pos, int whence=SEEK_SET);
50   virtual int64_t       GetPosition();
51   virtual int64_t       GetLength();
52   virtual int           Stat(const CURL& url, struct __stat64* buffer) { return -1; }
53   virtual void          Close();
54   virtual unsigned int  Read(void* buffer, int64_t size);
55   virtual CStdString    GetContent() { return ""; }
56   virtual bool          SkipNext();
57
58   virtual bool          Delete(const CURL& url);
59   virtual bool          Exists(const CURL& url);
60   virtual int           GetChunkSize() {return 1;};
61
62   virtual ILiveTVInterface* GetLiveTV() {return (ILiveTVInterface*)this;}
63
64   virtual bool           NextChannel(bool preview = false);
65   virtual bool           PrevChannel(bool preview = false);
66   virtual bool           SelectChannel(unsigned int channel);
67
68   virtual int            GetTotalTime();
69   virtual int            GetStartTime();
70
71   virtual bool           UpdateItem(CFileItem& item);
72
73   virtual IRecordable*   GetRecordable() {return (IRecordable*)this;}
74
75   virtual bool           CanRecord();
76   virtual bool           IsRecording();
77   virtual bool           Record(bool bOnOff);
78
79   virtual bool           GetCommBreakList(cmyth_commbreaklist_t& commbreaklist);
80   virtual bool           GetCutList(cmyth_commbreaklist_t& commbreaklist);
81
82   virtual int            IoControl(EIoControl request, void* param);
83 protected:
84   virtual void OnEvent(int event, const std::string& data);
85
86   bool HandleEvents();
87   bool ChangeChannel(int direction, const CStdString &channel);
88
89   bool SetupConnection(const CURL& url, bool control, bool event, bool database);
90   bool SetupRecording(const CURL& url);
91   bool SetupLiveTV(const CURL& url);
92   bool SetupFile(const CURL& url);
93
94   CStdString GetValue(char* str) { return m_session->GetValue(str); }
95   CDateTime  GetValue(const cmyth_timestamp_t t) { return m_session->GetValue(t); }
96
97   CMythSession*     m_session;
98   DllLibCMyth*      m_dll;
99   cmyth_conn_t      m_control;
100   cmyth_database_t  m_database;
101   cmyth_recorder_t  m_recorder;
102   cmyth_proginfo_t  m_program;
103   cmyth_file_t      m_file;
104   CStdString        m_filename;
105   CVideoInfoTag     m_infotag;
106
107   CCriticalSection  m_section;
108   std::queue<std::pair<int, std::string> > m_events;
109
110   bool              m_recording;
111
112   unsigned int      m_timestamp;
113 };
114
115 }
116
117