VTB: release CVBuffer after it actually has been rendered
[xbmc.git] / xbmc / storage / MediaManager.h
blob3ea422ff0266a967b69172604f34e2b8467b5ea1
1 #pragma once
2 /*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
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.
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.
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/>.
22 #include <map>
23 #include <vector>
25 #include "MediaSource.h" // for VECSOURCES
26 #include "utils/Job.h"
27 #include "IStorageProvider.h"
28 #include "threads/CriticalSection.h"
30 #define TRAY_OPEN 16
31 #define TRAY_CLOSED_NO_MEDIA 64
32 #define TRAY_CLOSED_MEDIA_PRESENT 96
34 #define DRIVE_OPEN 0 // Open...
35 #define DRIVE_NOT_READY 1 // Opening.. Closing...
36 #define DRIVE_READY 2
37 #define DRIVE_CLOSED_NO_MEDIA 3 // CLOSED...but no media in drive
38 #define DRIVE_CLOSED_MEDIA_PRESENT 4 // Will be send once when the drive just have closed
39 #define DRIVE_NONE 5 // system doesn't have an optical drive
41 class CNetworkLocation
43 public:
44 CNetworkLocation() { id = 0; };
45 int id;
46 std::string path;
49 class CMediaManager : public IStorageEventsCallback, public IJobCallback
51 public:
52 CMediaManager();
54 void Initialize();
55 void Stop();
57 bool LoadSources();
58 bool SaveSources();
60 void GetLocalDrives(VECSOURCES &localDrives, bool includeQ = true);
61 void GetRemovableDrives(VECSOURCES &removableDrives);
62 void GetNetworkLocations(VECSOURCES &locations, bool autolocations = true);
64 bool AddNetworkLocation(const std::string &path);
65 bool HasLocation(const std::string& path) const;
66 bool RemoveLocation(const std::string& path);
67 bool SetLocationPath(const std::string& oldPath, const std::string& newPath);
69 void AddAutoSource(const CMediaSource &share, bool bAutorun=false);
70 void RemoveAutoSource(const CMediaSource &share);
71 bool IsDiscInDrive(const std::string& devicePath="");
72 bool IsAudio(const std::string& devicePath="");
73 bool HasOpticalDrive();
74 std::string TranslateDevicePath(const std::string& devicePath, bool bReturnAsDevice=false);
75 DWORD GetDriveStatus(const std::string& devicePath="");
76 #ifdef HAS_DVD_DRIVE
77 MEDIA_DETECT::CCdInfo* GetCdInfo(const std::string& devicePath="");
78 bool RemoveCdInfo(const std::string& devicePath="");
79 std::string GetDiskLabel(const std::string& devicePath="");
80 std::string GetDiskUniqueId(const std::string& devicePath="");
81 #endif
82 std::string GetDiscPath();
83 void SetHasOpticalDrive(bool bstatus);
85 bool Eject(const std::string& mountpath);
86 void EjectTray( const bool bEject=true, const char cDriveLetter='\0' );
87 void CloseTray(const char cDriveLetter='\0');
88 void ToggleTray(const char cDriveLetter='\0');
90 void ProcessEvents();
92 std::vector<std::string> GetDiskUsage();
94 virtual void OnStorageAdded(const std::string &label, const std::string &path);
95 virtual void OnStorageSafelyRemoved(const std::string &label);
96 virtual void OnStorageUnsafelyRemoved(const std::string &label);
98 virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job) { }
99 protected:
100 std::vector<CNetworkLocation> m_locations;
102 CCriticalSection m_muAutoSource, m_CritSecStorageProvider;
103 #ifdef HAS_DVD_DRIVE
104 std::map<std::string,MEDIA_DETECT::CCdInfo*> m_mapCdInfo;
105 #endif
106 bool m_bhasoptical;
107 std::string m_strFirstAvailDrive;
109 private:
110 IStorageProvider *m_platformStorage;
113 extern class CMediaManager g_mediaManager;