xbmc/network/upnp/upnp.a
endif
+ifeq (@USE_MDNSEMBEDDED@,1)
+DIRECTORY_ARCHIVES += xbmc/network/mdns/mdns.a
+endif
+
ifeq ($(findstring osx,@ARCH@),osx)
DIRECTORY_ARCHIVES += xbmc/osx/osx.a
DIRECTORY_ARCHIVES += xbmc/network/osx/network.a
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
+ 0E3036EC1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
+ 0E3036ED1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
+ 0E3036EE1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
183FDF8A11AF0B0500B81E9C /* PluginSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 183FDF8811AF0B0500B81E9C /* PluginSource.cpp */; };
18404DA61396C31B00863BBA /* SlingboxLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 18404DA51396C31B00863BBA /* SlingboxLib.a */; };
1840B74D13993D8A007C848B /* JSONVariantParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1840B74B13993D8A007C848B /* JSONVariantParser.cpp */; };
43BF09A21080D1E900E25290 /* AVTransportSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF099E1080D1E900E25290 /* AVTransportSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
43BF09A31080D1E900E25290 /* RenderingControlSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF099F1080D1E900E25290 /* RenderingControlSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
43BF09AB1080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF09A81080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
+ 551C3A45175A12010051AAAD /* VDA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 551C3A43175A12010051AAAD /* VDA.cpp */; };
552840CC1626163B00ED1333 /* UPnPPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 552840CA1626163B00ED1333 /* UPnPPlayer.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
552A226915F7E14B0015C0D0 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 552A226815F7E14B0015C0D0 /* main.cpp */; };
553840F215F360B400CE061B /* PltMimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 553840ED15F360B400CE061B /* PltMimeType.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
- DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
DFF0F43817528350002DA3A4 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
DFF0F43917528350002DA3A4 /* DbUrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9466115CF1FA600727135 /* DbUrl.cpp */; };
DFF0F43A17528350002DA3A4 /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
- DFF0F43B17528350002DA3A4 /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
DFF0F43C17528350002DA3A4 /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
DFF0F43D17528350002DA3A4 /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
DFF0F43E17528350002DA3A4 /* GUILargeTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E17EE0D25F9FA00618676 /* GUILargeTextureManager.cpp */; };
E38E1FFA0D25F9FD00618676 /* DetectDVDType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16840D25F9FA00618676 /* DetectDVDType.cpp */; };
E38E1FFB0D25F9FD00618676 /* DNSNameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16890D25F9FA00618676 /* DNSNameCache.cpp */; };
E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
- E38E1FFE0D25F9FD00618676 /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16970D25F9FA00618676 /* MemBufferCache.cpp */; };
E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16990D25F9FA00618676 /* CacheStrategy.cpp */; };
E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E270D25F9FD00618676 /* BitstreamStats.cpp */; };
E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E290D25F9FD00618676 /* CharsetConverter.cpp */; };
E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */; };
- E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E350D25F9FD00618676 /* Event.cpp */; };
E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E400D25F9FD00618676 /* HTMLTable.cpp */; };
E4991449174E605900741B6D /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
E499144A174E605900741B6D /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
- E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
E499144F174E605900741B6D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
E4991450174E605900741B6D /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
E4991533174E642900741B6D /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
E4991534174E642900741B6D /* DbUrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9466115CF1FA600727135 /* DbUrl.cpp */; };
E4991535174E642900741B6D /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
- E4991536174E642900741B6D /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
E4991537174E642900741B6D /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
E4991538174E642900741B6D /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
E4991539174E642900741B6D /* GUILargeTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E17EE0D25F9FA00618676 /* GUILargeTextureManager.cpp */; };
/* Begin PBXFileReference section */
0E30286C1759FCC200D93596 /* SettingsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsManager.h; sourceTree = "<group>"; };
+ 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FavouritesDirectory.cpp; sourceTree = "<group>"; };
+ 0E3036EB1760F68A00D93596 /* FavouritesDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavouritesDirectory.h; sourceTree = "<group>"; };
18308CB41303370800AA309E /* stat_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stat_utf8.h; sourceTree = "<group>"; };
18308CB51303370800AA309E /* stdio_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdio_utf8.h; sourceTree = "<group>"; };
183FDF8811AF0B0500B81E9C /* PluginSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginSource.cpp; sourceTree = "<group>"; };
43BF09A91080D2ED00E25290 /* RenderingControlSCPD_Full.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = RenderingControlSCPD_Full.xml; sourceTree = "<group>"; };
43BF09DD1080D39300E25290 /* fastmemcpy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastmemcpy.h; sourceTree = "<group>"; };
43FAC87112D6349400F67914 /* IStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IStorageProvider.h; sourceTree = "<group>"; };
+ 551C3A43175A12010051AAAD /* VDA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VDA.cpp; sourceTree = "<group>"; };
+ 551C3A44175A12010051AAAD /* VDA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VDA.h; sourceTree = "<group>"; };
552840CA1626163B00ED1333 /* UPnPPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UPnPPlayer.cpp; sourceTree = "<group>"; };
552840CB1626163B00ED1333 /* UPnPPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UPnPPlayer.h; sourceTree = "<group>"; };
552A226815F7E14B0015C0D0 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = main/main.cpp; sourceTree = "<group>"; };
88ACB01D0DCF409E0083CFDF /* ASAPCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASAPCodec.h; sourceTree = "<group>"; };
88ACB01E0DCF409E0083CFDF /* DllASAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DllASAP.h; sourceTree = "<group>"; };
88ECB6580DE013C4003396A7 /* DiskArbitration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DiskArbitration.framework; path = /System/Library/Frameworks/DiskArbitration.framework; sourceTree = "<absolute>"; };
- 8DD76F7E0486A8DE00D96B5E /* XBMC */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = XBMC; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DD76F7E0486A8DE00D96B5E /* XBMC */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = XBMC; sourceTree = BUILT_PRODUCTS_DIR; };
AE84CB5915A5B8A600A3810E /* TagLibVFSStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagLibVFSStream.cpp; sourceTree = "<group>"; };
AE84CB5C15A5B8BA00A3810E /* TagLibVFSStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagLibVFSStream.h; sourceTree = "<group>"; };
AE89ACA41621DAB800E17DBC /* DVDDemuxBXA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDDemuxBXA.cpp; sourceTree = "<group>"; };
E38E168A0D25F9FA00618676 /* DNSNameCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSNameCache.h; sourceTree = "<group>"; };
E38E168C0D25F9FA00618676 /* DynamicDll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicDll.cpp; sourceTree = "<group>"; };
E38E168D0D25F9FA00618676 /* DynamicDll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicDll.h; sourceTree = "<group>"; };
- E38E16900D25F9FA00618676 /* Favourites.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Favourites.cpp; sourceTree = "<group>"; };
- E38E16910D25F9FA00618676 /* Favourites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Favourites.h; sourceTree = "<group>"; };
E38E16920D25F9FA00618676 /* FileItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileItem.cpp; sourceTree = "<group>"; };
E38E16930D25F9FA00618676 /* FileItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileItem.h; sourceTree = "<group>"; };
E38E16970D25F9FA00618676 /* MemBufferCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemBufferCache.cpp; sourceTree = "<group>"; };
E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUInfo.cpp; sourceTree = "<group>"; };
E38E1E2C0D25F9FD00618676 /* CPUInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUInfo.h; sourceTree = "<group>"; };
E38E1E2E0D25F9FD00618676 /* CriticalSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CriticalSection.h; sourceTree = "<group>"; };
- E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueue.cpp; sourceTree = "<group>"; };
- E38E1E320D25F9FD00618676 /* DownloadQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueue.h; sourceTree = "<group>"; };
- E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueueManager.cpp; sourceTree = "<group>"; };
- E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueueManager.h; sourceTree = "<group>"; };
E38E1E350D25F9FD00618676 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
E38E1E360D25F9FD00618676 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = "<group>"; };
E38E1E3D0D25F9FD00618676 /* fstrcmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fstrcmp.h; sourceTree = "<group>"; };
36A9466215CF1FA600727135 /* DbUrl.h */,
E38E168C0D25F9FA00618676 /* DynamicDll.cpp */,
E38E168D0D25F9FA00618676 /* DynamicDll.h */,
- E38E16900D25F9FA00618676 /* Favourites.cpp */,
- E38E16910D25F9FA00618676 /* Favourites.h */,
E38E16920D25F9FA00618676 /* FileItem.cpp */,
E38E16930D25F9FA00618676 /* FileItem.h */,
E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */,
E4991590174E6ABE00741B6D /* DVDVideoCodecVideoToolBox.h */,
E38E15410D25F9F900618676 /* DVDVideoPPFFmpeg.cpp */,
E38E15420D25F9F900618676 /* DVDVideoPPFFmpeg.h */,
+ 551C3A43175A12010051AAAD /* VDA.cpp */,
+ 551C3A44175A12010051AAAD /* VDA.h */,
);
path = Video;
sourceTree = "<group>";
E38E16B10D25F9FA00618676 /* DirectoryHistory.h */,
E38E16B40D25F9FA00618676 /* DllLibCurl.cpp */,
E38E16B50D25F9FA00618676 /* DllLibCurl.h */,
+ 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */,
+ 0E3036EB1760F68A00D93596 /* FavouritesDirectory.h */,
E38E16BA0D25F9FA00618676 /* File.cpp */,
E38E16BB0D25F9FA00618676 /* File.h */,
DF93D6671444A8B0007C6459 /* FileCache.cpp */,
F5BD02F5148D3A7E001B5583 /* CryptThreading.h */,
36A9443B15821E2800727135 /* DatabaseUtils.cpp */,
36A9443C15821E2800727135 /* DatabaseUtils.h */,
- E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */,
- E38E1E320D25F9FD00618676 /* DownloadQueue.h */,
- E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */,
- E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */,
7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */,
7CC30E8916296078003E7579 /* EdenVideoArtUpdater.h */,
436B38F3106628850049AB3B /* EndianSwap.h */,
E38E1FFA0D25F9FD00618676 /* DetectDVDType.cpp in Sources */,
E38E1FFB0D25F9FD00618676 /* DNSNameCache.cpp in Sources */,
E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */,
- E38E1FFE0D25F9FD00618676 /* Favourites.cpp in Sources */,
E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */,
E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */,
E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */,
E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */,
E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */,
E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */,
- E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */,
- E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */,
E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */,
E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */,
E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */,
820023DB171A28A300667D1C /* OSXTextInputResponder.mm in Sources */,
DF529BAE1741697B00523FB4 /* Environment.cpp in Sources */,
DFE4095B17417FDF00473BD9 /* LegacyPathTranslation.cpp in Sources */,
+ 0E3036EC1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
+ 551C3A45175A12010051AAAD /* VDA.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */,
DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */,
DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */,
- DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */,
- DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */,
DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */,
DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */,
DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */,
DFF0F43817528350002DA3A4 /* DatabaseManager.cpp in Sources */,
DFF0F43917528350002DA3A4 /* DbUrl.cpp in Sources */,
DFF0F43A17528350002DA3A4 /* DynamicDll.cpp in Sources */,
- DFF0F43B17528350002DA3A4 /* Favourites.cpp in Sources */,
DFF0F43C17528350002DA3A4 /* FileItem.cpp in Sources */,
DFF0F43D17528350002DA3A4 /* GUIInfoManager.cpp in Sources */,
DFF0F43E17528350002DA3A4 /* GUILargeTextureManager.cpp in Sources */,
DF3C3C0E1752A7EE000989C3 /* IOSEAGLView.mm in Sources */,
DF3C3C0F1752A7EE000989C3 /* IOSExternalTouchController.mm in Sources */,
DF3C3C101752A7EE000989C3 /* IOSScreenManager.mm in Sources */,
+ 0E3036EE1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E4991449174E605900741B6D /* Crc32.cpp in Sources */,
E499144A174E605900741B6D /* CryptThreading.cpp in Sources */,
E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */,
- E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */,
- E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */,
E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */,
E499144F174E605900741B6D /* Environment.cpp in Sources */,
E4991450174E605900741B6D /* Fanart.cpp in Sources */,
E4991533174E642900741B6D /* DatabaseManager.cpp in Sources */,
E4991534174E642900741B6D /* DbUrl.cpp in Sources */,
E4991535174E642900741B6D /* DynamicDll.cpp in Sources */,
- E4991536174E642900741B6D /* Favourites.cpp in Sources */,
E4991537174E642900741B6D /* FileItem.cpp in Sources */,
E4991538174E642900741B6D /* GUIInfoManager.cpp in Sources */,
E4991539174E642900741B6D /* GUILargeTextureManager.cpp in Sources */,
E4991592174E6B5C00741B6D /* fstrcmp.c in Sources */,
E4991593174E707400741B6D /* cc_decoder.c in Sources */,
E4991596174E70BF00741B6D /* yuv2rgb.neon.S in Sources */,
+ 0E3036ED1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
hal_disabled="== HAL support disabled. =="
avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
avahi_disabled="== Avahi support disabled. =="
+mdnsembedded_not_found="== Could not find mDNSEmbedded. Might prevent zeroconf support. =="
+mdnsembedded_disabled="== mDNSEmbedded support disabled. =="
vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
vdpau_disabled="== VDPAU support manually disabled. =="
vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
[disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
[use_avahi=$enableval],
[use_avahi=yes])
+
+ AC_ARG_ENABLE([mdnsembedded],
+ [AS_HELP_STRING([--disable-mdnsembedded],
+ [disable mDNSEmbedded support (default is auto)])],
+ [use_mdnsembedded=$enableval],
+ [use_mdnsembedded=auto])
AC_ARG_ENABLE([non-free],
[AS_HELP_STRING([--disable-non-free],
use_cpu=arm1176jzf-s
use_hardcoded_tables="yes"
use_alsa="no"
- USE_TEXTUREPACKER_NATIVE_ROOT="$TEXTUREPACKER_NATIVE_ROOT"
ARCH="arm"
AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
fi
fi
+# mdnsembedded
+if test "$use_mdnsembedded" != "no"; then
+ AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],,
+ [if test "$use_mdnsembedded" = "yes"; then
+ AC_MSG_ERROR($mdnsembedded_not_found)
+ USE_MDNSEMBEDDED=0
+ elif test "$use_mdnsembedded" != "no"; then
+ AC_MSG_NOTICE($mdnsembedded_not_found)
+ use_mdnsembedded="no"
+ USE_MDNSEMBEDDED=0
+ fi
+ ])
+ if test $use_mdnsembedded != "no"; then
+ USE_MDNSEMBEDDED=1
+ fi
+else
+ AC_MSG_RESULT($mdnsembedded_disabled)
+ USE_MDNSEMBEDDED=0
+fi
+AC_SUBST(USE_MDNSEMBEDDED)
+
# X11
if test "$use_x11" = "yes" && test "$host_vendor" != "apple"; then
AC_MSG_NOTICE($x11_enabled)
if test "$use_external_ffmpeg" = "yes"; then
FFMPEG_LIBNAMES="libavcodec libavfilter libavformat libavutil libpostproc libswscale"
- # libavcore is optional
- PKG_CHECK_EXISTS([libavcore], FFMPEG_LIBNAMES="$FFMPEG_LIBNAMES libavcore")
-
# one of libswresample or libavresample is needed
PKG_CHECK_EXISTS([libswresample], FFMPEG_LIBNAMES="$FFMPEG_LIBNAMES libswresample",
[PKG_CHECK_EXISTS([libavresample],
[INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"],
AC_MSG_ERROR($missing_library))
- # Determine whether AVPacket and relevant functions are defined in libavformat
- # or libavcodec
- AC_CHECK_LIB([avcodec], [av_free_packet],
- [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavcodec. ==)],
- [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavformat. ==)
- AC_DEFINE([AVPACKET_IN_AVFORMAT], [1], [Whether AVPacket is in libavformat.])])
-
# in case the headers are in a custom directory
SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
- # Possible places the ffmpeg headers may be
AC_CHECK_HEADERS([libavcodec/avcodec.h libavfilter/avfilter.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
- [AC_CHECK_HEADERS([ffmpeg/avcodec.h ffmpeg/avfilter.h ffmpeg/avformat.h ffmpeg/avutil.h postproc/postprocess.h ffmpeg/swscale.h],,
- [AC_MSG_ERROR($missing_headers)])])
-
- # optional
- AC_CHECK_HEADERS([libavcore/avcore.h libavcore/samplefmt.h libavutil/mem.h libavutil/samplefmt.h])
-
- # old FFmpeg have this in libavcodec/opt.h instead:
- AC_CHECK_HEADERS([libavutil/opt.h])
-
- # new FFmpeg have math headers
- AC_CHECK_HEADERS([libavutil/mathematics.h],,)
-
- # We'll support the use of rgb2rgb.h if it exists.
- AC_CHECK_HEADERS([libswscale/rgb2rgb.h],,)
- AC_CHECK_HEADERS([ffmpeg/rgb2rgb.h],,)
+ [AC_MSG_ERROR($missing_headers)])
# Check for libswresample or libavresample headers.
AC_CHECK_HEADERS([libswresample/swresample.h libavresample/avresample.h])
- # Check if AVFilterBufferRefVideoProps AVRational member is named
- # 'pixel_aspect' or 'sample_aspect_ratio'.
- AC_CHECK_MEMBER([AVFilterBufferRefVideoProps.sample_aspect_ratio],
- [AC_DEFINE([HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO],
- [1],
- [Define to 1 if AVFilterBufferRefVideoProps has member sample_aspect_ratio.])],
- [AC_CHECK_MEMBER([AVFilterBufferRefVideoProps.sample_aspect_ratio],
- [AC_DEFINE([HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO],
- [1],
- [Define to 1 if AVFilterBufferRefVideoProps has member sample_aspect_ratio.])],
- ,
- [[#include <ffmpeg/avfilter.h>]])],
- [[#include <libavfilter/avfilter.h>]])
-
AC_MSG_NOTICE($external_ffmpeg_enabled)
USE_EXTERNAL_FFMPEG=1
AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])
AC_MSG_RESULT($ffmpeg_vdpau_not_supported)
fi])
- # Check for 'PIX_FMT_VDPAU_MPEG4' from libavutil
- if test "x$use_vdpau" != "xno"; then
- AC_LANG_PUSH([C++])
- AC_LINK_IFELSE(
- [AC_LANG_SOURCE([ #include <libavutil/pixfmt.h>
- int main() { PixelFormat format = PIX_FMT_VDPAU_MPEG4; }])],
- [AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1],
- [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])],)
- AC_LANG_POP([C++])
- fi
CPPFLAGS="$SAVE_CPPFLAGS"
else
AC_MSG_NOTICE($external_ffmpeg_disabled)
USE_EXTERNAL_FFMPEG=0
- AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1], [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])
fi
echo "Checking for SWIG installation"
final_message="$final_message\n Avahi:\tNo"
fi
+if test "$use_mdnsembedded" != "no"; then
+ final_message="$final_message\n mDNSEmbedded:\tYes"
+else
+ final_message="$final_message\n mDNSEmbedded:\tNo"
+fi
+
if test "$use_nonfree" = "yes"; then
final_message="$final_message\n Non-free:\tYes"
HAVE_XBMC_NONFREE=1
ffmpg_config="$ffmpg_config --disable-devices --disable-doc"
ffmpg_config="$ffmpg_config --disable-ffplay --disable-ffmpeg"
ffmpg_config="$ffmpg_config --disable-ffprobe --disable-ffserver"
- ffmpg_config="$ffmpg_config --disable-vda --disable-crystalhd"
+ ffmpg_config="$ffmpg_config --enable-vda --disable-crystalhd"
ffmpg_config="$ffmpg_config --disable-decoder=mpeg_xvmc"
# handle conditional enables/disables
msgstr ""
#: system/settings/darwin.xml
+#: system/settings/settings.xml
msgctxt "#14046"
msgid "%i ms"
msgstr ""
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVCODEC_AVCODEC_H)
- #include <libavcodec/avcodec.h>
- #if (defined HAVE_LIBAVCODEC_OPT_H)
- #include <libavcodec/opt.h>
- #endif
- #if (defined AVPACKET_IN_AVFORMAT)
- #include <libavformat/avformat.h>
- #endif
- #elif (defined HAVE_FFMPEG_AVCODEC_H)
- #include <ffmpeg/avcodec.h>
- #include <ffmpeg/opt.h>
- #if (defined AVPACKET_IN_AVFORMAT)
- #include <ffmpeg/avformat.h>
- #endif
- #endif
+ #include <libavcodec/avcodec.h>
#else
#include "libavcodec/avcodec.h"
#endif
/* dependencies of libavcodec */
DllAvUtil m_dllAvUtil;
- // DllAvUtil loaded implicitely by m_dllAvCore
public:
static CCriticalSection m_critSection;
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVFILTER_AVFILTER_H)
- #include <libavfilter/avfiltergraph.h>
- #include <libavfilter/buffersink.h>
- #include <libavfilter/avcodec.h>
- #elif (defined HAVE_FFMPEG_AVFILTER_H)
- #include <ffmpeg/avfiltergraph.h>
- #include <ffmpeg/buffersink.h>
- #include <ffmpeg/avcodec.h>
- #endif
+ #include <libavfilter/avfiltergraph.h>
+ #include <libavfilter/buffersink.h>
+ #include <libavfilter/avcodec.h>
#else
#include "libavfilter/avfiltergraph.h"
#include "libavfilter/buffersink.h"
#pragma warning(disable:4244)
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVFORMAT_AVFORMAT_H)
- #include <libavformat/avformat.h>
- #else
- #include <ffmpeg/avformat.h>
- #endif
+ #include <libavformat/avformat.h>
/* xbmc_read_frame_flush() is defined for us in lib/xbmc-dll-symbols/DllAvFormat.c */
void xbmc_read_frame_flush(AVFormatContext *s);
#else
extern "C" {
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVUTIL_AVUTIL_H)
- #include <libavutil/avutil.h>
- // for av_get_default_channel_layout
- #include <libavutil/audioconvert.h>
- #include <libavutil/crc.h>
- #include <libavutil/fifo.h>
- // for enum AVSampleFormat
- #include <libavutil/samplefmt.h>
- // for LIBAVCODEC_VERSION_INT:
- #include <libavcodec/avcodec.h>
- #elif (defined HAVE_FFMPEG_AVUTIL_H)
- #include <ffmpeg/avutil.h>
- // for av_get_default_channel_layout
- #include <ffmpeg/audioconvert.h>
- #include <ffmpeg/crc.h>
- #include <ffmpeg/fifo.h>
- // for enum AVSampleFormat
- #include <ffmpeg/samplefmt.h>
- // for LIBAVCODEC_VERSION_INT:
- #include <ffmpeg/avcodec.h>
- #endif
- #if defined(HAVE_LIBAVUTIL_OPT_H)
- #include <libavutil/opt.h>
- #elif defined(HAVE_LIBAVCODEC_AVCODEC_H)
- #include <libavcodec/opt.h>
- #else
- #include <ffmpeg/opt.h>
- #endif
- #if defined(HAVE_LIBAVUTIL_MEM_H)
- #include <libavutil/mem.h>
- #else
- #include <ffmpeg/mem.h>
- #endif
- #if (defined HAVE_LIBAVUTIL_MATHEMATICS_H)
- #include <libavutil/mathematics.h>
- #endif
+ #include <libavutil/avutil.h>
+ // for av_get_default_channel_layout
+ #include <libavutil/audioconvert.h>
+ #include <libavutil/crc.h>
+ #include <libavutil/fifo.h>
+ // for LIBAVCODEC_VERSION_INT:
+ #include <libavcodec/avcodec.h>
+ // for enum AVSampleFormat
+ #include <libavutil/samplefmt.h>
+ #include <libavutil/opt.h>
+ #include <libavutil/mem.h>
+ #include <libavutil/mathematics.h>
#else
#include "libavutil/avutil.h"
//for av_get_default_channel_layout
virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) = 0;
virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) = 0;
virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0;
+ virtual void av_dict_free(AVDictionary **pm) = 0;
virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
virtual int64_t av_get_default_channel_layout(int nb_channels)=0;
};
{ return ::av_get_bytes_per_sample(p1); }
virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags){ return ::av_dict_get(m, key, prev, flags); }
virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { return ::av_dict_set(pm, key, value, flags); }
+ virtual void av_dict_free(AVDictionary **pm) { ::av_dict_free(pm); }
virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
{ return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); }
virtual int64_t av_get_default_channel_layout(int nb_channels) { return ::av_get_default_channel_layout(nb_channels); }
DEFINE_METHOD1(int, av_get_bytes_per_sample, (enum AVSampleFormat p1))
DEFINE_METHOD4(AVDictionaryEntry *, av_dict_get, (AVDictionary *p1, const char *p2, const AVDictionaryEntry *p3, int p4))
DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4));
+ DEFINE_METHOD1(void, av_dict_free, (AVDictionary **p1));
DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
DEFINE_METHOD1(int64_t, av_get_default_channel_layout, (int p1))
RESOLVE_METHOD(av_get_bytes_per_sample)
RESOLVE_METHOD(av_dict_get)
RESOLVE_METHOD(av_dict_set)
+ RESOLVE_METHOD(av_dict_free)
RESOLVE_METHOD(av_samples_get_buffer_size)
RESOLVE_METHOD(av_get_default_channel_layout)
END_METHOD_RESOLVE()
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVUTIL_AVUTIL_H)
- #include <libavutil/avutil.h>
- #elif (defined HAVE_FFMPEG_AVUTIL_H)
- #include <ffmpeg/avutil.h>
- #endif
- #if (defined HAVE_LIBPOSTPROC_POSTPROCESS_H)
- #include <libpostproc/postprocess.h>
- #elif (defined HAVE_POSTPROC_POSTPROCESS_H)
- #include <postproc/postprocess.h>
- #endif
+ #include <libavutil/avutil.h>
+ #include <libpostproc/postprocess.h>
#else
#include "libavutil/avutil.h"
#include "libpostproc/postprocess.h"
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBSWSCALE_SWSCALE_H)
- #include <libswscale/swscale.h>
- #elif (defined HAVE_FFMPEG_SWSCALE_H)
- #include <ffmpeg/swscale.h>
- #endif
+ #include <libswscale/swscale.h>
#else
#include "libswscale/swscale.h"
#endif
}
-#if !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(TARGET_POSIX)
void CommandData::ParseEnvVar()
{
char *EnvStr=getenv("RAR");
-#if !defined(_LINUX) && !defined(_XBMC)
+#if !defined(TARGET_POSIX) && !defined(_XBMC)
#include "rar.hpp"
#ifndef GUI
Key[2]=0x7515A235L;
Key[3]=0xA4E7F123L;
memset(Psw,0,sizeof(Psw));
-#if defined(_WIN_32) && !defined(GUI) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(GUI) && !defined(TARGET_POSIX)
CharToOemBuff(Password,(char*)Psw,strlen(Password));
#else
strncpy((char *)Psw,Password,MAXPASSWORD-1);
void _stdfunction ProcessSignal(int SigType)
#endif
{
-#if defined(_WIN_32) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(TARGET_POSIX)
if (SigType==CTRL_LOGOFF_EVENT)
return(TRUE);
#endif
#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
ExtRes.UnloadDLL();
#endif
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
exit(USER_BREAK);
#endif
#ifdef _WIN_32
throw Code;
#else
File::RemoveCreated();
-#if !defined(_XBMC) && !defined(_LINUX)
+#if !defined(_XBMC) && !defined(TARGET_POSIX)
exit(Code);
#endif
#endif
{*/
if (!SkipClose)
{
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
//success=CloseHandle(hFile) != FALSE;
m_File.Close();
#else
while (1)
{
bool success = true;
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
DWORD Written=0;
if (HandleType!=FILE_HANDLENORMAL)
{
#endif
if (ErrHandler.AskRepeatWrite(FileName))
{
-#if !defined(_WIN_32) && !defined(_LINUX)
+#if !defined(_WIN_32) && !defined(TARGET_POSIX)
clearerr(hFile);
#endif
if (Written<(unsigned int)Size && Written>0)
Offset=(Method==SEEK_CUR ? Tell():FileLength())+Offset;
Method=SEEK_SET;
}*/
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
//LONG HighDist=int64to32(Offset>>32);
//if (SetFilePointer(hFile,int64to32(Offset),&HighDist,Method)==0xffffffff &&
if (Offset > FileLength())
Int64 File::Tell()
{
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
//LONG HighDist=0;
//uint LowDist=SetFilePointer(hFile,0,&HighDist,FILE_CURRENT);
//Int64 pos = m_File.GetPosition();
void File::GetOpenFileTime(RarTime *ft)
{
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
/* FILETIME FileTime;
GetFileTime(hFile,NULL,NULL,&FileTime);
*ft=FileTime;*/
{
/*if (hFile==BAD_HANDLE)
return(false);*/
-#if defined(_XBOX) || defined(_LINUX) || defined(_XBMC)
+#if defined(_XBOX) || defined(TARGET_POSIX) || defined(_XBMC)
return false;
//#ifdef _WIN_32
#elif defined(_WIN_32)
#include "rar.hpp"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XFileUtils.h"
#endif
bool IsRemovable(const char *Name)
{
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
return false;
//#ifdef _WIN_32
#elif defined(_WIN_32)
#ifndef SFX_MODULE
Int64 GetFreeDisk(const char *Name)
{
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
char Root[NM];
GetPathRoot(Name,Root);
bool FileExist(const char *Name,const wchar *NameW)
{
#ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
if (WinNT() && NameW!=NULL && *NameW!=0)
return(GetFileAttributesW(NameW)!=0xffffffff);
else
uint GetFileAttr(const char *Name,const wchar *NameW)
{
#ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
if (WinNT() && NameW!=NULL && *NameW!=0)
return(GetFileAttributesW(NameW));
else
{
bool success;
#ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
if (WinNT() && NameW!=NULL && *NameW!=0)
success=SetFileAttributesW(NameW,Attr)!=0;
else
{
#ifdef _WIN_32
//#ifndef _WIN_CE
-#if !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(_WIN_CE) && !defined(TARGET_POSIX)
char FullName[NM],*NamePtr;
if (GetFullPathName(Src,sizeof(FullName),FullName,&NamePtr))
strcpy(Dest,FullName);
#endif
{
//#ifndef _WIN_CE
-#if !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(_WIN_CE) && !defined(TARGET_POSIX)
wchar FullName[NM],*NamePtr;
if (GetFullPathNameW(Src,sizeof(FullName)/sizeof(FullName[0]),FullName,&NamePtr))
strcpyw(Dest,FullName);
CurStr++;
}
}
-#if defined(_WIN_32) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(TARGET_POSIX)
if (ConvertToAnsi)
OemToChar(CurStr,CurStr);
#endif
#ifdef _WIN_32
HANDLE FindFile::Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,struct FindData *fd)
{
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
#ifndef _WIN_CE
if (WinNT())
#endif
#ifndef _RAR_OS_
#define _RAR_OS_
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
#include <windows.h>
#endif
#include "system.h"
#include <prsht.h>
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
#include "PlatformDefs.h"
#endif
#elif defined(_WIN_32)
if (Number!=0)
return(false);
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
GetModuleFileName(NULL,Path,NM);
RemoveNameFromPath(Path);
#endif
extern "C" void __crt0_load_environment_file (char *progname) { }
#endif
-#if !defined(GUI) && !defined(RARDLL) && !defined(_LINUX) && !defined(_XBMC)
+#if !defined(GUI) && !defined(RARDLL) && !defined(TARGET_POSIX) && !defined(_XBMC)
int main(int argc, char *argv[])
{
#ifdef _UNIX
#endif
-#if defined(_LINUX) || defined(_XBMC)
+#if defined(TARGET_POSIX) || defined(_XBMC)
/*-------------------------------------------------------------------------*\
XBOX interface
\*-------------------------------------------------------------------------*/
const int N_INDEXES=N1+N2+N3+N4;
// FIXME, this is probably broken on OS X.
-#if (defined(__GNUC__) || defined(_LINUX)) && !defined(__APPLE__)
+#if (defined(__GNUC__) || defined(TARGET_POSIX)) && !defined(TARGET_DARWIN)
#define _PACK_ATTR __attribute__ ((__packed__))
#else
#define _PACK_ATTR
#endif /* defined(__GNUC__) */
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#pragma pack(1)
#endif
struct RAR_MEM_BLK
void SupportDBCS::Init()
{
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
DBCSMode = true;
for (int I=0;I<sizeof(IsLeadByte)/sizeof(IsLeadByte[0]);I++)
IsLeadByte[I]=true;
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\addons;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;..\..\..\..\..\xbmc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\addons;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;..\..\..\..\..\xbmc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
*
* @deprecated Use synchronous decoding mode.
*/
-typedef struct {
+typedef struct vda_frame {
/**
* The PTS of the frame.
*
typedef __int64 s64;
#define U64F "I64"
#endif
-#ifdef _LINUX
+#ifndef _WIN32
typedef unsigned long long u64;
typedef signed long long s64;
#define U64F "l"
#endif
HTTP_ConnectionWatch *update_watch;
-
-#if !defined(WIN32) && !defined(_LINUX)
- // why is this here?
- SDiscover *discover;
-#endif
};
typedef struct
and tests it for death */
ts_mutex mtWorkerLock;
-#ifndef _LINUX
+#ifdef _WIN32
fnDiscUpdated pfnUpdateCallback;
#endif
void *pvCallbackArg;
struct CP_SThreadPool *tp;
-#ifndef _LINUX
+#ifdef _WIN32
mdnsd mdnsd_info;
#endif
int socket;
// answers
/* answers */
int pending_hosts;
-#ifndef _LINUX
+#ifdef _WIN32
SDiscover_HostList *prenamed;
SDiscover_HostList *pending;
SDiscover_HostList *have;
<ClCompile Include="..\..\xbmc\epg\EpgInfoTag.cpp" />
<ClCompile Include="..\..\xbmc\epg\EpgSearchFilter.cpp" />
<ClCompile Include="..\..\xbmc\epg\GUIEPGGridContainer.cpp" />
- <ClCompile Include="..\..\xbmc\Favourites.cpp" />
<ClCompile Include="..\..\xbmc\FileItem.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\AddonsDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\AFPDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\DllLibCurl.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\File.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp" />
+ <ClCompile Include="..\..\xbmc\filesystem\FavouritesDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FileDirectoryFactory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FileFactory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FileReaderFile.cpp" />
<ClCompile Include="..\..\xbmc\network\httprequesthandler\HTTPWebinterfaceAddonsHandler.cpp" />
<ClCompile Include="..\..\xbmc\network\httprequesthandler\HTTPWebinterfaceHandler.cpp" />
<ClCompile Include="..\..\xbmc\network\httprequesthandler\IHTTPRequestHandler.cpp" />
+ <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.cpp" />
+ <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfMDNS.cpp" />
<ClCompile Include="..\..\xbmc\network\Network.cpp" />
<ClCompile Include="..\..\xbmc\network\NetworkServices.cpp" />
<ClCompile Include="..\..\xbmc\network\Socket.cpp" />
<ClCompile Include="..\..\xbmc\network\websocket\WebSocketV13.cpp" />
<ClCompile Include="..\..\xbmc\network\websocket\WebSocketV8.cpp" />
<ClCompile Include="..\..\xbmc\network\windows\NetworkWin32.cpp" />
- <ClCompile Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.cpp" />
- <ClCompile Include="..\..\xbmc\network\windows\ZeroconfWIN.cpp" />
<ClCompile Include="..\..\xbmc\network\Zeroconf.cpp" />
<ClCompile Include="..\..\xbmc\network\ZeroconfBrowser.cpp" />
<ClCompile Include="..\..\xbmc\NfoFile.cpp" />
<ClInclude Include="..\..\xbmc\network\httprequesthandler\IHTTPRequestHandler.h" />
<ClInclude Include="..\..\xbmc\filesystem\CircularCache.h" />
<ClInclude Include="..\..\xbmc\filesystem\DirectoryCache.h" />
+ <ClInclude Include="..\..\xbmc\filesystem\FavouritesDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\FileCache.h" />
<ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h" />
<ClInclude Include="..\..\xbmc\filesystem\AddonsDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\ZipDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\ZipFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\ZipManager.h" />
- <ClInclude Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.h" />
+ <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.h" />
<ClInclude Include="..\..\xbmc\peripherals\devices\PeripheralImon.h" />
<ClInclude Include="..\..\xbmc\system_gl.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
<ClCompile Include="..\..\xbmc\utils\CPUInfo.cpp" />
<ClCompile Include="..\..\xbmc\utils\Crc32.cpp" />
<ClCompile Include="..\..\xbmc\utils\DatabaseUtils.cpp" />
- <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp" />
- <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp" />
<ClCompile Include="..\..\xbmc\utils\EdenVideoArtUpdater.cpp" />
<ClCompile Include="..\..\xbmc\utils\EndianSwap.cpp" />
<ClCompile Include="..\..\xbmc\utils\Fanart.cpp" />
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
<ClCompile Include="..\..\xbmc\win32\stdio_utf8.cpp" />
<ClCompile Include="..\..\xbmc\win32\strverscmp.cpp" />
<ClCompile Include="..\..\xbmc\win32\Win32DelayedDllLoad.cpp" />
- <ClCompile Include="..\..\xbmc\win32\win32env.cpp" />
<ClCompile Include="..\..\xbmc\win32\WIN32Util.cpp" />
<ClCompile Include="..\..\xbmc\win32\WindowHelper.cpp" />
<ClCompile Include="..\..\xbmc\win32\XBMC_PC.cpp">
<ClInclude Include="..\..\xbmc\epg\EpgInfoTag.h" />
<ClInclude Include="..\..\xbmc\epg\EpgSearchFilter.h" />
<ClInclude Include="..\..\xbmc\epg\GUIEPGGridContainer.h" />
- <ClInclude Include="..\..\xbmc\Favourites.h" />
<ClInclude Include="..\..\xbmc\FileItem.h" />
<ClInclude Include="..\..\xbmc\filesystem\PVRDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\PVRFile.h" />
<ClInclude Include="..\..\xbmc\network\EventServer.h" />
<ClInclude Include="..\..\xbmc\network\GUIDialogAccessPoints.h" />
<ClInclude Include="..\..\xbmc\network\GUIDialogNetworkSetup.h" />
+ <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfMDNS.h" />
<ClInclude Include="..\..\xbmc\network\Network.h" />
<ClInclude Include="..\..\xbmc\network\Socket.h" />
<ClInclude Include="..\..\xbmc\network\TCPServer.h" />
<ClInclude Include="..\..\xbmc\network\UdpClient.h" />
<ClInclude Include="..\..\xbmc\network\WebServer.h" />
<ClInclude Include="..\..\xbmc\network\windows\NetworkWin32.h" />
- <ClInclude Include="..\..\xbmc\network\windows\ZeroconfWIN.h" />
<ClInclude Include="..\..\xbmc\network\Zeroconf.h" />
<ClInclude Include="..\..\xbmc\network\ZeroconfBrowser.h" />
<ClInclude Include="..\..\xbmc\NfoFile.h" />
<ClInclude Include="..\..\xbmc\utils\CPUInfo.h" />
<ClInclude Include="..\..\xbmc\utils\Crc32.h" />
<ClInclude Include="..\..\xbmc\utils\DatabaseUtils.h" />
- <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h" />
- <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h" />
<ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h" />
<ClInclude Include="..\..\xbmc\utils\EndianSwap.h" />
<ClInclude Include="..\..\xbmc\utils\Fanart.h" />
<Filter Include="input\touch\generic">
<UniqueIdentifier>{d062c356-66f2-49e7-9510-b216701d2298}</UniqueIdentifier>
</Filter>
+ <Filter Include="network\mdns">
+ <UniqueIdentifier>{4deb3d70-7772-42be-8884-4a550c1ff666}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\xbmc\win32\pch.cpp">
<ClCompile Include="..\..\xbmc\utils\Crc32.cpp">
<Filter>utils</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp">
- <Filter>utils</Filter>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp">
- <Filter>utils</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\Fanart.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\win32\Win32DelayedDllLoad.cpp">
<Filter>win32</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\win32\win32env.cpp">
- <Filter>win32</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\interfaces\json-rpc\InputOperations.cpp">
<Filter>interfaces\json-rpc</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\utils\HttpParser.cpp">
<Filter>utils</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\network\windows\ZeroconfWIN.cpp">
- <Filter>network\windows</Filter>
+ <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfMDNS.cpp">
+ <Filter>network\mdns</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\peripherals\Peripherals.cpp">
<Filter>peripherals</Filter>
<ClCompile Include="..\..\xbmc\filesystem\DirectoryCache.cpp">
<Filter>filesystem</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\filesystem\FavouritesDirectory.cpp">
+ <Filter>filesystem</Filter>
+ </ClCompile>
<ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp">
<Filter>filesystem</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\network\ZeroconfBrowser.cpp">
<Filter>network</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.cpp">
- <Filter>network\windows</Filter>
+ <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.cpp">
+ <Filter>network\mdns</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\cores\AudioEngine\Encoders\AEEncoderFFmpeg.cpp">
<Filter>cores\AudioEngine\Encoders</Filter>
<ClCompile Include="..\..\xbmc\ApplicationMessenger.cpp" />
<ClCompile Include="..\..\xbmc\Autorun.cpp" />
<ClCompile Include="..\..\xbmc\AutoSwitch.cpp" />
- <ClCompile Include="..\..\xbmc\Favourites.cpp" />
<ClCompile Include="..\..\xbmc\DynamicDll.cpp" />
<ClCompile Include="..\..\xbmc\CueDocument.cpp" />
<ClCompile Include="..\..\xbmc\FileItem.cpp" />
<ClCompile Include="..\..\xbmc\utils\test\TestDatabaseUtils.cpp">
<Filter>utils\test</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
- <Filter>utils\test</Filter>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
- <Filter>utils\test</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
<Filter>utils\test</Filter>
</ClCompile>
<ClInclude Include="..\..\xbmc\utils\Crc32.h">
<Filter>utils</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h">
- <Filter>utils</Filter>
- </ClInclude>
- <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h">
- <Filter>utils</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\utils\HttpParser.h">
<Filter>utils</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\network\windows\ZeroconfWIN.h">
- <Filter>network\windows</Filter>
+ <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfMDNS.h">
+ <Filter>network\mdns</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\network\DllLibPlist.h">
<Filter>network</Filter>
<ClInclude Include="..\..\xbmc\filesystem\DirectoryCache.h">
<Filter>filesystem</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\filesystem\FavouritesDirectory.h">
+ <Filter>filesystem</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\filesystem\FileCache.h">
<Filter>filesystem</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\network\ZeroconfBrowser.h">
<Filter>network</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.h">
- <Filter>network\windows</Filter>
+ <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.h">
+ <Filter>network\mdns</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\cores\AudioEngine\Encoders\AEEncoderFFmpeg.h">
<Filter>cores\AudioEngine\Encoders</Filter>
<ClInclude Include="..\..\xbmc\ApplicationMessenger.h" />
<ClInclude Include="..\..\xbmc\Autorun.h" />
<ClInclude Include="..\..\xbmc\AutoSwitch.h" />
- <ClInclude Include="..\..\xbmc\Favourites.h" />
<ClInclude Include="..\..\xbmc\DynamicDll.h" />
<ClInclude Include="..\..\xbmc\CueDocument.h" />
<ClInclude Include="..\..\xbmc\FileItem.h" />
SET TMP_DIR=%DEPS_DIR%\tmp
SET LIBNAME=xbmc-pvr-addons
-SET VERSION=5ef7f7f88c9dd3ca9c1daf57e7c92c005faa5910
+SET VERSION=d9165b4e701f1655df03562acd87eb7309544fc3
SET SOURCE=%LIBNAME%
SET GIT_URL=git://github.com/opdenkamp/%LIBNAME%.git
SET SOURCE_DIR=%TMP_DIR%\%SOURCE%
<global>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="1">FullScreen</button>
<button id="2">Select</button>
<button id="3">Back</button>
<Home>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="3">XBMC.ActivateWindow(Favourites)</button>
</joystick>
</Home>
<MyMusicFiles>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="4">Queue</button>
</joystick>
</MyMusicFiles>
<MyMusicLibrary>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="4">Queue</button>
</joystick>
</MyMusicLibrary>
<FullscreenVideo>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="2">Pause</button>
<button id="3">Stop</button>
<button id="4">AspectRatio</button>
<FullscreenLiveTV>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<hat id="1" position="left">PreviousChannelGroup</hat>
<hat id="1" position="right">NextChannelGroup</hat>
<hat id="1" position="up">ChannelUp</hat>
<Visualisation>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="2">Pause</button>
<button id="3">Stop</button>
<button id="4">XBMC.ActivateWindow(VisualisationPresetList)</button>
<SlideShow>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="1">ZoomNormal</button>
<button id="2">Pause</button>
<button id="3">Stop</button>
<ScreenCalibration>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="2">NextCalibration</button>
</joystick>
</ScreenCalibration>
<MyVideoLibrary>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="4">Queue</button>
<button id="5">Info</button>
</joystick>
<MyVideoFiles>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="4">Queue</button>
<button id="5">Info</button>
</joystick>
<VirtualKeyboard>
<joystick name="Logitech Logitech Cordless RumblePad 2">
<altname>Logitech Cordless RumblePad 2</altname>
+ <altname>Logitech RumblePad 2 USB</altname>
<button id="1">Symbols</button>
<button id="3">BackSpace</button>
<button id="4">Shift</button>
</group>
</category>
</section>
+ <section id="videos">
+ <category id="videoplayer">
+ <group id="2">
+ <setting id="videoplayer.usevda" type="boolean" label="13429" help="36160">
+ <level>2</level>
+ <default>true</default>
+ </setting>
+ </group>
+ </category>
+ </section>
</settings>
+
+
<?xml version="1.0" encoding="utf-8" ?>
-<settings><section id="system">
+<settings>
+ <section id="videos">
+ <category id="videoplayer">
+ <group id="2">
+ <setting id="videoplayer.rendermethod">
+ <visible>false</visible>
+ </setting>
+ <setting id="videoplayer.hqscalers">
+ <visible>false</visible>
+ </setting>
+ <setting id="videoplayer.synctype">
+ <visible>false</visible>
+ </setting>
+ </group>
+ </category>
+ </section>
+
+ <section id="system">
<category id="videoscreen">
<group id="1">
<setting id="videoscreen.screen">
<visible>false</visible>
</setting>
+ <setting id="videoscreen.blankdisplays">
+ <visible>false</visible>
+ </setting>
+ <setting id="videoscreen.fakefullscreen">
+ <visible>false</visible>
+ </setting>
</group>
</category>
<category id="audiooutput">
<setting id="audiooutput.mode">
<default>2</default> <!-- AUDIO_HDMI -->
</setting>
+ <setting id="audiooutput.channels">
+ <visible>false</visible>
+ </setting>
+ <setting id="audiooutput.stereoupmix">
+ <visible>false</visible>
+ </setting>
<setting id="audiooutput.passthroughaac">
<visible>false</visible>
</setting>
<level>2</level>
<default>true</default>
</setting>
- <setting id="videoplayer.usevda" type="boolean" label="13429" help="36160">
- <visible>HasVDADecoder</visible>
- <level>2</level>
- <default>true</default>
- </setting>
<setting id="videoplayer.useomx" type="boolean" label="13430" help="36161">
<visible>HAVE_LIBOPENMAX</visible>
<level>2</level>
--- /dev/null
+--- How to build a XBMC debian package ---
+
+There are two available build methods:
+1.) debuild / debhelper
+ Requirements: debhelper, devscripts, all Xbmc build deps
+ sudo apt-get install debhelper devscripts
+ sudo apt-get build-dep xbmc (if you have on of our repos/ppas added, else read docs/README.linux or docs/README.ubuntu)
+
+ Result: debian package for your host distribution and architecture only
+ Recommended for local installs
+
+ Example Usage: ./mk-debian-package.sh
+
+2.) pdebuild / pbuilder
+ Requirements: pbuilder, devscripts, proper pbuilder environment
+ For a comprehensive example how to setup pbuilder read:
+ https://wiki.ubuntu.com/PbuilderHowto
+
+ Result: debian package for arbitrary debian based distributions and architectures
+ Recommended for hosting your own apt repository or (clean room) compile testing for various distributions
+
+ Example Usage:
+ RELEASEV=13 \
+ DISTS=-"unstable" \
+ ARCHS="i386 amd64" \
+ BUILDER="pdebuild" \
+ PDEBUILD_OPTS="--debbuildopts \"-j4\"" \
+ PBUILDER_BASE="/home/$USER/xbmc-packaging/pbuilder" \
+ DPUT_TARGET="local" \
+ ./mk-debian-package.sh
+
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2013 Team XBMC
+# http://www.xbmc.org
+#
+# This Program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This Program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with XBMC; see the file COPYING. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+
+RELEASEV=${RELEASEV:-"auto"}
+TAG=${TAG}
+REPO_DIR=${WORKSPACE:-$(cd "$(dirname $0)/../../../" ; pwd)}
+[[ $(which lsb_release) ]] && DISTS=${DISTS:-$(lsb_release -cs)} || DISTS=${DISTS:-"stable"}
+ARCHS=${ARCHS:-$(dpkg --print-architecture)}
+BUILDER=${BUILDER:-"debuild"}
+DEBUILD_OPTS=${DEBUILD_OPTS:-""}
+PDEBUILD_OPTS=${PDEBUILD_OPTS:-""}
+PBUILDER_BASE=${PBUILDER_BASE:-"/var/cache/pbuilder"}
+DPUT_TARGET=${DPUT_TARGET:-"local"}
+DEBIAN=${DEBIAN:-"https://github.com/xbmc/xbmc-packaging/archive/master.tar.gz"}
+
+function usage {
+ echo "$0: this script builds a Xbmc debian package from a git repository."
+ echo "The build is controlled by ENV variables, which van be overridden as appropriate:"
+ echo "BUILDER is either debuild(default) or pdebuild(needs a proper pbuilder setup)"
+ checkEnv
+}
+
+function checkEnv {
+ echo "#------ build environment ------#"
+ echo "REPO_DIR: $REPO_DIR"
+ [[ $RELEASEV == "auto" ]] && getVersion
+ echo "RELEASEV: $RELEASEV"
+ [[ -n $TAG ]] && echo "TAG: $TAG"
+ echo "DISTS: $DISTS"
+ echo "ARCHS: $ARCHS"
+ echo "DEBIAN: $DEBIAN"
+ echo "BUILDER: $BUILDER"
+ echo "CONFIGURATION: $Configuration"
+
+ if ! [[ $(which $BUILDER) ]]
+ then
+ echo "Error: can't find ${BUILDER}, consider using full path to [debuild|pdebuild]"
+ exit 1
+ fi
+
+ if [[ "$BUILDER" =~ "pdebuild" ]]
+ then
+ if ! [[ -d $PBUILDER_BASE ]] ; then echo "Error: $PBUILDER_BASE does not exist"; exit 1; fi
+ echo "PBUILDER_BASE: $PBUILDER_BASE"
+ echo "PDEBUILD_OPTS: $PDEBUILD_OPTS"
+ else
+ echo "DEBUILD_OPTS: $DEBUILD_OPTS"
+ fi
+
+ echo "#-------------------------------#"
+}
+
+function getVersion {
+ local MAJORVER=$(grep VERSION_MAJOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }')
+ local MINORVER=$(grep VERSION_MINOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }')
+ RELEASEV=${MAJORVER}.${MINORVER}
+}
+
+function getGitRev {
+ cd $REPO_DIR || exit 1
+ REV=$(git log -1 --pretty=format:"%h")
+ [[ -z $TAG ]] && TAG=$REV
+ [[ -z $TAGREV ]] && TAGREV=0
+}
+
+function archiveRepo {
+ cd $REPO_DIR || exit 1
+ git clean -xfd
+ getGitRev
+ echo $REV > VERSION
+ DEST="xbmc-${RELEASEV}~git$(date '+%Y%m%d.%H%M')-${TAG}"
+ [[ -d debian ]] && rm -rf debian
+ cd ..
+ tar -czf ${DEST}.tar.gz -h --exclude .git $(basename $REPO_DIR)
+ ln -s ${DEST}.tar.gz ${DEST/-/_}.orig.tar.gz
+ echo "Output Archive: ${DEST}.tar.gz"
+
+ cd $REPO_DIR || exit 1
+ getDebian
+}
+
+function getDebian {
+ if [[ -d $DEBIAN ]]
+ then
+ cp -r $DEBIAN .
+ else
+ mkdir tmp && cd tmp
+ curl -L -s $DEBIAN -o debian.tar.gz
+ tar xzf debian.tar.gz
+ cd xbmc-packaging-*
+ for FILE in *.unified; do mv $FILE debian/${FILE%.unified}; done
+ mv debian $REPO_DIR
+ cd $REPO_DIR ; rm -rf tmp
+ fi
+}
+
+function buildDebianPackages {
+ archiveRepo
+ cd $REPO_DIR || exit 1
+ sed -e "s/#PACKAGEVERSION#/${DEST#xbmc-}/g" -e "s/#TAGREV#/${TAGREV}/g" debian/changelog.in > debian/changelog.tmp
+ [ "$Configuration" == "Debug" ] && sed -i "s/XBMC_RELEASE = yes/XBMC_RELEASE = no/" debian/rules
+
+ for dist in $DISTS
+ do
+ sed "s/#DIST#/${dist}/g" debian/changelog.tmp > debian/changelog
+ for arch in $ARCHS
+ do
+ cd $REPO_DIR
+ echo "building: DIST=$dist ARCH=$arch"
+ if [[ "$BUILDER" =~ "pdebuild" ]]
+ then
+ DIST=$dist ARCH=$arch $BUILDER $PDEBUILD_OPTS
+ [ $? -eq 0 ] && uploadPkg || exit 1
+ else
+ $BUILDER $DEBUILD_OPTS
+ echo "output directory: $REPO_DIR/.."
+ fi
+ done
+ done
+}
+
+function uploadPkg {
+ PKG="${PBUILDER_BASE}/${dist}-${arch}/result/${DEST/-/_}-${TAGREV}_${arch}.changes"
+ echo "signing package"
+ debsign $PKG
+ echo "uploading $PKG to $DPUT_TARGET"
+ dput $DPUT_TARGET $PKG
+ UPLOAD_DONE=$?
+}
+
+function cleanup {
+ if [[ $UPLOAD_DONE -eq 0 ]] && [[ "$BUILDER" =~ "pdebuild" ]]
+ then
+ cd $REPO_DIR/.. || exit 1
+ rm ${DEST}*
+ rm ${DEST/-/_}*
+ fi
+}
+
+###
+# main
+###
+if [[ $1 = "-h" ]] || [[ $1 = "--help" ]]
+then
+ usage
+ exit
+fi
+
+checkEnv
+buildDebianPackages
+cleanup
+
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include "cmdlineargs.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define strncasecmp strnicmp
#endif
#include "DDSImage.h"
-DEFINES += -D_LINUX -DUSE_LZO_PACKING
+DEFINES += -DTARGET_POSIX -DUSE_LZO_PACKING
ifneq ($(or $(findstring powerpc,@ARCH@),$(findstring ppc, @ARCH@)),)
DEFINES += -DHOST_BIGENDIAN
endif
*
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <sys/types.h>
#include <sys/stat.h>
#define __STDC_FORMAT_MACROS
#include "cmdlineargs.h"
#include "libsquish/squish.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define strncasecmp strnicmp
#endif
#ifdef USE_LZO_PACKING
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "../../lib/win32/liblzo/LZO1X.H"
#else
#include <lzo/lzo1x.h>
{
OutputFilename = args[++i];
valid = true;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
char *c = NULL;
while ((c = (char *)strchr(OutputFilename.c_str(), '\\')) != NULL) *c = '/';
#endif
#include <inttypes.h>
#include "guilib/XBTF.h"
#include "utils/EndianSwap.h"
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
#include <stdlib.h>
-#elif !defined(__APPLE__)
+#elif !defined(TARGET_DARWIN)
#include <malloc.h>
#endif
#include <memory.h>
*
*/
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h"
#include "xwinapi.h"
typedef LPSTR PSZ;
strcpy (m_cmdline, cmdline);
ParseCmdLine();
} else {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
delete[] cmdline;
#endif
}
CmdLineArgs (const int argc, const char **argv)
{
std::string cmdline;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
cmdline = "\"";
#endif
for (int i = 0 ; i<argc ; i++)
cmdline += std::string(argv[i]);
if ( i != (argc-1) )
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
cmdline += "\" \"";
#else
cmdline += " ";
#endif
}
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
cmdline += "\"";
#endif
m_cmdline = new char [cmdline.length() + 1];
#include <string.h>
#include <errno.h>
#include "xwinapi.h"
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN
#include "OSXGNUReplacements.h"
#endif
OBJS = libcurl.so \
librtmp.so libmad.so \
libafpclient.so \
- libplist.so \
+ libplist.so libshairplay.so \
libxbogg.so libxbvorbis.so libxbvorbisfile.so libxbFLAC.so libxbmpeg2.so \
libxbmpeg2convert.so libnfs.so libass.so
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data android:mimeType="video/*" />
+ <data android:mimeType="audio/*" />
+ <data android:mimeType="image/*" />
+
+ <data android:scheme="file" />
+ <data android:scheme="content" />
+ <data android:scheme="http" />
+ <data android:scheme="https" />
+ <data android:scheme="ftp" />
+ <data android:scheme="ftps" />
+ <data android:scheme="rtp" />
+ <data android:scheme="rtsp" />
+ <data android:scheme="mms" />
+ <data android:scheme="dav" />
+ <data android:scheme="davs" />
+ <data android:scheme="ssh" />
+ <data android:scheme="sftp" />
+ <data android:scheme="smb" />
+ </intent-filter>
</activity>
<!--
public class Main extends NativeActivity
{
+ native void _onNewIntent(Intent intent);
public Main()
{
super();
{
super.onCreate(savedInstanceState);
}
+
+ @Override
+ protected void onNewIntent(Intent intent)
+ {
+ super.onNewIntent(intent);
+ _onNewIntent(intent);
+ }
+
}
--- /dev/null
+# We do not use unified dependencies here, but system libs
+exit 0
--- /dev/null
+# Nothing to be done, this is all handled by the package script
+exit 0
--- /dev/null
+# noop
+exit 0
--- /dev/null
+# noop
+exit 0
--- /dev/null
+WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )}
+XBMC_PLATFORM_DIR=linux-debian
+. $WORKSPACE/tools/buildsteps/defaultenv
+
+cd $WORKSPACE
+
+RELEASEV=$VERSION \
+TAG=$TAG \
+DISTS=${DISTS:-"stable"} \
+ARCHS=${ARCHS:-"i386 amd64"} \
+BUILDER=${BUILDER:-"pdebuild"} \
+PDEBUILD_OPTS=${PDEBUILD_OPTS:-"--debbuildopts \"-j$BUILDTHREADS\""} \
+PBUILDER_BASE=${PBUILDER_BASE:-"/home/$USER/xbmc-packaging/pbuilder"} \
+DPUT_TARGET=${DPUT_TARGET:-"local"} \
+Configuration="$Configuration" \
+tools/Linux/packaging/mk-debian-package.sh
--- /dev/null
+#nothing on linux
+exit 0
endif
ifeq ($(OS),android)
- EXCLUDED_DEPENDS = libshairplay
+ DEPENDS += mdnsresponder
endif
DEPENDS := $(filter-out $(EXCLUDED_DEPENDS),$(DEPENDS))
libflac: libogg gettext
libass: fontconfig libpng freetype2 expat $(ICONV)
librtmp: openssl
-libxml2: $(ICONV)
libmicrohttpd: openssl libgpg-error libgcrypt
python26: expat gettext libxml2 sqlite3 openssl libffi
libcdio: $(ICONV)
# specify the cross compiler
SET(CMAKE_C_COMPILER @CC@)
SET(CMAKE_CXX_COMPILER @CXX@)
+SET(CMAKE_AR @AR@ CACHE FILEPATH "Archiver")
+SET(CMAKE_LINKER @LD@ CACHE FILEPATH "Linker")
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH @prefix@/@deps_dir@ @use_toolchain@ @use_toolchain@/usr @use_sdk_path@ @use_sdk_path@/usr @use_toolchain@/sysroot/usr)
FILENAME=v$(VERSION)
ARCHIVE=$(SOURCE).tar.gz
LIBDYLIB=$(PLATFORM)/build/src/libplist++.so
-ICONV=$(shell echo $(LINK_ICONV) | sed -e 's/\-l//')
CFLAGS+=-fvisibility=default
all: .installed-$(PLATFORM)
cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
- echo $(ICONV)
rm -rf $(PLATFORM); mkdir -p $(PLATFORM)
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
cd $(PLATFORM); patch -p1 < ../0001-dontbuildswig.patch
- cd $(PLATFORM); sed -ie 's/TARGET_LINK_LIBRARIES( plist /TARGET_LINK_LIBRARIES( plist m z $(ICONV) /' src/CMakeLists.txt
+ cd $(PLATFORM); sed -ie 's/TARGET_LINK_LIBRARIES( plist /TARGET_LINK_LIBRARIES( plist m z /' src/CMakeLists.txt
cd $(PLATFORM); rm -rf build; mkdir -p build
- cd $(PLATFORM)/build; $(CMAKE) VERBOSE=1 -DCMAKE_C_FLAGS="$(CFLAGS)" ..
+ cd $(PLATFORM)/build; $(CMAKE) VERBOSE=1 -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="$(LDFLAGS)" ..
$(LIBDYLIB): $(PLATFORM)
$(MAKE) -j 1 -C $(PLATFORM)/build VERBOSE=1
.installed-$(PLATFORM): $(LIBDYLIB)
$(MAKE) -C $(PLATFORM) install
+ifeq ($(OS),android)
+ rm -f $(PREFIX)/lib/libshairplaylibshairplay.la $(PREFIX)/lib/libshairplay.so $(PREFIX)/lib/libshairplay.so.0
+ mv -f $(PREFIX)/lib/libshairplay.so.0.0.0 $(PREFIX)/lib/libshairplay.so
+ $(RPL) -e "libshairplay.so.0" "libshairplay.so\x00\x00" $(PREFIX)/lib/libshairplay.so
+ -$(READELF) --dynamic $(PREFIX)/lib/libshairplay.so | grep ibrary
+endif
+
touch $@
clean:
# configuration settings
CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \
- ./configure --prefix=$(PREFIX) --without-python --disable-shared
+ ./configure --prefix=$(PREFIX) --without-python --without-iconv --disable-shared
LIBDYLIB=$(PLATFORM)/.libs/$(LIBNAME).a
--- /dev/null
+diff -rupN mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h
+--- mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h 2011-06-30 22:56:04.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h 2012-04-15 15:10:42.000000000 +0200
+@@ -1051,6 +1051,10 @@ enum
+ McastResolver_FlagNew = 2
+ };
+
++// everyone loves proprietary language extensions in the global namespace
++#ifdef _MSC_VER
++#undef interface
++#endif
+ typedef struct McastResolver
+ {
+ struct McastResolver *next;
+diff -rupN mDNSResponder-333.10/mDNSPosix/mDNSPosix.h mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h
+--- mDNSResponder-333.10/mDNSPosix/mDNSPosix.h 2009-08-11 03:13:47.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h 2012-04-15 15:10:42.000000000 +0200
+@@ -25,6 +25,10 @@
+ extern "C" {
+ #endif
+
++#ifdef ANDROID
++#include <fcntl.h>
++#endif
++
+ // PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo
+ // type that supports extra fields needed by the Posix platform.
+ //
+diff -rupN mDNSResponder-333.10/mDNSShared/PlatformCommon.c mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c
+--- mDNSResponder-333.10/mDNSShared/PlatformCommon.c 2011-04-12 00:54:35.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c 2012-04-15 15:10:42.000000000 +0200
+@@ -27,6 +27,10 @@
+ #include "DNSCommon.h"
+ #include "PlatformCommon.h"
+
++#ifdef ANDROID
++#include <android/log.h>
++#endif
++
+ #ifdef NOT_HAVE_SOCKLEN_T
+ typedef unsigned int socklen_t;
+ #endif
+@@ -143,13 +147,20 @@ mDNSexport void ReadDDNSSettingsFromConf
+ #if MDNS_DEBUGMSGS
+ mDNSexport void mDNSPlatformWriteDebugMsg(const char *msg)
+ {
++#ifdef ANDROID
++ __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", msg);
++#else
+ fprintf(stderr,"%s\n", msg);
+ fflush(stderr);
++#endif
+ }
+ #endif
+
+ mDNSexport void mDNSPlatformWriteLogMsg(const char *ident, const char *buffer, mDNSLogLevel_t loglevel)
+ {
++#ifdef ANDROID
++ __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", buffer);
++#else
+ #if APPLE_OSX_mDNSResponder && LogTimeStamps
+ extern mDNS mDNSStorage;
+ extern mDNSu32 mDNSPlatformClockDivisor;
+@@ -193,4 +204,5 @@ mDNSexport void mDNSPlatformWriteLogMsg(
+ #endif
+ syslog(syslog_level, "%s", buffer);
+ }
++#endif
+ }
+diff -rupN mDNSResponder-333.10/mDNSShared/dns_sd.h mDNSResponder-333.10.patched/mDNSShared/dns_sd.h
+--- mDNSResponder-333.10/mDNSShared/dns_sd.h 2011-08-31 03:44:17.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dns_sd.h 2012-04-15 15:10:42.000000000 +0200
+@@ -93,7 +93,7 @@
+ /* standard calling convention under Win32 is __stdcall */
+ /* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */
+ /* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */
+-#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
++#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) && !defined(DISC_BONJOUR_EMBED)
+ #define DNSSD_API __stdcall
+ #else
+ #define DNSSD_API
+diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c
+--- mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2011-06-02 00:44:37.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c 2012-04-15 15:10:42.000000000 +0200
+@@ -25,6 +25,13 @@
+
+ #include "dns_sd.h" // Defines the interface to the client layer above
+ #include "mDNSEmbeddedAPI.h" // The interface we're building on top of
++#ifndef _MSC_VER
++#include <sys/socket.h>
++#include <netinet/in.h>
++#else
++#include <winsock2.h>
++#endif
++
+ extern mDNS mDNSStorage; // We need to pass the address of this storage to the lower-layer functions
+
+ #if MDNS_BUILDINGSHAREDLIBRARY || MDNS_BUILDINGSTUBLIBRARY
+@@ -71,6 +78,14 @@ typedef struct
+ typedef struct
+ {
+ mDNS_DirectOP_Dispose *disposefn;
++ DNSServiceRef aQuery;
++ DNSServiceGetAddrInfoReply callback;
++ void *context;
++ } mDNS_DirectOP_GetAddrInfo;
++
++typedef struct
++ {
++ mDNS_DirectOP_Dispose *disposefn;
+ DNSServiceResolveReply callback;
+ void *context;
+ const ResourceRecord *SRV;
+@@ -659,7 +674,7 @@ DNSServiceErrorType DNSServiceQueryRecor
+ x->q.ExpectUnique = mDNSfalse;
+ x->q.ForceMCast = (flags & kDNSServiceFlagsForceMulticast) != 0;
+ x->q.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0;
+- x->q.SuppressUnsable = (flags & kDNSServiceFlagsSuppressUnusable) != 0;
++ x->q.SuppressUnusable = (flags & kDNSServiceFlagsSuppressUnusable) != 0;
+ x->q.SearchListIndex = 0;
+ x->q.AppendSearchDomains = 0;
+ x->q.RetryWithSearchDomains = mDNSfalse;
+diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_ipc.h mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h
+--- mDNSResponder-333.10/mDNSShared/dnssd_ipc.h 2011-06-30 22:56:04.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h 2012-04-15 15:10:42.000000000 +0200
+@@ -29,6 +29,11 @@
+ #ifndef DNSSD_IPC_H
+ #define DNSSD_IPC_H
+
++#ifdef ANDROID
++#include <sys/socket.h>
++#include <sys/un.h>
++#endif
++
+ #include "dns_sd.h"
+
+ //
+diff -rupN mDNSResponder-333.10/mDNSShared/uds_daemon.h mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h
+--- mDNSResponder-333.10/mDNSShared/uds_daemon.h 2011-05-18 00:18:08.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h 2012-04-15 15:10:42.000000000 +0200
+@@ -22,6 +22,11 @@
+
+ */
+
++#ifdef ANDROID
++#include <sys/socket.h>
++#include <sys/un.h>
++#endif
++
+ #include "mDNSEmbeddedAPI.h"
+ #include "dnssd_ipc.h"
+
+diff -rupN mDNSResponder-333.10/mDNSWindows/mDNSWin32.c mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c
+--- mDNSResponder-333.10/mDNSWindows/mDNSWin32.c 2011-08-31 03:42:48.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c 2012-04-15 15:17:34.000000000 +0200
+@@ -2843,10 +2843,7 @@ mDNSlocal mStatus SetupSocket( mDNS * co
+ sa4.sin_family = AF_INET;
+ sa4.sin_port = port.NotAnInteger;
+ sa4.sin_addr.s_addr = ipv4.NotAnInteger;
+-
+- err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) );
+- check_translated_errno( err == 0, errno_compat(), kUnknownErr );
+-
++
+ // Turn on option to receive destination addresses and receiving interface.
+
+ option = 1;
+@@ -2887,6 +2884,9 @@ mDNSlocal mStatus SetupSocket( mDNS * co
+ err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &option, sizeof( option ) );
+ check_translated_errno( err == 0, errno_compat(), kOptionErr );
+
++ err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) );
++ check_translated_errno( err == 0, errno_compat(), kUnknownErr );
++
+ }
+ else if( inAddr->sa_family == AF_INET6 )
+ {
+@@ -2904,10 +2904,7 @@ mDNSlocal mStatus SetupSocket( mDNS * co
+ sa6.sin6_flowinfo = 0;
+ sa6.sin6_addr = sa6p->sin6_addr;
+ sa6.sin6_scope_id = sa6p->sin6_scope_id;
+-
+- err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) );
+- check_translated_errno( err == 0, errno_compat(), kUnknownErr );
+-
++
+ // Turn on option to receive destination addresses and receiving interface.
+
+ option = 1;
+@@ -2957,6 +2954,10 @@ mDNSlocal mStatus SetupSocket( mDNS * co
+ option = 255;
+ err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &option, sizeof( option ) );
+ check_translated_errno( err == 0, errno_compat(), kOptionErr );
++
++ err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) );
++ check_translated_errno( err == 0, errno_compat(), kUnknownErr );
++
+ }
+ else
+ {
+diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.c mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c
+--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c 1970-01-01 01:00:00.000000000 +0100
++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c 2013-06-01 13:04:44.000000000 +0100
+@@ -0,0 +1,145 @@
++/**
++ * @file
++ * @brief Wrapper for mDNSEmbeddedAPI with Bonjour.
++ * @author 2012 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
++ * @copyright Simplified BSD
++ *
++ * @cond
++ * This program is free software: you can redistribute it and/or modify
++ * it under the terms of the FreeBSD license as published by the FreeBSD
++ * project.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
++ *
++ * You should have received a copy of the FreeBSD license along with this
++ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
++ * @endcond
++ */
++
++#include <stdlib.h>
++#include <assert.h>
++#include <sys/select.h>
++// include order matters
++#include "mDNSEmbeddedAPI.h"
++#ifdef WIN32
++#include "../mDNSWindows/mDNSWin32.h" // Defines the specific types needed to run mDNS on windows platforms
++#else
++#include <sys/time.h>
++#include "../mDNSPosix/mDNSPosix.h" // Defines the specific types needed to run mDNS on posix platforms
++#endif
++
++#define RR_CACHE_SIZE 500
++static CacheEntity rrcachestorage[RR_CACHE_SIZE];
++mDNS mDNSStorage;
++//struct mDNS_PlatformSupport_struct {};
++static int mDNSIsInitialized = 0;
++static mDNS_PlatformSupport platformSupport;
++
++const char ProgramName[] = "umundo";
++extern mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout);
++extern mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds);
++
++// promise compiler that these will be there
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout);
++
++#if WIN32
++mStatus mDNSPoll(DWORD msec);
++static void embedded_mDNSInit_ReportStatus( int inType, const char *inFormat, ... ) {
++}
++#endif
++
++mDNSexport int embedded_mDNSInit() {
++ mStatus err;
++ if (mDNSIsInitialized != 0) {
++ return 0;
++ }
++
++ mDNSPlatformMemZero( &mDNSStorage, sizeof(mDNSStorage));
++ mDNSPlatformMemZero( &platformSupport, sizeof(platformSupport));
++
++ err = mDNS_Init(
++ &mDNSStorage,
++ &platformSupport,
++ rrcachestorage,
++ RR_CACHE_SIZE,
++ mDNS_Init_AdvertiseLocalAddresses,
++ mDNS_Init_NoInitCallback,
++ mDNS_Init_NoInitCallbackContext
++ );
++ if (err)
++ return err;
++
++#ifdef WIN32
++ platformSupport.reportStatusFunc = embedded_mDNSInit_ReportStatus;
++ err = SetupInterfaceList( &mDNSStorage );
++ if (err)
++ return err;
++ err = uDNS_SetupDNSConfig( &mDNSStorage );
++#endif
++
++ if (err == 0) {
++ mDNSIsInitialized = 1;
++ }
++ return err;
++}
++
++mDNSexport void embedded_mDNSExit() {
++#ifdef WIN32
++ struct timeval tv;
++ tv.tv_sec = 0;
++ tv.tv_usec = 0;
++// mDNS_StartExit(&mDNSStorage);
++// embedded_mDNSmainLoop(tv);
++// mDNS_FinalExit(&mDNSStorage);
++#else
++ mDNS_Close(&mDNSStorage);
++#endif
++}
++
++#ifdef WIN32
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) {
++ mDNS_Execute(&mDNSStorage);
++ mDNSPoll(100);
++// Sleep(100);
++ return 0;
++}
++
++#else
++
++// From <mDNSDir>/ExampleClientApp.c
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) {
++ int nfds = 0;
++ fd_set readfds;
++ int result;
++
++ // 1. Set up the fd_set as usual here.
++ // This example client has no file descriptors of its own,
++ // but a real application would call FD_SET to add them to the set here
++ FD_ZERO(&readfds);
++
++ // 2. Set up the timeout.
++ // This example client has no other work it needs to be doing,
++ // so we set an effectively infinite timeout
++// timeout.tv_sec = 0x3FFFFFFF;
++// timeout.tv_usec = 0;
++
++ assert(timeout.tv_sec < 10);
++ // 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout
++ mDNSPosixGetFDSet(&mDNSStorage, &nfds, &readfds, &timeout);
++
++ // 4. Call select as normal
++ result = select(nfds, &readfds, NULL, NULL, &timeout);
++
++ if (result > 0) {
++ // 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work
++ mDNSPosixProcessFDSet(&mDNSStorage, &readfds);
++
++ // 6. This example client has no other work it needs to be doing,
++ // but a real client would do its work here
++ // ... (do work) ...
++ }
++ return result;
++}
++#endif
+diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.h mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h
+--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 1970-01-01 01:00:00.000000000 +0100
++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 2013-06-01 13:00:29.000000000 +0100
+@@ -0,0 +1,32 @@
++/*
++ * Copyright (C) 2005-2013 Team XBMC
++ * http://www.xbmc.org
++ *
++ * This Program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This Program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with XBMC; see the file COPYING. If not, see
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#ifndef _MDNSEMBEDDED_H_
++#define _MDNSEMBEDDED_H_
++#ifdef __cplusplus
++extern "C" {
++#endif
++int embedded_mDNSInit();
++void embedded_mDNSExit();
++int embedded_mDNSmainLoop(struct timeval timeout);
++#ifdef __cplusplus
++}
++#endif
++#endif //_MDNSEMBEDDED_H_
+--- mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2013-06-04 21:24:45.000000000 +0200
++++ mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2013-06-04 22:01:48.000000000 +0200
+@@ -414,7 +414,7 @@
+
+ // Check parameters
+ if (!regtype[0] || !MakeDomainNameFromDNSNameString(&t, regtype)) { errormsg = "Illegal regtype"; goto badparam; }
+- if (!MakeDomainNameFromDNSNameString(&d, *domain ? domain : "local.")) { errormsg = "Illegal domain"; goto badparam; }
++ if (!MakeDomainNameFromDNSNameString(&d, domain ? domain : "local.")) { errormsg = "Illegal domain"; goto badparam; }
+
+ // Allocate memory, and handle failure
+ x = (mDNS_DirectOP_Browse *)mDNSPlatformMemAllocate(sizeof(*x));
--- /dev/null
+include ../../Makefile.include
+DEPS= ../../Makefile.include Makefile
+
+
+# lib name, version
+LIBNAME=mDNSResponder
+VERSION=333.10
+OUTPUTNAME=libmDNSEmbedded
+SOURCE=$(LIBNAME)-$(VERSION)
+ARCHIVE=$(SOURCE).tar.gz
+
+LIBDYLIB=$(PLATFORM)/$(OUTPUTNAME).a
+
+all: .installed-$(PLATFORM)
+
+$(TARBALLS_LOCATION)/$(ARCHIVE):
+ cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
+
+
+$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
+ rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
+ cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
+ cd $(PLATFORM); patch -p1 < ../01-android-embedded.patch
+ cd $(PLATFORM); cp ../makefile.internal Makefile
+
+$(LIBDYLIB): $(PLATFORM)
+ cd $(PLATFORM); CC="$(CC)" AR="$(AR)" CFLAGS="$(CFLAGS)" $(MAKE)
+
+.installed-$(PLATFORM): $(LIBDYLIB)
+ cd $(PLATFORM); PREFIX="$(PREFIX)" $(MAKE) install
+ touch $@
+
+clean:
+ make -C $(PLATFORM) clean
+ rm -f .installed-$(PLATFORM)
+
+distclean::
+ rm -rf $(PLATFORM) .installed-$(PLATFORM)
--- /dev/null
+DEFINES ?= -DNOT_HAVE_SA_LEN -DUSES_NETLINK
+INCLUDES ?= -I./mDNSShared -I./mDNSCore
+PREFIX ?= /usr/local
+LIBDIR ?= $(PREFIX)/lib
+INCDIR ?= $(PREFIX)/include
+LIB = libmDNSEmbedded.a
+
+HEADERS = mDNSShared/dns_sd.h mDNSCore/mDnsEmbedded.h
+
+OBJECTS = mDNSShared/dnssd_clientshim.o mDNSPosix/mDNSPosix.o mDNSCore/mDNS.o
+OBJECTS += mDNSCore/DNSCommon.o mDNSShared/mDNSDebug.o mDNSShared/GenLinkedList.o
+OBJECTS += mDNSCore/uDNS.o mDNSShared/PlatformCommon.o mDNSPosix/mDNSUNP.o
+OBJECTS += mDNSCore/DNSDigest.o mDNSCore/mDnsEmbedded.o mDNSShared/dnssd_clientlib.o
+
+all: $(LIB)
+install: $(LIBDIR)/$(LIB) $(addprefix $(INCDIR)/,$(HEADERS))
+
+$(INCDIR)/%.h: %.h
+ mkdir -p $(INCDIR)
+ install -m 644 $< $(INCDIR)
+
+$(LIBDIR)/$(LIB): $(LIB)
+ mkdir -p $(LIBDIR)
+ install -m 644 $< $@
+
+$(LIB): $(OBJECTS)
+ $(AR) rvs $@ $^
+
+%.o: %.c
+ $(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@
+
+clean:
+ -rm $(OBJECTS) $(LIB)
#DEPS= ../../Makefile.include Makefile
LIBNAME=xbmc-pvr-addons
-VERSION=5ef7f7f88c9dd3ca9c1daf57e7c92c005faa5910
+VERSION=d9165b4e701f1655df03562acd87eb7309544fc3
GIT_DIR=$(TARBALLS_LOCATION)/$(LIBNAME).git
BASE_URL=git://github.com/opdenkamp/$(LIBNAME).git
DYLIB=$(PLATFORM)/addons/pvr.demo/.libs/libpvrdemo-addon.so
export PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig
export PYTHON_VERSION=2.7
export PATH:=$(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(PATH)
- export TEXTUREPACKER_NATIVE_ROOT=/usr
+ export USE_TEXTUREPACKER_NATIVE_ROOT=/usr
export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION) -lpthread -ldl -lutil -lm
else
export CFLAGS=-pipe -O3 -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfloat-abi=softfp -mfpu=vfp -mabi=aapcs-linux -Wno-psabi -Wa,-mno-warn-deprecated -Wno-deprecated-declarations
export PKG_CONFIG_PATH=$(PREFIX)/bin/pkg-config
export PYTHON_VERSION=2.6
export PATH:=${PREFIX}/bin:$(PATH):${TOOLCHAIN}/bin
- export TEXTUREPACKER_NATIVE_ROOT=/usr
+ export USE_TEXTUREPACKER_NATIVE_ROOT=/usr
export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION)
endif
export PYTHON_CPPFLAGS=-I$(SDKSTAGE)/usr/include/python$(PYTHON_VERSION)
#include <SDL/SDL.h>
#endif
-#if defined(FILESYSTEM) && !defined(_LINUX)
+#if defined(FILESYSTEM) && !defined(TARGET_POSIX)
#include "filesystem/FileDAAP.h"
#endif
#ifdef HAS_UPNP
#include "network/upnp/UPnPSettings.h"
#include "filesystem/UPnPDirectory.h"
#endif
-#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
+#if defined(TARGET_POSIX) && defined(HAS_FILESYSTEM_SMB)
#include "filesystem/SMBDirectory.h"
#endif
#ifdef HAS_FILESYSTEM_NFS
#endif
#include "network/Zeroconf.h"
#include "network/ZeroconfBrowser.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include "threads/platform/win/Win32Exception.h"
#endif
#ifdef HAS_EVENT_SERVER
#include "settings/SkinSettings.h"
#include "view/ViewStateSettings.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XHandle.h"
#endif
#include "android/activity/XBMCApp.h"
#endif
-#ifdef TARGET_LINUX
-#include "linux/LinuxTimezone.h"
-#endif
-
#ifdef TARGET_WINDOWS
#include "utils/Environment.h"
#endif
g_graphicsContext.ResetOverscan((RESOLUTION)i, CDisplaySettings::Get().GetResolutionInfo(i).Overscan);
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
tzset(); // Initialize timezone information variables
#endif
// Grab a handle to our thread to be used later in identifying the render thread.
m_threadID = CThread::GetCurrentThreadId();
-#ifndef _LINUX
+#ifndef TARGET_POSIX
//floating point precision to 24 bits (faster performance)
_controlfp(_PC_24, _MCW_PC);
CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Darwin OSX (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
#elif defined(TARGET_DARWIN_IOS)
CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Darwin iOS (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: FreeBSD (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Linux (%s, %s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetLinuxDistro().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: %s. Built on %s (compiler %i)", g_infoManager.GetVersion().c_str(), g_sysinfo.GetKernelVersion().c_str(), __DATE__, _MSC_VER);
CLog::Log(LOGNOTICE, g_cpuInfo.getCPUModel().c_str());
CLog::Log(LOGNOTICE, CWIN32Util::GetResInfoString());
// for python scripts that check the OS
#if defined(TARGET_DARWIN)
setenv("OS","OS X",true);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
setenv("OS","Linux",true);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
CEnvironment::setenv("OS", "win32");
#endif
//depending on how it's compiled, SDL periodically calls XResetScreenSaver when it's fullscreen
//this might bring the monitor out of standby, so we have to disable it explicitly
//by passing 0 for overwrite to setsenv, the user can still override this by setting the environment variable
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
#endif
#endif // HAS_SDL
-#ifdef _LINUX
+#ifdef TARGET_POSIX
// for nvidia cards - vsync currently ALWAYS enabled.
// the reason is that after screen has been setup changing this env var will make no difference.
setenv("__GL_SYNC_TO_VBLANK", "1", 0);
might be mixed case.
*/
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
CStdString userName;
if (getenv("USER"))
userName = getenv("USER");
bool CApplication::InitDirectoriesWin32()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdString xbmcPath;
CUtil::GetHomePath(xbmcPath);
bool CApplication::Initialize()
{
-#if defined(HAS_DVD_DRIVE) && !defined(_WIN32) // somehow this throws an "unresolved external symbol" on win32
+#if defined(HAS_DVD_DRIVE) && !defined(TARGET_WINDOWS) // somehow this throws an "unresolved external symbol" on win32
// turn off cdio logging
cdio_loglevel_default = CDIO_LOG_ERROR;
#endif
-#ifdef _LINUX // TODO: Win32 has no special://home/ mapping by default, so we
+#ifdef TARGET_POSIX // TODO: Win32 has no special://home/ mapping by default, so we
// must create these here. Ideally this should be using special://home/ and
// be platform agnostic (i.e. unify the InitDirectories*() functions)
if (!m_bPlatformDirectories)
void CApplication::StartServices()
{
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
// Start Thread for DVD Mediatype detection
CLog::Log(LOGNOTICE, "start dvd mediatype detection");
m_DetectDVDType.Create(false, THREAD_MINSTACKSIZE);
{
m_network->NetworkMessage(CNetwork::SERVICES_DOWN, 0);
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
CLog::Log(LOGNOTICE, "stop dvd detect media");
m_DetectDVDType.StopThread();
#endif
CSettings::Get().Uninitialize();
g_advancedSettings.Clear();
-#ifdef _LINUX
+#ifdef TARGET_POSIX
CXHandle::DumpObjectTracker();
#ifdef HAS_DVD_DRIVE
}
-#if !defined(TARGET_DARWIN) && !defined(_LINUX)
+#if !defined(TARGET_POSIX)
g_audioManager.Enable(false);
#endif
UPNP::CUPnP::GetInstance()->UpdateState();
#endif
-#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
+#if defined(TARGET_POSIX) && defined(HAS_FILESYSTEM_SMB)
smb.CheckIfIdle();
#endif
#include "settings/ISettingsHandler.h"
#include "settings/ISettingCallback.h"
#include "settings/ISubSettings.h"
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
#include "storage/DetectDVDType.h"
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "win32/WIN32Util.h"
#endif
#include "utils/Stopwatch.h"
MEDIA_DETECT::CAutorun* m_Autorun;
#endif
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
MEDIA_DETECT::CDetectDVDMedia m_DetectDVDType;
#endif
ADDON::AddonPtr m_screenSaver;
// timer information
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CWinIdleTimer m_idleTimer;
CWinIdleTimer m_screenSaverTimer;
#else
#include "powermanagement/PowerManager.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "WIN32Util.h"
#define CHalManager CWIN32Util
#elif defined(TARGET_DARWIN)
}
break;
+ case TMSG_ACTIVATESCREENSAVER:
+ {
+ g_application.ActivateScreenSaver();
+ }
+ break;
+
case TMSG_MEDIA_PLAY:
{
// first check if we were called from the PlayFile() function
{
CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program",__FUNCTION__);
}
-#if defined( _LINUX) && !defined(TARGET_DARWIN)
+#if defined( TARGET_POSIX) && !defined(TARGET_DARWIN)
CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1));
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1));
#endif
/* Resume AE processing of XBMC native audio */
SendMessage(tMsg);
}
+void CApplicationMessenger::ActivateScreensaver()
+{
+ ThreadMessage tMsg = {TMSG_ACTIVATESCREENSAVER};
+ SendMessage(tMsg);
+}
+
void CApplicationMessenger::NetworkMessage(unsigned int dwMessage, unsigned int dwParam)
{
ThreadMessage tMsg = {TMSG_NETWORKMESSAGE, dwMessage, dwParam};
#define TMSG_RENDERER_FLUSH 312
#define TMSG_INHIBITIDLESHUTDOWN 313
#define TMSG_LOADPROFILE 314
+#define TMSG_ACTIVATESCREENSAVER 315
#define TMSG_NETWORKMESSAGE 500
void RestartApp();
void Reset();
void InhibitIdleShutdown(bool inhibit);
+ void ActivateScreensaver();
void SwitchToFullscreen(); //
void Minimize(bool wait = false);
void ExecOS(const CStdString command, bool waitExit = false);
if (mediaPath.IsEmpty())
mediaPath = path;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (mediaPath.IsEmpty() || mediaPath.CompareNoCase("iso9660://") == 0)
mediaPath = g_mediaManager.TranslateDevicePath("");
#endif
void CAutorun::HandleAutorun()
{
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
if (!m_bEnable)
{
CDetectDVDMedia::m_evAutorun.Reset();
{
CThread *pThread = new CThread(this, "BackgroundLoader");
pThread->Create();
-#ifndef _LINUX
+#ifndef TARGET_POSIX
pThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
#endif
m_workers.push_back(pThread);
m_replayGainAlbumGain = 0.0f;
m_iTotalTracks = 0;
m_iTrack = 0;
+ m_iDiscNumber = 0;
}
CCueDocument::~CCueDocument(void)
{
if (!ReadNextLine(strLine))
break;
- if (strLine.Left(8) == "INDEX 01")
+ if (StringUtils::StartsWith(strLine,"INDEX 01"))
{
if (bCurrentFileChanged)
{
if (m_iTotalTracks >= 0)
m_Track[m_iTotalTracks].iStartTime = time; // start time of the next track
}
- else if (strLine.Left(5) == "TITLE")
+ else if (StringUtils::StartsWith(strLine,"TITLE"))
{
if (m_iTotalTracks == -1) // No tracks yet
ExtractQuoteInfo(strLine, m_strAlbum);
}
}
}
- else if (strLine.Left(9) == "PERFORMER")
+ else if (StringUtils::StartsWith(strLine,"PERFORMER"))
{
if (m_iTotalTracks == -1) // No tracks yet
ExtractQuoteInfo(strLine, m_strArtist);
else // New Artist for this track
ExtractQuoteInfo(strLine, m_Track[m_iTotalTracks].strArtist);
}
- else if (strLine.Left(5) == "TRACK")
+ else if (StringUtils::StartsWith(strLine,"TRACK"))
{
- int iTrackNumber = ExtractNumericInfo(strLine.c_str() + 5);
+ int iTrackNumber = ExtractNumericInfo(strLine.Mid(5));
m_iTotalTracks++;
bCurrentFileChanged = false;
}
- else if (strLine.Left(4) == "FILE")
+ else if (StringUtils::StartsWith(strLine,"REM DISCNUMBER"))
+ {
+ int iDiscNumber = ExtractNumericInfo(strLine.Mid(14));
+ if (iDiscNumber > 0)
+ m_iDiscNumber = iDiscNumber;
+ }
+ else if (StringUtils::StartsWith(strLine,"FILE"))
{
// already a file name? then the time computation will be changed
if(strCurrentFile.size() > 0)
if (strCurrentFile.length() > 0)
ResolvePath(strCurrentFile, strFile);
}
- else if (strLine.Left(8) == "REM DATE")
+ else if (StringUtils::StartsWith(strLine,"REM DATE"))
{
- int iYear = ExtractNumericInfo(strLine.c_str() + 8);
+ int iYear = ExtractNumericInfo(strLine.Mid(8));
if (iYear > 0)
m_iYear = iYear;
}
- else if (strLine.Left(9) == "REM GENRE")
+ else if (StringUtils::StartsWith(strLine,"REM GENRE"))
{
if (!ExtractQuoteInfo(strLine, m_strGenre))
{
}
}
}
- else if (strLine.Left(25) == "REM REPLAYGAIN_ALBUM_GAIN")
+ else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_ALBUM_GAIN"))
m_replayGainAlbumGain = (float)atof(strLine.Mid(26));
- else if (strLine.Left(25) == "REM REPLAYGAIN_ALBUM_PEAK")
+ else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_ALBUM_PEAK"))
m_replayGainAlbumPeak = (float)atof(strLine.Mid(26));
- else if (strLine.Left(25) == "REM REPLAYGAIN_TRACK_GAIN" && m_iTotalTracks >= 0)
+ else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_TRACK_GAIN") && m_iTotalTracks >= 0)
m_Track[m_iTotalTracks].replayGainTrackGain = (float)atof(strLine.Mid(26));
- else if (strLine.Left(25) == "REM REPLAYGAIN_TRACK_PEAK" && m_iTotalTracks >= 0)
+ else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_TRACK_PEAK") && m_iTotalTracks >= 0)
m_Track[m_iTotalTracks].replayGainTrackPeak = (float)atof(strLine.Mid(26));
}
song.genre = StringUtils::Split(m_strGenre, g_advancedSettings.m_musicItemSeparator);
song.iYear = m_iYear;
song.iTrack = m_Track[i].iTrackNumber;
+ if ( m_iDiscNumber > 0 )
+ song.iTrack |= (m_iDiscNumber << 16); // see CMusicInfoTag::GetDiscNumber()
if (m_Track[i].strTitle.length() == 0) // No track information for this track!
song.strTitle.Format("Track %2d", i + 1);
else
int m_iYear; //album year
int m_iTrack; // current track
int m_iTotalTracks; // total tracks
+ int m_iDiscNumber; // Disc number
float m_replayGainAlbumGain;
float m_replayGainAlbumPeak;
*
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "DllPaths_win32.h"
-#elif defined (__ANDROID__)
+#elif defined (TARGET_ANDROID)
#include "DllPaths_generated_android.h"
#else
#include "DllPaths_generated.h"
#define DLL_PATH_VORBIS "@VORBIS_SONAME@"
/* broadcom crystalhd */
-#if defined(_LINUX) && !defined(__APPLE__)
-#define DLL_PATH_LIBCRYSTALHD "@CRYSTALHD_SONAME@"
-#else
+#if defined(TARGET_DARWIN)
#define DLL_PATH_LIBCRYSTALHD "libcrystalhd.dylib"
+#else
+#define DLL_PATH_LIBCRYSTALHD "@CRYSTALHD_SONAME@"
#endif
/* libbluray */
#define DLL_PATH_LIBBLURAY "@BLURAY_SONAME@"
-/* apple vdadecoder */
-#define DLL_PATH_LIBVDADECODER "/System/Library/Frameworks/VideoDecodeAcceleration.framework/Versions/Current/VideoDecodeAcceleration"
-
#endif
#define DEFINE_METHOD10(result, name, args) DEFINE_METHOD_LINKAGE10(result, __cdecl, name, args)
#define DEFINE_METHOD11(result, name, args) DEFINE_METHOD_LINKAGE11(result, __cdecl, name, args)
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
///////////////////////////////////////////////////////////
//
// DEFINE_FUNC_ALIGNED 0-X
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Favourites.h"
-#include "filesystem/File.h"
-#include "Util.h"
-#include "profiles/ProfilesManager.h"
-#include "FileItem.h"
-#include "utils/XBMCTinyXML.h"
-#include "utils/log.h"
-#include "utils/StringUtils.h"
-#include "utils/URIUtils.h"
-#include "settings/AdvancedSettings.h"
-#include "video/VideoInfoTag.h"
-
-bool CFavourites::Load(CFileItemList &items)
-{
- items.Clear();
- CStdString favourites;
-
- favourites = "special://xbmc/system/favourites.xml";
- if(XFILE::CFile::Exists(favourites))
- CFavourites::LoadFavourites(favourites, items);
- else
- CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
- favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
- if(XFILE::CFile::Exists(favourites))
- CFavourites::LoadFavourites(favourites, items);
- else
- CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");
-
- return true;
-}
-
-bool CFavourites::LoadFavourites(CStdString& strPath, CFileItemList& items)
-{
- CXBMCTinyXML doc;
- if (!doc.LoadFile(strPath))
- {
- CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
- return false;
- }
- TiXmlElement *root = doc.RootElement();
- if (!root || strcmp(root->Value(), "favourites"))
- {
- CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
- return false;
- }
-
- TiXmlElement *favourite = root->FirstChildElement("favourite");
- while (favourite)
- {
- // format:
- // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
- // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
- // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
- const char *name = favourite->Attribute("name");
- const char *thumb = favourite->Attribute("thumb");
- if (name && favourite->FirstChild())
- {
- if(!items.Contains(favourite->FirstChild()->Value()))
- {
- CFileItemPtr item(new CFileItem(name));
- item->SetPath(favourite->FirstChild()->Value());
- if (thumb) item->SetArt("thumb", thumb);
- items.Add(item);
- }
- }
- favourite = favourite->NextSiblingElement("favourite");
- }
- return true;
-}
-
-bool CFavourites::Save(const CFileItemList &items)
-{
- CStdString favourites;
- CXBMCTinyXML doc;
- TiXmlElement xmlRootElement("favourites");
- TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
- if (!rootNode) return false;
-
- for (int i = 0; i < items.Size(); i++)
- {
- const CFileItemPtr item = items[i];
- TiXmlElement favNode("favourite");
- favNode.SetAttribute("name", item->GetLabel().c_str());
- if (item->HasArt("thumb"))
- favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
- TiXmlText execute(item->GetPath());
- favNode.InsertEndChild(execute);
- rootNode->InsertEndChild(favNode);
- }
-
- favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
- return doc.SaveFile(favourites);
-}
-
-bool CFavourites::AddOrRemove(CFileItem *item, int contextWindow)
-{
- if (!item) return false;
-
- // load our list
- CFileItemList items;
- Load(items);
-
- CStdString executePath(GetExecutePath(item, contextWindow));
-
- CFileItemPtr match = items.Get(executePath);
- if (match)
- { // remove the item
- items.Remove(match.get());
- }
- else
- { // create our new favourite item
- CFileItemPtr favourite(new CFileItem(item->GetLabel()));
- if (item->GetLabel().IsEmpty())
- favourite->SetLabel(CUtil::GetTitleFromPath(item->GetPath(), item->m_bIsFolder));
- favourite->SetArt("thumb", item->GetArt("thumb"));
- favourite->SetPath(executePath);
- items.Add(favourite);
- }
-
- // and save our list again
- return Save(items);
-}
-
-bool CFavourites::IsFavourite(CFileItem *item, int contextWindow)
-{
- CFileItemList items;
- if (!Load(items)) return false;
-
- return items.Contains(GetExecutePath(item, contextWindow));
-}
-
-CStdString CFavourites::GetExecutePath(const CFileItem *item, int contextWindow)
-{
- CStdString execute;
- if (item->m_bIsFolder && (g_advancedSettings.m_playlistAsFolders ||
- !(item->IsSmartPlayList() || item->IsPlayList())))
- execute.Format("ActivateWindow(%i,%s)", contextWindow, StringUtils::Paramify(item->GetPath()).c_str());
- else if (item->IsScript())
- execute.Format("RunScript(%s)", StringUtils::Paramify(item->GetPath().Mid(9)).c_str());
- else if (item->IsAndroidApp())
- execute.Format("StartAndroidActivity(%s)", StringUtils::Paramify(item->GetPath().Mid(26)).c_str());
- else // assume a media file
- {
- if (item->IsVideoDb() && item->HasVideoInfoTag())
- execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath).c_str());
- else
- execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetPath()).c_str());
- }
- return execute;
-}
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/StdString.h"
-
-class CFileItemList;
-class CFileItem;
-
-class CFavourites
-{
-public:
- static bool Load(CFileItemList& items);
- static bool LoadFavourites(CStdString& strPath, CFileItemList& items);
- static bool AddOrRemove(CFileItem *item, int contextWindow);
- static bool Save(const CFileItemList& items);
- static bool IsFavourite(CFileItem *item, int contextWindow);
-private:
- static CStdString GetExecutePath(const CFileItem *item, int contextWindow);
-};
return true;
}
- extension = URIUtils::GetExtension(m_strPath);
-
- if (extension.IsEmpty())
- return false;
-
- extension.ToLower();
-
- return (g_advancedSettings.m_videoExtensions.Find(extension) != -1);
+ return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_videoExtensions);
}
bool CFileItem::IsEPG() const
return dbItem.IsDiscStub();
}
- CStdString strExtension = URIUtils::GetExtension(m_strPath);
-
- if (strExtension.IsEmpty())
- return false;
-
- strExtension.ToLower();
- strExtension += '|';
-
- return (g_advancedSettings.m_discStubExtensions + '|').Find(strExtension) != -1;
+ return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_discStubExtensions);
}
bool CFileItem::IsAudio() const
if (HasPictureInfoTag()) return false;
if (IsCDDA()) return true;
- CStdString extension;
if( m_mimetype.Left(12).Equals("application/") )
{ /* check for some standard types */
- extension = m_mimetype.Mid(12);
+ CStdString extension = m_mimetype.Mid(12);
if( extension.Equals("ogg")
|| extension.Equals("mp4")
|| extension.Equals("mxf") )
return true;
}
- extension = URIUtils::GetExtension(m_strPath);
-
- if (extension.IsEmpty())
- return false;
-
- extension.ToLower();
-
- return (g_advancedSettings.m_musicExtensions.Find(extension) != -1);
+ return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_musicExtensions);
}
bool CFileItem::IsKaraoke() const
bool CFileItem::IsLyrics() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".cdg", false) || URIUtils::GetExtension(m_strPath).Equals(".lrc", false);
+ return URIUtils::HasExtension(m_strPath, ".cdg|.lrc");
}
bool CFileItem::IsCUESheet() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".cue", false);
+ return URIUtils::HasExtension(m_strPath, ".cue");
}
bool CFileItem::IsInternetStream(const bool bStrictCheck /* = false */) const
|| IsZIP()
|| IsRAR()
|| IsRSS()
- || IsType(".ogg")
- || IsType(".oga")
- || IsType(".nsf")
- || IsType(".sid")
- || IsType(".sap")
- || IsType(".xsp")
+ || IsType(".ogg|.oga|.nsf|.sid|.sap|.xsp")
#if defined(TARGET_ANDROID)
|| IsType(".apk")
#endif
if (HasProperty("library.smartplaylist") && GetProperty("library.smartplaylist").asBoolean())
return true;
- CStdString strExtension = URIUtils::GetExtension(m_strPath);
- strExtension.ToLower();
- return (strExtension == ".xsp");
+ return URIUtils::HasExtension(m_strPath, ".xsp");
}
bool CFileItem::IsPlayList() const
bool CFileItem::IsPythonScript() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".py", false);
+ return URIUtils::HasExtension(m_strPath, ".py");
}
bool CFileItem::IsType(const char *ext) const
{
- return URIUtils::GetExtension(m_strPath).Equals(ext, false);
+ return URIUtils::HasExtension(m_strPath, ext);
}
bool CFileItem::IsNFO() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".nfo", false);
+ return URIUtils::HasExtension(m_strPath, ".nfo");
}
bool CFileItem::IsDVDImage() const
{
- CStdString strExtension = URIUtils::GetExtension(m_strPath);
- return (strExtension.Equals(".img") || strExtension.Equals(".iso") || strExtension.Equals(".nrg"));
+ return URIUtils::HasExtension(m_strPath, ".img|.iso|.nrg");
}
bool CFileItem::IsOpticalMediaFile() const
bool CFileItem::IsCBZ() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".cbz", false);
+ return URIUtils::HasExtension(m_strPath, ".cbz");
}
bool CFileItem::IsCBR() const
{
- return URIUtils::GetExtension(m_strPath).Equals(".cbr", false);
+ return URIUtils::HasExtension(m_strPath, ".cbr");
}
bool CFileItem::IsRSS() const
{
- if (m_strPath.Left(6).Equals("rss://"))
- return true;
-
- return URIUtils::GetExtension(m_strPath).Equals(".rss")
+ return m_strPath.Left(6).Equals("rss://") || URIUtils::HasExtension(m_strPath, ".rss")
|| GetMimeType() == "application/rss+xml";
}
SetPath(itemlist.GetPath());
SetLabel(itemlist.GetLabel());
m_sortDetails = itemlist.m_sortDetails;
+ m_sortMethod = itemlist.m_sortMethod;
+ m_sortOrder = itemlist.m_sortOrder;
m_replaceListing = itemlist.m_replaceListing;
m_content = itemlist.m_content;
m_mapProperties = itemlist.m_mapProperties;
#include "pictures/GUIWindowSlideShow.h"
#include "pictures/PictureInfoTag.h"
#include "music/tags/MusicInfoTag.h"
+#include "guilib/IGUIContainer.h"
#include "guilib/GUIWindowManager.h"
#include "playlists/PlayList.h"
#include "profiles/ProfilesManager.h"
bReturn = g_application.IsMusicScanning();
}
else if (condition == SYSTEM_PLATFORM_LINUX)
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
+#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_WINDOWS)
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
bReturn = true;
#else
bReturn = false;
if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
{ // update our variables
m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
g_cpuInfo.getTemperature(m_cpuTemp);
m_gpuTemp = GetGPUTemperature();
#endif
text.Format("%i%%", m_fanSpeed * 2);
break;
case SYSTEM_CPU_USAGE:
-#if defined(TARGET_DARWIN) || defined(_WIN32)
+#if defined(TARGET_DARWIN) || defined(TARGET_WINDOWS)
text.Format("%d%%", g_cpuInfo.getUsedPercentage());
#else
text.Format("%s", g_cpuInfo.GetCoresUsageString());
int iSwitch = iWindowID;
// check if a settings subcategory was called from other than settings window
- if (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_APPEARANCE)
+ if (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_MYPVR)
{
int iCWindowID = g_windowManager.GetActiveWindow();
- if (iCWindowID != WINDOW_SETTINGS_MENU && (iCWindowID < WINDOW_SCREEN_CALIBRATION || iCWindowID > WINDOW_SETTINGS_APPEARANCE))
+ if (iCWindowID != WINDOW_SETTINGS_MENU && (iCWindowID < WINDOW_SCREEN_CALIBRATION || iCWindowID > WINDOW_SETTINGS_MYPVR))
iSwitch = WINDOW_SETTINGS_MENU;
}
if (m_strRegionLocaleName.length() > 0)
{
strLocale = m_strLangLocaleName + "_" + m_strRegionLocaleName;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
strLocale += ".UTF-8";
#endif
}
// decimal separator is changed depending of the current language
// (ie. "," in French or Dutch instead of "."). This breaks atof() and
// others similar functions.
-#if defined(__FreeBSD__) || defined(TARGET_DARWIN_OSX)
+#if defined(TARGET_FREEBSD) || defined(TARGET_DARWIN_OSX)
// on FreeBSD and darwin libstdc++ is compiled with "generic" locale support
if (setlocale(LC_COLLATE, strLocale.c_str()) == NULL
|| setlocale(LC_CTYPE, strLocale.c_str()) == NULL)
if (pRootElement->Attribute("locale"))
m_defaultRegion.m_strLangLocaleName = pRootElement->Attribute("locale");
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// Windows need 3 chars isolang code
if (m_defaultRegion.m_strLangLocaleName.length() == 2)
{
if (pRegion->Attribute("locale"))
region.m_strRegionLocaleName = pRegion->Attribute("locale");
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// Windows need 3 chars regions code
if (region.m_strRegionLocaleName.length() == 2)
{
DatabaseManager.cpp \
DbUrl.cpp \
DynamicDll.cpp \
- Favourites.cpp \
FileItem.cpp \
GUIInfoManager.cpp \
GUILargeTextureManager.cpp \
m_strLockCode = "0";
m_iBadPwdCount = 0;
m_iHasLock = 0;
+ m_allowSharing = true;
if (URIUtils::IsMultiPath(strPath))
m_iDriveType = SOURCE_TYPE_VPATH;
SOURCE_TYPE_VPATH = 5,
SOURCE_TYPE_REMOVABLE = 6
};
- CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; };
+ CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; m_allowSharing=true; };
virtual ~CMediaSource() {};
bool operator==(const CMediaSource &right) const;
std::vector<CStdString> vecPaths;
bool m_ignore; /// <Do not store in xml
+ bool m_allowSharing; /// <Allow browsing of source from UPnP / WebServer
};
/*!
#if !defined(AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_)
#define AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "utils/XBMCTinyXML.h"
#include "addons/Scraper.h"
#include "GUILargeTextureManager.h"
#include "guilib/TextureManager.h"
#include "utils/AlarmClock.h"
-#include "utils/DownloadQueueManager.h"
#include "GUIInfoManager.h"
#include "filesystem/DllLibCurl.h"
#include "filesystem/DirectoryCache.h"
CGUIInfoManager g_infoManager;
XCURL::DllLibCurlGlobal g_curlInterface;
- CDownloadQueueManager g_DownloadManager;
CPartyModeManager g_partyModeManager;
#ifdef HAS_PYTHON
bool CTextureDDSJob::DoWork()
{
- if (URIUtils::GetExtension(m_original).Equals(".dds"))
+ if (URIUtils::HasExtension(m_original, ".dds"))
return false;
CBaseTexture *texture = CBaseTexture::LoadFromFile(m_original);
if (texture)
#include "FileItem.h"
#include "filesystem/StackDirectory.h"
#include "addons/Addon.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <sys\types.h>
#include <sys\stat.h>
#endif
struct __stat64 s;
if (XFILE::CFile::Stat(archiveName, &s) == 0)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (!S_ISDIR(s.st_mode))
#else
if (!(s.st_mode & S_IFDIR))
char CURL::GetDirectorySeparator() const
{
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if ( IsLocal() )
return '\\';
else
#include "utils/StdString.h"
#include "utils/UrlOptions.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#undef SetPort // WIN32INCLUDES this is defined as SetPortA in WinSpool.h which is being included _somewhere_
#endif
#include <mach-o/dyld.h>
#endif
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include "guilib/TextureManager.h"
#include "utils/fstrcmp.h"
#include "storage/MediaManager.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "utils/CharsetConverter.h"
#include <shlobj.h>
#include "WIN32Util.h"
#include "utils/TimeUtils.h"
#include "utils/URIUtils.h"
#include "utils/log.h"
+#include "utils/Environment.h"
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleTagSami.h"
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.h"
CRegExp reTags(true);
CRegExp reYear;
- CStdString strExtension = URIUtils::GetExtension(strFileName);
if (!reYear.RegComp(g_advancedSettings.m_videoCleanDateTimeRegExp))
{
// restore extension if needed
if (!bRemoveExtension)
- strTitleAndYear += strExtension;
+ strTitleAndYear += URIUtils::GetExtension(strFileName);
}
void CUtil::GetQualifiedFilename(const CStdString &strBasePath, CStdString &strFilename)
// If the filename starts "x:", "\\" or "/" it's already fully qualified so return
if (strFilename.size() > 1)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if ( (strFilename[1] == ':') || (strFilename[0] == '/') )
#else
if ( strFilename[1] == ':' || (strFilename[0] == '\\' && strFilename[1] == '\\'))
bool CUtil::TestMakeLegalPath()
{
CStdString path;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
path = "C:\\foo\\bar"; path = MakeLegalPath(path);
if (path != "C:\\foo\\bar") return false;
path = "C:\\foo:\\bar\\"; path = MakeLegalPath(path);
{
CStdString strHomePath;
strHomePath = ResolveExecutablePath();
-#ifdef _WIN32
- CStdStringW strPathW, strTargetW;
- g_charsetConverter.utf8ToW(strTarget, strTargetW);
- strPathW = _wgetenv(strTargetW);
- g_charsetConverter.wToUTF8(strPathW,strPath);
-#else
- strPath = getenv(strTarget);
-#endif
+ strPath = CEnvironment::getenv(strTarget);
- if (strPath != NULL && !strPath.IsEmpty())
+ if (!strPath.IsEmpty())
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
char tmp[1024];
//expand potential relative path to full path
if(GetFullPathName(strPath, 1024, tmp, 0) != 0)
strPath = strHomePath;
}
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
/* Change strPath accordingly when target is XBMC_HOME and when INSTALL_PATH
* and BIN_INSTALL_PATH differ
*/
bool CUtil::IsPicture(const CStdString& strFile)
{
- CStdString extension = URIUtils::GetExtension(strFile);
-
- if (extension.IsEmpty())
- return false;
-
- extension.ToLower();
- if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
- return true;
-
- if (extension == ".tbn" || extension == ".dds")
- return true;
-
- return false;
+ return URIUtils::HasExtension(strFile,
+ g_advancedSettings.m_pictureExtensions + "|.tbn|.dds");
}
bool CUtil::ExcludeFileOrFolder(const CStdString& strFileOrFolder, const CStdStringArray& regexps)
result->st_rdev = stat->st_rdev;
result->st_size = (int64_t)stat->st_size;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
result->st_atime = (long)(stat->st_atime & 0xFFFFFFFF);
result->st_mtime = (long)(stat->st_mtime & 0xFFFFFFFF);
result->st_ctime = (long)(stat->st_ctime & 0xFFFFFFFF);
result->st_gid = stat->st_gid;
result->st_rdev = stat->st_rdev;
result->st_size = stat->st_size;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
result->st_atime = (long)(stat->st_atime & 0xFFFFFFFF);
result->st_mtime = (long)(stat->st_mtime & 0xFFFFFFFF);
result->st_ctime = (long)(stat->st_ctime & 0xFFFFFFFF);
result->st_gid = stat->st_gid;
result->st_rdev = stat->st_rdev;
result->st_size = stat->st_size;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
result->st_atime = stat->st_atime;
result->st_mtime = stat->st_mtime;
result->st_ctime = stat->st_ctime;
result->st_uid = stat->st_uid;
result->st_gid = stat->st_gid;
result->st_rdev = stat->st_rdev;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if (stat->st_size <= LONG_MAX)
result->st_size = (_off_t)stat->st_size;
#else
result->st_ctime = (time_t)(stat->st_ctime & 0xFFFFFFFF);
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
void CUtil::Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat)
{
result->st_dev = stat->st_dev;
result->st_uid = stat->st_uid;
result->st_gid = stat->st_gid;
result->st_rdev = stat->st_rdev;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if (stat->st_size <= LONG_MAX)
result->st_size = (_off_t)stat->st_size;
#else
result->st_size = 0;
CLog::Log(LOGWARNING, "WARNING: File is larger than 32bit stat can handle, file size will be reported as 0 bytes");
}
-#ifndef _LINUX
+#ifndef TARGET_POSIX
result->st_atime = stat->st_atime;
result->st_mtime = stat->st_mtime;
result->st_ctime = stat->st_ctime;
return result;
// check the path for incorrect slashes
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (URIUtils::IsDOSPath(path))
{
result.Replace('/', '\\');
bool CUtil::IsUsingTTFSubtitles()
{
- return URIUtils::GetExtension(CSettings::Get().GetString("subtitles.font")).Equals(".ttf");
+ return URIUtils::HasExtension(CSettings::Get().GetString("subtitles.font"), ".ttf");
}
#ifdef UNIT_TESTING
srand(seed);
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
bool CUtil::RunCommandLine(const CStdString& cmdLine, bool waitExit)
{
CStdStringArray args;
CStdString CUtil::ResolveExecutablePath()
{
CStdString strExecutablePath;
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
wchar_t szAppPathW[MAX_PATH] = L"";
::GetModuleFileNameW(0, szAppPathW, sizeof(szAppPathW)/sizeof(szAppPathW[0]) - 1);
CStdStringW strPathW = szAppPathW;
GetDarwinExecutablePath(given_path, &path_size);
strExecutablePath = given_path;
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
char buf[PATH_MAX];
size_t buflen;
int mib[4];
for (int i = 0; sub_exts[i]; i++)
{
//Cache subtitle with same name as movie
- if (URIUtils::GetExtension(strItem).Equals(sub_exts[i]))
+ if (URIUtils::HasExtension(strItem, sub_exts[i]))
{
vecSubtitles.push_back( items[j]->GetPath() );
CLog::Log(LOGINFO, "%s: found subtitle file %s\n", __FUNCTION__, items[j]->GetPath().c_str() );
iSize = vecSubtitles.size();
for (int i = 0; i < iSize; i++)
{
- if (URIUtils::GetExtension(vecSubtitles[i]).Equals(".smi"))
+ if (URIUtils::HasExtension(vecSubtitles[i], ".smi"))
{
//Cache multi-language sami subtitle
CDVDSubtitleStream* pStream = new CDVDSubtitleStream();
CFileItemList ItemList;
// zip only gets the root dir
- if (URIUtils::GetExtension(strArchivePath).Equals(".zip"))
+ if (URIUtils::HasExtension(strArchivePath, ".zip"))
{
CStdString strZipPath;
URIUtils::CreateArchivePath(strZipPath,"zip",strArchivePath,"");
if (URIUtils::IsRAR(strPathInRar) || URIUtils::IsZIP(strPathInRar))
{
CStdString strRarInRar;
- if (URIUtils::GetExtension(strPathInRar).Equals(".rar"))
+ if (strExt == ".rar")
URIUtils::CreateArchivePath(strRarInRar, "rar", strArchivePath, strPathInRar);
else
URIUtils::CreateArchivePath(strRarInRar, "zip", strArchivePath, strPathInRar);
if (strExt.CompareNoCase(sub_exts[iPos]) == 0)
{
CStdString strSourceUrl;
- if (URIUtils::GetExtension(strArchivePath).Equals(".rar"))
+ if (URIUtils::HasExtension(strArchivePath, ".rar"))
URIUtils::CreateArchivePath(strSourceUrl, "rar", strArchivePath, strPathInRar);
else
strSourceUrl = strPathInRar;
*/
bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const CStdString& strIdxPath, CStdString& strSubPath )
{
- if (URIUtils::GetExtension(strIdxPath) == ".idx")
+ if (URIUtils::HasExtension(strIdxPath, ".idx"))
{
CStdString strIdxFile;
CStdString strIdxDirectory;
URIUtils::Split(vecSubtitles[j], strSubDirectory, strSubFile);
if (URIUtils::IsInArchive(vecSubtitles[j]))
CURL::Decode(strSubDirectory);
- if (URIUtils::GetExtension(strSubFile) == ".sub" &&
+ if (URIUtils::HasExtension(strSubFile, ".sub") &&
(URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(strIdxPath,""))))
{
*/
bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdString& strSubPath )
{
- if (URIUtils::GetExtension(strSubPath) == ".sub")
+ if (URIUtils::HasExtension(strSubPath, ".sub"))
{
CStdString strSubFile;
CStdString strSubDirectory;
CStdString strIdxFile;
CStdString strIdxDirectory;
URIUtils::Split(vecSubtitles[j], strIdxDirectory, strIdxFile);
- if (URIUtils::GetExtension(strIdxFile) == ".idx" &&
+ if (URIUtils::HasExtension(strIdxFile, ".idx") &&
(URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(vecSubtitles[j],""))))
return true;
bool CUtil::CanBindPrivileged()
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (geteuid() == 0)
return true; //root user can always bind to privileged ports
#endif //HAVE_LIBCAP
-#else //_LINUX
+#else //TARGET_POSIX
return true;
-#endif //_LINUX
+#endif //TARGET_POSIX
}
bool CUtil::ValidatePort(int port)
{
// check that it's a valid port
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (!CUtil::CanBindPrivileged() && (port < 1024 || port > 65535))
return false;
else
static void Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat);
static void StatI64ToStat64(struct __stat64 *result, struct _stati64 *stat);
static void Stat64ToStat(struct stat *result, struct __stat64 *stat);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
static void Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat);
#endif
static bool CreateDirectoryEx(const CStdString& strPath);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
static CStdString MakeLegalFileName(const CStdString &strFile, int LegalType=LEGAL_WIN32_COMPAT);
static CStdString MakeLegalPath(const CStdString &strPath, int LegalType=LEGAL_WIN32_COMPAT);
#else
// return -1 on error, valid range is 1-3999
static int TranslateRomanNumeral(const char* roman_numeral);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
// this will run the command using sudo in a new process.
// the user that runs xbmc should be allowed to issue the given sudo command.
// in order to allow a user to run sudo without supplying the password you'll need to edit sudoers
#if defined(TARGET_DARWIN)
#include "../osx/OSXGNUReplacements.h"
#endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include "freebsd/FreeBSDGNUReplacements.h"
#endif
#include "utils/log.h"
, m_parent(AddonPtr())
{
BuildLibName(ext);
+ Props().libname = m_strLibName;
BuildProfilePath();
m_userSettingsPath = URIUtils::AddFileToFolder(Profile(), "settings.xml");
m_enabled = true;
case ADDON_PVRDLL:
case ADDON_PLUGIN:
case ADDON_SERVICE:
+ case ADDON_REPOSITORY:
{
CStdString temp = CAddonMgr::Get().GetExtValue(extension->configuration, "@library");
m_strLibName = temp;
{
#if defined(TARGET_ANDROID)
m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_android");
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_linux");
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_wingl");
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_windx");
#elif defined(TARGET_DARWIN)
m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_osx");
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "ApplicationMessenger.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
#include "utils/JobManager.h"
#include "dialogs/GUIDialogYesNo.h"
#include "addons/AddonManager.h"
{
}
-bool CAddonInstallJob::DoWork()
+AddonPtr CAddonInstallJob::GetRepoForAddon(const AddonPtr& addon)
{
- // Addons are installed by downloading the .zip package on the server to the local
- // packages folder, then extracting from the local .zip package into the addons folder
- // Both these functions are achieved by "copying" using the vfs.
+ CAddonDatabase database;
+ database.Open();
+ CStdString repo;
+ database.GetRepoForAddon(addon->ID(), repo);
+ AddonPtr repoPtr;
+ CAddonMgr::Get().GetAddon(repo, repoPtr);
- CStdString dest="special://home/addons/packages/";
- CStdString package = URIUtils::AddFileToFolder("special://home/addons/packages/",
- URIUtils::GetFileName(m_addon->Path()));
+ return repoPtr;
+}
+bool CAddonInstallJob::DoWork()
+{
+ AddonPtr repoPtr = GetRepoForAddon(m_addon);
CStdString installFrom;
- if (URIUtils::HasSlashAtEnd(m_addon->Path()))
- { // passed in a folder - all we need do is copy it across
- installFrom = m_addon->Path();
- }
- else
+ if (!repoPtr || repoPtr->Props().libname.IsEmpty())
{
- // zip passed in - download + extract
- CStdString path(m_addon->Path());
- if (!m_referer.IsEmpty() && URIUtils::IsInternetStream(path))
- {
- CURL url(path);
- url.SetProtocolOptions(m_referer);
- path = url.Get();
+ // Addons are installed by downloading the .zip package on the server to the local
+ // packages folder, then extracting from the local .zip package into the addons folder
+ // Both these functions are achieved by "copying" using the vfs.
+
+ CStdString dest="special://home/addons/packages/";
+ CStdString package = URIUtils::AddFileToFolder("special://home/addons/packages/",
+ URIUtils::GetFileName(m_addon->Path()));
+
+ if (URIUtils::HasSlashAtEnd(m_addon->Path()))
+ { // passed in a folder - all we need do is copy it across
+ installFrom = m_addon->Path();
}
- if (!CFile::Exists(package) && !DownloadPackage(path, dest))
+ else
{
- CFile::Delete(package);
- return false;
- }
+ // zip passed in - download + extract
+ CStdString path(m_addon->Path());
+ if (!m_referer.IsEmpty() && URIUtils::IsInternetStream(path))
+ {
+ CURL url(path);
+ url.SetProtocolOptions(m_referer);
+ path = url.Get();
+ }
+ if (!CFile::Exists(package) && !DownloadPackage(path, dest))
+ {
+ CFile::Delete(package);
+ return false;
+ }
- // at this point we have the package - check that it is valid
- if (!CFile::Exists(package) || !CheckHash(package))
- {
- CFile::Delete(package);
- return false;
- }
+ // at this point we have the package - check that it is valid
+ if (!CFile::Exists(package) || !CheckHash(package))
+ {
+ CFile::Delete(package);
+ return false;
+ }
- // check the archive as well - should have just a single folder in the root
- CStdString archive;
- URIUtils::CreateArchivePath(archive,"zip",package,"");
+ // check the archive as well - should have just a single folder in the root
+ CStdString archive;
+ URIUtils::CreateArchivePath(archive,"zip",package,"");
- CFileItemList archivedFiles;
- CDirectory::GetDirectory(archive, archivedFiles);
+ CFileItemList archivedFiles;
+ CDirectory::GetDirectory(archive, archivedFiles);
- if (archivedFiles.Size() != 1 || !archivedFiles[0]->m_bIsFolder)
- { // invalid package
- CFile::Delete(package);
- return false;
+ if (archivedFiles.Size() != 1 || !archivedFiles[0]->m_bIsFolder)
+ { // invalid package
+ CFile::Delete(package);
+ return false;
+ }
+ installFrom = archivedFiles[0]->GetPath();
}
- installFrom = archivedFiles[0]->GetPath();
+ repoPtr.reset();
}
// run any pre-install functions
bool reloadAddon = OnPreInstall();
// perform install
- if (!Install(installFrom))
+ if (!Install(installFrom, repoPtr))
return false; // something went wrong
// run any post-install guff
return job.DoWork();
}
-bool CAddonInstallJob::Install(const CStdString &installFrom)
+bool CAddonInstallJob::Install(const CStdString &installFrom, const AddonPtr& repo)
{
- CStdString addonFolder(installFrom);
- URIUtils::RemoveSlashAtEnd(addonFolder);
- addonFolder = URIUtils::AddFileToFolder("special://home/addons/",
- URIUtils::GetFileName(addonFolder));
-
- CFileItemList install;
- install.Add(CFileItemPtr(new CFileItem(installFrom, true)));
- install[0]->Select(true);
- CFileOperationJob job(CFileOperationJob::ActionReplace, install, "special://home/addons/");
-
- AddonPtr addon;
- if (!job.DoWork() || !CAddonMgr::Get().LoadAddonDescription(addonFolder, addon))
- { // failed extraction or failed to load addon description
- CStdString addonID = URIUtils::GetFileName(addonFolder);
- ReportInstallError(addonID, addonID);
- CLog::Log(LOGERROR,"Could not read addon description of %s", addonID.c_str());
- DeleteAddon(addonFolder);
- return false;
+ if (repo)
+ {
+ CFileItemList dummy;
+ CStdString s;
+ s.Format("plugin://%s/?action=install"
+ "&package=%s&version=%s", repo->ID().c_str(),
+ m_addon->ID().c_str(),
+ m_addon->Version().c_str());
+ if (!CDirectory::GetDirectory(s, dummy))
+ return false;
}
-
- // resolve dependencies
- CAddonMgr::Get().FindAddons(); // needed as GetDeps() grabs directly from c-pluff via the addon manager
- ADDONDEPS deps = addon->GetDeps();
- CStdString referer;
- referer.Format("Referer=%s-%s.zip",addon->ID().c_str(),addon->Version().c_str());
- for (ADDONDEPS::iterator it = deps.begin(); it != deps.end(); ++it)
+ else
{
- if (it->first.Equals("xbmc.metadata"))
- continue;
+ CStdString addonFolder(installFrom);
+ URIUtils::RemoveSlashAtEnd(addonFolder);
+ addonFolder = URIUtils::AddFileToFolder("special://home/addons/",
+ URIUtils::GetFileName(addonFolder));
- const CStdString &addonID = it->first;
- const AddonVersion &version = it->second.first;
- bool optional = it->second.second;
- AddonPtr dependency;
- bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dependency);
- if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
- { // we have it but our version isn't good enough, or we don't have it and we need it
- bool force=(dependency != NULL);
- // dependency is already queued up for install - ::Install will fail
- // instead we wait until the Job has finished. note that we
- // recall install on purpose in case prior installation failed
- if (CAddonInstaller::Get().HasJob(addonID))
- {
- while (CAddonInstaller::Get().HasJob(addonID))
- Sleep(50);
- force = false;
- }
- // don't have the addon or the addon isn't new enough - grab it (no new job for these)
- if (!CAddonInstaller::Get().Install(addonID, force, referer, false))
- {
- DeleteAddon(addonFolder);
- return false;
+ CFileItemList install;
+ install.Add(CFileItemPtr(new CFileItem(installFrom, true)));
+ install[0]->Select(true);
+ CFileOperationJob job(CFileOperationJob::ActionReplace, install, "special://home/addons/");
+
+ AddonPtr addon;
+ if (!job.DoWork() || !CAddonMgr::Get().LoadAddonDescription(addonFolder, addon))
+ { // failed extraction or failed to load addon description
+ CStdString addonID = URIUtils::GetFileName(addonFolder);
+ ReportInstallError(addonID, addonID);
+ CLog::Log(LOGERROR,"Could not read addon description of %s", addonID.c_str());
+ DeleteAddon(addonFolder);
+ return false;
+ }
+
+ // resolve dependencies
+ CAddonMgr::Get().FindAddons(); // needed as GetDeps() grabs directly from c-pluff via the addon manager
+ ADDONDEPS deps = addon->GetDeps();
+ CStdString referer;
+ referer.Format("Referer=%s-%s.zip",addon->ID().c_str(),addon->Version().c_str());
+ for (ADDONDEPS::iterator it = deps.begin(); it != deps.end(); ++it)
+ {
+ if (it->first.Equals("xbmc.metadata"))
+ continue;
+
+ const CStdString &addonID = it->first;
+ const AddonVersion &version = it->second.first;
+ bool optional = it->second.second;
+ AddonPtr dependency;
+ bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dependency);
+ if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
+ { // we have it but our version isn't good enough, or we don't have it and we need it
+ bool force=(dependency != NULL);
+ // dependency is already queued up for install - ::Install will fail
+ // instead we wait until the Job has finished. note that we
+ // recall install on purpose in case prior installation failed
+ if (CAddonInstaller::Get().HasJob(addonID))
+ {
+ while (CAddonInstaller::Get().HasJob(addonID))
+ Sleep(50);
+ force = false;
+ }
+ // don't have the addon or the addon isn't new enough - grab it (no new job for these)
+ if (!CAddonInstaller::Get().Install(addonID, force, referer, false))
+ {
+ DeleteAddon(addonFolder);
+ return false;
+ }
}
}
}
if (service)
service->Stop();
}
- if (!CAddonInstallJob::DeleteAddon(m_addon->Path()))
- return false;
+
+ AddonPtr repoPtr = CAddonInstallJob::GetRepoForAddon(m_addon);
+ RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(repoPtr);
+ if (therepo && !therepo->Props().libname.IsEmpty())
+ {
+ CFileItemList dummy;
+ CStdString s;
+ s.Format("plugin://%s/?action=uninstall"
+ "&package=%s", therepo->ID().c_str(), m_addon->ID().c_str());
+ if (!CDirectory::GetDirectory(s, dummy))
+ return false;
+ }
+ else
+ {
+ if (!CAddonInstallJob::DeleteAddon(m_addon->Path()))
+ return false;
+ }
OnPostUnInstall();
bool bSave(false);
CFileItemList items;
- CFavourites::Load(items);
+ XFILE::CFavouritesDirectory::Load(items);
for (int i=0; i < items.Size(); ++i)
{
if (items[i]->GetPath().Find(m_addon->ID()) > -1)
}
if (bSave)
- CFavourites::Save(items);
+ CFavouritesDirectory::Save(items);
if (m_addon->Type() == ADDON_PVRDLL)
{
\param addonFolder - the folder to delete
*/
static bool DeleteAddon(const CStdString &addonFolder);
+
+ /*! \brief Find which repository hosts an add-on
+ * \param addon The add-on to find the repository for
+ * \return The hosting repository
+ */
+ static ADDON::AddonPtr GetRepoForAddon(const ADDON::AddonPtr& addon);
private:
bool OnPreInstall();
void OnPostInstall(bool reloadAddon);
- bool Install(const CStdString &installFrom);
+ bool Install(const CStdString &installFrom, const ADDON::AddonPtr& repo=ADDON::AddonPtr());
bool DownloadPackage(const CStdString &path, const CStdString &dest);
/*! \brief Queue a notification for addon installation/update failure
if (type == ADDON_SCREENSAVER)
{ // Python screensaver
CStdString library = CAddonMgr::Get().GetExtValue(props->configuration, "@library");
- if (URIUtils::GetExtension(library).Equals(".py", false))
+ if (URIUtils::HasExtension(library, ".py"))
return AddonPtr(new CScreenSaver(props));
}
#if defined(TARGET_ANDROID)
if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_android")) && value.empty())
break;
- #elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_linux")) && value.empty())
break;
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_wingl")) && value.empty())
break;
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_windx")) && value.empty())
break;
#elif defined(TARGET_DARWIN)
return true;
#if defined(TARGET_ANDROID)
if (platforms[i] == "android")
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
if (platforms[i] == "linux")
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
if (platforms[i] == "wingl")
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
if (platforms[i] == "windx")
#elif defined(TARGET_DARWIN_OSX)
// Remove this after Frodo and add an architecture filter
#include "TextureDatabase.h"
#include "URL.h"
#include "pvr/PVRManager.h"
+#include "filesystem/PluginDirectory.h"
using namespace XFILE;
using namespace ADDON;
CLog::Log(LOGERROR,"Repository %s returned no add-ons, listing may have failed",repo->Name().c_str());
reposum = checksum; // don't update the checksum
}
- database.AddRepository(repo->ID(),addons,reposum);
+ else
+ {
+ bool add=true;
+ if (!repo->Props().libname.empty())
+ {
+ CFileItemList dummy;
+ CStdString s;
+ s.Format("plugin://%s/?action=update", repo->ID());
+ add = CDirectory::GetDirectory(s, dummy);
+ }
+ if (add)
+ database.AddRepository(repo->ID(),addons,reposum);
+ }
}
else
database.GetRepository(repo->ID(),addons);
bool CScreenSaver::CreateScreenSaver()
{
#ifdef HAS_PYTHON
- if (URIUtils::GetExtension(LibPath()).Equals(".py", false))
+ if (URIUtils::HasExtension(LibPath(), ".py"))
{
// Don't allow a previously-scheduled alarm to kill our new screensaver
g_alarmClock.Stop(PYTHON_ALARM, true);
void CScreenSaver::Destroy()
{
#ifdef HAS_PYTHON
- if (URIUtils::GetExtension(LibPath()).Equals(".py", false))
+ if (URIUtils::HasExtension(LibPath(), ".py"))
{
g_alarmClock.Start(PYTHON_ALARM, PYTHON_SCRIPT_TIMEOUT, "StopScript(" + LibPath() + ")", true, false);
return;
CStdString settingValue = ((const CSettingString*)setting)->GetValue();
// Remove the .xml extension from the Themes
- if (URIUtils::GetExtension(settingValue) == ".xml")
+ if (URIUtils::HasExtension(settingValue, ".xml"))
URIUtils::RemoveExtension(settingValue);
// Set the choosen theme
#include "cores/IPlayer.h"
#include "cores/AudioEngine/AEFactory.h"
#include "cores/AudioEngine/Utils/AEConvert.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <dlfcn.h>
#include "filesystem/SpecialProtocol.h"
#endif
*
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <windows.h>
#else
#ifndef __cdecl
* Call one of the menu hooks (if supported).
* Supported PVR_MENUHOOK instances have to be added in ADDON_Create(), by calling AddMenuHook() on the callback.
* @param menuhook The hook to call.
+ * @param item The selected item for which the hook was called.
* @return PVR_ERROR_NO_ERROR if the hook was called successfully.
* @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function.
*/
- PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook);
+ PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook, const PVR_MENUHOOK_DATA &item);
//@}
/*! @name PVR EPG methods
#ifndef __PVRCLIENT_TYPES_H__
#define __PVRCLIENT_TYPES_H__
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <windows.h>
#else
#ifndef __cdecl
#define PVR_STREAM_MAX_STREAMS 20
/* current PVR API version */
-#define XBMC_PVR_API_VERSION "1.7.0"
+#define XBMC_PVR_API_VERSION "1.8.0"
/* min. PVR API version */
-#define XBMC_PVR_MIN_API_VERSION "1.7.0"
+#define XBMC_PVR_MIN_API_VERSION "1.8.0"
#ifdef __cplusplus
extern "C" {
*/
typedef enum
{
+ PVR_MENUHOOK_UNKNOWN =-1, /*!< @brief unknown menu hook */
PVR_MENUHOOK_ALL = 0, /*!< @brief all categories */
PVR_MENUHOOK_CHANNEL = 1, /*!< @brief for channels */
PVR_MENUHOOK_TIMER = 2, /*!< @brief for timers */
} ATTRIBUTE_PACKED PVR_EDL_ENTRY;
/*!
+ * @brief PVR menu hook data
+ */
+ typedef struct PVR_MENUHOOK_DATA
+ {
+ PVR_MENUHOOK_CAT cat;
+ union data {
+ int iEpgUid;
+ PVR_CHANNEL channel;
+ PVR_TIMER timer;
+ PVR_RECORDING recording;
+ } data;
+ } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA;
+
+ /*!
* @brief Structure to transfer the methods from xbmc_pvr_dll.h to XBMC
*/
typedef struct PVRClient
const char* (__cdecl* GetBackendVersion)(void);
const char* (__cdecl* GetConnectionString)(void);
PVR_ERROR (__cdecl* GetDriveSpace)(long long*, long long*);
- PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&);
+ PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&);
PVR_ERROR (__cdecl* GetEpg)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t);
int (__cdecl* GetChannelGroupsAmount)(void);
PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool);
#include "guilib/GUIWindowManager.h"
#include "utils/log.h"
#include "ApplicationMessenger.h"
+#include "utils/StringUtils.h"
+#include "AppParamParser.h"
#include <android/bitmap.h>
#include "android/jni/JNIThreading.h"
#include "android/jni/BroadcastReceiver.h"
#include "android/jni/BitmapDrawable.h"
#include "android/jni/Bitmap.h"
#include "android/jni/CharSequence.h"
+#include "android/jni/URI.h"
+#include "android/jni/Cursor.h"
+#include "android/jni/ContentResolver.h"
+#include "android/jni/MediaStore.h"
#define GIGABYTES 1073741824
int CXBMCApp::m_batteryLevel = 0;
CXBMCApp::CXBMCApp(ANativeActivity* nativeActivity)
- : CJNIContext(nativeActivity), m_wakeLock(NULL)
+ : CJNIContext(nativeActivity)
+ , CJNIBroadcastReceiver("org/xbmc/xbmc/XBMCBroadcastReceiver")
+ , m_wakeLock(NULL)
{
m_activity = nativeActivity;
m_firstrun = true;
void CXBMCApp::onResume()
{
android_printf("%s: ", __PRETTY_FUNCTION__);
+ CJNIIntentFilter batteryFilter;
+ batteryFilter.addAction("android.intent.action.BATTERY_CHANGED");
+ registerReceiver(*this, batteryFilter);
}
void CXBMCApp::onPause()
{
android_printf("%s: ", __PRETTY_FUNCTION__);
+ unregisterReceiver(*this);
}
void CXBMCApp::onStop()
CJNIIntent startIntent = getIntent();
android_printf("XBMC Started with action: %s\n",startIntent.getAction().c_str());
- CJNIIntentFilter batteryFilter;
- batteryFilter.addAction("android.intent.action.BATTERY_CHANGED");
- registerReceiver(*this, batteryFilter);
+ std::string filenameToPlay = GetFilenameFromIntent(startIntent);
+ if (!filenameToPlay.empty())
+ {
+ int argc = 2;
+ const char** argv = (const char**) malloc(argc*sizeof(char*));
+
+ std::string exe_name("XBMC");
+ argv[0] = exe_name.c_str();
+ argv[1] = filenameToPlay.c_str();
+
+ CAppParamParser appParamParser;
+ appParamParser.Parse((const char **)argv, argc);
+
+ free(argv);
+ }
android_printf(" => waiting for a window");
// Hack!
AndroidBitmapInfo info;
CJNIBitmapDrawable drawable = (CJNIBitmapDrawable)GetPackageManager().getApplicationIcon(packageName);
CJNIBitmap icon(drawable.getBitmap());
- AndroidBitmap_getInfo(env, icon.get(), &info);
+ AndroidBitmap_getInfo(env, icon.get_raw(), &info);
*width = info.width;
*height = info.height;
return true;
JNIEnv* env = xbmc_jnienv();
CJNIBitmapDrawable drawable = (CJNIBitmapDrawable)GetPackageManager().getApplicationIcon(packageName);
CJNIBitmap bitmap(drawable.getBitmap());
- AndroidBitmap_lockPixels(env, bitmap.get(), &bitmapBuf);
+ AndroidBitmap_lockPixels(env, bitmap.get_raw(), &bitmapBuf);
if (bitmapBuf)
{
memcpy(buffer, bitmapBuf, bufSize);
- AndroidBitmap_unlockPixels(env, bitmap.get());
+ AndroidBitmap_unlockPixels(env, bitmap.get_raw());
return true;
}
return false;
m_batteryLevel = intent.getIntExtra("level",-1);
}
+void CXBMCApp::onNewIntent(CJNIIntent intent)
+{
+ std::string action = intent.getAction();
+ if (action == "android.intent.action.VIEW")
+ {
+ std::string playFile = GetFilenameFromIntent(intent);
+ CApplicationMessenger::Get().MediaPlay(playFile);
+ }
+}
+
void CXBMCApp::SetupEnv()
{
setenv("XBMC_ANDROID_SYSTEM_LIBS", CJNISystem::getProperty("java.library.path").c_str(), 0);
else
setenv("HOME", getenv("XBMC_TEMP"), 0);
}
+
+std::string CXBMCApp::GetFilenameFromIntent(const CJNIIntent &intent)
+{
+ std::string ret;
+ if (!intent)
+ return ret;
+ CJNIURI data = intent.getData();
+ if (!data)
+ return ret;
+ std::string scheme = data.getScheme();
+ StringUtils::ToLower(scheme);
+ if (scheme == "content")
+ {
+ std::vector<std::string> filePathColumn;
+ filePathColumn.push_back(CJNIMediaStoreMediaColumns::DATA);
+ CJNICursor cursor = getContentResolver().query(data, filePathColumn, std::string(), std::vector<std::string>(), std::string());
+ if(cursor.moveToFirst())
+ {
+ int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
+ ret = cursor.getString(columnIndex);
+ }
+ cursor.close();
+ }
+ else if(scheme == "file")
+ ret = data.getPath();
+ else
+ ret = data.toString();
+ return ret;
+}
#include "xbmc.h"
#include "android/jni/Context.h"
+#include "android/jni/BroadcastReceiver.h"
// forward delares
class CJNIWakeLock;
};
-class CXBMCApp : public IActivityHandler, public CJNIContext
+class CXBMCApp : public IActivityHandler, public CJNIContext, public CJNIBroadcastReceiver
{
public:
CXBMCApp(ANativeActivity *nativeActivity);
virtual ~CXBMCApp();
virtual void onReceive(CJNIIntent intent);
+ virtual void onNewIntent(CJNIIntent intent);
bool isValid() { return m_activity != NULL; }
private:
static bool HasLaunchIntent(const std::string &package);
bool getWakeLock();
+ std::string GetFilenameFromIntent(const CJNIIntent &intent);
void run();
void stop();
void SetupEnv();
}
exit(0);
}
+
+extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ jint version = JNI_VERSION_1_6;
+ JNIEnv* env;
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), version) != JNI_OK)
+ return -1;
+
+ jclass cMain = env->FindClass("org/xbmc/xbmc/XBMCBroadcastReceiver");
+ if(cMain)
+ {
+ JNINativeMethod mOnReceive = { "_onReceive", "(Landroid/content/Intent;)V", (void*)&CJNIBroadcastReceiver::_onReceive};
+ env->RegisterNatives(cMain, &mOnReceive, 1);
+ }
+
+ jclass cBroadcastReceiver = env->FindClass("org/xbmc/xbmc/Main");
+ if(cBroadcastReceiver)
+ {
+ JNINativeMethod mOnNewIntent = { "_onNewIntent", "(Landroid/content/Intent;)V", (void*)&CJNIContext::_onNewIntent};
+ env->RegisterNatives(cBroadcastReceiver, &mOnNewIntent, 1);
+ }
+ return version;
+}
using namespace jni;
int CJNIAudioManager::STREAM_MUSIC(0);
-CJNIAudioManager::CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object)
+
+void CJNIAudioManager::PopulateStaticFields()
{
- STREAM_MUSIC = (get_static_field<int>(m_object, "STREAM_MUSIC"));
+ jhclass clazz = find_class("android/media/AudioManager");
+ STREAM_MUSIC = (get_static_field<int>(clazz, "STREAM_MUSIC"));
}
int CJNIAudioManager::getStreamMaxVolume()
// Note removal of streamType param.
int getStreamMaxVolume();
void setStreamVolume(int index = 0, int flags = 0);
+
+ static void PopulateStaticFields();
~CJNIAudioManager(){};
- CJNIAudioManager(const jni::jhobject &object);
+ CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object){};
private:
CJNIAudioManager();
--- /dev/null
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "BaseColumns.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+std::string CJNIBaseColumns::_ID;
+std::string CJNIBaseColumns::_COUNT;
+
+void CJNIBaseColumns::PopulateStaticFields()
+{
+ jhclass clazz = find_class("android/provider/BaseColumns");
+ _ID = (jcast<std::string>(get_static_field<jhstring>(clazz, "_ID")));
+ _COUNT = (jcast<std::string>(get_static_field<jhstring>(clazz, "_COUNT")));
+}
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <string>
+class CJNIBaseColumns
+{
+public:
+ static std::string _ID;
+ static std::string _COUNT;
+ static void PopulateStaticFields();
+private:
+ CJNIBaseColumns();
+};
void CJNIBitSet::set(int fromIndex, bool state)
{
- call_method<void>(m_object, "fromIndex", "(IZ)V", (jint)index, state);
+ call_method<void>(m_object, "fromIndex", "(IZ)V", fromIndex, state);
}
void CJNIBitSet::set(int fromIndex, int toIndex)
bool CJNIBitSet::intersects(const CJNIBitSet &bs)
{
- return call_method<jboolean>(m_object, "intersects", "(Ljava/util/BitSet;)Z");
+ return call_method<jboolean>(m_object, "intersects", "(Ljava/util/BitSet;)Z", bs.get_raw());
}
int CJNIBitSet::cardinality()
void CJNIBitSet::jand(const CJNIBitSet &bs)
{
- call_method<void>(m_object, "jand", "(Ljava/util/BitSet;)V");
+ call_method<void>(m_object, "jand", "(Ljava/util/BitSet;)V", bs.get_raw());
}
void CJNIBitSet::jor(const CJNIBitSet &bs)
{
- call_method<void>(m_object, "jor", "(Ljava/util/BitSet;)V");
+ call_method<void>(m_object, "jor", "(Ljava/util/BitSet;)V", bs.get_raw());
}
void CJNIBitSet::jxor(const CJNIBitSet &bs)
{
- call_method<void>(m_object, "jxor", "(Ljava/util/BitSet;)V");
+ call_method<void>(m_object, "jxor", "(Ljava/util/BitSet;)V", bs.get_raw());
}
void CJNIBitSet::jandNot(const CJNIBitSet &bs)
{
- call_method<void>(m_object, "jandNot", "(Ljava/util/BitSet;)V");
+ call_method<void>(m_object, "jandNot", "(Ljava/util/BitSet;)V", bs.get_raw());
}
int CJNIBitSet::hashCode()
public:
CJNIBitmapDrawable();
CJNIBitmapDrawable(const jni::jhobject &object) : CJNIDrawable(object){};
- CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get()){};
+ CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get_raw()){};
CJNIBitmap getBitmap();
~CJNIBitmapDrawable(){};
};
#include "ClassLoader.h"
#include "jutils/jutils-details.hpp"
-CJNIContext * CJNIBroadcastReceiver::jni_app_context=NULL;
-
using namespace jni;
-CJNIBroadcastReceiver::CJNIBroadcastReceiver(CJNIContext *context) : CJNIBase("org/xbmc/xbmc/XBMCBroadcastReceiver")
-{
- jni_app_context = context;
-}
-void CJNIBroadcastReceiver::InitializeBroadcastReceiver()
+CJNIBroadcastReceiver *CJNIBroadcastReceiver::m_receiverInstance(NULL);
+CJNIBroadcastReceiver::CJNIBroadcastReceiver(const std::string &className) : CJNIBase(className)
{
+ CJNIContext *appInstance = CJNIContext::GetAppInstance();
+ if (!appInstance || className.empty())
+ return;
+
// Convert "the/class/name" to "the.class.name" as loadClass() expects it.
- std::string className = GetClassName();
- for (std::string::iterator it = className.begin(); it != className.end(); ++it)
+ std::string dotClassName = GetClassName();
+ for (std::string::iterator it = dotClassName.begin(); it != dotClassName.end(); ++it)
{
if (*it == '/')
*it = '.';
}
- m_object = new_object(jni_app_context->getClassLoader().loadClass(className));
+ m_object = new_object(appInstance->getClassLoader().loadClass(dotClassName));
+ m_receiverInstance = this;
m_object.setGlobal();
}
-void CJNIBroadcastReceiver::DestroyBroadcastReceiver()
-{
- m_object.reset();
-}
-
-extern "C"
-JNIEXPORT void JNICALL Java_org_xbmc_xbmc_XBMCBroadcastReceiver__1onReceive
- (JNIEnv *env, jobject context, jobject intent)
+void CJNIBroadcastReceiver::_onReceive(JNIEnv *env, jobject context, jobject intent)
{
- if(CJNIBroadcastReceiver::jni_app_context)
- CJNIBroadcastReceiver::jni_app_context->onReceive(CJNIIntent(jhobject(intent)));
+ (void)env;
+ (void)context;
+ if(m_receiverInstance)
+ m_receiverInstance->onReceive(CJNIIntent(jhobject(intent)));
}
*
*/
#include "JNIBase.h"
-class CJNIContext;
+class CJNIIntent;
class CJNIBroadcastReceiver : public CJNIBase
{
public:
- static CJNIContext *jni_app_context;
+ static void _onReceive(JNIEnv *env, jobject context, jobject intent);
+
protected:
- void DestroyBroadcastReceiver();
- CJNIBroadcastReceiver(CJNIContext *context);
+ virtual void onReceive(CJNIIntent intent)=0;
~CJNIBroadcastReceiver(){};
- void InitializeBroadcastReceiver();
+ CJNIBroadcastReceiver(const std::string &className);
+
private:
- explicit CJNIBroadcastReceiver(jni::jhobject const& object);
+ static CJNIBroadcastReceiver* m_receiverInstance;
};
int CJNIConnectivityManager::TYPE_ETHERNET(0);
int CJNIConnectivityManager::DEFAULT_NETWORK_PREFERENCE(0);
using namespace jni;
-CJNIConnectivityManager::CJNIConnectivityManager(const jhobject &object) : CJNIBase(object)
+
+void CJNIConnectivityManager::PopulateStaticFields()
{
- TYPE_MOBILE = (get_static_field<int>(m_object, "TYPE_MOBILE"));
- TYPE_WIFI = (get_static_field<int>(m_object, "TYPE_WIFI"));
- TYPE_MOBILE_MMS = (get_static_field<int>(m_object, "TYPE_MOBILE_MMS"));
- TYPE_MOBILE_SUPL = (get_static_field<int>(m_object, "TYPE_MOBILE_SUPL"));
- TYPE_MOBILE_DUN = (get_static_field<int>(m_object, "TYPE_MOBILE_DUN"));
- TYPE_MOBILE_HIPRI = (get_static_field<int>(m_object, "TYPE_MOBILE_HIPRI"));
- TYPE_WIMAX = (get_static_field<int>(m_object, "TYPE_WIMAX"));
- TYPE_BLUETOOTH = (get_static_field<int>(m_object, "TYPE_BLUETOOTH"));
- TYPE_DUMMY = (get_static_field<int>(m_object, "TYPE_DUMMY"));
- TYPE_ETHERNET = (get_static_field<int>(m_object, "TYPE_ETHERNET"));
- DEFAULT_NETWORK_PREFERENCE = (get_static_field<int>(m_object, "DEFAULT_NETWORK_PREFERENCE"));
+ jhclass clazz = find_class("android.net.ConnectivityManager");
+ TYPE_MOBILE = (get_static_field<int>(clazz, "TYPE_MOBILE"));
+ TYPE_WIFI = (get_static_field<int>(clazz, "TYPE_WIFI"));
+ TYPE_MOBILE_MMS = (get_static_field<int>(clazz, "TYPE_MOBILE_MMS"));
+ TYPE_MOBILE_SUPL = (get_static_field<int>(clazz, "TYPE_MOBILE_SUPL"));
+ TYPE_MOBILE_DUN = (get_static_field<int>(clazz, "TYPE_MOBILE_DUN"));
+ TYPE_MOBILE_HIPRI = (get_static_field<int>(clazz, "TYPE_MOBILE_HIPRI"));
+ TYPE_WIMAX = (get_static_field<int>(clazz, "TYPE_WIMAX"));
+ TYPE_BLUETOOTH = (get_static_field<int>(clazz, "TYPE_BLUETOOTH"));
+ TYPE_DUMMY = (get_static_field<int>(clazz, "TYPE_DUMMY"));
+ TYPE_ETHERNET = (get_static_field<int>(clazz, "TYPE_ETHERNET"));
+ DEFAULT_NETWORK_PREFERENCE = (get_static_field<int>(clazz, "DEFAULT_NETWORK_PREFERENCE"));
}
bool CJNIConnectivityManager::isNetworkTypeValid(int networkType)
class CJNIConnectivityManager : public CJNIBase
{
public:
- CJNIConnectivityManager(const jni::jhobject &object);
+ CJNIConnectivityManager(const jni::jhobject &object) : CJNIBase(object){};
bool isNetworkTypeValid(int);
void setNetworkPreference(int);
int getNetworkPreference();
static int TYPE_DUMMY;
static int TYPE_ETHERNET;
static int DEFAULT_NETWORK_PREFERENCE;
+
+ static void PopulateStaticFields();
private:
CJNIConnectivityManager();
};
--- /dev/null
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "ContentResolver.h"
+#include "Cursor.h"
+#include "jutils/jutils-details.hpp"
+#include "URI.h"
+std::string CJNIContentResolver::SCHEME_CONTENT;
+std::string CJNIContentResolver::SCHEME_ANDROID_RESOURCE;
+std::string CJNIContentResolver::SCHEME_FILE;
+std::string CJNIContentResolver::CURSOR_ITEM_BASE_TYPE;
+std::string CJNIContentResolver::CURSOR_DIR_BASE_TYPE;
+
+using namespace jni;
+void CJNIContentResolver::PopulateStaticFields()
+{
+ jhclass clazz = find_class("android/content/ContentResolver");
+ SCHEME_CONTENT = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_CONTENT"));
+ SCHEME_ANDROID_RESOURCE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_ANDROID_RESOURCE"));
+ SCHEME_FILE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_FILE"));
+ CURSOR_ITEM_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_ITEM_BASE_TYPE"));
+ CURSOR_DIR_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_DIR_BASE_TYPE"));
+}
+
+CJNICursor CJNIContentResolver::query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder)
+{
+
+ return (CJNICursor)(call_method<jhobject>(m_object, \
+ "query","(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", \
+ uri.get_raw(), jcast<jhobjectArray>(projection), jcast<jhstring>(selection), jcast<jhobjectArray>(selectionArgs), jcast<jhstring>(sortOrder)));
+}
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+
+class CJNICursor;
+class CJNIURI;
+class CJNIContentResolver : public CJNIBase
+{
+public:
+ CJNIContentResolver(const jni::jhobject &object) : CJNIBase(object){};
+
+ static std::string SCHEME_CONTENT;
+ static std::string SCHEME_ANDROID_RESOURCE;
+ static std::string SCHEME_FILE;
+ static std::string CURSOR_ITEM_BASE_TYPE;
+ static std::string CURSOR_DIR_BASE_TYPE;
+
+ CJNICursor query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder);
+
+ static void PopulateStaticFields();
+private:
+ CJNIContentResolver();
+};
#include "JNIThreading.h"
#include "ApplicationInfo.h"
#include "File.h"
+#include "ContentResolver.h"
+#include "BaseColumns.h"
+#include "MediaStore.h"
+#include "PowerManager.h"
+#include "Cursor.h"
+#include "ConnectivityManager.h"
+#include "AudioManager.h"
#include <android/native_activity.h>
using namespace jni;
jhobject CJNIContext::m_context(0);
-CJNIContext::CJNIContext(const ANativeActivity *nativeActivity) : CJNIBroadcastReceiver(this)
+CJNIContext* CJNIContext::m_appInstance(NULL);
+CJNIContext::CJNIContext(const ANativeActivity *nativeActivity)
{
m_context.reset(nativeActivity->clazz);
xbmc_jni_on_load(nativeActivity->vm, nativeActivity->env);
- InitializeBroadcastReceiver();
+ PopulateStaticFields();
+ m_appInstance = this;
}
CJNIContext::~CJNIContext()
{
+ m_appInstance = NULL;
m_context.release();
- DestroyBroadcastReceiver();
xbmc_jni_on_unload();
}
+void CJNIContext::PopulateStaticFields()
+{
+ CJNIBaseColumns::PopulateStaticFields();
+ CJNIMediaStoreMediaColumns::PopulateStaticFields();
+ CJNIPowerManager::PopulateStaticFields();
+ CJNIPackageManager::PopulateStaticFields();
+ CJNIMediaStoreMediaColumns::PopulateStaticFields();
+ CJNICursor::PopulateStaticFields();
+ CJNIContentResolver::PopulateStaticFields();
+ CJNIConnectivityManager::PopulateStaticFields();
+ CJNIAudioManager::PopulateStaticFields();
+
+}
+
CJNIPackageManager CJNIContext::GetPackageManager()
{
return (CJNIPackageManager)call_method<jhobject>(m_context, "getPackageManager", "()Landroid/content/pm/PackageManager;");
void CJNIContext::startActivity(const CJNIIntent &intent)
{
- call_method<void>(jhobject(m_context), "startActivity", "(Landroid/content/Intent;)V", intent.get());
+ call_method<void>(jhobject(m_context), "startActivity", "(Landroid/content/Intent;)V", intent.get_raw());
}
int CJNIContext::checkCallingOrSelfPermission(const std::string &permission)
CJNIIntent CJNIContext::registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter)
{
return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \
- "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", receiver.get(), filter.get());
+ "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", receiver.get_raw(), filter.get_raw());
}
CJNIIntent CJNIContext::registerReceiver(const CJNIIntentFilter &filter)
{
return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \
- "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", (jobject)NULL, filter.get());
+ "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", (jobject)NULL, filter.get_raw());
+}
+
+void CJNIContext::unregisterReceiver(const CJNIBroadcastReceiver &receiver)
+{
+ call_method<void>(m_context, "unregisterReceiver", "(Landroid/content/BroadcastReceiver;)V", receiver.get_raw());
}
CJNIIntent CJNIContext::sendBroadcast(const CJNIIntent &intent)
{
- return (CJNIIntent)call_method<jhobject>(m_context, "sendBroadcast", "(Landroid/content/Intent;)V", intent.get());
+ return (CJNIIntent)call_method<jhobject>(m_context, "sendBroadcast", "(Landroid/content/Intent;)V", intent.get_raw());
}
CJNIIntent CJNIContext::getIntent()
{
return (CJNIFile)call_method<jhobject>(m_context, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;", jcast<jhstring>(path));
}
+
+CJNIContentResolver CJNIContext::getContentResolver()
+{
+ return (CJNIContentResolver)call_method<jhobject>(m_context, "getContentResolver", "()Landroid/content/ContentResolver;");
+}
+
+void CJNIContext::_onNewIntent(JNIEnv *env, jobject context, jobject intent)
+{
+ (void)env;
+ (void)context;
+ if(m_appInstance)
+ m_appInstance->onNewIntent(CJNIIntent(jhobject(intent)));
+}
class CJNIClassLoader;
class CJNIApplicationInfo;
class CJNIFile;
-class CJNIContext : public CJNIBroadcastReceiver
+class CJNIContentResolver;
+class CJNIContext
{
public:
static CJNIPackageManager GetPackageManager();
static int checkCallingOrSelfPermission(const std::string &permission);
static CJNIIntent registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter);
static CJNIIntent registerReceiver(const CJNIIntentFilter &filter);
+ static void unregisterReceiver(const CJNIBroadcastReceiver &receiver);
static CJNIIntent sendBroadcast(const CJNIIntent &intent);
static CJNIIntent getIntent();
static CJNIClassLoader getClassLoader();
static CJNIFile getCacheDir();
static CJNIFile getDir(const std::string &path, int mode);
static CJNIFile getExternalFilesDir(const std::string &path);
- virtual void onReceive(CJNIIntent intent)=0;
+ static CJNIContentResolver getContentResolver();
+ static CJNIContext* GetAppInstance() { return m_appInstance; };
+ static void _onNewIntent(JNIEnv *env, jobject context, jobject intent);
protected:
+ virtual void onNewIntent(CJNIIntent intent)=0;
CJNIContext(const ANativeActivity *nativeActivity);
~CJNIContext();
private:
CJNIContext();
+ void PopulateStaticFields();
void operator=(CJNIContext const&){};
static jni::jhobject m_context;
+ static CJNIContext *m_appInstance;
};
--- /dev/null
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "Cursor.h"
+#include "jutils/jutils-details.hpp"
+#include "URI.h"
+
+using namespace jni;
+
+int CJNICursor::FIELD_TYPE_NULL(0);
+int CJNICursor::FIELD_TYPE_INTEGER(0);
+int CJNICursor::FIELD_TYPE_FLOAT(0);
+int CJNICursor::FIELD_TYPE_STRING(0);
+int CJNICursor::FIELD_TYPE_BLOB(0);
+
+void CJNICursor::PopulateStaticFields()
+{
+ jhclass clazz = find_class("android/database/Cursor");
+ FIELD_TYPE_NULL = (get_static_field<int>(clazz, "FIELD_TYPE_NULL"));
+ FIELD_TYPE_INTEGER = (get_static_field<int>(clazz, "FIELD_TYPE_INTEGER"));
+ FIELD_TYPE_FLOAT = (get_static_field<int>(clazz, "FIELD_TYPE_FLOAT"));
+ FIELD_TYPE_STRING = (get_static_field<int>(clazz, "FIELD_TYPE_STRING"));
+ FIELD_TYPE_BLOB = (get_static_field<int>(clazz, "FIELD_TYPE_BLOB"));
+}
+
+int CJNICursor::getCount()
+{
+ return call_method<jint>(m_object, "getCount", "()I");
+}
+
+int CJNICursor::getPosition()
+{
+ return call_method<jint>(m_object, "getPosition", "()I");
+}
+
+bool CJNICursor::move(int offset)
+{
+ return call_method<jboolean>(m_object, "move", "(I)Z", offset);
+}
+
+bool CJNICursor::moveToPosition(int position)
+{
+ return call_method<jboolean>(m_object, "moveToPosition", "(I)Z", position);
+}
+
+bool CJNICursor::moveToFirst()
+{
+ return call_method<jboolean>(m_object, "moveToFirst", "()Z");
+}
+
+bool CJNICursor::moveToLast()
+{
+ return call_method<jboolean>(m_object, "moveToLast", "()Z");
+}
+
+bool CJNICursor::moveToNext()
+{
+ return call_method<jboolean>(m_object, "moveToNext", "()Z");
+}
+
+bool CJNICursor::moveToPrevious()
+{
+ return call_method<jboolean>(m_object, "moveToPrevious", "()Z");
+}
+
+bool CJNICursor::isFirst()
+{
+ return call_method<jboolean>(m_object, "isFirst", "()Z");
+}
+
+bool CJNICursor::isLast()
+{
+ return call_method<jboolean>(m_object, "isLast", "()Z");
+}
+
+bool CJNICursor::isBeforeFirst()
+{
+ return call_method<jboolean>(m_object, "isBeforeFirst", "()Z");
+}
+
+bool CJNICursor::isAfterLast()
+{
+ return call_method<jboolean>(m_object, "isAfterLast", "()Z");
+}
+
+int CJNICursor::getColumnIndex(const std::string &columnName)
+{
+ return call_method<jint>(m_object, "getColumnIndex", "(Ljava/lang/String;)I", jcast<jhstring>(columnName));
+}
+
+std::string CJNICursor::getColumnName(int columnIndex)
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "getColumnName", "(I)Ljava/lang/String;", columnIndex));
+}
+
+std::vector<std::string> CJNICursor::getColumnNames()
+{
+ return jcast<std::vector<std::string>>(call_method<jhobjectArray>(m_object, "getColumnNames", "()[Ljava/lang/String;"));
+}
+
+int CJNICursor::getColumnCount()
+{
+ return call_method<jint>(m_object, "getColumnCount", "()I");
+}
+
+std::string CJNICursor::getString(int columnIndex)
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "getString", "(I)Ljava/lang/String;", columnIndex));
+}
+
+short CJNICursor::getShort(int columnIndex)
+{
+ return call_method<jshort>(m_object, "getShort", "()S", columnIndex);
+}
+
+int CJNICursor::getInt(int columnIndex)
+{
+ return call_method<jint>(m_object, "getInt", "()I", columnIndex);
+}
+
+long CJNICursor::getLong(int columnIndex)
+{
+ return call_method<jint>(m_object, "getLong", "()J", columnIndex);
+}
+
+float CJNICursor::getFloat(int columnIndex)
+{
+ return call_method<jfloat>(m_object, "getFloat", "()F", columnIndex);
+}
+
+double CJNICursor::getDouble(int columnIndex)
+{
+ return call_method<jdouble>(m_object, "getDouble", "()D", columnIndex);
+}
+
+int CJNICursor::getType(int columnIndex)
+{
+ return call_method<jint>(m_object, "getType", "(I)I", columnIndex);
+}
+
+bool CJNICursor::isNull(int columnIndex)
+{
+ return call_method<jboolean>(m_object, "isNull", "(I)Z", columnIndex);
+}
+
+void CJNICursor::deactivate()
+{
+ call_method<void>(m_object, "deactivate", "()V");
+}
+
+bool CJNICursor::requery()
+{
+ return call_method<jboolean>(m_object, "requery", "()Z");
+}
+
+void CJNICursor::close()
+{
+ call_method<void>(m_object, "close", "()V");
+}
+
+bool CJNICursor::isClosed()
+{
+ return call_method<jboolean>(m_object, "isClosed", "()Z");
+}
+
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+#include "MediaStore.h"
+class CJNIURI;
+class CJNICursor : public CJNIBase
+{
+public:
+ ~CJNICursor(){};
+ CJNICursor(const jni::jhobject &object) : CJNIBase(object){};
+ int getCount();
+ int getPosition();
+ bool move(int offset);
+ bool moveToPosition(int position);
+ bool moveToFirst();
+ bool moveToLast();
+ bool moveToNext();
+ bool moveToPrevious();
+ bool isFirst();
+ bool isLast();
+ bool isBeforeFirst();
+ bool isAfterLast();
+ int getColumnIndex(const std::string &columnName);
+ std::string getColumnName(int columnIndex);
+ std::vector<std::string> getColumnNames();
+ int getColumnCount();
+ std::string getString(int columnIndex);
+ short getShort(int columnIndex);
+ int getInt(int columnIndex);
+ long getLong(int columnIndex);
+ float getFloat(int columnIndex);
+ double getDouble(int columnIndex);
+ int getType(int columnIndex);
+ bool isNull(int columnIndex);
+ void deactivate();
+ bool requery();
+ void close();
+ bool isClosed();
+
+ static int FIELD_TYPE_NULL;
+ static int FIELD_TYPE_INTEGER;
+ static int FIELD_TYPE_FLOAT;
+ static int FIELD_TYPE_STRING;
+ static int FIELD_TYPE_BLOB;
+
+ static void PopulateStaticFields();
+private:
+ CJNICursor();
+};
}
bool CJNIEnum::equals(const CJNIEnum &object)
{
- return call_method<jboolean>(m_object, "equals", "(Ljava/lang/Object;)Z", object.get());
+ return call_method<jboolean>(m_object, "equals", "(Ljava/lang/Object;)Z", object.get_raw());
}
CJNIIntent::CJNIIntent(const std::string &action) : CJNIBase("android/content/Intent")
{
- m_object = new_object(GetClassName());
+ if(action.empty())
+ m_object = new_object(GetClassName());
+ else
+ m_object = new_object(GetClassName(), "<init>", "(Ljava/lang/String;)V", jcast<jhstring>(action));
}
std::string CJNIIntent::getAction()
void CJNIIntent::setDataAndType(const CJNIURI &uri, const std::string &type)
{
- call_method<jhobject>(m_object, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", uri.get(), jcast<jhstring>(type));
+ call_method<jhobject>(m_object, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", uri.get_raw(), jcast<jhstring>(type));
}
void CJNIIntent::setFlags(int flags)
call_method<jhobject>(m_object, "setType", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(type));
}
+CJNIURI CJNIIntent::getData() const
+{
+ return (CJNIURI)call_method<jhobject>(m_object, "getData","()Landroid/net/Uri;");
+}
void setPackage(const std::string &packageName);
void setType(const std::string &type);
+ CJNIURI getData() const;
};
void CJNIIntentFilter::addAction(std::string action)
{
- call_method<jhobject>(m_object, "addAction", "(Ljava/lang/String;)V", jcast<jhstring>(action));
+ call_method<void>(m_object, "addAction", "(Ljava/lang/String;)V", jcast<jhstring>(action));
}
void CJNIIntentFilter::addDataScheme(std::string scheme)
{
- call_method<jhobject>(m_object, "addDataScheme", "(Ljava/lang/String;)V", jcast<jhstring>(scheme));
+ call_method<void>(m_object, "addDataScheme", "(Ljava/lang/String;)V", jcast<jhstring>(scheme));
}
public:
operator safe_bool_type() const { return !m_object ? 0 : &CJNIBase::non_null_object; }
- const jni::jhobject& get() const { return m_object; }
+ const jni::jhobject& get_raw() const { return m_object; }
protected:
CJNIBase(jni::jhobject const& object);
static void jnienv_detach_thread(void *arg)
{
+ (void)arg;
if (!jvm())
return;
__android_log_print(ANDROID_LOG_VERBOSE, "XBMC","detaching thread");
SRCS += URI.cpp
SRCS += WifiInfo.cpp
SRCS += WifiManager.cpp
+SRCS += WifiManagerMulticastLock.cpp
SRCS += ScanResult.cpp
SRCS += List.cpp
SRCS += DhcpInfo.cpp
SRCS += ApplicationInfo.cpp
SRCS += BitmapDrawable.cpp
SRCS += CharSequence.cpp
+SRCS += ContentResolver.cpp
+SRCS += Cursor.cpp
+SRCS += BaseColumns.cpp
+SRCS += MediaStore.cpp
LIB = jni.a
-CXXFLAGS+=-std=gnu++0x
+CXXFLAGS+=-std=gnu++0x -Wextra
include @abs_top_srcdir@/Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
--- /dev/null
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "MediaStore.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+std::string CJNIMediaStoreMediaColumns::DATA;
+std::string CJNIMediaStoreMediaColumns::SIZE;
+std::string CJNIMediaStoreMediaColumns::DISPLAY_NAME;
+std::string CJNIMediaStoreMediaColumns::TITLE;
+std::string CJNIMediaStoreMediaColumns::DATE_ADDED;
+std::string CJNIMediaStoreMediaColumns::DATE_MODIFIED;
+std::string CJNIMediaStoreMediaColumns::MIME_TYPE;
+void CJNIMediaStoreMediaColumns::PopulateStaticFields()
+{
+ jhclass clazz = find_class("android/provider/MediaStore$MediaColumns");
+ DATA = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATA")));
+ SIZE = (jcast<std::string>(get_static_field<jhstring>(clazz, "SIZE")));
+ DISPLAY_NAME = (jcast<std::string>(get_static_field<jhstring>(clazz, "DISPLAY_NAME")));
+ TITLE = (jcast<std::string>(get_static_field<jhstring>(clazz, "TITLE")));
+ DATE_ADDED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_ADDED")));
+ DATE_MODIFIED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_MODIFIED")));
+ MIME_TYPE = (jcast<std::string>(get_static_field<jhstring>(clazz, "MIME_TYPE")));
+}
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+#include "BaseColumns.h"
+class CJNIMediaStoreMediaColumns : public CJNIBaseColumns
+{
+public:
+ static std::string DATA;
+ static std::string SIZE;
+ static std::string DISPLAY_NAME;
+ static std::string TITLE;
+ static std::string DATE_ADDED;
+ static std::string DATE_MODIFIED;
+ static std::string MIME_TYPE;
+ static void PopulateStaticFields();
+private:
+ CJNIMediaStoreMediaColumns();
+};
+
+class CJNIMediaStore : public CJNIBase
+{
+public:
+ ~CJNIMediaStore(){};
+ CJNIMediaStore(const jni::jhobject &object) : CJNIBase(object){};
+};
using namespace jni;
int CJNIPackageManager::GET_ACTIVITIES(0);
-CJNIPackageManager::CJNIPackageManager(const jni::jhobject &object) : CJNIBase(object)
+void CJNIPackageManager::PopulateStaticFields()
{
- GET_ACTIVITIES = (get_static_field<int>(m_object, "GET_ACTIVITIES"));
+ jhclass clazz = find_class("android/content/pm/PackageManager");
+ GET_ACTIVITIES = (get_static_field<int>(clazz, "GET_ACTIVITIES"));
}
CJNIIntent CJNIPackageManager::getLaunchIntentForPackage(const std::string &package)
CJNICharSequence CJNIPackageManager::getApplicationLabel(const CJNIApplicationInfo &info)
{
- return (CJNICharSequence)call_method<jhobject>(m_object, "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", info.get());
+ return (CJNICharSequence)call_method<jhobject>(m_object, "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", info.get_raw());
}
CJNIList<CJNIApplicationInfo> CJNIPackageManager::getInstalledApplications(int flags)
class CJNIPackageManager : public CJNIBase
{
public:
- CJNIPackageManager(const jni::jhobject &object);
+ CJNIPackageManager(const jni::jhobject &object) : CJNIBase(object) {};
~CJNIPackageManager(){};
CJNIIntent getLaunchIntentForPackage(const std::string &package);
CJNIList<CJNIApplicationInfo> getInstalledApplications(int flags);
CJNICharSequence getApplicationLabel(const CJNIApplicationInfo &info);
+ static void PopulateStaticFields();
static int GET_ACTIVITIES;
private:
CJNIPackageManager();
using namespace jni;
int CJNIPowerManager::FULL_WAKE_LOCK(0);
-CJNIPowerManager::CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object)
+
+void CJNIPowerManager::PopulateStaticFields()
{
- FULL_WAKE_LOCK = (get_static_field<int>(m_object, "FULL_WAKE_LOCK"));
+ jhclass clazz = find_class("android/os/PowerManager");
+ FULL_WAKE_LOCK = (get_static_field<int>(clazz, "FULL_WAKE_LOCK"));
}
CJNIWakeLock CJNIPowerManager::newWakeLock(const std::string &name)
void reboot(const std::string &reason);
void goToSleep(int64_t timestamp);
- CJNIPowerManager(const jni::jhobject &object);
+ static void PopulateStaticFields();
+ CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object){};
~CJNIPowerManager(){};
private:
{
return (CJNIURI)call_static_method<jhobject>("android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", jcast<jhstring>(uriString));
}
+
+std::string CJNIURI::getScheme() const
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "getScheme", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::toString() const
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::getLastPathSegment() const
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "getLastPathSegment", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::getPath() const
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "getPath", "()Ljava/lang/String;"));
+}
class CJNIURI : public CJNIBase
{
public:
+ CJNIURI(const jni::jhobject &uri) : CJNIBase(uri){};
+ std::string getScheme() const;
+ std::string toString() const;
+ std::string getLastPathSegment() const;
+ std::string getPath() const;
static CJNIURI parse(std::string uriString);
~CJNIURI(){};
private:
- CJNIURI(const jni::jhobject &uri) : CJNIBase(uri){};
CJNIURI();
};
CJNINetworkInfoDetailedState CJNIWifiInfo::getDetailedStateOf(const CJNISupplicantState &suppState)
{
- return call_static_method<jhobject>("android/net/wifi/WifiInfo", "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", suppState.get());
+ return call_static_method<jhobject>("android/net/wifi/WifiInfo", "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", suppState.get_raw());
}
#include "WifiInfo.h"
#include "WifiConfiguration.h"
#include "ScanResult.h"
+#include "WifiManagerMulticastLock.h"
#include "jutils/jutils-details.hpp"
using namespace jni;
{
return call_static_method<jint>("android/net/wifi/WifiManager", "compareSignalLevel", "(II)I", rssiA, rssiB);
}
+
+CJNIWifiManagerMulticastLock CJNIWifiManager::createMulticastLock(const std::string &tag)
+{
+ return (CJNIWifiManagerMulticastLock)call_method<jhobject>(m_object, "createMulticastLock", "(Ljava/lang/String;)Landroid/net/wifi/WifiManager$MulticastLock;", jcast<jhstring>(tag));
+}
class CJNIWifiInfo;
class CJNIScanResult;
class CJNIWifiConfiguration;
+class CJNIWifiManagerMulticastLock;
class CJNIWifiManager : public CJNIBase
{
friend class CJNIContext;
bool isWifiEnabled();
static int calculateSignalLevel(int, int);
static int compareSignalLevel(int, int);
+ CJNIWifiManagerMulticastLock createMulticastLock(const std::string &tag);
private:
CJNIWifiManager();
};
--- /dev/null
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "WifiManagerMulticastLock.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+void CJNIWifiManagerMulticastLock::acquire()
+{
+ call_method<void>(m_object, "acquire", "()V");
+}
+
+void CJNIWifiManagerMulticastLock::release()
+{
+ call_method<void>(m_object, "release", "()V");
+}
+
+void CJNIWifiManagerMulticastLock::setReferenceCounted(bool refCounted)
+{
+ call_method<void>(m_object, "setReferenceCounted", "(Z)V", refCounted);
+}
+
+bool CJNIWifiManagerMulticastLock::isHeld()
+{
+ return call_method<jboolean>(m_object, "setReferenceCounted", "()Z");
+}
+
+std::string CJNIWifiManagerMulticastLock::toString()
+{
+ return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;"));
+}
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+
+class CJNIWifiManagerMulticastLock : public CJNIBase
+{
+public:
+ CJNIWifiManagerMulticastLock(const jni::jhobject &wakelock) : CJNIBase(wakelock){};
+ ~CJNIWifiManagerMulticastLock(){};
+ void acquire();
+ void release();
+ void setReferenceCounted(bool refCounted);
+ bool isHeld();
+ std::string toString();
+private:
+ CJNIWifiManagerMulticastLock();
+};
jhstring jcast_helper<jhstring, std::string>::cast(const std::string &s)
{
JNIEnv *env = xbmc_jnienv();
- jstring obj = env->NewStringUTF(s.c_str());
- return jhstring(obj);
+ jstring ret = NULL;
+ if (!s.empty())
+ {
+ ret = env->NewStringUTF(s.c_str());
+ }
+ return jhstring(ret);
+}
+
+jhobjectArray jcast_helper<jhobjectArray, std::vector<std::string> >::cast(const std::vector<std::string> &s)
+{
+ JNIEnv *env = xbmc_jnienv();
+ jobjectArray ret = NULL;
+ if (!s.empty())
+ {
+ ret = env->NewObjectArray(s.size(), env->FindClass("java/lang/String"), NULL);
+ for (unsigned int i = 0; i < s.size(); i++)
+ env->SetObjectArrayElement(ret, i, env->NewStringUTF(s[i].c_str()));
+ }
+ return jhobjectArray(ret);
+}
+
+std::vector<std::string> jcast_helper<std::vector<std::string>, jobjectArray >::cast(const jobjectArray &s)
+{
+ JNIEnv *env = xbmc_jnienv();
+ std::vector<std::string> ret;
+ jstring element;
+ const char* newString = NULL;
+ if (!s)
+ return ret;
+
+ unsigned int arraySize = env->GetArrayLength(s);
+ ret.reserve(arraySize);
+ for (unsigned int i = 0; i < arraySize; ++i)
+ {
+ element = (jstring) env->GetObjectArrayElement(s, i);
+ newString = env->GetStringUTFChars(element, JNI_FALSE);
+ if (newString)
+ {
+ ret.push_back(newString);
+ env->ReleaseStringUTFChars(element, newString);
+ }
+ }
+ return ret;
}
#define CRYSTAX_PP_CAT(a, b, c) CRYSTAX_PP_CAT_IMPL(a, b, c)
template <typename T>
struct result_helper
{
- static T make_result(JNIEnv *env, T obj) {return obj;}
+ static T make_result(JNIEnv *env, T obj) {(void)env; return obj;}
};
template <typename T>
};
template <>
+struct jcast_helper<std::vector<std::string>, jobjectArray>
+{
+ static std::vector<std::string> cast(jobjectArray const &v);
+};
+
+template <>
struct jcast_helper<jhstring, std::string>
{
static jhstring cast(const std::string &v);
};
template <>
+struct jcast_helper<jhobjectArray, std::vector<std::string> >
+{
+ static jhobjectArray cast(const std::vector<std::string> &v);
+};
+
+template <>
struct jcast_helper<std::string, jhstring>
{
static std::string cast(jhstring const &v)
}
};
+template <>
+struct jcast_helper<std::vector<std::string>, jhobjectArray>
+{
+ static std::vector<std::string> cast(jhobjectArray const &v)
+ {
+ return jcast_helper<std::vector<std::string>, jobjectArray>::cast(v);
+ }
+};
+
} // namespace details
*/
// Get static field
-template <typename Ret, typename T>
-Ret get_static_field(JNIEnv *env, jholder<T> const &obj, const char *name, const char *signature)
+template <typename Ret>
+Ret get_static_field(JNIEnv *env, jhobject const &obj, const char *name, const char *signature)
{
return details::jni_helper<Ret>::get_static_field(env, get_class(env, obj), get_static_field_id(env, obj, name, signature));
}
+template <typename Ret>
+Ret get_static_field(JNIEnv *env, jhclass const &cls, const char *name, const char *signature)
+{
+ return details::jni_helper<Ret>::get_static_field(env, cls, get_static_field_id(env, cls, name, signature));
+}
+
template <typename Ret, typename T>
Ret get_static_field(jholder<T> const &obj, const char *name, const char *signature)
{
CStdString CCDDARipJob::SetupTempFile()
{
char tmp[MAX_PATH];
-#ifndef _LINUX
+#ifndef TARGET_POSIX
GetTempFileName(CSpecialProtocol::TranslatePath("special://temp/"), "riptrack", 0, tmp);
#else
int fd;
virtual const char* GetType() const { return "cdrip"; };
virtual bool operator==(const CJob *job) const;
virtual bool DoWork();
+ CStdString GetOutput() const { return m_output; }
protected:
//! \brief Setup the audio encoder
CEncoder* SetupEncoder(XFILE::CFile& reader);
#include "utils/log.h"
#include "utils/TimeUtils.h"
#include "utils/URIUtils.h"
+#include "settings/MediaSourceSettings.h"
+#include "Application.h"
+#include "music/MusicDatabase.h"
using namespace std;
using namespace XFILE;
}
CCDDARipper::CCDDARipper()
+ : CJobQueue(false, 1) //enforce fifo and non-parallel processing
{
}
bool CCDDARipper::RipTrack(CFileItem* pItem)
{
// don't rip non cdda items
- if (URIUtils::GetExtension(pItem->GetPath()).CompareNoCase(".cdda") != 0)
+ if (!URIUtils::HasExtension(pItem->GetPath(), ".cdda"))
{
CLog::Log(LOGDEBUG, "cddaripper: file is not a cdda track");
return false;
CFileItem ripPath(strDirectory, true);
if (ripPath.IsSmb())
legalType = LEGAL_WIN32_COMPAT;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (ripPath.IsHD())
legalType = LEGAL_WIN32_COMPAT;
#endif
void CCDDARipper::OnJobComplete(unsigned int jobID, bool success, CJob* job)
{
if (success)
+ {
+ if(CJobQueue::QueueEmpty())
+ {
+ CStdString dir;
+ URIUtils::GetDirectory(((CCDDARipJob*)job)->GetOutput(), dir);
+ bool unimportant;
+ int source = CUtil::GetMatchingSource(dir, *CMediaSourceSettings::Get().CMediaSourceSettings::GetSources("music"), unimportant);
+
+ CMusicDatabase database;
+ database.Open();
+ if (source>=0 && database.InsideScannedPath(dir))
+ g_application.StartMusicScan(dir);
+ database.Close();
+ }
return CJobQueue::OnJobComplete(jobID, success, job);
+ }
CancelJobs();
}
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include <ogg/ogg.h>
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include <vorbis/vorbisenc.h>
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include <vorbis/vorbisenc.h>
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "stdint.h"
#else
#define INT64_C __int64
#include "settings/Settings.h"
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
#else
#define fopen_utf8 fopen
// an approximate sleep time.
int frames_written = read_bytes / m_sink_frameSize;
double empty_ms = 1000.0 * (double)frames_written / m_format.m_sampleRate;
- #if defined(_LINUX)
+ #if defined(TARGET_POSIX)
usleep(empty_ms * 1000.0);
#else
Sleep((int)empty_ms);
#include <limits>
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
#else
#define fopen_utf8 fopen
typedef BOOL (APIENTRY *EntryFunc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
/*
* This is a dirty hack.
* The win32 DLLs contain an alloca routine, that first probes the soon
/* since we are handing execution over to unknown code, safeguard here */
try
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
extend_stack_for_dll_alloca();
#endif
initdll((HINSTANCE)hModule, DLL_PROCESS_ATTACH , 0); //call "DllMain" with DLL_PROCESS_ATTACH
char* ResolveReferencedDll(char* dll);
int LoadExports();
void LoadSymbols();
- void UnloadSymbols();
+ static void UnloadSymbols();
};
*/
#include "DllLoaderContainer.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "SoLoader.h"
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "Win32DllLoader.h"
#endif
#include "DllLoader.h"
{ // Has a path, just try to load
return LoadDll(sName, bLoadSymbols);
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
else if (strcmp(sName, "xbmc.so") == 0)
return LoadDll(sName, bLoadSymbols);
#endif
#endif
LibraryLoader* pLoader;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (strstr(sName, ".so") != NULL || strstr(sName, ".vis") != NULL || strstr(sName, ".xbs") != NULL
|| strstr(sName, ".mvis") != NULL || strstr(sName, ".dylib") != NULL || strstr(sName, ".framework") != NULL || strstr(sName, ".pvr") != NULL)
pLoader = new SoLoader(sName, bLoadSymbols);
else
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
if (1)
pLoader = new Win32DllLoader(sName);
else
#define LIBRARY_LOADER
#include "system.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h"
#endif
#include <stdio.h>
#include "system.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h"
#endif
#include "DllLoader.h"
private:
void OverrideImports(const CStdString &dll);
void RestoreImports();
- bool ResolveImport(const char *dllName, const char *functionName, void **fixup);
- bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup);
+ static bool ResolveImport(const char *dllName, const char *functionName, void **fixup);
+ static bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup);
bool NeedsHooking(const char *dllName);
HMODULE m_dllHandle;
{
if ( hModule )
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
free(hModule);
#else
VirtualFree(hModule, 0, MEM_RELEASE);
return 0;
// alloc aligned memory
-#ifdef _LINUX
+#ifdef TARGET_POSIX
hModule = malloc(tempWindowsHeader.SizeOfImage);
#else
hModule = VirtualAllocEx(0, (PVOID)tempWindowsHeader.ImageBase, tempWindowsHeader.SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}
SymbolTable_t;
-#if !defined(_WIN32)
+#if !defined(TARGET_WINDOWS)
#define IMAGE_SYM_UNDEFINED 0
#define IMAGE_SYM_ABSOLUTE 0xFFFF
{
if (NULL == hModule)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GetModuleFileNameA(hModule, lpFilename, nSize);
#else
CLog::Log(LOGDEBUG, "%s - No hModule specified", __FUNCTION__);
#include "threads/CriticalSection.h"
#include "PlatformDefs.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "system.h" // for SOCKET
#endif
void tracker_dll_data_track(DllLoader* pDll, uintptr_t addr);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define _ReturnAddress() __builtin_return_address(0)
#endif
}
#endif
-#ifndef _LINUX
+#ifndef TARGET_POSIX
extern "C" void * _ReturnAddress(void);
#pragma intrinsic(_ReturnAddress)
#endif
#include "threads/SingleLock.h"
#include "utils/log.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define dll_open open
#define dll_fopen fopen
#define dll_close close
#include "utils/log.h"
#include "dll_util.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <windows.h>
#endif
#include <stdlib.h>
uintptr_t get_win_function_address(const char* strDllName, const char* strFunctionName)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
HMODULE handle = GetModuleHandle(strDllName);
if(handle == NULL)
{
#include "storage/IoSupport.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <process.h>
#include "utils/CharsetConverter.h"
#endif
#include "../dll_tracker.h"
#include "filesystem/SpecialProtocol.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "../../../linux/PlatformInclude.h"
#define __except catch
#endif
return FindClose(hFile);
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define CORRECT_SEP_STR(str) \
if (strstr(str, "://") == NULL) \
{ \
#define CORRECT_SEP_STR(str)
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
static void to_WIN32_FIND_DATA(LPWIN32_FIND_DATAW wdata, LPWIN32_FIND_DATA data)
{
CStdString strname;
e[0] = '\0';
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
struct _WIN32_FIND_DATAW FindFileDataW;
CStdStringW strwfile;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(p), strwfile, false);
extern "C" BOOL WINAPI dllFindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
struct _WIN32_FIND_DATAW FindFileDataW;
to_WIN32_FIND_DATAW(lpFindFileData, &FindFileDataW);
BOOL res = FindNextFileW(hFindFile, &FindFileDataW);
}
else strcpy(str, lpFileName);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
// convert '/' to '\\'
char *p = str;
while (p = strchr(p, '/')) * p = '\\';
extern "C" DWORD WINAPI dllGetCurrentProcessId(void)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return (DWORD)getppid();
#else
return GetCurrentProcessId();
hSourceProcessHandle, hSourceHandle, hTargetProcessHandle,
lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions);
#endif
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
*lpTargetHandle = hSourceHandle;
return 1;
#else
extern "C" BOOL WINAPI dllDisableThreadLibraryCalls(HMODULE h)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return DisableThreadLibraryCalls(h);
#else
not_implement("kernel32.dll fake function DisableThreadLibraryCalls called\n"); //warning
#endif
}
-#ifndef _LINUX
+#ifndef TARGET_POSIX
static void DumpSystemInfo(const SYSTEM_INFO* si)
{
CLog::Log(LOGDEBUG, " Processor architecture %d\n", si->wProcessorArchitecture);
#ifdef API_DEBUG
CLog::Log(LOGDEBUG, "GetSystemInfo(0x%x) =>", lpSystemInfo);
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// VS 2003 complains about x even so it's defined
lpSystemInfo->wProcessorArchitecture = 0; //#define PROCESSOR_ARCHITECTURE_INTEL 0
#else
}
extern "C" HANDLE WINAPI dllGetCurrentProcess()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GetCurrentProcess();
#else
#ifdef API_DEBUG
extern "C" LPVOID WINAPI dllGetEnvironmentStrings()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GetEnvironmentStrings();
#else
#ifdef API_DEBUG
extern "C" LPVOID WINAPI dllGetEnvironmentStringsW()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GetEnvironmentStringsW();
#else
return 0;
extern "C" int WINAPI dllGetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GetEnvironmentVariableA(lpName, lpBuffer, nSize);
#else
if (lpBuffer)
extern "C" DWORD WINAPI dllFormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, va_list* Arguments)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return FormatMessageA(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments);
#else
not_implement("kernel32.dll fake function FormatMessage called\n"); //warning
extern "C" DWORD WINAPI dllGetFullPathNameA(LPCTSTR lpFileName, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR* lpFilePart)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (!lpFileName) return 0;
if(strstr(lpFileName, "://"))
{
extern "C" DWORD WINAPI dllGetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (!lpFileName) return 0;
if(wcsstr(lpFileName, L"://"))
{
extern "C" DWORD WINAPI dllExpandEnvironmentStringsA(LPCTSTR lpSrc, LPTSTR lpDst, DWORD nSize)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return ExpandEnvironmentStringsA(lpSrc, lpDst, nSize);
#else
not_implement("kernel32.dll fake function ExpandEnvironmentStringsA called\n"); //warning
extern "C" HANDLE WINAPI dllGetProcessHeap()
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
CLog::Log(LOGWARNING, "KERNEL32!GetProcessHeap() linux cant provide this service!");
return 0;
#else
destinationBuffer = (LPWSTR)malloc(destinationBufferSize * sizeof(WCHAR));
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int ret = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, destinationBuffer, destinationBufferSize);
#else
int ret = 0;
destinationBuffer = (LPSTR)malloc(destinationBufferSize * sizeof(char));
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int ret = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, destinationBuffer, destinationBufferSize, lpDefaultChar, lpUsedDefaultChar);
#else
int ret = 0;
extern "C" UINT WINAPI dllSetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return SetConsoleCtrlHandler(HandlerRoutine, Add);
#else
// no consoles exists on the xbox, do nothing
p++;
if (p == (BYTE *)lpBuffer + numChecked)
{ // fully NULL block - reread
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
LONG low = 0;
LONG high = 0;
#else
extern "C" LPVOID WINAPI dllLockResource(HGLOBAL hResData)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return LockResource(hResData);
#else
not_implement("kernel32.dll fake function LockResource called\n"); //warning
extern "C" SIZE_T WINAPI dllGlobalSize(HGLOBAL hMem)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return GlobalSize(hMem);
#else
not_implement("kernel32.dll fake function GlobalSize called\n"); //warning
extern "C" DWORD WINAPI dllSizeofResource(HMODULE hModule, HRSRC hResInfo)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return SizeofResource(hModule, hResInfo);
#else
not_implement("kernel32.dll fake function SizeofResource called\n"); //warning
#define MAX_LEADBYTES 12
#define MAX_DEFAULTCHAR 2
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
typedef struct _STARTUPINFOA
{
DWORD cb;
#endif
typedef DWORD LCTYPE;
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
typedef BOOL (*PHANDLER_ROUTINE)(DWORD);
typedef struct _OSVERSIONINFO
}
OSVERSIONINFOW, *LPOSVERSIONINFOW;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define EXCEPTION_MAXIMUM_PARAMETERS 15
typedef struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define LANG_ENGLISH 0x09
#define SUBLANG_ENGLISH_US 0x01
#define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | ((DWORD)((WORD )(lgid)))))
// LOCAL defines from mingw
#define MAX_LEADBYTES 12
#define MAX_DEFAULTCHAR 2
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
#define LOCALE_NOUSEROVERRIDE 0x80000000
#define LOCALE_USE_CP_ACP 0x40000000
#if (WINVER >= 0x0400)
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <io.h>
#include <direct.h>
#include <process.h>
#else
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
#include <mntent.h>
#endif
#endif
#include <sys/stat.h>
#include <sys/types.h>
-#if !defined(__FreeBSD__)
+#if !defined(TARGET_FREEBSD)
#include <sys/timeb.h>
#endif
#include "system.h" // for HAS_DVD_DRIVE
#ifdef HAS_DVD_DRIVE
- #ifdef _LINUX
+ #ifdef TARGET_POSIX
#include <sys/ioctl.h>
#if defined(TARGET_DARWIN)
#include <IOKit/storage/IODVDMediaBSDClient.h>
- #elif !defined(__FreeBSD__)
+ #elif !defined(TARGET_FREEBSD)
#include <linux/cdrom.h>
#endif
#endif
#include <fcntl.h>
#include <time.h>
#include <signal.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h" // for __stat64
#endif
#include "Util.h"
#include "util/EmuFileWrapper.h"
#include "utils/log.h"
#include "threads/SingleLock.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include "utils/CharsetConverter.h"
#include "utils/URIUtils.h"
#endif
#if defined(TARGET_ANDROID)
#include "android/loader/AndroidDyload.h"
-#elif !defined(_WIN32)
+#elif !defined(TARGET_WINDOWS)
#include <dlfcn.h>
#endif
+#include "utils/Environment.h"
+
using namespace std;
using namespace XFILE;
-#if defined(_MSC_VER) && _MSC_VER < 1500
-extern "C" {
- __int64 __cdecl _ftelli64(FILE *);
- int __cdecl _fseeki64(FILE *, __int64, int);
-}
-#endif
-
struct SDirData
{
CFileItemList items;
memset(dll__environ, 0, EMU_MAX_ENVIRONMENT_ITEMS + 1);
// python
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
// fill our array with the windows system vars
LPTSTR lpszVariable;
LPTCH lpvEnv;
dll_putenv("OS=win32");
#elif defined(TARGET_DARWIN)
dll_putenv("OS=darwin");
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
dll_putenv("OS=linux");
#else
dll_putenv("OS=unknown");
strProxy += CSettings::Get().GetString("network.httpproxyserver");
strProxy += ":" + CSettings::Get().GetString("network.httpproxyport");
-#ifdef _WIN32
- pgwin32_putenv(("HTTP_PROXY=http://" +strProxy).c_str());
- pgwin32_putenv(("HTTPS_PROXY=http://" +strProxy).c_str());
-#else
- setenv( "HTTP_PROXY", "http://" + strProxy, true );
- setenv( "HTTPS_PROXY", "http://" + strProxy, true );
-#endif
+ CEnvironment::setenv( "HTTP_PROXY", "http://" + strProxy, true );
+ CEnvironment::setenv( "HTTPS_PROXY", "http://" + strProxy, true );
}
else
{
return iMode;
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
static void to_finddata64i32(_wfinddata64i32_t *wdata, _finddata64i32_t *data)
{
CStdString strname;
#if defined(TARGET_ANDROID)
CAndroidDyload temp;
return temp.Open(filename);
-#elif !defined(_WIN32)
+#elif !defined(TARGET_WINDOWS)
return dlopen(filename, flag);
#else
return NULL;
else if (!IS_STD_STREAM(stream))
{
// it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
flockfile(stream);
return;
#else
else if (!IS_STD_STREAM(stream))
{
// it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return ftrylockfile(stream);
#else
CLog::Log(LOGERROR, "%s: ftrylockfile not available on non-linux platforms", __FUNCTION__);
else if (!IS_STD_STREAM(stream))
{
// it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
funlockfile(stream);
return;
#else
return EOF;
}
-#ifndef _LINUX
+#ifndef TARGET_POSIX
// should be moved to CFile classes
intptr_t dll_findfirst(const char *file, struct _finddata_t *data)
{
FILE* dll_fopen(const char* filename, const char* mode)
{
FILE* file = NULL;
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if defined(TARGET_LINUX) && !defined(TARGET_ANDROID)
if (strcmp(filename, MOUNTED) == 0
|| strcmp(filename, MNTTAB) == 0)
{
{
// it might be something else than a file, or the file is not emulated
// let the operating system handle it
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
return fseek(stream, offset, origin);
#else
return fseeko64(stream, offset, origin);
{
// it might be something else than a file, or the file is not emulated
// let the operating system handle it
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
return ftello(stream);
#else
return ftello64(stream);
{
// it might be something else than a file, or the file is not emulated
// let the operating system handle it
-#ifndef _LINUX
+#ifndef TARGET_POSIX
return tell(fd);
#else
return lseek(fd, 0, SEEK_CUR);
// let the operating system handle it
// not supported return telli64(fd);
CLog::Log(LOGWARNING, "msvcrt.dll: dll_telli64 called, TODO: add 'int64 -> long' type checking"); //warning
-#ifndef _LINUX
+#ifndef TARGET_POSIX
return (__int64)tell(fd);
-#elif defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#elif defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
return lseek(fd, 0, SEEK_CUR);
#else
return lseek64(fd, 0, SEEK_CUR);
int ret;
ret = dll_fgetpos64(stream, &tmpPos);
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
*pos = (fpos_t)tmpPos;
#else
pos->__pos = (off_t)tmpPos.__pos;
CFile* pFile = g_emuFileWrapper.GetFileXbmcByStream(stream);
if (pFile != NULL)
{
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
*pos = pFile->GetPosition();
#else
pos->__pos = pFile->GetPosition();
int fd = g_emuFileWrapper.GetDescriptorByStream(stream);
if (fd >= 0)
{
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
if (dll_lseeki64(fd, *pos, SEEK_SET) >= 0)
#else
if (dll_lseeki64(fd, (__off64_t)pos->__pos, SEEK_SET) >= 0)
{
// it might be something else than a file, or the file is not emulated
// let the operating system handle it
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
return fsetpos(stream, pos);
#else
return fsetpos64(stream, pos);
if (fd >= 0)
{
fpos64_t tmpPos;
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
tmpPos= *pos;
#else
tmpPos.__pos = (off64_t)(pos->__pos);
if (!strnicmp(path, "mms://", 6)) // don't stat mms
return -1;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (!_stricmp(path, "D:") || !_stricmp(path, "D:\\"))
{
buffer->st_mode = S_IFDIR;
if (!strnicmp(path, "mms://", 6)) // don't stat mms
return -1;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (!_stricmp(path, "D:") || !_stricmp(path, "D:\\"))
{
buffer->st_mode = _S_IFDIR;
return CFile::Stat(path, buffer);
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int dll_stat64i32(const char *path, struct _stat64i32 *buffer)
{
struct __stat64 a;
return -1;
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int dll_fstat64i32(int fd, struct _stat64i32 *buffer)
{
CFile* pFile = g_emuFileWrapper.GetFileXbmcByDescriptor(fd);
// Make sure the slashes are correct & translate the path
CStdString strPath = CUtil::ValidatePath(CSpecialProtocol::TranslatePath(dir));
-#ifndef _LINUX
+#ifndef TARGET_POSIX
CStdStringW strWPath;
g_charsetConverter.utf8ToW(strPath, strWPath, false);
return _wmkdir(strWPath.c_str());
void (__cdecl * dll_signal(int sig, void (__cdecl *func)(int)))(int)
{
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
//vs2008 asserts for known signals, return err for everything unknown to windows.
if (sig == 5 || sig == 7 || sig == 9 || sig == 10 || sig == 12 || sig == 14 || sig == 18 || sig == 19 || sig == 20)
return SIG_ERR;
{
// it might be something else than a file, or the file is not emulated
// let the operating system handle it
-#ifndef _LINUX
+#ifndef TARGET_POSIX
return _commit(fd);
#else
return fsync(fd);
return (char***)&t;
}
-#ifdef _LINUX
-#if defined(__ANDROID__)
+#ifdef TARGET_POSIX
+#if defined(TARGET_ANDROID)
volatile int * __cdecl dll_errno(void)
{
return &errno;
if (!pFile)
return -1;
-#if defined(HAS_DVD_DRIVE) && !defined(__FreeBSD__)
+#if defined(HAS_DVD_DRIVE) && !defined(TARGET_FREEBSD)
#if !defined(TARGET_DARWIN)
if(request == DVD_READ_STRUCT || request == DVD_AUTH)
#else
CLog::Log(LOGERROR, "%s - getmntent is not implemented for our virtual filesystem", __FUNCTION__);
return NULL;
}
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
return getmntent(fp);
#else
CLog::Log(LOGWARNING, "%s - unimplemented function called", __FUNCTION__);
else
return 0;
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return 0;
#else
return _filbuf(fp);
else
return 0;
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return 0;
#else
return _flsbuf(data, fp);
#endif
}
-#if _MSC_VER <= 1310
- long __cdecl _ftol2_sse(double d)
- {
- return (long)d;
- }
-#endif
// this needs to be wrapped, since dll's have their own file
// descriptor list, but we always use app's list with our wrappers
int __cdecl dll_open_osfhandle(intptr_t _OSFileHandle, int _Flags)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return _open_osfhandle(_OSFileHandle, _Flags);
#else
return -1;
#ifndef _EMU_MSVCRT_H_
#define _EMU_MSVCRT_H_
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define _onexit_t void*
#endif
typedef off64_t __off64_t;
typedef fpos_t fpos64_t;
#endif
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
typedef long int __off_t;
typedef long int __off64_t;
typedef fpos_t fpos64_t; // no 64-bit on android
#endif
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
#include "win32/dirent.h"
#else
#include <dirent.h>
#define IS_STDIN_STREAM(stream) (stream != NULL && __IS_STDIN_STREAM(stream))
#define IS_STDOUT_STREAM(stream) (stream != NULL && __IS_STDOUT_STREAM(stream))
#define IS_STDERR_STREAM(stream) (stream != NULL && __IS_STDERR_STREAM(stream))
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define IS_VALID_STREAM(stream) (stream != NULL && (stream->_ptr != NULL))
#else
#define IS_VALID_STREAM(stream) true
__off_t dll_lseek(int fd, __off_t lPos, int iWhence);
char* dll_getenv(const char* szKey);
int dll_fclose (FILE * stream);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
intptr_t dll_findfirst(const char *file, struct _finddata_t *data);
int dll_findnext(intptr_t f, _finddata_t* data);
int dll_findclose(intptr_t handle);
uintptr_t dll_beginthread(void( *start_address )( void * ),unsigned stack_size,void *arglist);
HANDLE dll_beginthreadex(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags,
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
LPLONG lpThreadId);
#else
LPDWORD lpThreadId);
#endif
int dll_stati64(const char *path, struct _stati64 *buffer);
int dll_stat64(const char *path, struct __stat64 *buffer);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int dll_stat64i32(const char *path, struct _stat64i32 *buffer);
#endif
int dll_stat(const char *path, struct stat *buffer);
int dll_ftrylockfile(FILE *file);
void dll_funlockfile(FILE *file);
int dll_fstat64(int fd, struct __stat64 *buf);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int dll_fstat64i32(int fd, struct _stat64i32 *buffer);
int dll_open_osfhandle(intptr_t _OSFileHandle, int _Flags);
#endif
int dll_filbuf(FILE *fp);
int dll_flsbuf(int data, FILE*fp);
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
volatile int * __cdecl dll_errno(void);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
int * __cdecl dll_errno(void);
#endif
* SUCH DAMAGE.
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <windows.h>
typedef unsigned long in_addr_t;
#endif
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
#include <netinet/in.h>
#endif
#include "system.h"
#include "threads/CriticalSection.h"
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID)
#define _file _fileno
#endif
EmuFileObject* GetFileObjectByStream(FILE* stream);
XFILE::CFile* GetFileXbmcByDescriptor(int fd);
XFILE::CFile* GetFileXbmcByStream(FILE* stream);
- int GetDescriptorByStream(FILE* stream);
+ static int GetDescriptorByStream(FILE* stream);
FILE* GetStreamByDescriptor(int fd);
- bool DescriptorIsEmulatedFile(int fd);
- bool StreamIsEmulatedFile(FILE* stream);
+ static bool DescriptorIsEmulatedFile(int fd);
+ static bool StreamIsEmulatedFile(FILE* stream);
private:
EmuFileObject m_files[MAX_EMULATED_FILES];
CCriticalSection m_criticalSection;
//
#include <sys/types.h>
#include <sys/stat.h>
-#if !defined(__ANDROID__)
+#if !defined(TARGET_ANDROID)
#include <sys/statvfs.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "win32-dirent.h"
#else
#include <dirent.h>
#endif
#include <dlfcn.h>
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
typedef off_t __off_t;
typedef int64_t off64_t;
typedef off64_t __off64_t;
#endif
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define _stat stat
#endif
struct mntent *__wrap_getmntent(FILE *fp)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return dll_getmntent(fp);
#endif
return NULL;
#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
_syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
#else
-#if defined(__ANDROID__) && defined(__i386__) && !defined(modify_ldt)
+#if defined(TARGET_ANDROID) && defined(__i386__) && !defined(modify_ldt)
#define modify_ldt(a,b,c) syscall( __NR_modify_ldt, a, b, c);
#else
int modify_ldt(int func, void *ptr, unsigned long bytecount);
}
#endif
#else
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <machine/segments.h>
#include <machine/sysarch.h>
#endif
#define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
/* i got this value from wine sources, it's the first free LDT entry */
-#if (defined(TARGET_DARWIN) || defined(__FreeBSD__)) && defined(LDT_AUTO_ALLOC)
+#if (defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)) && defined(LDT_AUTO_ALLOC)
#define TEB_SEL_IDX LDT_AUTO_ALLOC
#define USE_LDT_AA
#endif
);
}
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
{
*buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
}
#endif /*linux*/
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
{
unsigned long d[2];
#endif
}
}
-#endif // __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || TARGET_DARWIN
+#endif // __NetBSD__ || TARGET_FREEBSD || __OpenBSD__ || __DragonFly__ || TARGET_DARWIN
#if defined(__svr4__)
{
#include "utils/TimeUtils.h"
#include "utils/log.h"
#include "cores/AudioEngine/AEFactory.h"
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
#include "utils/CharsetConverter.h"
#include "Windows.h"
#ifdef HAS_IRSERVERSUITE
using namespace XFILE;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
extern HWND g_hWnd;
#endif
m_yPos = 0;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
memset(&m_processInfo, 0, sizeof(m_processInfo));
#endif
}
if (m_dialog && m_dialog->IsActive()) m_dialog->Close();
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
if (m_bIsPlaying && m_processInfo.hProcess)
{
TerminateProcess(m_processInfo.hProcess, 1);
// make sure we surround the arguments with quotes where necessary
CStdString strFName;
CStdString strFArgs;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
// W32 batch-file handline
if (m_filename.Right(4) == ".bat" || m_filename.Right(4) == ".cmd")
{
strFArgs.append("\"");
}
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
if (m_warpcursor)
{
GetCursorPos(&m_ptCursorpos);
CLog::Log(LOGNOTICE, "%s: Hiding XBMC window", __FUNCTION__);
g_Windowing.Hide();
}
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
else if (currentStyle & WS_EX_TOPMOST)
{
CLog::Log(LOGNOTICE, "%s: Lowering XBMC window", __FUNCTION__);
BOOL ret = TRUE;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
ret = ExecuteAppW32(strFName.c_str(),strFArgs.c_str());
#elif defined(TARGET_ANDROID)
ret = ExecuteAppAndroid(m_filename.c_str(), mainFile.c_str());
-#elif defined(_LINUX) || defined(TARGET_DARWIN_OSX)
+#elif defined(TARGET_POSIX) || defined(TARGET_DARWIN_OSX)
ret = ExecuteAppLinux(strFArgs.c_str());
#endif
int64_t elapsedMillis = XbmcThreads::SystemClockMillis() - m_playbackStartTime;
m_bIsPlaying = false;
CLog::Log(LOGNOTICE, "%s: Stop", __FUNCTION__);
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
g_Windowing.Restore();
if (currentStyle & WS_EX_TOPMOST)
g_Windowing.Show();
}
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
if (m_warpcursor)
{
m_xPos = 0;
m_callback.OnPlayBackEnded();
}
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
BOOL CExternalPlayer::ExecuteAppW32(const char* strPath, const char* strSwitches)
{
CLog::Log(LOGNOTICE, "%s: %s %s", __FUNCTION__, strPath, strSwitches);
}
#endif
-#if !defined(TARGET_ANDROID) && (defined(_LINUX) || defined(TARGET_DARWIN_OSX))
+#if !defined(TARGET_ANDROID) && (defined(TARGET_POSIX) || defined(TARGET_DARWIN_OSX))
BOOL CExternalPlayer::ExecuteAppLinux(const char* strSwitches)
{
CLog::Log(LOGNOTICE, "%s: %s", __FUNCTION__, strSwitches);
XMLUtils::GetBoolean(pConfig, "hidexbmc", m_hidexbmc);
if (!XMLUtils::GetBoolean(pConfig, "hideconsole", m_hideconsole))
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// Default depends on whether player is a batch file
m_hideconsole = m_filename.Right(4) == ".bat";
#endif
m_islauncher ? "true" : "false",
warpCursor.c_str());
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
m_filenameReplacers.push_back("^smb:// , / , \\\\ , g");
m_filenameReplacers.push_back("^smb:\\\\\\\\ , smb:(\\\\\\\\[^\\\\]*\\\\) , \\1 , ");
#endif
virtual CStdString GetPlayerState();
virtual bool SetPlayerState(CStdString state);
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
virtual BOOL ExecuteAppW32(const char* strPath, const char* strSwitches);
//static void CALLBACK AppFinished(void* closure, BOOLEAN TimerOrWaitFired);
#elif defined(TARGET_ANDROID)
virtual BOOL ExecuteAppAndroid(const char* strSwitches,const char* strPath);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
virtual BOOL ExecuteAppLinux(const char* strSwitches);
#endif
int m_time;
CStdString m_launchFilename;
HWND m_hwndXbmc;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
POINT m_ptCursorpos;
PROCESS_INFORMATION m_processInfo;
#endif
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
switch(requestedMethod)
{
case RENDER_METHOD_AUTO:
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
//with render method set to auto, don't try glsl on ati if we're on linux
//it seems to be broken in a random way with every new driver release
tryGlsl = g_Windowing.GetRenderVendor().Left(3).CompareNoCase("ati") != 0;
inline int NP2( unsigned x ) {
-#if defined(_LINUX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__)
+#if defined(TARGET_POSIX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__)
// If there are any issues compiling this, just append a ' && 0'
- // to the above to make it '#if defined(_LINUX) && 0'
+ // to the above to make it '#if defined(TARGET_POSIX) && 0'
// Linux assembly is AT&T Unix style, not Intel style
unsigned y;
*/
#include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
class CRetakeLock
{
public:
- CRetakeLock(CSharedSection §ion, bool immidiate = true, CCriticalSection &owned = g_graphicsContext)
- : m_lock (NULL ),
- m_owned(owned )
+ CRetakeLock(CSharedSection §ion, CCriticalSection &owned = g_graphicsContext)
+ : m_count(owned.exit())
+ , m_lock (section),
+ m_owned(owned)
{
- m_count = m_owned.exit();
- m_lock = new T(section);
- if(immidiate)
- {
- m_owned.restore(m_count);
- m_count = 0;
- }
+ m_owned.restore(m_count);
}
- ~CRetakeLock()
+
+ void Leave() { m_lock.Leave(); }
+ void Enter()
{
- delete m_lock;
+ m_count = m_owned.exit();
+ m_lock.Enter();
m_owned.restore(m_count);
}
- void Leave() { m_lock->Leave(); }
- void Enter() { m_lock->Enter(); }
private:
- T* m_lock;
- CCriticalSection &m_owned;
DWORD m_count;
+ T m_lock;
+ CCriticalSection &m_owned;
};
CXBMCRenderManager::CXBMCRenderManager()
if(g_graphicsContext.IsFullScreenVideo())
next = (m_Queue[idx].timestamp <= clocktime + MAXPRESENTDELAY);
else
- next = (m_Queue[idx].timestamp <= clocktime);
+ next = (m_Queue[idx].timestamp <= clocktime + frametime);
if (next)
{
RESOLUTION GetResolution();
- float GetMaximumFPS();
+ static float GetMaximumFPS();
inline bool IsStarted() { return m_bIsStarted;}
double GetDisplayLatency() { return m_displayLatency; }
int GetSkippedFrames() { return m_QueueSkip; }
EINTERLACEMETHOD AutoInterlaceMethod(EINTERLACEMETHOD mInt);
- double GetPresentTime();
+ static double GetPresentTime();
void WaitPresentTime(double presenttime);
CStdString GetVSyncState();
* <http://www.gnu.org/licenses/>.
*
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define _USE_MATH_DEFINES
#endif
*
*/
-#if !defined(_LINUX) && !defined(HAS_GL)
+#if !defined(TARGET_POSIX) && !defined(HAS_GL)
#include "guilib/GraphicContext.h"
#include "RenderFlags.h"
for(unsigned int i=0;i<filenames.size();i++)
{
// if vobsub subtitle:
- if (URIUtils::GetExtension(filenames[i]) == ".idx")
+ if (URIUtils::HasExtension(filenames[i], ".idx"))
{
CStdString strSubFile;
if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "threads/CriticalSection.h"
#include "system.h"
#include "cores/AudioEngine/AEAudioFormat.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include <vector>
*/
#include "DVDAudioCodecFFmpeg.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XMemUtils.h"
#endif
#include "../../DVDStreamInfo.h"
/* request output of wanted endianness */
if (!fOut->priv_class || m_dllAvUtil.av_opt_set(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0) != 0)
{
-#if defined(WORDS_BIGENDIAN) && !defined(__APPLE__)
+#if defined(WORDS_BIGENDIAN) && !defined(TARGET_DARWIN)
CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Unable to set big-endian stream mode (FFmpeg too old?), disabling passthrough");
Dispose();
return false;
* <http://www.gnu.org/licenses/>.
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
-#if defined(_LINUX) || defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) || defined(TARGET_DARWIN)
#include <mad.h>
#else
#include "libmad/mad.h"
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#else
hwSupport += "AMCodec:no ";
#endif
-#if defined(HAVE_LIBOPENMAX) && defined(_LINUX)
+#if defined(HAVE_LIBOPENMAX) && defined(TARGET_POSIX)
hwSupport += "OpenMax:yes ";
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
hwSupport += "OpenMax:no ";
#endif
-#if defined(HAVE_LIBVDPAU) && defined(_LINUX)
+#if defined(HAVE_LIBVDPAU) && defined(TARGET_POSIX)
hwSupport += "VDPAU:yes ";
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
hwSupport += "VDPAU:no ";
#endif
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
hwSupport += "DXVA:yes ";
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
hwSupport += "DXVA:no ";
#endif
-#if defined(HAVE_LIBVA) && defined(_LINUX)
+#if defined(HAVE_LIBVA) && defined(TARGET_POSIX)
hwSupport += "VAAPI:yes ";
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
hwSupport += "VAAPI:no ";
#endif
#endif
// try to decide if we want to try halfres decoding
-#if !defined(_LINUX) && !defined(_WIN32)
+#if !defined(TARGET_POSIX) && !defined(TARGET_WINDOWS)
float pixelrate = (float)hint.width*hint.height*hint.fpsrate/hint.fpsscale;
if( pixelrate > 1400.0f*720.0f*30.0f )
{
/* number of text colors specified by EIA-608 standard */
#define NUM_FG_COL 7
-#ifndef WIN32
+#ifndef TARGET_WINDOWS
/* colors specified by the EIA 608 standard */
enum { WHITE, GREEN, BLUE, CYAN, RED, YELLOW, MAGENTA, BLACK, TRANSPARENT };
#else
* available at http://sourceforge.net/projects/ccdecoder/.
*/
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#undef EMULATE_INTTYPES
#else
#define EMULATE_INTTYPES
-#endif /* _LINUX */
+#endif /* TARGET_POSIX */
#ifndef EMULATE_INTTYPES
# include <stdint.h>
*/
#include "system.h"
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
#include "WIN32Util.h"
#include "util.h"
#include "dialogs/GUIDialogKaiToast.h"
namespace BCM
{
- #if defined(WIN32)
+ #if defined(TARGET_WINDOWS)
typedef void *HANDLE;
#else
#ifndef __LINUX_USER__
memset(&m_sps_pps_context, 0, sizeof(m_sps_pps_context));
m_dll = new DllLibCrystalHD;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdString strDll;
if(CWIN32Util::GetCrystalHDLibraryPath(strDll) && m_dll->SetFile(strDll) && m_dll->Load() && m_dll->IsLoaded() )
#else
// bitstream to bytestream (Annex B) conversion support.
bool bitstream_convert_init(void *in_extradata, int in_extrasize);
bool bitstream_convert(uint8_t* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size);
- void bitstream_alloc_and_copy( uint8_t **poutbuf, int *poutbuf_size,
+ static void bitstream_alloc_and_copy( uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size);
typedef struct chd_bitstream_ctx {
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#include "DllAvCodec.h"
#endif
*/
#include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "DVDVideoCodecFFmpeg.h"
#include "DVDCodecs/DVDCodecs.h"
#include "DVDCodecs/DVDCodecUtils.h"
#include "DVDVideoPPFFmpeg.h"
-#if defined(_LINUX) || defined(_WIN32)
+#if defined(TARGET_POSIX) || defined(TARGET_WINDOWS)
#include "utils/CPUInfo.h"
#endif
#include "settings/AdvancedSettings.h"
#include "boost/shared_ptr.hpp"
#include "threads/Atomics.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#define RINT(x) ((x) >= 0 ? ((int)((x) + 0.5)) : ((int)((x) - 0.5)))
#else
#include <math.h>
#ifdef HAVE_LIBVA
#include "VAAPI.h"
#endif
+#ifdef TARGET_DARWIN_OSX
+#include "VDA.h"
+#endif
using namespace boost;
dec->Release();
}
#endif
+
+#ifdef TARGET_DARWIN_OSX
+ if (*cur == AV_PIX_FMT_VDA_VLD && CSettings::Get().GetBool("videoplayer.usevda"))
+ {
+ VDA::CDecoder* dec = new VDA::CDecoder();
+ if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
+ {
+ ctx->SetHardware(dec);
+ return *cur;
+ }
+ else
+ dec->Release();
+ }
+#endif
cur++;
}
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
/* use variable in the frame */
AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio;
if (m_pBufferRef)
+#if defined(LIBAVFILTER_FROM_FFMPEG)
pixel_aspect = m_pBufferRef->video->sample_aspect_ratio;
+#else
+ pixel_aspect = m_pBufferRef->video->pixel_aspect;
+#endif
if (pixel_aspect.num == 0)
aspect_ratio = 0;
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
typedef struct frame_queue {
double dts;
double pts;
- double sort_time;
+ int64_t sort_time;
FourCharCode pixel_buffer_format;
CVBufferRef pixel_buffer_ref;
struct frame_queue *nextframe;
////////////////////////////////////////////////////////////////////////////////////////////
// helper function that wraps dts/pts into a dictionary
-static CFDictionaryRef CreateDictionaryWithDisplayTime(double time, double dts, double pts)
+static CFDictionaryRef CreateDictionaryWithDisplayTime(int64_t time, double dts, double pts)
{
CFStringRef key[3] = {
CFSTR("VideoDisplay_TIME"),
CFNumberRef value[3];
CFDictionaryRef display_time;
- value[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &time);
+ value[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &time);
value[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &dts);
value[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &pts);
CFDictionaryRef inFrameInfoDictionary, frame_queue *frame)
{
// default to DVD_NOPTS_VALUE
- frame->sort_time = -1.0;
+ frame->sort_time = -1;
frame->dts = DVD_NOPTS_VALUE;
frame->pts = DVD_NOPTS_VALUE;
if (inFrameInfoDictionary == NULL)
//
value[0] = (CFNumberRef)CFDictionaryGetValue(inFrameInfoDictionary, CFSTR("VideoDisplay_TIME"));
if (value[0])
- CFNumberGetValue(value[0], kCFNumberDoubleType, &frame->sort_time);
+ CFNumberGetValue(value[0], kCFNumberLongLongType, &frame->sort_time);
value[1] = (CFNumberRef)CFDictionaryGetValue(inFrameInfoDictionary, CFSTR("VideoDisplay_DTS"));
if (value[1])
CFNumberGetValue(value[1], kCFNumberDoubleType, &frame->dts);
memset(&m_videobuffer, 0, sizeof(DVDVideoPicture));
m_DropPictures = false;
m_decode_async = false;
- m_sort_time_offset = 0.0;
+ m_sort_time = 0;
m_use_cvBufferRef = false;
}
CFRelease(avcCData);
return false;
}
- if (m_max_ref_frames == 0)
- m_max_ref_frames = 2;
}
if (profile == FF_PROFILE_H264_MAIN && level == 32 && m_max_ref_frames > 4)
}
m_DropPictures = false;
- m_max_ref_frames = std::min(m_max_ref_frames, 5);
- m_sort_time_offset = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
-
+ m_max_ref_frames = std::max(m_max_ref_frames + 1, 5);
+ m_sort_time = 0;
return true;
}
CFDataRef avc_demux = CFDataCreate(kCFAllocatorDefault,
m_bitstream->GetConvertBuffer(), m_bitstream->GetConvertSize());
- double sort_time = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
- CFDictionaryRef avc_time = CreateDictionaryWithDisplayTime(sort_time - m_sort_time_offset, dts, pts);
+ CFDictionaryRef avc_time = CreateDictionaryWithDisplayTime(m_sort_time++, dts, pts);
uint32_t avc_flags = 0;
if (m_DropPictures)
if (m_queue_depth < m_max_ref_frames)
return VC_BUFFER;
- return VC_PICTURE | VC_BUFFER;
+ return VC_PICTURE;
}
void CDVDVideoCodecVDA::Reset(void)
while (m_queue_depth)
DisplayQueuePop();
- m_sort_time_offset = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
+ m_sort_time = 0;
}
bool CDVDVideoCodecVDA::GetPicture(DVDVideoPicture* pDvdVideoPicture)
//CLog::Log(LOGNOTICE, "%s - VDADecoderDecode dts(%f), pts(%f)", __FUNCTION__,
// pDvdVideoPicture->dts, pDvdVideoPicture->pts);
- return VC_PICTURE | VC_BUFFER;
+ return true;
}
bool CDVDVideoCodecVDA::ClearPicture(DVDVideoPicture* pDvdVideoPicture)
newFrame->pixel_buffer_ref = CVBufferRetain(imageBuffer);
GetFrameDisplayTimeFromDictionary(frameInfo, newFrame);
- // if both dts or pts are good we use those, else use decoder insert time for frame sort
- if ((newFrame->pts != DVD_NOPTS_VALUE) || (newFrame->dts != DVD_NOPTS_VALUE))
- {
- // if pts is borked (stupid avi's), use dts for frame sort
- if (newFrame->pts == DVD_NOPTS_VALUE)
- newFrame->sort_time = newFrame->dts;
- else
- newFrame->sort_time = newFrame->pts;
- }
-
// since the frames we get may be in decode order rather than presentation order
// our hypothetical callback places them in a queue of frames which will
// hold them in display order for display on another thread
pthread_mutex_lock(&ctx->m_queue_mutex);
- //
- frame_queue *queueWalker = ctx->m_display_queue;
- if (!queueWalker || (newFrame->sort_time < queueWalker->sort_time))
+
+ frame_queue base;
+ base.nextframe = ctx->m_display_queue;
+ frame_queue *ptr = &base;
+ for(; ptr->nextframe; ptr = ptr->nextframe)
{
- // we have an empty queue, or this frame earlier than the current queue head.
- newFrame->nextframe = queueWalker;
- ctx->m_display_queue = newFrame;
- } else {
- // walk the queue and insert this frame where it belongs in display order.
- bool frameInserted = false;
- frame_queue *nextFrame = NULL;
- //
- while (!frameInserted)
- {
- nextFrame = queueWalker->nextframe;
- if (!nextFrame || (newFrame->sort_time < nextFrame->sort_time))
- {
- // if the next frame is the tail of the queue, or our new frame is earlier.
- newFrame->nextframe = nextFrame;
- queueWalker->nextframe = newFrame;
- frameInserted = true;
- }
- queueWalker = nextFrame;
- }
+ if(ptr->nextframe->pts == DVD_NOPTS_VALUE
+ || newFrame->pts == DVD_NOPTS_VALUE)
+ continue;
+ if(ptr->nextframe->pts > newFrame->pts)
+ break;
}
+ /* insert after ptr */
+ newFrame->nextframe = ptr->nextframe;
+ ptr->nextframe = newFrame;
+
+ /* update anchor if needed */
+ if(newFrame->nextframe == ctx->m_display_queue)
+ ctx->m_display_queue = newFrame;
+
ctx->m_queue_depth++;
//
pthread_mutex_unlock(&ctx->m_queue_mutex);
unsigned CDVDVideoCodecVDA::GetAllowedReferences()
{
if (m_use_cvBufferRef)
- return 2; /* TODO can this be increased? */
+ return 3;
else
return 0;
}
bool m_DropPictures;
bool m_decode_async;
- double m_sort_time_offset;
+ int64_t m_sort_time;
pthread_mutex_t m_queue_mutex; // mutex protecting queue manipulation
frame_queue *m_display_queue; // display-order queue - next display frame is always at the queue head
int32_t m_queue_depth; // we will try to keep the queue depth around 16+1 frames
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
extern "C" {
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/mpeg2convert.h"
#else
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include "system.h"
+#ifdef TARGET_DARWIN_OSX
+#include "osx/CocoaInterface.h"
+#include "DVDVideoCodec.h"
+#include "DVDCodecs/DVDCodecUtils.h"
+#include "VDA.h"
+
+extern "C" {
+ #include <libavcodec/vda.h>
+}
+
+using namespace std;
+using namespace VDA;
+
+
+static void RelBufferS(AVCodecContext *avctx, AVFrame *pic)
+{ ((CDecoder*)((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetHardware())->RelBuffer(avctx, pic); }
+
+static int GetBufferS(AVCodecContext *avctx, AVFrame *pic)
+{ return ((CDecoder*)((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetHardware())->GetBuffer(avctx, pic); }
+
+CDecoder::CDecoder()
+: m_renderbuffers_count(0)
+{
+ m_ctx = (vda_context*)calloc(1, sizeof(vda_context));
+}
+
+CDecoder::~CDecoder()
+{
+ Close();
+ free(m_ctx);
+}
+
+void CDecoder::RelBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+ CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3];
+ CVPixelBufferRelease(cv_buffer);
+
+ for (int i = 0; i < 4; i++)
+ pic->data[i] = NULL;
+}
+
+int CDecoder::GetBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+ pic->type = FF_BUFFER_TYPE_USER;
+ pic->data[0] = (uint8_t *)1;
+ return 0;
+}
+
+static void vda_decoder_callback (void *vda_hw_ctx,
+ CFDictionaryRef user_info,
+ OSStatus status,
+ uint32_t infoFlags,
+ CVImageBufferRef image_buffer)
+{
+ struct vda_context *vda_ctx = (struct vda_context *)vda_hw_ctx;
+
+ if (!image_buffer)
+ return;
+
+ if (vda_ctx->cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
+ return;
+
+ vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer);
+}
+
+bool CDecoder::Create(AVCodecContext *avctx)
+{
+ OSStatus status;
+ CFNumberRef height;
+ CFNumberRef width;
+ CFNumberRef format;
+ CFDataRef avc_data;
+ CFMutableDictionaryRef config_info;
+ CFMutableDictionaryRef buffer_attributes;
+ CFMutableDictionaryRef io_surface_properties;
+ CFNumberRef cv_pix_fmt;
+
+ m_ctx->priv_bitstream = NULL;
+ m_ctx->priv_allocated_size = 0;
+
+ /* Each VCL NAL in the bitstream sent to the decoder
+ * is preceded by a 4 bytes length header.
+ * Change the avcC atom header if needed, to signal headers of 4 bytes. */
+ if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) {
+ uint8_t *rw_extradata;
+
+ if (!(rw_extradata = (uint8_t*)av_malloc(avctx->extradata_size)))
+ return false;
+
+ memcpy(rw_extradata, avctx->extradata, avctx->extradata_size);
+
+ rw_extradata[4] |= 0x03;
+
+ avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size);
+
+ av_freep(&rw_extradata);
+ } else {
+ avc_data = CFDataCreate(kCFAllocatorDefault, avctx->extradata, avctx->extradata_size);
+ }
+
+ config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 4,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+
+ height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->height);
+ width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->width);
+ format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->format);
+
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height , height);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width , width);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData , avc_data);
+
+ buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 2,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberSInt32Type,
+ &m_ctx->cv_pix_fmt_type);
+ CFDictionarySetValue(buffer_attributes,
+ kCVPixelBufferPixelFormatTypeKey,
+ cv_pix_fmt);
+ CFDictionarySetValue(buffer_attributes,
+ kCVPixelBufferIOSurfacePropertiesKey,
+ io_surface_properties);
+
+ status = VDADecoderCreate(config_info,
+ buffer_attributes,
+ (VDADecoderOutputCallback*)vda_decoder_callback,
+ m_ctx,
+ &m_ctx->decoder);
+
+ CFRelease(height);
+ CFRelease(width);
+ CFRelease(format);
+ CFRelease(avc_data);
+ CFRelease(config_info);
+ CFRelease(io_surface_properties);
+ CFRelease(cv_pix_fmt);
+ CFRelease(buffer_attributes);
+
+ if(status != kVDADecoderNoErr)
+ {
+ CLog::Log(LOGERROR, "VDA::CDecoder - Failed to init VDA decoder: %d", status);
+ return false;
+ }
+ return true;
+}
+
+void CDecoder::Close()
+{
+ OSStatus status = kVDADecoderNoErr;
+
+ if (m_ctx->decoder)
+ status = VDADecoderDestroy(m_ctx->decoder);
+ m_ctx->decoder = NULL;
+ av_freep(&m_ctx->priv_bitstream);
+}
+
+bool CDecoder::Open(AVCodecContext *avctx, enum PixelFormat fmt, unsigned int surfaces)
+{
+ Close();
+
+ if(fmt != AV_PIX_FMT_VDA_VLD)
+ return false;
+
+ if(avctx->codec_id != AV_CODEC_ID_H264)
+ return false;
+
+ switch(avctx->profile)
+ {
+ case FF_PROFILE_H264_HIGH_10:
+ case FF_PROFILE_H264_HIGH_10_INTRA:
+ case FF_PROFILE_H264_HIGH_422:
+ case FF_PROFILE_H264_HIGH_422_INTRA:
+ case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+ case FF_PROFILE_H264_HIGH_444_INTRA:
+ case FF_PROFILE_H264_CAVLC_444:
+ return false;
+ default:
+ break;
+ }
+
+ if (Cocoa_GPUForDisplayIsNvidiaPureVideo3() && !CDVDCodecUtils::IsVP3CompatibleWidth(avctx->width))
+ {
+ CLog::Log(LOGNOTICE, "%s - Nvidia 9400 GPU hardware limitation, cannot decode a width of %d", __FUNCTION__, avctx->width);
+ return false;
+ }
+
+ if (avctx->profile == FF_PROFILE_H264_MAIN && avctx->level == 32 && avctx->refs > 4)
+ {
+ // Main@L3.2, VDA cannot handle greater than 4 reference frames
+ CLog::Log(LOGNOTICE, "%s - Main@L3.2 detected, VDA cannot decode.", __FUNCTION__);
+ return false;
+ }
+
+ /* init vda */
+ memset(m_ctx, 0, sizeof(struct vda_context));
+ m_ctx->width = avctx->width;
+ m_ctx->height = avctx->height;
+ m_ctx->format = 'avc1';
+ m_ctx->use_sync_decoding = 1;
+ m_ctx->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
+
+ if (!Create(avctx))
+ return false;
+
+ avctx->pix_fmt = fmt;
+ avctx->hwaccel_context = m_ctx;
+ avctx->get_buffer = GetBufferS;
+ avctx->release_buffer = RelBufferS;
+
+ return true;
+}
+
+int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
+{
+ int status = Check(avctx);
+ if(status)
+ return status;
+
+ if(frame)
+ return VC_BUFFER | VC_PICTURE;
+ else
+ return VC_BUFFER;
+}
+
+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
+{
+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(picture);
+
+ picture->format = RENDER_FMT_CVBREF;
+ picture->cvBufferRef = (CVPixelBufferRef)frame->data[3];
+ return true;
+}
+
+int CDecoder::Check(AVCodecContext* avctx)
+{
+ return 0;
+}
+
+unsigned CDecoder::GetAllowedReferences()
+{
+ return m_renderbuffers_count;
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#pragma once
+
+#include "system_gl.h"
+
+#include "DllAvCodec.h"
+#include "DVDVideoCodecFFmpeg.h"
+
+struct vda_context;
+
+namespace VDA {
+
+class CDecoder
+ : public CDVDVideoCodecFFmpeg::IHardwareDecoder
+{
+public:
+ CDecoder();
+ ~CDecoder();
+ virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces = 0);
+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame);
+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
+ virtual int Check (AVCodecContext* avctx);
+ virtual void Close();
+ virtual const std::string Name() { return "vda"; }
+ virtual CCriticalSection* Section() { return NULL; }
+ virtual unsigned GetAllowedReferences();
+
+ int GetBuffer(AVCodecContext *avctx, AVFrame *pic);
+ void RelBuffer(AVCodecContext *avctx, AVFrame *pic);
+protected:
+ bool Create(AVCodecContext* avctx);
+ unsigned m_renderbuffers_count;
+ vda_context* m_ctx;
+};
+
+}
vdp_video_mixer_query_feature_support = NULL;
vdp_video_mixer_destroy = NULL;
vdp_video_mixer_render = NULL;
+ m_hwContext.bitstream_buffers_allocated = 0;
}
bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
-#if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL) && \
- (defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP)
+#if (defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP)
case AV_CODEC_ID_MPEG4:
vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
#pragma warning(disable:4244)
#endif
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
-#ifndef _LINUX
+#ifndef TARGET_POSIX
// enum CodecID; // auto defined when neccesary
#include <libavcodec/avcodec.h>
#else
#include "DVDDemux.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define __attribute__(dummy_val)
#else
#include <config.h>
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma pack(push)
#pragma pack(1)
#endif
uint64_t durationMs;
} __attribute__((__packed__)) Demux_BXA_FmtHeader;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma pack(pop)
#endif
#include "DVDDemux.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define __attribute__(dummy_val)
#else
#include <config.h>
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "stdint.h"
#endif
#include "DVDDemuxFFmpeg.h"
#include "threads/Thread.h"
#include "threads/SystemClock.h"
#include "utils/TimeUtils.h"
+#include "URL.h"
void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo)
{
{
// special stream type that makes avformat handle file opening
// allows internal ffmpeg protocols to be used
+ CURL url = m_pInput->GetURL();
+ CStdString protocol = url.GetProtocol();
+
+ AVDictionary *options = GetFFMpegOptionsFromURL(url);
+
int result=-1;
- if (strFile.substr(0,6) == "mms://")
+ if (protocol.Equals("mms"))
{
// try mmsh, then mmst
- CStdString strFile2;
- strFile2.Format("mmsh://%s",strFile.substr(6,strFile.size()-6).c_str());
- result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile2.c_str(), iformat, NULL);
+ url.SetProtocol("mmsh");
+ url.SetProtocolOptions("");
+ result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, url.Get().c_str(), iformat, &options);
if (result < 0)
{
- strFile = "mmst://";
- strFile += strFile2.Mid(7).c_str();
+ url.SetProtocol("mmst");
+ strFile = url.Get();
}
}
- if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0 )
+ if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0 )
{
CLog::Log(LOGDEBUG, "Error, could not open file %s", strFile.c_str());
Dispose();
+ m_dllAvUtil.av_dict_free(&options);
return false;
}
+ m_dllAvUtil.av_dict_free(&options);
}
else
{
}
}
+AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromURL(const CURL &url)
+{
+ CStdString protocol = url.GetProtocol();
+
+ AVDictionary *options = NULL;
+
+ if (protocol.Equals("http") || protocol.Equals("https"))
+ {
+ std::map<CStdString, CStdString> protocolOptions;
+ url.GetProtocolOptions(protocolOptions);
+ std::string headers;
+ bool hasUserAgent = false;
+ for(std::map<CStdString, CStdString>::const_iterator it = protocolOptions.begin(); it != protocolOptions.end(); ++it)
+ {
+ const CStdString &name = it->first;
+ const CStdString &value = it->second;
+
+ if (name.Equals("seekable"))
+ m_dllAvUtil.av_dict_set(&options, "seekable", value.c_str(), 0);
+ else if (name.Equals("User-Agent"))
+ {
+ m_dllAvUtil.av_dict_set(&options, "user-agent", value.c_str(), 0);
+ hasUserAgent = true;
+ }
+ else if (!name.Equals("auth") && !name.Equals("Encoding"))
+ // all other protocol options can be added as http header.
+ headers.append(name).append(": ").append(value).append("\r\n");
+ }
+ if (!hasUserAgent)
+ // set default xbmc user-agent.
+ m_dllAvUtil.av_dict_set(&options, "user-agent", g_advancedSettings.m_userAgent.c_str(), 0);
+
+ if (!headers.empty())
+ m_dllAvUtil.av_dict_set(&options, "headers", headers.c_str(), 0);
+ }
+ return options;
+}
+
double CDVDDemuxFFmpeg::ConvertTimestamp(int64_t pts, int den, int num)
{
if (pts == (int64_t)AV_NOPTS_VALUE)
#include <map>
class CDVDDemuxFFmpeg;
+class CURL;
class CDemuxStreamVideoFFmpeg
: public CDemuxStreamVideo
void CreateStreams(unsigned int program = UINT_MAX);
void DisposeStreams();
+ AVDictionary *GetFFMpegOptionsFromURL(const CURL &url);
double ConvertTimestamp(int64_t pts, int den, int num);
void UpdateCurrentPTS();
bool IsProgramChange();
#include "DllAvCodec.h"
#include "DllAvFormat.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <libavformat/avformat.h>
#else
extern "C" {
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "DVDDemuxUtils.h"
bool CDVDInputStream::Open(const char* strFile, const std::string &content)
{
- CURL url = CURL(strFile);
+ CURL url(strFile);
- // get rid of any |option parameters which might have sneaked in here
- // those are only handled by our curl impl.
+ m_url = url;
+ // get rid of any protocol options which might have sneaked in here
+ // but keep them in m_url.
url.SetProtocolOptions("");
m_strFileName = url.Get();
#include "filesystem/IFileTypes.h"
#include "FileItem.h"
+#include "URL.h"
#include "guilib/Geometry.h"
enum DVDStreamType
virtual int64_t GetLength() = 0;
virtual std::string& GetContent() { return m_content; };
virtual std::string& GetFileName() { return m_strFileName; }
+ virtual CURL &GetURL() { return m_url; }
virtual ENextStream NextStream() { return NEXTSTREAM_NONE; }
virtual void Abort() {}
virtual int GetBlockSize() { return 0; }
protected:
DVDStreamType m_streamType;
std::string m_strFileName;
+ CURL m_url;
BitstreamStats m_stats;
std::string m_content;
CFileItem m_item;
CStdString strPath(strFile);
CStdString filename;
CStdString root;
- CStdString ext(URIUtils::GetExtension(strPath));
- ext.ToLower();
if(strPath.Left(7).Equals("bluray:"))
{
root = url.GetHostName();
filename = URIUtils::GetFileName(url.GetFileName());
}
- else if(ext == ".iso"
- || ext == ".img")
+ else if(URIUtils::HasExtension(strPath, ".iso|.img"))
{
CURL url("udf://");
url.SetHostName(strPath);
m_navmode = false;
m_title = GetTitleLongest();
}
- else if(URIUtils::GetExtension(filename).Equals(".mpls"))
+ else if(URIUtils::HasExtension(filename, ".mpls"))
{
m_navmode = false;
m_title = GetTitleFile(filename);
#include "DVDInputStreamFile.h"
#include "filesystem/File.h"
#include "filesystem/IFile.h"
+#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
unsigned int flags = READ_TRUNCATED | READ_BITRATE | READ_CHUNKED;
+ if ( g_advancedSettings.m_alwaysForceBuffer &&
+ !URIUtils::IsOnDVD(strFile) &&
+ !URIUtils::IsBluray(strFile) )
+ flags |= READ_CACHED;
+
+
if (content == "video/mp4" || content == "video/x-msvideo" || content == "video/avi")
flags |= READ_MULTI_STREAM;
bool PrevChannel(bool preview = false);
bool SelectChannelByNumber(unsigned int channel);
bool SelectChannel(const PVR::CPVRChannel &channel) { return false; }
- bool GetSelectedChannel(PVR::CPVRChannel *channel) {return false; }
+ static bool GetSelectedChannel(PVR::CPVRChannel *channel) {return false; }
bool UpdateItem(CFileItem& item);
bool CanRecord() { return false; }
int ConvertSubtitleStreamId_XBMCToExternal(int id);
int ConvertSubtitleStreamId_ExternalToXBMC(int id);
- void SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes);
- void SetSubtitleStreamName(DVDNavStreamInfo &info, const subp_attr_t subp_attributes);
+ static void SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes);
+ static void SetSubtitleStreamName(DVDNavStreamInfo &info, const subp_attr_t subp_attributes);
DllDvdNav m_dll;
bool m_bCheckButtons;
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "system.h" // just for HAS_LIBRTMP
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "system.h"
#endif
*/
/* config.h. Generated by hand. */
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
#include "PlatformInclude.h"
#else
#include <windows.h>
#include <limits.h>
#include <string.h>
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
/* pthread_mutex_* wrapper for win32 */
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <windows.h>
#include <process.h>
typedef CRITICAL_SECTION pthread_mutex_t;
#define pthread_mutex_lock(a) EnterCriticalSection(a)
#define pthread_mutex_unlock(a) LeaveCriticalSection(a)
#define pthread_mutex_destroy(a) DeleteCriticalSection(a)
-#endif // !_LINUX
+#endif // !TARGET_POSIX
#ifndef HAVE_GETTIMEOFDAY
/* replacement gettimeofday implementation */
#define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
#endif
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <io.h> /* read() */
#define lseek64 _lseeki64
-#endif // !_LINUX
+#endif // !TARGET_POSIX
#else
#include <pthread.h>
-#endif /* WIN32 */
+#endif /* TARGET_WINDOWS */
/* Uncomment for VM command tracing */
/* #define TRACE */
#else
#define printerrf(...) \
do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
-#endif /* WIN32 */
+#endif /* TARGET_WINDOWS */
#endif
#define printerr(str) \
do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
for(unsigned int i=0;i<filenames.size();i++)
{
// if vobsub subtitle:
- if (URIUtils::GetExtension(filenames[i]) == ".idx")
+ if (URIUtils::HasExtension(filenames[i], ".idx"))
{
CStdString strSubFile;
if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
{
// check if we should read from subtitle demuxer
- if(m_dvdPlayerSubtitle.AcceptsData() && m_pSubtitleDemuxer )
+ if( m_pSubtitleDemuxer && m_dvdPlayerSubtitle.AcceptsData() )
{
- if(m_pSubtitleDemuxer)
- packet = m_pSubtitleDemuxer->Read();
+ packet = m_pSubtitleDemuxer->Read();
if(packet)
{
m_CurrentSubtitle.stream = (void*)pStream;
m_CurrentSubtitle.started = false;
+ CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = m_SelectionStreams.IndexOf(STREAM_SUBTITLE, source, iStream);
return true;
}
}
}
- switch (action.GetID())
- {
- case ACTION_NEXT_ITEM:
- if(GetChapterCount() > 0)
- {
- m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()+1));
- g_infoManager.SetDisplayAfterSeek();
- return true;
- }
- else
- break;
- case ACTION_PREV_ITEM:
- if(GetChapterCount() > 0)
- {
- m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()-1));
- g_infoManager.SetDisplayAfterSeek();
- return true;
- }
- else
- break;
- }
-
// return false to inform the caller we didn't handle the message
return false;
}
g_dvdPerformanceCounter.EnableAudioDecodePerformance(this);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CoInitializeEx(NULL, COINIT_MULTITHREADED);
#endif
}
{
g_dvdPerformanceCounter.DisableAudioDecodePerformance();
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CoUninitialize();
#endif
#include "DVDDemuxers/DVDDemuxUtils.h"
#include "utils/log.h"
#include "threads/SingleLock.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "config.h"
#endif
#pragma once
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
extern "C" {
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
#include "lib/libass/libass/ass.h"
#else
#include <ass/ass.h>
void GetPattern(std::vector<double>& pattern); //gets the current pattern
void GetDifftypes(std::vector<double>& difftypes); //gets the difftypes from the ringbuffer
- bool MatchDiff(double diff1, double diff2); //checks if two diffs match by MAXERR
- bool MatchDifftype(int* diffs1, int* diffs2, int nrdiffs); //checks if the difftypes match
+ static bool MatchDiff(double diff1, double diff2); //checks if two diffs match by MAXERR
+ static bool MatchDifftype(int* diffs1, int* diffs2, int nrdiffs); //checks if the difftypes match
//builds a pattern of timestamps in the ringbuffer
void BuildPattern(std::vector<double>& pattern, int patternlength);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
SPEAKER_TOP_FRONT_CENTER, SPEAKER_LOW_FREQUENCY,
SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT,
- SPEAKER_BACK_CENTER, SPEAKER_SIDE_RIGHT
+ SPEAKER_BACK_CENTER, 0
};
static const uint16_t AC3Bitrates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
COMXAudio::COMXAudio() :
m_pCallback (NULL ),
m_Initialized (false ),
- m_Pause (false ),
- m_CanPause (false ),
m_CurrentVolume (0 ),
m_drc (0 ),
m_Passthrough (false ),
m_BitsPerSample (0 ),
m_omx_clock (NULL ),
m_av_clock (NULL ),
- m_first_frame (true ),
+ m_settings_changed(false ),
m_LostSync (true ),
m_SampleRate (0 ),
m_eEncoding (OMX_AUDIO_CodingPCM),
m_extradata (NULL ),
m_extrasize (0 ),
- m_vizBufferSamples(0 ),
- m_last_pts (DVD_NOPTS_VALUE),
- m_omx_render (NULL )
+ m_last_pts (DVD_NOPTS_VALUE)
{
m_vizBufferSize = m_vizRemapBufferSize = VIS_PACKET_SIZE * sizeof(float);
m_vizRemapBuffer = (uint8_t *)_aligned_malloc(m_vizRemapBufferSize,16);
return info;
}
+
+bool COMXAudio::PortSettingsChanged()
+{
+ OMX_ERRORTYPE omx_err = OMX_ErrorNone;
+
+ if (m_settings_changed)
+ {
+ m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
+ m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
+ return true;
+ }
+
+ if(!m_Passthrough)
+ {
+ if(!m_omx_mixer.Initialize("OMX.broadcom.audio_mixer", OMX_IndexParamAudioInit))
+ return false;
+ }
+
+ if(!m_omx_render.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
+ return false;
+
+ m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), &m_omx_render, m_omx_render.GetInputPort()+1);
+
+ omx_err = m_omx_tunnel_clock.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ m_omx_render.ResetEos();
+
+ OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
+ OMX_INIT_STRUCTURE(audioDest);
+ strncpy((char *)audioDest.sName, m_deviceuse.c_str(), strlen(m_deviceuse.c_str()));
+
+ omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
+ if (omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_render.SetConfig omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ if(!m_Passthrough)
+ {
+ m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_mixer, m_omx_mixer.GetInputPort());
+ m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+ CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d nopassthrough", CLASSNAME, __func__,
+ (int)m_pcm_input.nBitPerSample, m_pcm_input.ePCMMode, (int)m_pcm_input.nChannels, (int)m_pcm_input.nSamplingRate);
+ }
+ else
+ {
+ m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+ CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d passthrough", CLASSNAME, __func__,
+ 0, 0, 0, 0);
+ }
+
+ omx_err = m_omx_tunnel_decoder.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ if(!m_Passthrough)
+ {
+ omx_err = m_omx_mixer.SetStateForComponent(OMX_StateExecuting);
+ if(omx_err != OMX_ErrorNone) {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_mixer OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ omx_err = m_omx_tunnel_mixer.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ }
+
+ omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_render OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ m_settings_changed = true;
+ return true;
+}
+
bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode)
{
+ OMX_ERRORTYPE omx_err;
+
Deinitialize();
if(!m_dllAvUtil.Load())
return false;
+ if(device == "hdmi") {
+ m_deviceuse = "hdmi";
+ } else {
+ m_deviceuse = "local";
+ }
+
m_HWDecode = bUseHWDecode;
m_Passthrough = bUsePassthrough;
if (!m_Passthrough)
{
- /* setup output channel map */
- /*
- int ch = 0, map;
- int chan = 0;
- m_OutputChannels = 0;
-
- for (unsigned int ch = 0; ch < m_format.m_channelLayout.Count(); ++ch)
- {
- for(map = 0; map < OMX_MAX_CHANNELS; ++map)
- {
- if (m_output_channels[ch] == OMXChannelMap[map])
- {
- printf("output %d\n", chan);
- m_output_channels[chan] = OMXChannels[map];
- chan++;
- break;
- }
- }
- }
-
- m_OutputChannels = chan;
- */
-
/* setup input channel map */
int map = 0;
int chan = 0;
m_pcm_output.eNumData = OMX_NumericalDataSigned;
m_pcm_output.eEndian = OMX_EndianLittle;
m_pcm_output.bInterleaved = OMX_TRUE;
- m_pcm_output.nBitPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+ m_pcm_output.nBitPerSample = 16; // float is decoded to 16bit integer by gpu
m_pcm_output.ePCMMode = OMX_AUDIO_PCMModeLinear;
m_pcm_output.nChannels = m_OutputChannels;
m_pcm_output.nSamplingRate = m_format.m_sampleRate;
m_SampleRate = m_format.m_sampleRate;
m_BitsPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
m_BufferLen = m_BytesPerSec = m_format.m_sampleRate *
- (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3) *
- m_format.m_channelLayout.Count();
+ (m_BitsPerSample >> 3) * m_format.m_channelLayout.Count();
m_BufferLen *= AUDIO_BUFFER_SECONDS;
- m_ChunkLen = 6144;
+ // should be big enough that common formats (e.g. 6 channel DTS) fit in a single packet.
+ // we don't mind less common formats being split (e.g. ape/wma output large frames)
+ m_ChunkLen = 32*1024;
m_wave_header.Samples.wSamplesPerBlock = 0;
m_wave_header.Format.nChannels = m_format.m_channelLayout.Count();
m_wave_header.Format.nBlockAlign = m_format.m_channelLayout.Count() *
- (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3);
- m_wave_header.Format.wFormatTag = WAVE_FORMAT_PCM;
+ (m_BitsPerSample >> 3);
+ // 0x8000 is custom format interpreted by GPU as WAVE_FORMAT_IEEE_FLOAT_PLANAR
+ m_wave_header.Format.wFormatTag = m_BitsPerSample == 32 ? 0x8000 : WAVE_FORMAT_PCM;
m_wave_header.Format.nSamplesPerSec = m_format.m_sampleRate;
m_wave_header.Format.nAvgBytesPerSec = m_BytesPerSec;
- m_wave_header.Format.wBitsPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
- m_wave_header.Samples.wValidBitsPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+ m_wave_header.Format.wBitsPerSample = m_BitsPerSample;
+ m_wave_header.Samples.wValidBitsPerSample = m_BitsPerSample;
m_wave_header.Format.cbSize = 0;
m_wave_header.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
m_pcm_input.eNumData = OMX_NumericalDataSigned;
m_pcm_input.eEndian = OMX_EndianLittle;
m_pcm_input.bInterleaved = OMX_TRUE;
- m_pcm_input.nBitPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+ m_pcm_input.nBitPerSample = m_BitsPerSample;
m_pcm_input.ePCMMode = OMX_AUDIO_PCMModeLinear;
m_pcm_input.nChannels = m_format.m_channelLayout.Count();
m_pcm_input.nSamplingRate = m_format.m_sampleRate;
- std::string componentName = "OMX.broadcom.audio_render";
-
- if(!m_omx_render)
- m_omx_render = new COMXCoreComponent();
- if(!m_omx_render)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize error allocate OMX.broadcom.audio_render\n");
- return false;
- }
-
- if(!m_omx_render->Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
- return false;
-
- m_omx_render->ResetEos();
-
- OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
- OMX_INIT_STRUCTURE(audioDest);
- strncpy((char *)audioDest.sName, device.c_str(), strlen(device.c_str()));
-
- OMX_ERRORTYPE omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
- if (omx_err != OMX_ErrorNone)
- return false;
-
- OMX_CONFIG_BOOLEANTYPE configBool;
- OMX_INIT_STRUCTURE(configBool);
- configBool.bEnabled = OMX_FALSE;
-
- omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
- if (omx_err != OMX_ErrorNone)
- return false;
-
- componentName = "OMX.broadcom.audio_decode";
- if(!m_omx_decoder.Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
+ if(!m_omx_decoder.Initialize("OMX.broadcom.audio_decode", OMX_IndexParamAudioInit))
return false;
- if(!m_Passthrough)
- {
- componentName = "OMX.broadcom.audio_mixer";
- if(!m_omx_mixer.Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
- return false;
- }
-
OMX_CONFIG_BOOLEANTYPE boolType;
OMX_INIT_STRUCTURE(boolType);
if(m_Passthrough)
omx_err = m_omx_decoder.SetParameter(OMX_IndexParamPortDefinition, &port_param);
if(omx_err != OMX_ErrorNone)
{
- CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition omx_err(0x%08x)\n", omx_err);
+ CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition (intput) omx_err(0x%08x)\n", omx_err);
+ return false;
+ }
+
+ // set up the number/size of buffers for decoder output
+ OMX_INIT_STRUCTURE(port_param);
+ port_param.nPortIndex = m_omx_decoder.GetOutputPort();
+
+ omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_param);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "COMXAudio::Initialize error get OMX_IndexParamPortDefinition (output) omx_err(0x%08x)\n", omx_err);
+ return false;
+ }
+
+ //port_param.nBufferCountActual = std::max(1, (int)(m_BufferLen / port_param.nBufferSize));
+
+ omx_err = m_omx_decoder.SetParameter(OMX_IndexParamPortDefinition, &port_param);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition (output) omx_err(0x%08x)\n", omx_err);
return false;
}
- //if(m_HWDecode)
{
OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
OMX_INIT_STRUCTURE(formatType);
}
}
- m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), m_omx_render, m_omx_render->GetInputPort()+1);
-
- omx_err = m_omx_tunnel_clock.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize m_omx_tunnel_clock.Establish\n");
- return false;
- }
-
omx_err = m_omx_decoder.AllocInputBuffers();
if(omx_err != OMX_ErrorNone)
{
return false;
}
- if(!m_Passthrough)
- {
- m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_mixer, m_omx_mixer.GetInputPort());
- omx_err = m_omx_tunnel_decoder.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
- return false;
- }
-
- omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
- if(omx_err != OMX_ErrorNone) {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
- return false;
- }
-
- m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
- omx_err = m_omx_tunnel_mixer.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
- return false;
- }
-
- omx_err = m_omx_mixer.SetStateForComponent(OMX_StateExecuting);
- if(omx_err != OMX_ErrorNone) {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
- return false;
- }
- }
- else
- {
- m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
- omx_err = m_omx_tunnel_decoder.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
- return false;
- }
-
- omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
- if(omx_err != OMX_ErrorNone) {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
- return false;
- }
- }
-
- omx_err = m_omx_render->SetStateForComponent(OMX_StateExecuting);
- if(omx_err != OMX_ErrorNone)
- {
+ omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
+ if(omx_err != OMX_ErrorNone) {
CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
return false;
}
- m_omx_decoder.EnablePort(m_omx_decoder.GetInputPort(), true);
if(m_eEncoding == OMX_AUDIO_CodingPCM)
{
return false;
m_Initialized = true;
- m_first_frame = true;
+ m_settings_changed = false;
m_last_pts = DVD_NOPTS_VALUE;
CLog::Log(LOGDEBUG, "COMXAudio::Initialize Ouput bps %d samplerate %d channels %d buffer size %d bytes per second %d",
m_omx_tunnel_clock.Deestablish();
if(!m_Passthrough)
- {
- // workaround for the strange BCM mixer component
- if(m_omx_mixer.GetState() == OMX_StateExecuting)
- m_omx_mixer.SetStateForComponent(OMX_StatePause);
- if(m_omx_mixer.GetState() != OMX_StateIdle)
- m_omx_mixer.SetStateForComponent(OMX_StateIdle);
- m_omx_mixer.DisableAllPorts();
- m_omx_tunnel_mixer.Deestablish(true);
- }
+ m_omx_tunnel_mixer.Deestablish();
m_omx_tunnel_decoder.Deestablish();
m_omx_decoder.FlushInput();
- if(m_omx_render)
- m_omx_render->Deinitialize(true);
+ m_omx_render.Deinitialize(true);
if(!m_Passthrough)
m_omx_mixer.Deinitialize(true);
m_omx_decoder.Deinitialize(true);
m_dllAvUtil.Unload();
- m_first_frame = true;
m_last_pts = DVD_NOPTS_VALUE;
- delete m_omx_render;
- m_omx_render = NULL;
-
return true;
}
m_last_pts = DVD_NOPTS_VALUE;
m_LostSync = true;
- //m_first_frame = true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Pause()
-{
- if (!m_Initialized)
- return -1;
-
- if(m_Pause) return true;
- m_Pause = true;
-
- m_omx_decoder.SetStateForComponent(OMX_StatePause);
-
- return true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Resume()
-{
- if (!m_Initialized)
- return -1;
-
- if(!m_Pause) return true;
- m_Pause = false;
-
- m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
-
- return true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Stop()
-{
- if (!m_Initialized)
- return -1;
-
- Flush();
-
- m_Pause = false;
-
- return true;
}
//***********************************************************************************************
{
OMX_AUDIO_CONFIG_VOLUMETYPE volume;
OMX_INIT_STRUCTURE(volume);
- volume.nPortIndex = m_omx_render->GetInputPort();
+ volume.nPortIndex = m_omx_render.GetInputPort();
volume.bLinear = OMX_TRUE;
float hardwareVolume = fVolume * gain * 100.0f;
volume.sVolume.nValue = (int)(hardwareVolume + 0.5f);
OMX_ERRORTYPE omx_err =
- m_omx_render->SetConfig(OMX_IndexConfigAudioVolume, &volume);
+ m_omx_render.SetConfig(OMX_IndexConfigAudioVolume, &volume);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "%s::%s - error setting OMX_IndexConfigAudioVolume, error 0x%08x\n",
return len;
}
- m_vizBufferSamples = 0;
-
- if (m_pCallback && len)
+ if (m_pCallback && len && !(m_Passthrough || m_HWDecode))
{
/* input samples */
- m_vizBufferSamples = len / (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3);
- CAEConvert::AEConvertToFn m_convertFn = CAEConvert::ToFloat(AE_FMT_S16LE);
+ unsigned int vizBufferSamples = len / (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3);
+
/* input frames */
- unsigned int frames = m_vizBufferSamples / m_format.m_channelLayout.Count();
+ unsigned int frames = vizBufferSamples / m_format.m_channelLayout.Count();
+ float *floatBuffer = (float *)data;
- /* check convert buffer */
- CheckOutputBufferSize((void **)&m_vizBuffer, &m_vizBufferSize, m_vizBufferSamples * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
+ if (m_format.m_dataFormat != AE_FMT_FLOAT)
+ {
+ CAEConvert::AEConvertToFn m_convertFn = CAEConvert::ToFloat(m_format.m_dataFormat);
+
+ /* check convert buffer */
+ CheckOutputBufferSize((void **)&m_vizBuffer, &m_vizBufferSize, vizBufferSamples * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
- /* convert to float */
- m_convertFn((uint8_t *)data, m_vizBufferSamples, (float *)m_vizBuffer);
+ /* convert to float */
+ m_convertFn((uint8_t *)data, vizBufferSamples, (float *)m_vizBuffer);
+ floatBuffer = (float *)m_vizBuffer;
+ }
- /* check remap buffer */
- CheckOutputBufferSize((void **)&m_vizRemapBuffer, &m_vizRemapBufferSize, frames * 2 * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
+ // Viz channel count is 2
+ CheckOutputBufferSize((void **)&m_vizRemapBuffer, &m_vizRemapBufferSize, frames * 2 * sizeof(float));
/* remap */
- m_vizRemap.Remap((float *)m_vizBuffer, (float*)m_vizRemapBuffer, frames);
+ m_vizRemap.Remap(floatBuffer, (float*)m_vizRemapBuffer, frames);
/* output samples */
- m_vizBufferSamples = m_vizBufferSamples / m_format.m_channelLayout.Count() * 2;
+ vizBufferSamples = vizBufferSamples / m_format.m_channelLayout.Count() * 2;
/* viz size is limited */
- if(m_vizBufferSamples > VIS_PACKET_SIZE)
- m_vizBufferSamples = VIS_PACKET_SIZE;
+ if(vizBufferSamples > VIS_PACKET_SIZE)
+ vizBufferSamples = VIS_PACKET_SIZE;
if(m_pCallback)
- m_pCallback->OnAudioData((float *)m_vizRemapBuffer, m_vizBufferSamples);
+ m_pCallback->OnAudioData((float *)m_vizRemapBuffer, vizBufferSamples);
}
if(m_eEncoding == OMX_AUDIO_CodingDTS && m_LostSync && (m_Passthrough || m_HWDecode))
return len;
}
- unsigned int demuxer_bytes = (unsigned int)len;
+ int m_InputChannels = m_format.m_channelLayout.Count();
+ unsigned pitch = (m_Passthrough || m_HWDecode) ? 1:(m_BitsPerSample >> 3) * m_InputChannels;
+ unsigned int demuxer_samples = len / pitch;
+ unsigned int demuxer_samples_sent = 0;
uint8_t *demuxer_content = (uint8_t *)data;
OMX_ERRORTYPE omx_err;
OMX_BUFFERHEADERTYPE *omx_buffer = NULL;
- while(demuxer_bytes)
+ while(demuxer_samples_sent < demuxer_samples)
{
// 200ms timeout
omx_buffer = m_omx_decoder.GetInputBuffer(200);
omx_buffer->nOffset = 0;
omx_buffer->nFlags = 0;
- omx_buffer->nFilledLen = (demuxer_bytes > omx_buffer->nAllocLen) ? omx_buffer->nAllocLen : demuxer_bytes;
- memcpy(omx_buffer->pBuffer, demuxer_content, omx_buffer->nFilledLen);
+ unsigned int remaining = demuxer_samples-demuxer_samples_sent;
+ unsigned int samples_space = omx_buffer->nAllocLen/pitch;
+ unsigned int samples = std::min(remaining, samples_space);
+
+ omx_buffer->nFilledLen = samples * pitch;
+
+ if (samples < demuxer_samples && m_BitsPerSample==32 && !(m_Passthrough || m_HWDecode))
+ {
+ uint8_t *dst = omx_buffer->pBuffer;
+ uint8_t *src = demuxer_content + demuxer_samples_sent * (m_BitsPerSample >> 3);
+ // we need to extract samples from planar audio, so the copying needs to be done per plane
+ for (int i=0; i<m_InputChannels; i++)
+ {
+ memcpy(dst, src, omx_buffer->nFilledLen / m_InputChannels);
+ dst += omx_buffer->nFilledLen / m_InputChannels;
+ src += demuxer_samples * (m_BitsPerSample >> 3);
+ }
+ assert(dst <= omx_buffer->pBuffer + m_ChunkLen);
+ }
+ else
+ {
+ uint8_t *dst = omx_buffer->pBuffer;
+ uint8_t *src = demuxer_content + demuxer_samples_sent * pitch;
+ memcpy(dst, src, omx_buffer->nFilledLen);
+ }
uint64_t val = (uint64_t)(pts == DVD_NOPTS_VALUE) ? 0 : pts;
omx_buffer->nTimeStamp = ToOMXTime(val);
- demuxer_bytes -= omx_buffer->nFilledLen;
- demuxer_content += omx_buffer->nFilledLen;
+ demuxer_samples_sent += samples;
- if(demuxer_bytes == 0)
+ if(demuxer_samples_sent == demuxer_samples)
omx_buffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
int nRetry = 0;
}
}
- if(m_first_frame)
+ omx_err = m_omx_decoder.WaitForEvent(OMX_EventPortSettingsChanged, 0);
+ if (omx_err == OMX_ErrorNone)
{
- m_first_frame = false;
- //m_omx_render.WaitForEvent(OMX_EventPortSettingsChanged);
-
- m_omx_render->DisablePort(m_omx_render->GetInputPort(), false);
- if(!m_Passthrough)
- {
- m_omx_mixer.DisablePort(m_omx_mixer.GetOutputPort(), false);
- m_omx_mixer.DisablePort(m_omx_mixer.GetInputPort(), false);
- }
- m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), false);
-
- if(!m_Passthrough)
- {
- if(m_HWDecode)
- {
- OMX_INIT_STRUCTURE(m_pcm_input);
- m_pcm_input.nPortIndex = m_omx_decoder.GetOutputPort();
- omx_err = m_omx_decoder.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 1 omx_err(0x%08x)\n", omx_err);
- }
- }
-
- memcpy(m_pcm_input.eChannelMapping, m_input_channels, sizeof(m_input_channels));
- m_pcm_input.nSamplingRate = m_format.m_sampleRate;
-
- /* setup mixer input */
- m_pcm_input.nPortIndex = m_omx_mixer.GetInputPort();
- omx_err = m_omx_mixer.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 input omx_err(0x%08x)\n", omx_err);
- }
- omx_err = m_omx_mixer.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 input omx_err(0x%08x)\n", omx_err);
- }
-
- m_pcm_output.nSamplingRate = m_format.m_sampleRate;
-
- /* setup mixer output */
- m_pcm_output.nPortIndex = m_omx_mixer.GetOutputPort();
- omx_err = m_omx_mixer.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 output omx_err(0x%08x)\n", omx_err);
- }
- omx_err = m_omx_mixer.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 output omx_err(0x%08x)\n", omx_err);
- }
-
- m_pcm_output.nSamplingRate = m_format.m_sampleRate;
-
- m_pcm_output.nPortIndex = m_omx_render->GetInputPort();
- omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 render omx_err(0x%08x)\n", omx_err);
- }
- omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 render omx_err(0x%08x)\n", omx_err);
- }
-
- PrintPCM(&m_pcm_input, std::string("input"));
- PrintPCM(&m_pcm_output, std::string("output"));
- }
- else
- {
- OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
- OMX_INIT_STRUCTURE(formatType);
- formatType.nPortIndex = m_omx_render->GetInputPort();
-
- omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPortFormat, &formatType);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
- assert(0);
- }
-
- formatType.eEncoding = m_eEncoding;
-
- omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPortFormat, &formatType);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
- assert(0);
- }
-
- if(m_eEncoding == OMX_AUDIO_CodingDDP)
- {
- OMX_AUDIO_PARAM_DDPTYPE m_ddParam;
- OMX_INIT_STRUCTURE(m_ddParam);
-
- m_ddParam.nPortIndex = m_omx_render->GetInputPort();
-
- m_ddParam.nChannels = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
- m_ddParam.nSampleRate = m_SampleRate;
- m_ddParam.eBitStreamId = OMX_AUDIO_DDPBitStreamIdAC3;
- m_ddParam.nBitRate = 0;
-
- for(unsigned int i = 0; i < OMX_MAX_CHANNELS; i++)
- {
- if(i >= m_ddParam.nChannels)
- break;
-
- m_ddParam.eChannelMapping[i] = OMXChannels[i];
- }
-
- m_omx_render->SetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
- m_omx_render->GetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
- PrintDDP(&m_ddParam);
- }
- else if(m_eEncoding == OMX_AUDIO_CodingDTS)
- {
- m_dtsParam.nPortIndex = m_omx_render->GetInputPort();
-
- m_dtsParam.nChannels = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
- m_dtsParam.nBitRate = 0;
-
- for(unsigned int i = 0; i < OMX_MAX_CHANNELS; i++)
- {
- if(i >= m_dtsParam.nChannels)
- break;
-
- m_dtsParam.eChannelMapping[i] = OMXChannels[i];
- }
-
- m_omx_render->SetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
- m_omx_render->GetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
- PrintDTS(&m_dtsParam);
- }
- }
-
- m_omx_render->EnablePort(m_omx_render->GetInputPort(), false);
- if(!m_Passthrough)
+ if(!PortSettingsChanged())
{
- m_omx_mixer.EnablePort(m_omx_mixer.GetOutputPort(), false);
- m_omx_mixer.EnablePort(m_omx_mixer.GetInputPort(), false);
+ CLog::Log(LOGERROR, "%s::%s - error PortSettingsChanged omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
}
- m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), false);
}
-
}
return len;
float COMXAudio::GetDelay()
{
unsigned int free = m_omx_decoder.GetInputBufferSize() - m_omx_decoder.GetInputBufferSpace();
- return (float)free / (float)m_BytesPerSec;
+ return m_BytesPerSec ? (float)free / (float)m_BytesPerSec : 0.0f;
}
float COMXAudio::GetCacheTime()
float fBufferLenFull = (float)m_BufferLen - (float)GetSpace();
if(fBufferLenFull < 0)
fBufferLenFull = 0;
- float ret = fBufferLenFull / (float)m_BytesPerSec;
+ float ret = m_BytesPerSec ? fBufferLenFull / (float)m_BytesPerSec : 0.0f;
return ret;
}
float COMXAudio::GetCacheTotal()
{
- return (float)m_BufferLen / (float)m_BytesPerSec;
+ return m_BytesPerSec ? (float)m_BufferLen / (float)m_BytesPerSec : 0.0f;
}
//***********************************************************************************************
void COMXAudio::RegisterAudioCallback(IAudioCallback *pCallback)
{
- m_vizBufferSamples = 0;
if(!m_Passthrough && !m_HWDecode)
{
m_pCallback = pCallback;
void COMXAudio::UnRegisterAudioCallback()
{
m_pCallback = NULL;
- m_vizBufferSamples = 0;
}
unsigned int COMXAudio::GetAudioRenderingLatency()
OMX_PARAM_U32TYPE param;
OMX_INIT_STRUCTURE(param);
- param.nPortIndex = m_omx_render->GetInputPort();
+ param.nPortIndex = m_omx_render.GetInputPort();
OMX_ERRORTYPE omx_err =
- m_omx_render->GetConfig(OMX_IndexConfigAudioRenderingLatency, ¶m);
+ m_omx_render.GetConfig(OMX_IndexConfigAudioRenderingLatency, ¶m);
if(omx_err != OMX_ErrorNone)
{
{
CSingleLock lock (m_critSection);
- if(!m_Initialized || m_Pause)
+ if(!m_Initialized)
return;
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
bool COMXAudio::IsEOS()
{
- if(!m_Initialized || m_Pause)
+ if(!m_Initialized)
return true;
unsigned int latency = GetAudioRenderingLatency();
CSingleLock lock (m_critSection);
unsigned int COMXAudio::SyncAC3(BYTE* pData, unsigned int iSize)
{
unsigned int skip = 0;
- //unsigned int fSize = 0;
for(skip = 0; iSize - skip > 6; ++skip, ++pData)
{
case 2: framesize = bitrate * 4; break;
}
- //fSize = framesize * 2;
m_SampleRate = AC3FSCod[fscod];
/* dont do extensive testing if we have not lost sync */
float GetCacheTotal();
COMXAudio();
bool Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode);
+ bool PortSettingsChanged();
~COMXAudio();
unsigned int AddPackets(const void* data, unsigned int len);
unsigned int AddPackets(const void* data, unsigned int len, double dts, double pts);
unsigned int GetSpace();
bool Deinitialize();
- bool Pause();
- bool Stop();
- bool Resume();
long GetCurrentVolume() const;
void Mute(bool bMute);
void SetCodingType(AEDataFormat dataFormat);
static bool CanHWDecode(CodecID codec);
- void PrintChannels(OMX_AUDIO_CHANNELTYPE eChannelMapping[]);
+ static void PrintChannels(OMX_AUDIO_CHANNELTYPE eChannelMapping[]);
void PrintPCM(OMX_AUDIO_PARAM_PCMMODETYPE *pcm, std::string direction);
void PrintDDP(OMX_AUDIO_PARAM_DDPTYPE *ddparm);
void PrintDTS(OMX_AUDIO_PARAM_DTSTYPE *dtsparam);
private:
IAudioCallback* m_pCallback;
bool m_Initialized;
- bool m_Pause;
- bool m_CanPause;
float m_CurrentVolume;
long m_drc;
bool m_Passthrough;
unsigned int m_BitsPerSample;
COMXCoreComponent *m_omx_clock;
OMXClock *m_av_clock;
- bool m_first_frame;
+ bool m_settings_changed;
bool m_LostSync;
int m_SampleRate;
OMX_AUDIO_CODINGTYPE m_eEncoding;
uint8_t *m_extradata;
int m_extrasize;
+ std::string m_deviceuse;
// stuff for visualisation
- unsigned int m_vizBufferSamples;
double m_last_pts;
int m_vizBufferSize;
uint8_t *m_vizBuffer;
WAVEFORMATEXTENSIBLE m_wave_header;
AEAudioFormat m_format;
protected:
- COMXCoreComponent *m_omx_render;
+ COMXCoreComponent m_omx_render;
COMXCoreComponent m_omx_mixer;
COMXCoreComponent m_omx_decoder;
COMXCoreTunel m_omx_tunnel_clock;
CAEChannelInfo m_channelLayout;
- CAEChannelInfo GetChannelLayout(AEAudioFormat format);
+ static CAEChannelInfo GetChannelLayout(AEAudioFormat format);
- void CheckOutputBufferSize(void **buffer, int *oldSize, int newSize);
+ static void CheckOutputBufferSize(void **buffer, int *oldSize, int newSize);
CCriticalSection m_critSection;
};
#endif
*/
#include "OMXAudioCodecOMX.h"
-#ifdef _LINUX
+#ifdef TARGET_LINUX
#include "XMemUtils.h"
#endif
#include "utils/log.h"
#define MAX_AUDIO_FRAME_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE*2)
-template <class AudioDataType>
-static inline void _Upmix(AudioDataType *input,
- unsigned int channelsInput, AudioDataType *output,
- unsigned int channelsOutput, unsigned int frames)
-{
- unsigned int unused = channelsOutput - channelsInput;
- AudioDataType *_input = input;
- AudioDataType *_output = output;
-
- for (unsigned int i = 0; i < frames; i++)
- {
- // get input channels
- for(unsigned int j = 0; j < channelsInput; j++)
- *_output++ = *_input++;
- // set unused channels
- for(unsigned int j = 0; j < unused; j++)
- *_output++ = 0;
- }
-}
-
-void COMXAudioCodecOMX::Upmix(void *input,
- unsigned int channelsInput, void *output,
- unsigned int channelsOutput, unsigned int frames, AEDataFormat dataFormat)
-{
- // input channels must be less than output channels
- if (channelsInput >= channelsOutput)
- return;
-
- switch (CAEUtil::DataFormatToBits(dataFormat))
- {
- case 8: _Upmix ( (unsigned char *) input, channelsInput, (unsigned char *) output, channelsOutput, frames ); break;
- case 16: _Upmix ( (short *) input, channelsInput, (short *) output, channelsOutput, frames ); break;
- case 32: _Upmix ( (float *) input, channelsInput, (float *) output, channelsOutput, frames ); break;
- default: _Upmix ( (int *) input, channelsInput, (int *) output, channelsOutput, frames ); break;
- }
-}
-
COMXAudioCodecOMX::COMXAudioCodecOMX()
{
m_iBufferSize2 = 0;
m_layout = 0;
m_pFrame1 = NULL;
m_iSampleFormat = AV_SAMPLE_FMT_NONE;
+ m_desiredSampleFormat = AV_SAMPLE_FMT_NONE;
m_iBufferSize1 = 0;
}
return false;
}
+ m_bFirstFrame = true;
m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
m_pCodecContext->debug_mv = 0;
m_pCodecContext->debug = 0;
m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame();
m_bOpenedCodec = true;
m_iSampleFormat = AV_SAMPLE_FMT_NONE;
+ m_desiredSampleFormat = m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_S16 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_FLTP;
return true;
}
if (m_pCodecContext)
{
+ if (m_pCodecContext->extradata) m_dllAvUtil.av_free(m_pCodecContext->extradata);
+ m_pCodecContext->extradata = NULL;
if (m_bOpenedCodec) m_dllAvCodec.avcodec_close(m_pCodecContext);
m_bOpenedCodec = false;
m_dllAvUtil.av_free(m_pCodecContext);
int iBytesUsed, got_frame;
if (!m_pCodecContext) return -1;
- m_iBufferSize1 = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- m_iBufferSize2 = 0;
-
AVPacket avpkt;
m_dllAvCodec.av_init_packet(&avpkt);
avpkt.data = pData;
m_iBufferSize2 = 0;
return iBytesUsed;
}
- m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
+ int linesize1, linesize2;
+ m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(&linesize1, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
+ m_iBufferSize2 = m_dllAvUtil.av_samples_get_buffer_size(&linesize2, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1);
/* some codecs will attempt to consume more data than what we gave */
if (iBytesUsed > iSize)
else
m_iBuffered = 0;
- if(m_pCodecContext->sample_fmt != AV_SAMPLE_FMT_S16 && m_iBufferSize1 > 0)
+ if (m_bFirstFrame)
+ {
+ CLog::Log(LOGDEBUG, "COMXAudioCodecOMX::Decode(%p,%d) format=%d(%d) chan=%d samples=%d size=%d/%d,%d/%d,%d data=%p,%p,%p,%p,%p,%p,%p,%p",
+ pData, iSize, m_pCodecContext->sample_fmt, m_desiredSampleFormat, m_pCodecContext->channels, m_pFrame1->nb_samples,
+ m_iBufferSize1, m_iBufferSize2, linesize1, linesize2, m_pFrame1->linesize[0],
+ m_pFrame1->data[0], m_pFrame1->data[1], m_pFrame1->data[2], m_pFrame1->data[3], m_pFrame1->data[4], m_pFrame1->data[5], m_pFrame1->data[6], m_pFrame1->data[7]
+ );
+ }
+
+ if(m_pCodecContext->sample_fmt != m_desiredSampleFormat && m_iBufferSize1 > 0)
{
if(m_pConvert && (m_pCodecContext->sample_fmt != m_iSampleFormat || m_channels != m_pCodecContext->channels))
m_dllSwResample.swr_free(&m_pConvert);
m_iSampleFormat = m_pCodecContext->sample_fmt;
m_pConvert = m_dllSwResample.swr_alloc_set_opts(NULL,
m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels),
- AV_SAMPLE_FMT_S16, m_pCodecContext->sample_rate,
+ m_desiredSampleFormat, m_pCodecContext->sample_rate,
m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels),
m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate,
0, NULL);
if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0)
{
- CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", m_pCodecContext->sample_fmt);
+ CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to initialise convert format %d to %d", m_pCodecContext->sample_fmt, m_desiredSampleFormat);
m_iBufferSize1 = 0;
m_iBufferSize2 = 0;
return iBytesUsed;
}
+ m_iBufferSize1 = 0;
+
+ BYTE *out_planes[] = {
+ m_pBuffer2 + 0 * linesize2, m_pBuffer2 + 1 * linesize2, m_pBuffer2 + 2 * linesize2, m_pBuffer2 + 3 * linesize2,
+ m_pBuffer2 + 4 * linesize2, m_pBuffer2 + 5 * linesize2, m_pBuffer2 + 6 * linesize2, m_pBuffer2 + 7 * linesize2,
+ };
- int len = m_iBufferSize1 / m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt);
- if(m_dllSwResample.swr_convert(m_pConvert, &m_pBuffer2, len, (const uint8_t**)m_pFrame1->data, m_pFrame1->nb_samples) < 0)
+ if(m_dllSwResample.swr_convert(m_pConvert, out_planes, m_pFrame1->nb_samples, (const uint8_t **)m_pFrame1->data, m_pFrame1->nb_samples) < 0)
{
- CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", (int)m_pCodecContext->sample_fmt);
+ CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert format %d to %d", (int)m_pCodecContext->sample_fmt, m_desiredSampleFormat);
m_iBufferSize1 = 0;
m_iBufferSize2 = 0;
return iBytesUsed;
}
-
- m_iBufferSize1 = 0;
- m_iBufferSize2 = len * m_dllAvUtil.av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
+ }
+ else
+ {
+ m_iBufferSize2 = 0;
}
return iBytesUsed;
int COMXAudioCodecOMX::GetData(BYTE** dst)
{
- unsigned int size = 0;
- BYTE *src = NULL;
+ int size = 0;
+ bool contiguous = true;
if(m_iBufferSize1)
{
- *dst = m_pFrame1->data[0];
- src = m_pFrame1->data[0];
- size = m_iBufferSize1;
+ int i;
+ int linesize;
+ BYTE *next = m_pFrame1->data[0];
+ m_dllAvUtil.av_samples_get_buffer_size(&linesize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
+ for (i=0; i<m_pCodecContext->channels; i++)
+ {
+ if (!m_pFrame1->data[i])
+ break;
+ if (next != m_pFrame1->data[i])
+ contiguous = false;
+ next += linesize;
+ size += linesize;
+ }
+ if (size != m_iBufferSize1)
+ contiguous = false;
+
+ if (contiguous)
+ {
+ *dst = m_pFrame1->data[0];
+ size = m_iBufferSize1;
+ }
+ else
+ {
+ m_iBufferUpmixSize = 0;
+ for (i=0; i<m_pCodecContext->channels; i++)
+ {
+ if (m_iBufferUpmixSize + linesize <= MAX_AUDIO_FRAME_SIZE && m_pFrame1->data[i])
+ {
+ memcpy(m_pBufferUpmix + m_iBufferUpmixSize, m_pFrame1->data[i], linesize);
+ m_iBufferUpmixSize += linesize;
+ } else assert(0);
+ }
+ *dst = m_pBufferUpmix;
+ size = m_iBufferUpmixSize;
+ }
}
if(m_iBufferSize2)
{
*dst = m_pBuffer2;
- src = m_pBuffer2;
size = m_iBufferSize2;
}
-
- if(m_pCodecContext->channels > 4 && size)
+ if (m_bFirstFrame)
{
- unsigned int m_frameSize = (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3) * m_pCodecContext->channels;
- unsigned int frames = size / m_frameSize;
-
- memset(m_pBufferUpmix, 0, MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-
- Upmix(src, m_pCodecContext->channels, m_pBufferUpmix, 8, frames, AE_FMT_S16LE);
-
- m_iBufferUpmixSize = frames * 8 * (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3);
-
- *dst = m_pBufferUpmix;
- size = m_iBufferUpmixSize;
+ CLog::Log(LOGDEBUG, "COMXAudioCodecOMX::GetData size=%d/%d/%d cont=%d buf=%p", m_iBufferSize1, m_iBufferSize2, size, contiguous, *dst);
+ m_bFirstFrame = false;
}
-
return size;
}
int COMXAudioCodecOMX::GetChannels()
{
- return (m_pCodecContext->channels > 4) ? 8 : m_pCodecContext->channels;
+ if (!m_pCodecContext)
+ return 0;
+ return m_pCodecContext->channels;
}
int COMXAudioCodecOMX::GetSampleRate()
{
- if (m_pCodecContext) return m_pCodecContext->sample_rate;
- return 0;
+ if (!m_pCodecContext)
+ return 0;
+ return m_pCodecContext->sample_rate;
}
int COMXAudioCodecOMX::GetBitsPerSample()
{
- return 16;
+ if (!m_pCodecContext)
+ return 0;
+ return m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 32;
}
int COMXAudioCodecOMX::GetBitRate()
{
- if (m_pCodecContext) return m_pCodecContext->bit_rate;
- return 0;
+ if (!m_pCodecContext)
+ return 0;
+ return m_pCodecContext->bit_rate;
}
static unsigned count_bits(int64_t value)
if (layout & AV_CH_TOP_BACK_LEFT ) m_channelLayout += AE_CH_BL ;
if (layout & AV_CH_TOP_BACK_CENTER ) m_channelLayout += AE_CH_BC ;
if (layout & AV_CH_TOP_BACK_RIGHT ) m_channelLayout += AE_CH_BR ;
-
- //terminate the channel map
- if(m_pCodecContext->channels > 4)
- {
- for(int i = m_pCodecContext->channels; i < 8; i++)
- m_channelLayout += AE_CH_RAW;
- }
}
CAEChannelInfo COMXAudioCodecOMX::GetChannelMap()
class COMXAudioCodecOMX
{
public:
- static void Upmix(void *input, unsigned int channelsInput, void *output,
- unsigned int channelsOutput, unsigned int frames, AEDataFormat dataFormat);
COMXAudioCodecOMX();
virtual ~COMXAudioCodecOMX();
bool Open(CDVDStreamInfo &hints);
int GetChannels();
virtual CAEChannelInfo GetChannelMap();
int GetSampleRate();
- static int GetBitsPerSample();
+ int GetBitsPerSample();
static const char* GetName() { return "FFmpeg"; }
int GetBufferSize() { return m_iBuffered; }
int GetBitRate();
AVCodecContext* m_pCodecContext;
SwrContext* m_pConvert;
enum AVSampleFormat m_iSampleFormat;
+ enum AVSampleFormat m_desiredSampleFormat;
CAEChannelInfo m_channelLayout;
AVFrame* m_pFrame1;
int m_channels;
uint64_t m_layout;
+ bool m_bFirstFrame;
DllAvCodec m_dllAvCodec;
DllAvUtil m_dllAvUtil;
DllSwResample m_dllSwResample;
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
#include "DVDInputStreams/DVDInputStreamTV.h"
#include "DVDInputStreams/DVDInputStreamPVRManager.h"
+#include "DVDDemuxers/DVDDemux.h"
#include "DVDDemuxers/DVDDemuxUtils.h"
#include "DVDDemuxers/DVDDemuxVobsub.h"
#include "DVDDemuxers/DVDFactoryDemuxer.h"
#include "DVDDemuxers/DVDDemuxFFmpeg.h"
-#include "DVDFileInfo.h"
+#include "DVDCodecs/DVDCodecs.h"
+#include "DVDCodecs/DVDFactoryCodec.h"
-#include "Util.h"
-#include "LangInfo.h"
+#include "DVDFileInfo.h"
-#include "utils/JobManager.h"
-//#include "cores/AudioEngine/AEFactory.h"
-//#include "cores/AudioEngine/Utils/AEUtil.h"
-#include "video/VideoThumbLoader.h"
+#include "utils/LangCodeExpander.h"
+#include "guilib/Key.h"
+#include "guilib/LocalizeStrings.h"
+#include "utils/URIUtils.h"
+#include "GUIInfoManager.h"
+#include "guilib/GUIWindowManager.h"
+#include "Application.h"
+#include "ApplicationMessenger.h"
+#include "DVDPerformanceCounter.h"
+#include "filesystem/File.h"
+#include "pictures/Picture.h"
+#include "DllSwScale.h"
+#ifdef HAS_VIDEO_PLAYBACK
+#include "cores/VideoRenderers/RenderManager.h"
+#endif
+#ifdef HAS_PERFORMANCE_SAMPLE
+#include "xbmc/utils/PerformanceSample.h"
+#else
+#define MEASURE_FUNCTION
+#endif
+#include "settings/AdvancedSettings.h"
+#include "FileItem.h"
+#include "GUIUserMessages.h"
+#include "settings/Settings.h"
+#include "settings/MediaSettings.h"
+#include "utils/log.h"
+#include "utils/TimeUtils.h"
+#include "utils/StreamDetails.h"
#include "pvr/PVRManager.h"
#include "pvr/channels/PVRChannel.h"
#include "pvr/windows/GUIWindowPVR.h"
#include "pvr/addons/PVRClients.h"
#include "filesystem/PVRFile.h"
-
+#include "video/dialogs/GUIDialogFullScreenInfo.h"
+#include "utils/StreamUtils.h"
+#include "utils/Variant.h"
+#include "storage/MediaManager.h"
+#include "dialogs/GUIDialogBusy.h"
+#include "dialogs/GUIDialogKaiToast.h"
+#include "xbmc/playlists/PlayListM3U.h"
#include "utils/StringUtils.h"
+#include "Util.h"
+#include "LangInfo.h"
+#include "URL.h"
-using namespace XFILE;
+using namespace std;
using namespace PVR;
-// ****************************************************************
void COMXSelectionStreams::Clear(StreamType type, StreamSource source)
{
CSingleLock lock(m_section);
}
}
-// ****************************************************************
COMXPlayer::COMXPlayer(IPlayerCallback &callback)
: IPlayer(callback),
CThread("OMXPlayer"),
m_CurrentSubtitle(STREAM_SUBTITLE, DVDPLAYER_SUBTITLE),
m_CurrentTeletext(STREAM_TELETEXT, DVDPLAYER_TELETEXT),
m_messenger("player"),
- m_player_video(&m_av_clock, &m_overlayContainer, m_messenger),
- m_player_audio(&m_av_clock, m_messenger),
- m_player_subtitle(&m_overlayContainer),
- m_player_teletext(),
+ m_omxPlayerVideo(&m_av_clock, &m_overlayContainer, m_messenger),
+ m_omxPlayerAudio(&m_av_clock, m_messenger),
+ m_dvdPlayerSubtitle(&m_overlayContainer),
+ m_dvdPlayerTeletext(),
m_ready(true)
{
- m_bAbortRequest = false;
m_pDemuxer = NULL;
m_pSubtitleDemuxer = NULL;
m_pInputStream = NULL;
- m_UpdateApplication = 0;
- m_caching = CACHESTATE_DONE;
- m_playSpeed = DVD_PLAYSPEED_NORMAL;
- m_HasVideo = false;
- m_HasAudio = false;
m_dvd.Clear();
m_State.Clear();
m_EdlAutoSkipMarkers.Clear();
+ m_UpdateApplication = 0;
+
+ m_bAbortRequest = false;
+ m_errorCount = 0;
+ m_offset_pts = 0.0;
+ m_playSpeed = DVD_PLAYSPEED_NORMAL;
+ m_caching = CACHESTATE_DONE;
+ m_HasVideo = false;
+ m_HasAudio = false;
memset(&m_SpeedState, 0, sizeof(m_SpeedState));
+
+#ifdef DVDDEBUG_MESSAGE_TRACKER
+ g_dvdMessageTracker.Init();
+#endif
}
COMXPlayer::~COMXPlayer()
{
CloseFile();
- if(m_messenger.IsInited())
- m_messenger.End();
+#ifdef DVDDEBUG_MESSAGE_TRACKER
+ g_dvdMessageTracker.DeInit();
+#endif
}
bool COMXPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
if(IsRunning())
CloseFile();
- if(!m_av_clock.OMXInitialize(false, false))
+ if(!m_av_clock.OMXInitialize(&m_clock, false, false))
{
return false;
}
if(CSettings::Get().GetBool("videoplayer.adjustrefreshrate"))
m_av_clock.HDMIClockSync();
- m_playSpeed = DVD_PLAYSPEED_NORMAL;
- SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
+ m_bAbortRequest = false;
- m_PlayerOptions = options;
- m_bAbortRequest = false;
+ SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
+ m_State.Clear();
m_UpdateApplication = 0;
m_offset_pts = 0;
m_current_volume = 0;
m_current_mute = false;
m_change_volume = true;
+ m_PlayerOptions = options;
m_item = file;
m_mimetype = file.GetMimeType();
m_filename = file.GetPath();
- m_State.Clear();
-
m_ready.Reset();
+#if defined(HAS_VIDEO_PLAYBACK)
g_renderManager.PreInit();
+#endif
Create();
if(!m_ready.WaitMSec(100))
// we are done after the StopThread call
StopThread();
- CLog::Log(LOGDEBUG, "COMXPlayer: finished waiting");
-
m_Edl.Clear();
m_EdlAutoSkipMarkers.Clear();
m_HasVideo = false;
m_HasAudio = false;
+ CLog::Log(LOGNOTICE, "DVDPlayer: finished waiting");
+#if defined(HAS_VIDEO_PLAYBACK)
g_renderManager.UnInit();
+#endif
return true;
}
// before creating the input stream, if this is an HLS playlist then get the
// most appropriate bitrate based on our network settings
- if (filename.Left(7) == "http://" && filename.Right(5) == ".m3u8")
+ // ensure to strip off the url options by using a temp CURL object
+ if (filename.Left(7) == "http://" && CURL(filename).GetFileName().Right(5) == ".m3u8")
{
// get the available bandwidth (as per user settings)
int maxrate = CSettings::Get().GetInt("network.bandwidth");
for(unsigned int i=0;i<filenames.size();i++)
{
// if vobsub subtitle:
- if (URIUtils::GetExtension(filenames[i]) == ".idx")
+ if (URIUtils::HasExtension(filenames[i], ".idx"))
{
CStdString strSubFile;
if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
- m_av_clock.Reset();
+ m_clock.Reset();
m_dvd.Clear();
+ m_errorCount = 0;
m_iChannelEntryTimeOut = 0;
return true;
CloseAudioStream(true);
// enable subtitles
- m_player_video.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn);
+ m_omxPlayerVideo.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn);
// open subtitle stream
streams = m_SelectionStreams.Get(STREAM_SUBTITLE, PredicateSubtitlePriority);
{
valid = true;
if(it->flags & CDemuxStream::FLAG_FORCED)
- m_player_video.EnableSubtitle(true);
+ m_omxPlayerVideo.EnableSubtitle(true);
}
}
if(!valid)
{
// check if we should read from subtitle demuxer
- if(m_player_subtitle.AcceptsData() && m_pSubtitleDemuxer)
+ if(m_dvdPlayerSubtitle.AcceptsData() && m_pSubtitleDemuxer)
{
if(m_pSubtitleDemuxer)
packet = m_pSubtitleDemuxer->Read();
return;
}
- m_player_video.EnableFullscreen(true);
+ // allow renderer to switch to fullscreen if requested
+ m_omxPlayerVideo.EnableFullscreen(m_PlayerOptions.fullscreen);
OpenDefaultStreams();
if (!CachePVRStream())
SetCaching(CACHESTATE_FLUSH);
- /*
- if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
- {
- if (!WaitForPausedThumbJobs(20000))
- {
- CJobManager::GetInstance().UnPause(kJobTypeMediaFlags);
- CLog::Log(LOGINFO, "COMXPlayer::Process:thumbgen jobs still running !!!");
- }
- }
- */
-
while (!m_bAbortRequest)
{
#ifdef _DEBUG
if ((count++ & 15) == 0)
{
vc_gencmd(response, sizeof response, "render_bar 4 video_fifo %d %d %d %d",
- m_player_video.GetDecoderBufferSize()-m_player_video.GetDecoderFreeSpace(),
- 0 , 0, m_player_video.GetDecoderBufferSize());
+ m_omxPlayerVideo.GetDecoderBufferSize()-m_omxPlayerVideo.GetDecoderFreeSpace(),
+ 0 , 0, m_omxPlayerVideo.GetDecoderBufferSize());
vc_gencmd(response, sizeof response, "render_bar 5 audio_fifo %d %d %d %d",
- (int)(100.0*m_player_audio.GetDelay()), 0, 0, 100*AUDIO_BUFFER_SECONDS);
+ (int)(100.0*m_omxPlayerAudio.GetDelay()), 0, 0, 100*AUDIO_BUFFER_SECONDS);
vc_gencmd(response, sizeof response, "render_bar 6 video_queue %d %d %d %d",
- m_player_video.GetLevel(), 0, 0, 100);
+ m_omxPlayerVideo.GetLevel(), 0, 0, 100);
vc_gencmd(response, sizeof response, "render_bar 7 audio_queue %d %d %d %d",
- m_player_audio.GetLevel(), 0, 0, 100);
+ m_omxPlayerAudio.GetLevel(), 0, 0, 100);
}
#endif
// handle messages send to this thread, like seek or demuxer reset requests
OpenDefaultStreams();
// never allow first frames after open to be skipped
- if( m_player_video.IsInited() )
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+ if( m_omxPlayerVideo.IsInited() )
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
if (CachePVRStream())
SetCaching(CACHESTATE_PVR);
UpdateApplication(1000);
// OMX emergency exit
- if(HasAudio() && m_player_audio.BadState())
+ if(HasAudio() && m_omxPlayerAudio.BadState())
{
- CLog::Log(LOGERROR, "%s - Closing stream due to m_player_audio.BadState()", __FUNCTION__);
+ CLog::Log(LOGERROR, "%s - Closing stream due to m_omxPlayerAudio.BadState()", __FUNCTION__);
m_bAbortRequest = true;
break;
}
continue;
// if the queues are full, no need to read more
- if ((!m_player_audio.AcceptsData() && m_CurrentAudio.id >= 0)
- || (!m_player_video.AcceptsData() && m_CurrentVideo.id >= 0))
+ if ((!m_omxPlayerAudio.AcceptsData() && m_CurrentAudio.id >= 0) ||
+ (!m_omxPlayerVideo.AcceptsData() && m_CurrentVideo.id >= 0))
{
Sleep(10);
continue;
}
// always yield to players if they have data levels > 50 percent
- if((m_player_audio.GetLevel() > 50 || m_CurrentAudio.id < 0)
- && (m_player_video.GetLevel() > 50 || m_CurrentVideo.id < 0))
+ if((m_omxPlayerAudio.GetLevel() > 50 || m_CurrentAudio.id < 0)
+ && (m_omxPlayerVideo.GetLevel() > 50 || m_CurrentVideo.id < 0))
Sleep(0);
DemuxPacket* pPacket = NULL;
Sleep(100);
continue;
}
- else if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER))
- {
- CDVDInputStreamPVRManager* pStream = static_cast<CDVDInputStreamPVRManager*>(m_pInputStream);
- if (pStream->IsEOF())
- break;
-
- Sleep(100);
- continue;
- }
// make sure we tell all players to finish it's data
if (!bOmxSentEOFs)
{
if(m_CurrentAudio.inited)
{
- m_player_audio.SendMessage (new CDVDMsg(CDVDMsg::GENERAL_EOF));
+ m_omxPlayerAudio.SendMessage (new CDVDMsg(CDVDMsg::GENERAL_EOF));
bOmxWaitAudio = true;
}
if(m_CurrentVideo.inited)
{
- m_player_video.SendMessage (new CDVDMsg(CDVDMsg::GENERAL_EOF));
+ m_omxPlayerVideo.SendMessage (new CDVDMsg(CDVDMsg::GENERAL_EOF));
bOmxWaitVideo = true;
}
if(m_CurrentSubtitle.inited)
- m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+ m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
if(m_CurrentTeletext.inited)
- m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+ m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+ m_CurrentAudio.inited = false;
+ m_CurrentVideo.inited = false;
+ m_CurrentSubtitle.inited = false;
+ m_CurrentTeletext.inited = false;
bOmxSentEOFs = true;
}
SetCaching(CACHESTATE_DONE);
// while players are still playing, keep going to allow seekbacks
- if(m_player_video.HasData()
- || m_player_audio.HasData())
+ if(m_omxPlayerVideo.HasData()
+ || m_omxPlayerAudio.HasData())
{
Sleep(100);
continue;
}
// wait for omx components to finish
- if(bOmxWaitVideo && !m_player_video.IsEOS())
+ if(bOmxWaitVideo && !m_omxPlayerVideo.IsEOS())
{
Sleep(100);
continue;
}
- if(bOmxWaitAudio && !m_player_audio.IsEOS())
+ if(bOmxWaitAudio && !m_omxPlayerAudio.IsEOS())
{
Sleep(100);
continue;
if (!m_pInputStream->IsEOF())
CLog::Log(LOGINFO, "%s - eof reading from demuxer", __FUNCTION__);
- m_CurrentAudio.inited = false;
- m_CurrentVideo.inited = false;
- m_CurrentSubtitle.inited = false;
- m_CurrentTeletext.inited = false;
m_CurrentAudio.started = false;
m_CurrentVideo.started = false;
m_CurrentSubtitle.started = false;
break;
}
+ // it's a valid data packet, reset error counter
+ m_errorCount = 0;
+
// check so that none of our streams has become invalid
- if (!IsValidStream(m_CurrentAudio) && m_player_audio.IsStalled()) CloseAudioStream(true);
- if (!IsValidStream(m_CurrentVideo) && m_player_video.IsStalled()) CloseVideoStream(true);
- if (!IsValidStream(m_CurrentSubtitle) && m_player_subtitle.IsStalled()) CloseSubtitleStream(true);
+ if (!IsValidStream(m_CurrentAudio) && m_omxPlayerAudio.IsStalled()) CloseAudioStream(true);
+ if (!IsValidStream(m_CurrentVideo) && m_omxPlayerVideo.IsStalled()) CloseVideoStream(true);
+ if (!IsValidStream(m_CurrentSubtitle) && m_dvdPlayerSubtitle.IsStalled()) CloseSubtitleStream(true);
if (!IsValidStream(m_CurrentTeletext)) CloseTeletextStream(true);
// see if we can find something better to play
if(m_change_volume && m_CurrentAudio.started)
{
- m_player_audio.SetCurrentVolume(m_current_mute ? VOLUME_MINIMUM : m_current_volume);
+ m_omxPlayerAudio.SetCurrentVolume(m_current_mute ? VOLUME_MINIMUM : m_current_volume);
m_change_volume = false;
}
else if (m_Edl.InCut(DVD_TIME_TO_MSEC(m_CurrentAudio.dts + m_offset_pts), &cut) && cut.action == CEdl::MUTE // Inside EDL mute
&& !m_EdlAutoSkipMarkers.mute) // Mute not already triggered
{
- m_player_audio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, true));
+ m_omxPlayerAudio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, true));
m_EdlAutoSkipMarkers.mute = true;
}
else if (!m_Edl.InCut(DVD_TIME_TO_MSEC(m_CurrentAudio.dts + m_offset_pts), &cut) // Outside of any EDL
&& m_EdlAutoSkipMarkers.mute) // But the mute hasn't been removed yet
{
- m_player_audio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, false));
+ m_omxPlayerAudio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, false));
m_EdlAutoSkipMarkers.mute = false;
}
- m_player_audio.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+ m_omxPlayerAudio.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
}
void COMXPlayer::ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket)
if (CheckSceneSkip(m_CurrentVideo))
drop = true;
- m_player_video.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+ m_omxPlayerVideo.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
}
void COMXPlayer::ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket)
if (CheckSceneSkip(m_CurrentSubtitle))
drop = true;
- m_player_subtitle.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+ m_dvdPlayerSubtitle.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
if(m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
- m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
+ m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
}
void COMXPlayer::ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket)
if (CheckSceneSkip(m_CurrentTeletext))
drop = true;
- m_player_teletext.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+ m_dvdPlayerTeletext.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
}
bool COMXPlayer::GetCachingTimes(double& level, double& delay, double& offset)
if(GetCachingTimes(level, delay, offset))
{
if(level < 0.0)
+ {
+ CGUIDialogKaiToast::QueueNotification(g_localizeStrings.Get(21454), g_localizeStrings.Get(21455));
caching = CACHESTATE_INIT;
+ }
if(level >= 1.0)
caching = CACHESTATE_INIT;
}
else
{
- if ((!m_player_audio.AcceptsData() && m_CurrentAudio.id >= 0)
- || (!m_player_video.AcceptsData() && m_CurrentVideo.id >= 0))
+ if ((!m_omxPlayerAudio.AcceptsData() && m_CurrentAudio.id >= 0)
+ || (!m_omxPlayerVideo.AcceptsData() && m_CurrentVideo.id >= 0))
caching = CACHESTATE_INIT;
}
}
// handle situation that we get no data on one stream
if(m_CurrentAudio.id >= 0 && m_CurrentVideo.id >= 0)
{
- if ((!m_player_audio.AcceptsData() && !m_CurrentVideo.started)
- || (!m_player_video.AcceptsData() && !m_CurrentAudio.started))
+ if ((!m_omxPlayerAudio.AcceptsData() && !m_CurrentVideo.started)
+ || (!m_omxPlayerVideo.AcceptsData() && !m_CurrentAudio.started))
{
caching = CACHESTATE_DONE;
}
{
bool bGotAudio(m_pDemuxer->GetNrOfAudioStreams() > 0);
bool bGotVideo(m_pDemuxer->GetNrOfVideoStreams() > 0);
- bool bAudioLevelOk(m_player_audio.GetLevel() > g_advancedSettings.m_iPVRMinAudioCacheLevel);
- bool bVideoLevelOk(m_player_video.GetLevel() > g_advancedSettings.m_iPVRMinVideoCacheLevel);
- bool bAudioFull(!m_player_audio.AcceptsData());
- bool bVideoFull(!m_player_video.AcceptsData());
+ bool bAudioLevelOk(m_omxPlayerAudio.GetLevel() > g_advancedSettings.m_iPVRMinAudioCacheLevel);
+ bool bVideoLevelOk(m_omxPlayerVideo.GetLevel() > g_advancedSettings.m_iPVRMinVideoCacheLevel);
+ bool bAudioFull(!m_omxPlayerAudio.AcceptsData());
+ bool bVideoFull(!m_omxPlayerVideo.AcceptsData());
if (/* if all streams got at least g_advancedSettings.m_iPVRMinCacheLevel in their buffers, we're done */
((bGotVideo || bGotAudio) && (!bGotAudio || bAudioLevelOk) && (!bGotVideo || bVideoLevelOk)) ||
(bAudioFull || bVideoFull))
{
CLog::Log(LOGDEBUG, "set caching from pvr to done. audio (%d) = %d. video (%d) = %d",
- bGotAudio, m_player_audio.GetLevel(),
- bGotVideo, m_player_video.GetLevel());
+ bGotAudio, m_omxPlayerAudio.GetLevel(),
+ bGotVideo, m_omxPlayerVideo.GetLevel());
CFileItem currentItem(g_application.CurrentFileItem());
if (currentItem.HasPVRChannelInfoTag())
{
/* ensure that automatically started players are stopped while caching */
if (m_CurrentAudio.started)
- m_player_audio.SetSpeed(DVD_PLAYSPEED_PAUSE);
+ m_omxPlayerAudio.SetSpeed(DVD_PLAYSPEED_PAUSE);
if (m_CurrentVideo.started)
- m_player_video.SetSpeed(DVD_PLAYSPEED_PAUSE);
+ m_omxPlayerVideo.SetSpeed(DVD_PLAYSPEED_PAUSE);
}
}
if(caching == CACHESTATE_PLAY)
{
// if all enabled streams have started playing we are done
- if((m_CurrentVideo.id < 0 || !m_player_video.IsStalled())
- && (m_CurrentAudio.id < 0 || !m_player_audio.IsStalled()))
+ if((m_CurrentVideo.id < 0 || !m_omxPlayerVideo.IsStalled())
+ && (m_CurrentAudio.id < 0 || !m_omxPlayerAudio.IsStalled()))
caching = CACHESTATE_DONE;
}
}
else if (m_CurrentVideo.id >= 0
&& m_CurrentVideo.inited == true
- && m_SpeedState.lastpts != m_player_video.GetCurrentPTS()
+ && m_SpeedState.lastpts != m_omxPlayerVideo.GetCurrentPts()
&& m_SpeedState.lasttime != GetTime())
{
- m_SpeedState.lastpts = m_player_video.GetCurrentPTS();
+ m_SpeedState.lastpts = m_omxPlayerVideo.GetCurrentPts();
m_SpeedState.lasttime = GetTime();
// check how much off clock video is when ff/rw:ing
// a problem here is that seeking isn't very accurate
// when seeking, give the player a headstart to make sure
// the time it takes to seek doesn't make a difference.
double error;
- error = m_av_clock.GetClock() - m_SpeedState.lastpts;
+ error = m_clock.GetClock() - m_SpeedState.lastpts;
error *= m_playSpeed / abs(m_playSpeed);
if(error > DVD_MSEC_TO_TIME(1000))
{
CLog::Log(LOGDEBUG, "COMXPlayer::Process - Seeking to catch up");
- int64_t iTime = (int64_t)DVD_TIME_TO_MSEC(m_av_clock.GetClock() + m_State.time_offset + 500000.0 * m_playSpeed / DVD_PLAYSPEED_NORMAL);
+ int64_t iTime = (int64_t)DVD_TIME_TO_MSEC(m_clock.GetClock() + m_State.time_offset + 500000.0 * m_playSpeed / DVD_PLAYSPEED_NORMAL);
m_messenger.Put(new CDVDMsgPlayerSeek(iTime, (GetPlaySpeed() < 0), true, false, false, true));
}
}
if(IsInMenu())
return false;
- if((current.type == STREAM_AUDIO && m_player_audio.IsStalled())
- || (current.type == STREAM_VIDEO && m_player_video.IsStalled()))
+ if((current.type == STREAM_AUDIO && m_omxPlayerAudio.IsStalled())
+ || (current.type == STREAM_VIDEO && m_omxPlayerVideo.IsStalled()))
{
if (CachePVRStream())
{
- if ((current.type == STREAM_AUDIO && current.started && m_player_audio.GetLevel() == 0) ||
- (current.type == STREAM_VIDEO && current.started && m_player_video.GetLevel() == 0))
+ if ((current.type == STREAM_AUDIO && current.started && m_omxPlayerAudio.GetLevel() == 0) ||
+ (current.type == STREAM_VIDEO && current.started && m_omxPlayerVideo.GetLevel() == 0))
{
CLog::Log(LOGDEBUG, "%s stream stalled. start buffering", current.type == STREAM_AUDIO ? "audio" : "video");
SetCaching(CACHESTATE_PVR);
}
// don't start caching if it's only a single stream that has run dry
- if(m_player_audio.GetLevel() > 50
- || m_player_video.GetLevel() > 50)
+ if(m_omxPlayerAudio.GetLevel() > 50
+ || m_omxPlayerVideo.GetLevel() > 50)
return false;
if(current.inited)
}
}
-void COMXPlayer::UpdateLimits(double& minimum, double& maximum, double dts)
+static void UpdateLimits(double& minimum, double& maximum, double dts)
{
if(dts == DVD_NOPTS_VALUE)
return;
/*
* Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
*/
- m_messenger.Put(new CDVDMsgPlayerSeek((int)seek, true, true, true, false, true));
+ m_messenger.Put(new CDVDMsgPlayerSeek((int)seek, true, false, true, false, true));
/*
* Seek doesn't always work reliably. Last physical seek time is recorded to prevent looping
* if there was an error with seeking and it landed somewhere unexpected, perhaps back in the
/*
* Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
*/
- m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, true, true, false, true));
+ m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, false, true, false, true));
/*
* Each commercial break is only skipped once so poorly detected commercial breaks can be
* manually re-entered. Start and end are recorded to prevent looping and to allow seeking back
CDVDMsgGeneralSynchronize* message = new CDVDMsgGeneralSynchronize(timeout, sources);
if (m_CurrentAudio.id >= 0)
- m_player_audio.SendMessage(message->Acquire());
+ m_omxPlayerAudio.SendMessage(message->Acquire());
if (m_CurrentVideo.id >= 0)
- m_player_video.SendMessage(message->Acquire());
+ m_omxPlayerVideo.SendMessage(message->Acquire());
/* TODO - we have to rewrite the sync class, to not require
all other players waiting for subtitle, should only
be the oposite way
if (m_CurrentSubtitle.id >= 0)
- m_player_subtitle.SendMessage(message->Acquire());
+ m_dvdPlayerSubtitle.SendMessage(message->Acquire());
*/
message->Release();
}
void COMXPlayer::SendPlayerMessage(CDVDMsg* pMsg, unsigned int target)
{
if(target == DVDPLAYER_AUDIO)
- m_player_audio.SendMessage(pMsg);
+ m_omxPlayerAudio.SendMessage(pMsg);
if(target == DVDPLAYER_VIDEO)
- m_player_video.SendMessage(pMsg);
+ m_omxPlayerVideo.SendMessage(pMsg);
if(target == DVDPLAYER_SUBTITLE)
- m_player_subtitle.SendMessage(pMsg);
+ m_dvdPlayerSubtitle.SendMessage(pMsg);
if(target == DVDPLAYER_TELETEXT)
- m_player_teletext.SendMessage(pMsg);
+ m_dvdPlayerTeletext.SendMessage(pMsg);
}
void COMXPlayer::OnExit()
// clean up all selection streams
m_SelectionStreams.Clear(STREAM_NONE, STREAM_SOURCE_NONE);
- m_messenger.Flush();
+ m_messenger.End();
m_av_clock.OMXDeinitialize();
{
CDVDMsgBool* pValue = (CDVDMsgBool*)pMsg;
- m_player_video.EnableSubtitle(pValue->m_value);
+ m_omxPlayerVideo.EnableSubtitle(pValue->m_value);
if (m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
static_cast<CDVDInputStreamNavigator*>(m_pInputStream)->EnableSubtitleStream(pValue->m_value);
if(m_State.timestamp > 0)
{
double offset;
- offset = m_av_clock.GetAbsoluteClock() - m_State.timestamp;
+ offset = m_clock.GetAbsoluteClock() - m_State.timestamp;
offset *= m_playSpeed / DVD_PLAYSPEED_NORMAL;
if(offset > 1000) offset = 1000;
if(offset < -1000) offset = -1000;
m_State.time += DVD_TIME_TO_MSEC(offset);
- m_State.timestamp = m_av_clock.GetAbsoluteClock();
+ m_State.timestamp = m_clock.GetAbsoluteClock();
}
if (speed != DVD_PLAYSPEED_PAUSE && m_playSpeed != DVD_PLAYSPEED_PAUSE && speed != m_playSpeed)
// 2. skip frames and adjust their pts or the clock
m_playSpeed = speed;
m_caching = CACHESTATE_DONE;
- m_av_clock.SetSpeed(speed);
+ m_clock.SetSpeed(speed);
m_av_clock.OMXSetSpeed(speed);
- m_player_audio.SetSpeed(speed);
- m_player_video.SetSpeed(speed);
+ m_omxPlayerAudio.SetSpeed(speed);
+ m_omxPlayerVideo.SetSpeed(speed);
// TODO - we really shouldn't pause demuxer
// until our buffers are somewhat filled
CSingleLock lock(m_StateSection);
/* prioritize data from video player, but only accept data *
* after it has been started to avoid race conditions after seeks */
- if(m_CurrentVideo.started && !m_player_video.SubmittedEOS())
+ if(m_CurrentVideo.started && !m_omxPlayerVideo.SubmittedEOS())
{
if(state.player == DVDPLAYER_VIDEO)
m_State = state;
|| state == CACHESTATE_INIT
|| state == CACHESTATE_PVR)
{
- m_av_clock.SetSpeed(DVD_PLAYSPEED_PAUSE);
+ m_clock.SetSpeed(DVD_PLAYSPEED_PAUSE);
m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_PAUSE);
- m_player_audio.SetSpeed(DVD_PLAYSPEED_PAUSE);
- m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
- m_player_video.SetSpeed(DVD_PLAYSPEED_PAUSE);
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+ m_omxPlayerAudio.SetSpeed(DVD_PLAYSPEED_PAUSE);
+ m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+ m_omxPlayerVideo.SetSpeed(DVD_PLAYSPEED_PAUSE);
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
if (state == CACHESTATE_PVR)
m_pInputStream->ResetScanTimeout((unsigned int) CSettings::Get().GetInt("pvrplayback.scantime") * 1000);
if(state == CACHESTATE_PLAY
||(state == CACHESTATE_DONE && m_caching != CACHESTATE_PLAY))
{
- m_av_clock.SetSpeed(m_playSpeed);
+ m_clock.SetSpeed(m_playSpeed);
m_av_clock.OMXSetSpeed(m_playSpeed);
- m_player_audio.SetSpeed(m_playSpeed);
- m_player_video.SetSpeed(m_playSpeed);
+ m_omxPlayerAudio.SetSpeed(m_playSpeed);
+ m_omxPlayerVideo.SetSpeed(m_playSpeed);
+ m_pInputStream->ResetScanTimeout(0);
}
m_caching = state;
}
return;
m_messenger.Put(new CDVDMsgInt(CDVDMsg::PLAYER_SETSPEED, speed));
+ m_omxPlayerAudio.SetSpeed(speed);
+ m_omxPlayerVideo.SetSpeed(speed);
SynchronizeDemuxer(100);
}
bool COMXPlayer::IsPassthrough() const
{
- return m_player_audio.Passthrough();
+ return m_omxPlayerAudio.Passthrough();
}
bool COMXPlayer::CanSeek()
void COMXPlayer::Seek(bool bPlus, bool bLargeStep)
{
+#if 0
+ // sadly this doesn't work for now, audio player must
+ // drop packets at the same rate as we play frames
+ if( m_playSpeed == DVD_PLAYSPEED_PAUSE && bPlus && !bLargeStep)
+ {
+ m_omxPlayerVideo.StepFrame();
+ return;
+ }
+#endif
if (!m_State.canseek)
return;
* Alter the standard seek position based on whether any commercial breaks have been
* automatically skipped.
*/
- const int clock = DVD_TIME_TO_MSEC(m_av_clock.GetClock());
+ const int clock = DVD_TIME_TO_MSEC(m_clock.GetClock());
/*
* If a large backwards seek occurs within 10 seconds of the end of the last automated
* commercial skip, then seek back to the start of the commercial break under the assumption
{ CSingleLock lock(m_StateSection);
strAudioInfo.Format("D(%s)", m_StateInput.demux_audio.c_str());
}
- strAudioInfo.AppendFormat("\nP(%s)", m_player_audio.GetPlayerInfo().c_str());
+ strAudioInfo.AppendFormat("\nP(%s)", m_omxPlayerAudio.GetPlayerInfo().c_str());
}
void COMXPlayer::GetVideoInfo(CStdString &strVideoInfo)
{ CSingleLock lock(m_StateSection);
strVideoInfo.Format("D(%s)", m_StateInput.demux_video.c_str());
}
- strVideoInfo.AppendFormat("\nP(%s)", m_player_video.GetPlayerInfo().c_str());
+ strVideoInfo.AppendFormat("\nP(%s)", m_omxPlayerVideo.GetPlayerInfo().c_str());
}
void COMXPlayer::GetGeneralInfo(CStdString& strGeneralInfo)
{
if (!m_bStop)
{
- double dDelay = m_player_video.GetDelay() / DVD_TIME_BASE - g_renderManager.GetDisplayLatency();
+ double dDelay = m_omxPlayerVideo.GetDelay() / DVD_TIME_BASE - g_renderManager.GetDisplayLatency();
- double apts = m_player_audio.GetCurrentPTS();
- double vpts = m_player_video.GetCurrentPTS();
+ double apts = m_omxPlayerAudio.GetCurrentPts();
+ double vpts = m_omxPlayerVideo.GetCurrentPts();
double dDiff = 0;
if( apts != DVD_NOPTS_VALUE && vpts != DVD_NOPTS_VALUE )
, dDiff
, strEDL.c_str()
, (int)(CThread::GetRelativeUsage()*100)
- , (int)(m_player_audio.GetRelativeUsage()*100)
- , (int)(m_player_video.GetRelativeUsage()*100)
+ , (int)(m_omxPlayerAudio.GetRelativeUsage()*100)
+ , (int)(m_omxPlayerVideo.GetRelativeUsage()*100)
, strBuf.c_str()
- , m_player_video.GetFreeSpace()
- , m_player_audio.GetDelay());
+ , m_omxPlayerVideo.GetFreeSpace()
+ , m_omxPlayerAudio.GetDelay());
}
}
-void COMXPlayer::SeekPercentage(float fPercent)
+void COMXPlayer::SeekPercentage(float iPercent)
{
int64_t iTotalTime = GetTotalTimeInMsec();
if (!iTotalTime)
return;
- SeekTime((int64_t)(iTotalTime * fPercent / 100));
+ SeekTime((int64_t)(iTotalTime * iPercent / 100));
}
float COMXPlayer::GetPercentage()
void COMXPlayer::SetAVDelay(float fValue)
{
- m_player_video.SetDelay(fValue * DVD_TIME_BASE);
+ m_omxPlayerVideo.SetDelay(fValue * DVD_TIME_BASE);
}
float COMXPlayer::GetAVDelay()
{
- return m_player_video.GetDelay() / (float)DVD_TIME_BASE;
+ return m_omxPlayerVideo.GetDelay() / (float)DVD_TIME_BASE;
}
void COMXPlayer::SetSubTitleDelay(float fValue)
{
- m_player_video.SetSubtitleDelay(-fValue * DVD_TIME_BASE);
+ m_omxPlayerVideo.SetSubtitleDelay(-fValue * DVD_TIME_BASE);
}
float COMXPlayer::GetSubTitleDelay()
{
- return -m_player_video.GetSubtitleDelay() / DVD_TIME_BASE;
+ return -m_omxPlayerVideo.GetSubtitleDelay() / DVD_TIME_BASE;
}
// priority: 1: libdvdnav, 2: external subtitles, 3: muxed subtitles
return pStream->IsSubtitleStreamEnabled();
}
- return m_player_video.IsSubtitleEnabled();
+ return m_omxPlayerVideo.IsSubtitleEnabled();
}
void COMXPlayer::SetSubtitleVisible(bool bVisible)
if (m_CurrentTeletext.id < 0)
return 0;
- return m_player_teletext.GetTeletextCache();
+ return m_dvdPlayerTeletext.GetTeletextCache();
}
void COMXPlayer::LoadPage(int p, int sp, unsigned char* buffer)
if (m_CurrentTeletext.id < 0)
return;
- return m_player_teletext.LoadPage(p, sp, buffer);
+ return m_dvdPlayerTeletext.LoadPage(p, sp, buffer);
}
void COMXPlayer::SeekTime(int64_t iTime)
const double limit = DVD_MSEC_TO_TIME(200);
if(m_State.timestamp > 0)
{
- offset = m_av_clock.GetAbsoluteClock() - m_State.timestamp;
+ offset = m_clock.GetAbsoluteClock() - m_State.timestamp;
offset *= m_playSpeed / DVD_PLAYSPEED_NORMAL;
if(offset > limit) offset = limit;
if(offset < -limit) offset = -limit;
if(m_CurrentAudio.id < 0
|| m_CurrentAudio.hint != hint)
{
- if(!m_player_audio.OpenStream(hint))
+ if(!m_omxPlayerAudio.OpenStream(hint))
{
/* mark stream as disabled, to disallaw further attempts*/
CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
pStream->SetDiscard(AVDISCARD_ALL);
return false;
}
- m_av_clock.SetSpeed(DVD_PLAYSPEED_NORMAL);
- m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_NORMAL);
}
else if (reset)
- m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
/* store information about stream */
m_CurrentAudio.id = iStream;
m_CurrentAudio.hint = hint;
m_CurrentAudio.stream = (void*)pStream;
m_CurrentAudio.started = false;
+ m_clock.SetMasterClock(false);
m_HasAudio = true;
/* we are potentially going to be waiting on this */
- m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+ m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
/* software decoding normaly consumes full cpu time so prio it */
- m_player_audio.SetPriority(GetPriority()+1);
+ m_omxPlayerAudio.SetPriority(GetPriority()+1);
return true;
}
if(m_CurrentVideo.id < 0
|| m_CurrentVideo.hint != hint)
{
- if (!m_player_video.OpenStream(hint))
+ // for music file, don't open artwork as video
+ bool disabled = false;
+ CStdString extension = URIUtils::GetExtension(m_filename);
+ if (!extension.IsEmpty() && g_advancedSettings.m_musicExtensions.Find(extension.ToLower()) != -1)
+ {
+ CLog::Log(LOGWARNING, "%s - Ignoring video in audio filetype:%s", __FUNCTION__, m_filename.c_str());
+ disabled = true;
+ }
+
+ if (disabled || !m_omxPlayerVideo.OpenStream(hint))
{
/* mark stream as disabled, to disallaw further attempts */
CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
pStream->SetDiscard(AVDISCARD_ALL);
return false;
}
- m_av_clock.SetSpeed(DVD_PLAYSPEED_NORMAL);
- m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_NORMAL);
}
else if (reset)
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
unsigned flags = 0;
if(m_filename.find("3DSBS") != string::npos || m_filename.find("HSBS") != string::npos)
flags = CONF_FLAGS_FORMAT_SBS;
else if(m_filename.find("3DTAB") != string::npos || m_filename.find("HTAB") != string::npos)
flags = CONF_FLAGS_FORMAT_TB;
- m_player_video.SetFlags(flags);
+ m_omxPlayerVideo.SetFlags(flags);
/* store information about stream */
m_CurrentVideo.id = iStream;
m_HasVideo = true;
/* we are potentially going to be waiting on this */
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
/* use same priority for video thread as demuxing thread, as */
/* otherwise demuxer will starve if video consumes the full cpu */
- m_player_video.SetPriority(GetPriority());
+ m_omxPlayerVideo.SetPriority(GetPriority());
return true;
}
if(!pStream || pStream->disabled)
return false;
pStream->SetDiscard(AVDISCARD_NONE);
- double pts = m_player_video.GetCurrentPTS();
+ double pts = m_omxPlayerVideo.GetCurrentPts();
if(pts == DVD_NOPTS_VALUE)
pts = m_CurrentVideo.dts;
if(pts == DVD_NOPTS_VALUE)
CloseSubtitleStream(false);
}
- if(!m_player_subtitle.OpenStream(hint, filename))
+ if(!m_dvdPlayerSubtitle.OpenStream(hint, filename))
{
CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
if(pStream)
}
}
else
- m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
m_CurrentSubtitle.id = iStream;
m_CurrentSubtitle.source = source;
CDVDStreamInfo hint(*pStream, true);
- if (!m_player_teletext.CheckStream(hint))
+ if (!m_dvdPlayerTeletext.CheckStream(hint))
return false;
CLog::Log(LOGNOTICE, "Opening teletext stream: %i source: %i", iStream, source);
CloseTeletextStream(true);
}
- if (!m_player_teletext.OpenStream(hint))
+ if (!m_dvdPlayerTeletext.OpenStream(hint))
{
/* mark stream as disabled, to disallaw further attempts*/
CLog::Log(LOGWARNING, "%s - Unsupported teletext stream %d. Stream disabled.", __FUNCTION__, iStream);
}
}
else
- m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
/* store information about stream */
m_CurrentTeletext.id = iStream;
if(bWaitForBuffers)
SetCaching(CACHESTATE_DONE);
- m_player_audio.CloseStream(bWaitForBuffers);
+ m_omxPlayerAudio.CloseStream(bWaitForBuffers);
m_CurrentAudio.Clear();
return true;
if(bWaitForBuffers)
SetCaching(CACHESTATE_DONE);
- m_player_video.CloseStream(bWaitForBuffers);
+ m_omxPlayerVideo.CloseStream(bWaitForBuffers);
m_CurrentVideo.Clear();
return true;
CLog::Log(LOGNOTICE, "Closing subtitle stream");
- m_player_subtitle.CloseStream(!bKeepOverlays);
+ m_dvdPlayerSubtitle.CloseStream(!bKeepOverlays);
m_CurrentSubtitle.Clear();
return true;
if(bWaitForBuffers)
SetCaching(CACHESTATE_DONE);
- m_player_teletext.CloseStream(bWaitForBuffers);
+ m_dvdPlayerTeletext.CloseStream(bWaitForBuffers);
m_CurrentTeletext.Clear();
return true;
if(queued)
{
- m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
- m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
- m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+ m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+ m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
SynchronizePlayers(SYNCSOURCE_ALL);
}
else
{
- m_player_video.Flush();
- m_player_audio.Flush();
- m_player_subtitle.Flush();
- m_player_teletext.Flush();
+ m_omxPlayerAudio.Flush();
+ m_omxPlayerVideo.Flush();
+ m_dvdPlayerSubtitle.Flush();
+ m_dvdPlayerTeletext.Flush();
// clear subtitle and menu overlays
m_overlayContainer.Clear();
{
// make sure players are properly flushed, should put them in stalled state
CDVDMsgGeneralSynchronize* msg = new CDVDMsgGeneralSynchronize(1000, 0);
- m_player_video.SendMessage(msg->Acquire(), 1);
- m_player_audio.SendMessage(msg->Acquire(), 1);
+ m_omxPlayerAudio.SendMessage(msg->Acquire(), 1);
+ m_omxPlayerVideo.SendMessage(msg->Acquire(), 1);
msg->Wait(&m_bStop, 0);
msg->Release();
}
if(pts != DVD_NOPTS_VALUE)
- m_av_clock.Discontinuity(pts);
+ m_clock.Discontinuity(pts);
UpdatePlayState(0);
// update state, buffers are flushed and it may take some time until
else if(iMessage == 3)
m_dvd.iSelectedSPUStream = *(int*)pData;
else if(iMessage == 4)
- m_player_video.EnableSubtitle(*(int*)pData ? true: false);
+ m_omxPlayerVideo.EnableSubtitle(*(int*)pData ? true: false);
else if(iMessage == 5)
{
if (m_dvd.state != DVDSTATE_STILL)
unsigned int time = 0;
if( m_CurrentVideo.stream && m_dvd.iDVDStillTime > 0 )
{
- time = (unsigned int)(m_player_video.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
+ time = (unsigned int)(m_omxPlayerVideo.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
if( time < 10000 && time > 0 )
m_dvd.iDVDStillTime += time;
}
DWORD time = 0;
if( m_CurrentVideo.stream && m_dvd.iDVDStillTime > 0 )
{
- time = (DWORD)(m_player_video.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
+ time = (DWORD)(m_omxPlayerVideo.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
if( time < 10000 && time > 0 )
m_dvd.iDVDStillTime += time;
}
break;
case DVDNAV_SPU_CLUT_CHANGE:
{
- m_player_subtitle.SendMessage(new CDVDMsgSubtitleClutChange((BYTE*)pData));
+ m_dvdPlayerSubtitle.SendMessage(new CDVDMsgSubtitleClutChange((BYTE*)pData));
}
break;
case DVDNAV_SPU_STREAM_CHANGE:
int iStream = event->physical_wide;
bool visible = !(iStream & 0x80);
- m_player_video.EnableSubtitle(visible);
+ m_omxPlayerVideo.EnableSubtitle(visible);
if (iStream >= 0)
m_dvd.iSelectedSPUStream = (iStream & ~0x80);
//dvdnav_highlight_event_t* pInfo = (dvdnav_highlight_event_t*)pData;
int iButton = pStream->GetCurrentButton();
CLog::Log(LOGDEBUG, "DVDNAV_HIGHLIGHT: Highlight button %d\n", iButton);
- m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
+ m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
}
break;
case DVDNAV_VTS_CHANGE:
//Force an aspect ratio that is set in the dvdheaders if available
m_CurrentVideo.hint.aspect = pStream->GetVideoAspectRatio();
- if( m_player_video.IsInited() )
- m_player_video.SendMessage(new CDVDMsgDouble(CDVDMsg::VIDEO_SET_ASPECT, m_CurrentVideo.hint.aspect));
+ if( m_omxPlayerVideo.IsInited() )
+ m_omxPlayerVideo.SendMessage(new CDVDMsgDouble(CDVDMsg::VIDEO_SET_ASPECT, m_CurrentVideo.hint.aspect));
m_SelectionStreams.Clear(STREAM_NONE, STREAM_SOURCE_NAV);
m_SelectionStreams.Update(m_pInputStream, m_pDemuxer);
m_dvd.state = DVDSTATE_NORMAL;
- if( m_player_video.IsInited() )
- m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+ if( m_omxPlayerVideo.IsInited() )
+ m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
}
break;
case DVDNAV_NAV_PACKET:
CLog::Log(LOGDEBUG, " - button select");
// show button pushed overlay
if(m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
- m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_CLICKED);
+ m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_CLICKED);
pMenus->ActivateButton();
}
}
}
- switch (action.GetID())
- {
- case ACTION_NEXT_ITEM:
- if(GetChapterCount() > 0)
- {
- m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()+1));
- g_infoManager.SetDisplayAfterSeek();
- return true;
- }
- else
- break;
- case ACTION_PREV_ITEM:
- if(GetChapterCount() > 0)
- {
- m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()-1));
- g_infoManager.SetDisplayAfterSeek();
- return true;
- }
- else
- break;
- }
-
// return false to inform the caller we didn't handle the message
return false;
}
bool COMXPlayer::GetCurrentSubtitle(CStdString& strSubtitle)
{
+ double pts = m_av_clock.OMXMediaTime(false);
+
if (m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
return false;
- double pts = m_av_clock.OMXMediaTime(false);
-
- m_player_subtitle.GetCurrentSubtitle(strSubtitle, pts - m_player_video.GetSubtitleDelay());
+ m_dvdPlayerSubtitle.GetCurrentSubtitle(strSubtitle, pts - m_omxPlayerVideo.GetSubtitleDelay());
// In case we stalled, don't output any subs
- if ((m_player_video.IsStalled() && HasVideo()) || (m_player_audio.IsStalled() && HasAudio()))
+ if ((m_omxPlayerVideo.IsStalled() && HasVideo()) || (m_omxPlayerAudio.IsStalled() && HasAudio()))
strSubtitle = m_lastSub;
else
m_lastSub = strSubtitle;
double COMXPlayer::GetQueueTime()
{
- int a = m_player_video.GetLevel();
- int v = m_player_audio.GetLevel();
+ int a = m_omxPlayerVideo.GetLevel();
+ int v = m_omxPlayerAudio.GetLevel();
return max(a, v) * 8000.0 / 100;
}
void COMXPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
{
- info.bitrate = m_player_video.GetVideoBitrate();
+ info.bitrate = m_omxPlayerVideo.GetVideoBitrate();
CStdString retVal;
if (m_pDemuxer && (m_CurrentVideo.id != -1))
return;
if (index == GetAudioStream())
- info.bitrate = m_player_audio.GetAudioBitrate();
+ info.bitrate = m_omxPlayerAudio.GetAudioBitrate();
else
info.bitrate = m_pDemuxer->GetStreamFromAudioId(index)->iBitRate;
void COMXPlayer::UpdatePlayState(double timeout)
{
if(m_StateInput.timestamp != 0
- && m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > m_av_clock.GetAbsoluteClock())
+ && m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > m_clock.GetAbsoluteClock())
return;
SPlayerState state(m_StateInput);
if(state.dts == DVD_NOPTS_VALUE)
state.time = 0;
else
- // TODO : workaround until omx clock handling is rewritten
- if(m_playSpeed == DVD_PLAYSPEED_NORMAL)
- state.time = DVD_TIME_TO_MSEC(m_av_clock.OMXMediaTime(true));
- else
- state.time = DVD_TIME_TO_MSEC(state.dts + m_offset_pts);
+ state.time = DVD_TIME_TO_MSEC(state.dts + m_offset_pts);
state.time_total = m_pDemuxer->GetStreamLength();
state.time_src = ETIMESOURCE_CLOCK;
}
else
state.cache_bytes = 0;
- state.timestamp = m_av_clock.GetAbsoluteClock();
+ state.timestamp = m_clock.GetAbsoluteClock();
//{CLog::Log(LOGINFO, "%s: time:%.2f stamp:%.2f dts:%d m:%d (p:%d,c:%d) =%llu", __func__, (double)state.time, (double)state.timestamp, (int)DVD_TIME_TO_MSEC(state.dts + m_offset_pts), (int)DVD_TIME_TO_MSEC(m_av_clock.OMXMediaTime()), (int)m_playSpeed, (int)m_caching, llrint(state.time + DVD_TIME_TO_MSEC(offset)));}
CSingleLock lock(m_StateSection);
void COMXPlayer::UpdateApplication(double timeout)
{
if(m_UpdateApplication != 0
- && m_UpdateApplication + DVD_MSEC_TO_TIME(timeout) > m_av_clock.GetAbsoluteClock())
+ && m_UpdateApplication + DVD_MSEC_TO_TIME(timeout) > m_clock.GetAbsoluteClock())
return;
CDVDInputStream::IChannel* pStream = dynamic_cast<CDVDInputStream::IChannel*>(m_pInputStream);
CApplicationMessenger::Get().SetCurrentItem(item);
}
}
- m_UpdateApplication = m_av_clock.GetAbsoluteClock();
+ m_UpdateApplication = m_clock.GetAbsoluteClock();
}
bool COMXPlayer::CanRecord()
* and UpdatePlayState() has been called at least once. In this case dvdplayer duration/AR will
* return 0 and we'll have to fallback to the (less accurate) info from the demuxer.
*/
- float aspect = m_player_video.GetAspectRatio();
+ float aspect = m_omxPlayerVideo.GetAspectRatio();
if (aspect > 0.0f)
((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect = aspect;
CStdString COMXPlayer::GetPlayingTitle()
{
/* Currently we support only Title Name from Teletext line 30 */
- TextCacheStruct_t* ttcache = m_player_teletext.GetTeletextCache();
+ TextCacheStruct_t* ttcache = m_dvdPlayerTeletext.GetTeletextCache();
if (ttcache && !ttcache->line30.empty())
return ttcache->line30;
m_change_volume = true;
}
-bool COMXPlayer::WaitForPausedThumbJobs(int timeout_ms)
-{
- // use m_bStop and Sleep so we can get canceled.
- while (!m_bStop && (timeout_ms > 0))
- {
- if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
- {
- Sleep(100);
- timeout_ms -= 100;
- }
- else
- return true;
- }
-
- return false;
-}
-
void COMXPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
{
renderFeatures.push_back(RENDERFEATURE_STRETCH);
*
*/
-#if defined(HAVE_CONFIG_H) && !defined(TARGET_WINDOWS)
-#include "config.h"
-#define DECLARE_UNUSED(a,b) a __attribute__((unused)) b;
-#endif
-
-#include <semaphore.h>
-#include <deque>
-
-#include "FileItem.h"
#include "cores/IPlayer.h"
-#include "cores/dvdplayer/IDVDPlayer.h"
-#include "dialogs/GUIDialogBusy.h"
#include "threads/Thread.h"
-#include "threads/SingleLock.h"
+#include "cores/dvdplayer/IDVDPlayer.h"
+
+#include "DVDMessageQueue.h"
#include "OMXCore.h"
#include "OMXClock.h"
#include "OMXPlayerAudio.h"
#include "DVDPlayerSubtitle.h"
#include "DVDPlayerTeletext.h"
+//#include "DVDChapterReader.h"
+#include "DVDSubtitles/DVDFactorySubtitle.h"
#include "utils/BitstreamStats.h"
#include "linux/DllBCM.h"
#include "Edl.h"
-
-#define MAX_CHAPTERS 64
-
-#define DVDPLAYER_AUDIO 1
-#define DVDPLAYER_VIDEO 2
-#define DVDPLAYER_SUBTITLE 3
-#define DVDPLAYER_TELETEXT 4
-
-#define DVDSTATE_NORMAL 0x00000001 // normal dvd state
-#define DVDSTATE_STILL 0x00000002 // currently displaying a still frame
-#define DVDSTATE_WAIT 0x00000003 // waiting for demuxer read error
-#define DVDSTATE_SEEK 0x00000004 // we are finishing a seek request
+#include "FileItem.h"
+#include "threads/SingleLock.h"
class COMXPlayer;
class OMXPlayerVideo;
class CPVRChannel;
}
+#define DVDSTATE_NORMAL 0x00000001 // normal dvd state
+#define DVDSTATE_STILL 0x00000002 // currently displaying a still frame
+#define DVDSTATE_WAIT 0x00000003 // waiting for demuxer read error
+#define DVDSTATE_SEEK 0x00000004 // we are finishing a seek request
+
class COMXCurrentStream
{
public:
};
+#define DVDPLAYER_AUDIO 1
+#define DVDPLAYER_VIDEO 2
+#define DVDPLAYER_SUBTITLE 3
+#define DVDPLAYER_TELETEXT 4
+
class COMXPlayer : public IPlayer, public CThread, public IDVDPlayer
{
public:
COMXPlayer(IPlayerCallback &callback);
virtual ~COMXPlayer();
- virtual void RegisterAudioCallback(IAudioCallback* pCallback) { m_player_audio.RegisterAudioCallback(pCallback); };
- virtual void UnRegisterAudioCallback() { m_player_audio.UnRegisterAudioCallback(); };
-
- virtual bool IsValidStream(COMXCurrentStream& stream);
- virtual bool IsBetterStream(COMXCurrentStream& current, CDemuxStream* stream);
- virtual bool CheckDelayedChannelEntry(void);
- virtual bool ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream);
- virtual bool CloseAudioStream(bool bWaitForBuffers);
- virtual bool CloseVideoStream(bool bWaitForBuffers);
- virtual bool CloseSubtitleStream(bool bKeepOverlays);
- virtual bool CloseTeletextStream(bool bWaitForBuffers);
- virtual bool OpenAudioStream(int iStream, int source, bool reset = true);
- virtual bool OpenVideoStream(int iStream, int source, bool reset = true);
- virtual bool OpenSubtitleStream(int iStream, int source);
- virtual bool OpenTeletextStream(int iStream, int source);
- virtual void OpenDefaultStreams(bool reset = true);
- virtual bool OpenDemuxStream();
- virtual bool OpenInputStream();
- virtual bool CheckPlayerInit(COMXCurrentStream& current, unsigned int source);
- virtual void UpdateCorrection(DemuxPacket* pkt, double correction);
- virtual void UpdateTimestamps(COMXCurrentStream& current, DemuxPacket* pPacket);
- virtual void UpdateLimits(double& minimum, double& maximum, double dts);
- virtual bool CheckSceneSkip(COMXCurrentStream& current);
- virtual void CheckAutoSceneSkip();
- virtual void CheckContinuity(COMXCurrentStream& current, DemuxPacket* pPacket);
- virtual void ProcessAudioData(CDemuxStream* pStream, DemuxPacket* pPacket);
- virtual void ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket);
- virtual void ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket);
- virtual void ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket);
- virtual void ProcessPacket(CDemuxStream* pStream, DemuxPacket* pPacket);
- virtual void SynchronizeDemuxer(unsigned int timeout);
- virtual void SynchronizePlayers(unsigned int sources);
- virtual void SendPlayerMessage(CDVDMsg* pMsg, unsigned int target);
- virtual void HandleMessages();
-
virtual bool OpenFile(const CFileItem &file, const CPlayerOptions &options);
- virtual bool QueueNextFile(const CFileItem &file) {return false;}
- virtual void OnNothingToQueueNotify() {}
virtual bool CloseFile();
virtual bool IsPlaying() const;
- virtual void SetPlaySpeed(int speed);
- int GetPlaySpeed() { return m_playSpeed; }
virtual void Pause();
virtual bool IsPaused() const;
virtual bool HasVideo() const;
virtual bool HasAudio() const;
virtual bool IsPassthrough() const;
virtual bool CanSeek();
- virtual void Seek(bool bPlus = true, bool bLargeStep = false);
+ virtual void Seek(bool bPlus, bool bLargeStep);
virtual bool SeekScene(bool bPlus = true);
- virtual void SeekPercentage(float fPercent = 0.0f);
+ virtual void SeekPercentage(float iPercent);
virtual float GetPercentage();
virtual float GetCachePercentage();
- virtual void SetMute(bool bOnOff);
- virtual void SetVolume(float fVolume);
- virtual bool ControlsVolume() {return true;}
- virtual void SetDynamicRangeCompression(long drc) {}
- virtual void GetAudioInfo(CStdString &strAudioInfo);
- virtual void GetVideoInfo(CStdString &strVideoInfo);
- virtual void GetGeneralInfo(CStdString &strVideoInfo);
- virtual void UpdateApplication(double timeout);
- virtual bool CanRecord();
- virtual bool IsRecording();
- virtual bool CanPause();
- virtual bool Record(bool bOnOff);
- virtual void SetAVDelay(float fValue = 0.0f);
+ virtual void RegisterAudioCallback(IAudioCallback* pCallback) { m_omxPlayerAudio.RegisterAudioCallback(pCallback); }
+ virtual void UnRegisterAudioCallback() { m_omxPlayerAudio.UnRegisterAudioCallback(); }
+ virtual void SetVolume(float nVolume);
+ virtual void SetMute(bool bOnOff);
+ virtual bool ControlsVolume() {return true;}
+ virtual void SetDynamicRangeCompression(long drc) {}
+ virtual void GetAudioInfo(CStdString &strAudioInfo);
+ virtual void GetVideoInfo(CStdString &strVideoInfo);
+ virtual void GetGeneralInfo(CStdString &strVideoInfo);
+ virtual bool CanRecord();
+ virtual bool IsRecording();
+ virtual bool CanPause();
+ virtual bool Record(bool bOnOff);
+ virtual void SetAVDelay(float fValue = 0.0f);
virtual float GetAVDelay();
virtual void SetSubTitleDelay(float fValue = 0.0f);
virtual void GetChapterName(CStdString& strChapterName);
virtual int SeekChapter(int iChapter);
- virtual void SeekTime(int64_t iTime = 0);
- virtual int64_t GetTotalTimeInMsec();
+ virtual void SeekTime(int64_t iTime);
virtual int64_t GetTime();
virtual int64_t GetTotalTime();
- virtual void ToFFRW(int iSpeed = 0);
- virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
- virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
- virtual int GetSourceBitrate();
- virtual int GetPictureWidth();
- virtual int GetPictureHeight();
- virtual bool GetStreamDetails(CStreamDetails &details);
-
- virtual bool IsInMenu() const;
- virtual bool HasMenu();
-
- virtual bool GetCurrentSubtitle(CStdString& strSubtitle);
- //returns a state that is needed for resuming from a specific time
+ virtual void ToFFRW(int iSpeed );
+ virtual bool OnAction(const CAction &action);
+ virtual bool HasMenu();
+ virtual int GetSourceBitrate();
+ virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
+
+ virtual int GetPictureWidth();
+ virtual int GetPictureHeight();
+ virtual bool GetStreamDetails(CStreamDetails &details);
+ virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
+
+ virtual bool GetCurrentSubtitle(CStdString& strSubtitle);
+
virtual CStdString GetPlayerState();
- virtual bool SetPlayerState(CStdString state);
+ virtual bool SetPlayerState(CStdString state);
virtual CStdString GetPlayingTitle();
, CACHESTATE_FLUSH // temporary state player will choose startup between init or full
};
- int m_playSpeed;
- struct SSpeedState
- {
- double lastpts; // holds last display pts during ff/rw operations
- double lasttime;
- } m_SpeedState;
-
- void HandlePlaySpeed();
- bool GetCachingTimes(double& play_left, double& cache_left, double& file_offset);
- bool CheckStartCaching(COMXCurrentStream& current);
- void SetCaching(ECacheState state);
- double GetQueueTime();
- virtual bool IsCaching() const { return m_caching == CACHESTATE_FULL; }
+ virtual bool IsCaching() const { return m_caching == CACHESTATE_FULL || m_caching == CACHESTATE_PVR; }
virtual int GetCacheLevel() const;
virtual int OnDVDNavResult(void* pData, int iMessage);
- virtual bool OnAction(const CAction &action);
virtual void GetRenderFeatures(std::vector<int> &renderFeatures);
virtual void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
virtual void OnStartup();
virtual void OnExit();
- bool WaitForPausedThumbJobs(int timeout_ms);
virtual void Process();
+ bool OpenAudioStream(int iStream, int source, bool reset = true);
+ bool OpenVideoStream(int iStream, int source, bool reset = true);
+ bool OpenSubtitleStream(int iStream, int source);
+ bool OpenTeletextStream(int iStream, int source);
+ bool CloseAudioStream(bool bWaitForBuffers);
+ bool CloseVideoStream(bool bWaitForBuffers);
+ bool CloseSubtitleStream(bool bKeepOverlays);
+ bool CloseTeletextStream(bool bWaitForBuffers);
+
+ void ProcessPacket(CDemuxStream* pStream, DemuxPacket* pPacket);
+ void ProcessAudioData(CDemuxStream* pStream, DemuxPacket* pPacket);
+ void ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket);
+ void ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket);
+ void ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket);
+
+ bool ShowPVRChannelInfo();
+
+ int AddSubtitleFile(const std::string& filename, const std::string& subfilename = "", CDemuxStream::EFlags flags = CDemuxStream::FLAG_NONE);
+
+ /**
+ * one of the DVD_PLAYSPEED defines
+ */
+ void SetPlaySpeed(int iSpeed);
+ int GetPlaySpeed() { return m_playSpeed; }
+ void SetCaching(ECacheState state);
+
+ int64_t GetTotalTimeInMsec();
+
+ double GetQueueTime();
+ bool GetCachingTimes(double& play_left, double& cache_left, double& file_offset);
+
+
+ void FlushBuffers(bool queued, double pts = DVD_NOPTS_VALUE, bool accurate = true);
+
+
+ void HandleMessages();
+ void HandlePlaySpeed();
+ bool IsInMenu() const;
+
+ void SynchronizePlayers(unsigned int sources);
+ void SynchronizeDemuxer(unsigned int timeout);
+ void CheckAutoSceneSkip();
+ void CheckContinuity(COMXCurrentStream& current, DemuxPacket* pPacket);
+ bool CheckSceneSkip(COMXCurrentStream& current);
+ bool CheckPlayerInit(COMXCurrentStream& current, unsigned int source);
+ bool CheckStartCaching(COMXCurrentStream& current);
+ void UpdateCorrection(DemuxPacket* pkt, double correction);
+ void UpdateTimestamps(COMXCurrentStream& current, DemuxPacket* pPacket);
+ void SendPlayerMessage(CDVDMsg* pMsg, unsigned int target);
+ bool ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream);
+ bool IsValidStream(COMXCurrentStream& stream);
+ bool IsBetterStream(COMXCurrentStream& current, CDemuxStream* stream);
+ bool CheckDelayedChannelEntry(void);
+ bool OpenInputStream();
+ bool OpenDemuxStream();
+ void OpenDefaultStreams(bool reset = true);
+
+ void UpdateApplication(double timeout);
+ void UpdatePlayState(double timeout);
+ double m_UpdateApplication;
+
+ bool m_bAbortRequest;
+
std::string m_filename; // holds the actual filename
- CDVDInputStream *m_pInputStream;
- CDVDDemux *m_pDemuxer;
+ std::string m_mimetype; // hold a hint to what content file contains (mime type)
+ ECacheState m_caching;
+ CFileItem m_item;
+ unsigned int m_iChannelEntryTimeOut;
+
+
+ COMXCurrentStream m_CurrentAudio;
+ COMXCurrentStream m_CurrentVideo;
+ COMXCurrentStream m_CurrentSubtitle;
+ COMXCurrentStream m_CurrentTeletext;
+
+ COMXSelectionStreams m_SelectionStreams;
+
+ int m_playSpeed;
+ struct SSpeedState
+ {
+ double lastpts; // holds last display pts during ff/rw operations
+ double lasttime;
+ } m_SpeedState;
+
+ int m_errorCount;
+ double m_offset_pts;
+
+ CDVDMessageQueue m_messenger; // thread messenger
+
+ OMXPlayerVideo m_omxPlayerVideo; // video part
+ OMXPlayerAudio m_omxPlayerAudio; // audio part
+ CDVDPlayerSubtitle m_dvdPlayerSubtitle; // subtitle part
+ CDVDTeletextData m_dvdPlayerTeletext; // teletext part
+
+ CDVDClock m_clock; // master clock
+ OMXClock m_av_clock;
+
+ float m_current_volume;
+ bool m_current_mute;
+ bool m_change_volume;
+
+ CDVDOverlayContainer m_overlayContainer;
+
+ CDVDInputStream* m_pInputStream; // input stream for current playing file
+ CDVDDemux* m_pDemuxer; // demuxer for current playing file
CDVDDemux* m_pSubtitleDemuxer;
- COMXSelectionStreams m_SelectionStreams;
- std::string m_mimetype;
- COMXCurrentStream m_CurrentAudio;
- COMXCurrentStream m_CurrentVideo;
- COMXCurrentStream m_CurrentSubtitle;
- COMXCurrentStream m_CurrentTeletext;
+
+ CStdString m_lastSub;
struct SDVDInfo
{
} m_State, m_StateInput;
CCriticalSection m_StateSection;
+ CEvent m_ready;
+ CCriticalSection m_critStreamSection; // need to have this lock when switching streams (audio / video)
+
CEdl m_Edl;
struct SEdlAutoSkipMarkers {
} m_EdlAutoSkipMarkers;
- bool ShowPVRChannelInfo();
-
- int AddSubtitleFile(const std::string& filename, const std::string& subfilename = "", CDemuxStream::EFlags flags = CDemuxStream::FLAG_NONE);
- virtual void UpdatePlayState(double timeout);
-
- double m_UpdateApplication;
-
- void RenderUpdateCallBack(const void *ctx, const CRect &SrcRect, const CRect &DestRect);
-
-private:
- void FlushBuffers(bool queued, double pts = DVD_NOPTS_VALUE, bool accurate = true);
-
- CCriticalSection m_critStreamSection;
-
- bool m_paused;
- bool m_bAbortRequest;
- CFileItem m_item;
CPlayerOptions m_PlayerOptions;
- unsigned int m_iChannelEntryTimeOut;
-
- std::string m_lastSub;
-
- double m_offset_pts;
-
- CDVDMessageQueue m_messenger;
-
- OMXClock m_av_clock;
- OMXPlayerVideo m_player_video;
- OMXPlayerAudio m_player_audio;
- CDVDPlayerSubtitle m_player_subtitle;
- CDVDTeletextData m_player_teletext;
-
- CEvent m_ready;
-
- float m_current_volume;
- bool m_current_mute;
- bool m_change_volume;
- CDVDOverlayContainer m_overlayContainer;
- ECacheState m_caching;
bool m_HasVideo;
bool m_HasAudio;
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
m_buffer_empty = false;
m_nChannels = 0;
m_DecoderOpen = false;
- m_freq = CurrentHostFrequency();
m_bad_state = false;
m_hints_current.Clear();
- m_av_clock->SetMasterClock(false);
-
m_messageQueue.SetMaxDataSize(3 * 1024 * 1024);
m_messageQueue.SetMaxTimeSize(8.0);
m_use_passthrough = false;
m_use_hw_decode = false;
m_hw_decode = false;
m_silence = false;
- m_error = 0.0;
- m_errorbuff = 0.0;
- m_errorcount = 0;
- m_syncclock = false;
- m_integral = 0.0;
- m_skipdupcount = 0;
- m_prevskipped = false;
m_flush = false;
- m_synctype = 0;
-
}
m_speed = DVD_PLAYSPEED_NORMAL;
m_audioClock = 0;
- m_error = 0;
- m_errorbuff = 0;
- m_errorcount = 0;
- m_integral = 0;
- m_skipdupcount = 0;
- m_prevskipped = false;
- m_syncclock = true;
m_hw_decode = false;
- m_errortime = CurrentHostCounter();
m_silence = false;
m_started = false;
m_flush = false;
m_nChannels = 0;
- m_synctype = SYNC_DISCON;
m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
m_use_passthrough = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI) ? true : false ;
m_use_hw_decode = g_advancedSettings.m_omxHWAudioDecode;
CLog::Log(LOGNOTICE, "thread end: OMXPlayerAudio::OnExit()");
}
-
-
-void OMXPlayerAudio::HandleSyncError(double duration)
-{
- double clock = m_av_clock->GetClock();
- double error = m_audioClock - clock;
- int64_t now;
-
- if( fabs(error) > DVD_MSEC_TO_TIME(100) || m_syncclock )
- {
- m_av_clock->Discontinuity(clock+error);
- /*
- if(m_speed == DVD_PLAYSPEED_NORMAL)
- CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Discontinuity - was:%f, should be:%f, error:%f\n", clock, clock+error, error);
- */
-
- m_errorbuff = 0;
- m_errorcount = 0;
- m_skipdupcount = 0;
- m_error = 0;
- m_syncclock = false;
- m_errortime = CurrentHostCounter();
-
- return;
- }
-
- if (m_speed != DVD_PLAYSPEED_NORMAL)
- {
- m_errorbuff = 0;
- m_errorcount = 0;
- m_integral = 0;
- m_skipdupcount = 0;
- m_error = 0;
- m_errortime = CurrentHostCounter();
- return;
- }
-
- //check if measured error for 1 second
- now = CurrentHostCounter();
- if ((now - m_errortime) >= m_freq)
- {
- m_errortime = now;
- m_error = m_errorbuff / m_errorcount;
-
- m_errorbuff = 0;
- m_errorcount = 0;
-
- if (m_synctype == SYNC_DISCON)
- {
- double limit, error;
-
- if (m_av_clock->GetRefreshRate(&limit) > 0)
- {
- //when the videoreferenceclock is running, the discontinuity limit is one vblank period
- limit *= DVD_TIME_BASE;
-
- //make error a multiple of limit, rounded towards zero,
- //so it won't interfere with the sync methods in CXBMCRenderManager::WaitPresentTime
- if (m_error > 0.0)
- error = limit * floor(m_error / limit);
- else
- error = limit * ceil(m_error / limit);
- }
- else
- {
- limit = DVD_MSEC_TO_TIME(10);
- error = m_error;
- }
-
- /*
- limit = DVD_MSEC_TO_TIME(10);
- error = m_error;
- */
-
- if (fabs(error) > limit - 0.001)
- {
- m_av_clock->Discontinuity(clock+error);
- /*
- if(m_speed == DVD_PLAYSPEED_NORMAL)
- CLog::Log(LOGDEBUG, "COMXPlayerAudio:: Discontinuity - was:%f, should be:%f, error:%f", clock, clock+error, error);
- */
- }
- }
- /*
- else if (m_synctype == SYNC_SKIPDUP && m_skipdupcount == 0 && fabs(m_error) > DVD_MSEC_TO_TIME(10))
- if (m_skipdupcount == 0 && fabs(m_error) > DVD_MSEC_TO_TIME(10))
- {
- //check how many packets to skip/duplicate
- m_skipdupcount = (int)(m_error / duration);
- //if less than one frame off, see if it's more than two thirds of a frame, so we can get better in sync
- if (m_skipdupcount == 0 && fabs(m_error) > duration / 3 * 2)
- m_skipdupcount = (int)(m_error / (duration / 3 * 2));
-
- if (m_skipdupcount > 0)
- CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Duplicating %i packet(s) of %.2f ms duration",
- m_skipdupcount, duration / DVD_TIME_BASE * 1000.0);
- else if (m_skipdupcount < 0)
- CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Skipping %i packet(s) of %.2f ms duration ",
- m_skipdupcount * -1, duration / DVD_TIME_BASE * 1000.0);
- }
- */
- }
-}
-
bool OMXPlayerAudio::CodecChange()
{
unsigned int old_bitrate = m_hints.bitrate;
int n = (m_nChannels * m_hints.bitspersample * m_hints.samplerate)>>3;
if (n > 0)
m_audioClock += ((double)decoded_size * DVD_TIME_BASE) / n;
-
- if(m_speed == DVD_PLAYSPEED_NORMAL)
- HandleSyncError((((double)decoded_size * DVD_TIME_BASE) / n));
break;
}
m_omxAudio.AddPackets(pkt->pData, pkt->iSize, m_audioClock, m_audioClock);
}
- if(m_speed == DVD_PLAYSPEED_NORMAL)
- HandleSyncError(0);
-
m_audioStats.AddSampleBytes(pkt->iSize);
break;
else if (pMsg->IsType(CDVDMsg::GENERAL_RESYNC))
{ //player asked us to set internal clock
CDVDMsgGeneralResync* pMsgGeneralResync = (CDVDMsgGeneralResync*)pMsg;
-
- if (pMsgGeneralResync->m_timestamp != DVD_NOPTS_VALUE)
- m_audioClock = pMsgGeneralResync->m_timestamp;
-
- if (pMsgGeneralResync->m_clock)
- {
- CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, 1)", m_audioClock);
- m_av_clock->Discontinuity(m_audioClock);
- //m_av_clock->OMXUpdateClock(m_audioClock);
- }
- else
- CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, 0)", m_audioClock);
+ CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, %d)", m_audioClock, pMsgGeneralResync->m_clock);
m_flush = false;
}
else if (pMsg->IsType(CDVDMsg::GENERAL_RESET))
m_omxAudio.Flush();
m_av_clock->OMXReset(false);
m_av_clock->UnLock();
- m_syncclock = true;
m_stalled = true;
m_started = false;
m_speed = static_cast<CDVDMsgInt*>(pMsg)->m_value;
CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::PLAYER_SETSPEED %d", m_speed);
}
- if (m_speed != DVD_PLAYSPEED_NORMAL)
- {
- m_syncclock = true;
- }
}
else if (pMsg->IsType(CDVDMsg::AUDIO_SILENCE))
{
hdmi_passthrough_ac3 = true;
if (m_DllBcmHost.vc_tv_hdmi_audio_supported(EDID_AudioFormat_eDTS, 2, EDID_AudioSampleRate_e44KHz, EDID_AudioSampleSize_16bit ) == 0)
hdmi_passthrough_dts = true;
- //printf("Audio support AC3=%d, DTS=%d\n", hdmi_passthrough_ac3, hdmi_passthrough_dts);
m_passthrough = false;
m_hw_decode = false;
/* software path */
if(!m_passthrough && !m_hw_decode)
{
- /* 6 channel have to be mapped to 8 for PCM */
- if(m_nChannels > 4)
- m_nChannels = 8;
- dataFormat = AE_FMT_S16NE;
+ if (m_pAudioCodec && m_pAudioCodec->GetBitsPerSample() == 16)
+ dataFormat = AE_FMT_S16NE;
+ else
+ dataFormat = AE_FMT_FLOAT;
}
return dataFormat;
return m_omxAudio.GetCacheTime();
}
+double OMXPlayerAudio::GetCacheTotal()
+{
+ return m_omxAudio.GetCacheTotal();
+}
+
void OMXPlayerAudio::SubmitEOS()
{
if(!m_bad_state)
int m_speed;
bool m_silence;
double m_audioClock;
- double m_error; //last average error
-
- int64_t m_errortime; //timestamp of last time we measured
- int64_t m_freq;
-
- void HandleSyncError(double duration);
- double m_errorbuff; //place to store average errors
- int m_errorcount;//number of errors stored
- bool m_syncclock;
-
- double m_integral; //integral correction for resampler
- int m_skipdupcount; //counter for skip/duplicate synctype
- bool m_prevskipped;
bool m_stalled;
bool m_started;
struct timespec m_starttime, m_endtime;
bool m_buffer_empty;
bool m_flush;
- //SYNC_DISCON, SYNC_SKIPDUP, SYNC_RESAMPLE
- int m_synctype;
int m_nChannels;
bool m_DecoderOpen;
void CloseDecoder();
double GetDelay();
double GetCacheTime();
- double GetCurrentPTS() { return m_audioClock; };
+ double GetCacheTotal();
+ double GetCurrentPts() { return m_audioClock; };
void WaitCompletion();
void SubmitEOS();
void RegisterAudioCallback(IAudioCallback* pCallback);
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
#include "settings/MediaSettings.h"
#include "cores/VideoRenderers/RenderFormats.h"
#include "cores/VideoRenderers/RenderFlags.h"
+#include "guilib/GraphicContext.h"
#include "OMXPlayer.h"
{
m_av_clock = av_clock;
m_pOverlayContainer = pOverlayContainer;
- m_pTempOverlayPicture = NULL;
m_open = false;
m_stream_id = -1;
m_fFrameRate = 25.0f;
m_speed = DVD_PLAYSPEED_NORMAL;
m_stalled = false;
m_iSubtitleDelay = 0;
- m_FlipTimeStamp = 0.0;
m_bRenderSubs = false;
m_flags = 0;
m_bAllowFullscreen = false;
m_iCurrentPts = DVD_NOPTS_VALUE;
m_iVideoDelay = 0;
- m_autosync = 1;
m_fForcedAspectRatio = 0.0f;
m_messageQueue.SetMaxDataSize(10 * 1024 * 1024);
m_messageQueue.SetMaxTimeSize(8.0);
m_dst_rect.SetRect(0, 0, 0, 0);
- m_iSleepEndTime = 0.0;
- m_Deinterlace = false;
- m_audio_count = 0;
+ m_nextOverlay = DVD_NOPTS_VALUE;
m_started = false;
m_flush = false;
m_view_mode = 0;
bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints)
{
- /*
- if(IsRunning())
- CloseStream(false);
- */
-
m_hints = hints;
- m_Deinterlace = ( CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true;
m_hdmi_clock_sync = (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF);
m_started = false;
m_flush = false;
m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
- m_autosync = 1;
- m_iSleepEndTime = DVD_NOPTS_VALUE;
+ m_nextOverlay = DVD_NOPTS_VALUE;
// force SetVideoRect to be called initially
m_dst_rect.SetRect(0, 0, 0, 0);
Create();
}
- /*
- if(!OpenStream(hints, NULL))
- return false;
-
- CLog::Log(LOGNOTICE, "Creating video thread");
- m_messageQueue.Init();
- Create();
- */
-
m_open = true;
return true;
m_speed = DVD_PLAYSPEED_NORMAL;
m_started = false;
- if (m_pTempOverlayPicture)
- {
- CDVDCodecUtils::FreePicture(m_pTempOverlayPicture);
- m_pTempOverlayPicture = NULL;
- }
-
m_av_clock->Lock();
m_av_clock->OMXStop(false);
m_omxVideo.Close();
void OMXPlayerVideo::OnStartup()
{
m_iCurrentPts = DVD_NOPTS_VALUE;
- m_FlipTimeStamp = m_av_clock->GetAbsoluteClock();
+ m_nextOverlay = DVD_NOPTS_VALUE;
}
void OMXPlayerVideo::OnExit()
CLog::Log(LOGNOTICE, "thread end: video_thread");
}
+double OMXPlayerVideo::NextOverlay(double pts)
+{
+ double delta_start, delta_stop, min_delta = DVD_NOPTS_VALUE;
+
+ CSingleLock lock(*m_pOverlayContainer);
+ VecOverlays* pVecOverlays = m_pOverlayContainer->GetOverlays();
+ VecOverlaysIter it = pVecOverlays->begin();
+
+ //Find the minimum time before a subtitle is added or removed
+ while (it != pVecOverlays->end())
+ {
+ CDVDOverlay* pOverlay = *it++;
+ if(!pOverlay->bForced && !m_bRenderSubs)
+ continue;
+
+ double pts2 = pOverlay->bForced ? pts : pts - m_iSubtitleDelay;
+
+ delta_start = pOverlay->iPTSStartTime - pts2;
+ delta_stop = pOverlay->iPTSStopTime - pts2;
+
+ // when currently on screen, we periodically update to allow (limited rate) ASS animation
+ if (delta_start <= 0.0 && delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || DVD_MSEC_TO_TIME(100) < min_delta))
+ min_delta = DVD_MSEC_TO_TIME(100);
+
+ else if (delta_start > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_start < min_delta))
+ min_delta = delta_start;
+
+ else if (delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_stop < min_delta))
+ min_delta = delta_stop;
+ }
+ return min_delta == DVD_NOPTS_VALUE ? pts+DVD_MSEC_TO_TIME(500) : pts+min_delta;
+}
+
+
void OMXPlayerVideo::ProcessOverlays(double pts)
{
// remove any overlays that are out of time
return;
}
- // calculate the time we need to delay this picture before displaying
- double iSleepTime, iClockSleep, iFrameSleep, iPlayingClock, iCurrentClock, iFrameDuration;
-
- iPlayingClock = m_av_clock->GetClock(iCurrentClock, false); // snapshot current clock
- iClockSleep = pts - iPlayingClock; //sleep calculated by pts to clock comparison
- iFrameSleep = m_FlipTimeStamp - iCurrentClock; // sleep calculated by duration of frame
- iFrameDuration = (double)DVD_TIME_BASE / m_fFrameRate; //pPacket->duration;
-
- // correct sleep times based on speed
- if(m_speed)
- {
- iClockSleep = iClockSleep * DVD_PLAYSPEED_NORMAL / m_speed;
- iFrameSleep = iFrameSleep * DVD_PLAYSPEED_NORMAL / abs(m_speed);
- iFrameDuration = iFrameDuration * DVD_PLAYSPEED_NORMAL / abs(m_speed);
- }
- else
- {
- iClockSleep = 0;
- iFrameSleep = 0;
- }
-
- // dropping to a very low framerate is not correct (it should not happen at all)
- iClockSleep = min(iClockSleep, DVD_MSEC_TO_TIME(500));
- iFrameSleep = min(iFrameSleep, DVD_MSEC_TO_TIME(500));
-
- if( m_stalled )
- iSleepTime = iFrameSleep;
- else
- iSleepTime = iFrameSleep + (iClockSleep - iFrameSleep) / m_autosync;
-
- // present the current pts of this frame to user, and include the actual
- // presentation delay, to allow him to adjust for it
- if( m_stalled )
- m_iCurrentPts = DVD_NOPTS_VALUE;
- else
- m_iCurrentPts = pts - max(0.0, iSleepTime);
+ m_iCurrentPts = pts;
- // timestamp when we think next picture should be displayed based on current duration
- m_FlipTimeStamp = iCurrentClock;
- m_FlipTimeStamp += max(0.0, iSleepTime);
- m_FlipTimeStamp += iFrameDuration;
-
- if( m_speed < 0 )
- {
- if( iClockSleep < -DVD_MSEC_TO_TIME(200))
- return;
- }
-
- if(bDropPacket)
+ if (CThread::m_bStop)
return;
- // DVDPlayer sleeps until m_iSleepEndTime here before calling FlipPage.
- // Video playback in asynchronous in OMXPlayer, so we don't want to do that here, as it prevents the video fifo from being kept full.
- // So, we keep track of when FlipPage would have been called on DVDPlayer and return early if it is not time.
- // m_iSleepEndTime == DVD_NOPTS_VALUE means we are not waiting to call FlipPage, otherwise it is the time we want to call FlipPage
- if (m_iSleepEndTime == DVD_NOPTS_VALUE) {
- m_iSleepEndTime = iCurrentClock + iSleepTime;
- }
+ // we aim to submit subtitles 100ms early
+ const double preroll = DVD_MSEC_TO_TIME(100);
+ double media_pts = m_av_clock->OMXMediaTime(false);
- if (!CThread::m_bStop && m_av_clock->GetAbsoluteClock(false) < m_iSleepEndTime + DVD_MSEC_TO_TIME(500))
+ if (m_nextOverlay != DVD_NOPTS_VALUE && media_pts + preroll <= m_nextOverlay)
return;
- int buffer = g_renderManager.WaitForBuffer(CThread::m_bStop, iSleepTime + DVD_MSEC_TO_TIME(500));
+ int buffer = g_renderManager.WaitForBuffer(CThread::m_bStop);
if (buffer < 0)
return;
- double pts_media = m_av_clock->OMXMediaTime(false);
- ProcessOverlays(pts_media);
+ double subtitle_pts = m_nextOverlay;
+ double time = subtitle_pts != DVD_NOPTS_VALUE ? subtitle_pts - media_pts : 0.0;
+
+ if (m_nextOverlay != DVD_NOPTS_VALUE)
+ media_pts = m_nextOverlay;
- g_renderManager.FlipPage(CThread::m_bStop, m_iSleepEndTime / DVD_TIME_BASE, -1, FS_NONE);
+ m_nextOverlay = NextOverlay(media_pts);
- m_iSleepEndTime = DVD_NOPTS_VALUE;
+ ProcessOverlays(media_pts);
- //m_av_clock->WaitAbsoluteClock((iCurrentClock + iSleepTime));
+ time += m_av_clock->GetAbsoluteClock();
+ g_renderManager.FlipPage(CThread::m_bStop, time/DVD_TIME_BASE);
}
void OMXPlayerVideo::Process()
else if (pMsg->IsType(CDVDMsg::GENERAL_RESYNC))
{
CDVDMsgGeneralResync* pMsgGeneralResync = (CDVDMsgGeneralResync*)pMsg;
-
- if(pMsgGeneralResync->m_timestamp != DVD_NOPTS_VALUE)
- pts = pMsgGeneralResync->m_timestamp;
-
- double delay = m_FlipTimeStamp - m_av_clock->GetAbsoluteClock();
- if( delay > frametime ) delay = frametime;
- else if( delay < 0 ) delay = 0;
-
- if(pMsgGeneralResync->m_clock)
- {
- CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, 1)", pts);
- m_av_clock->Discontinuity(pts - delay);
- //m_av_clock->OMXUpdateClock(pts - delay);
- }
- else
- CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, 0)", pts);
-
+ CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, %d)", pts, pMsgGeneralResync->m_clock);
pMsgGeneralResync->Release();
continue;
}
m_av_clock->OMXReset(false);
m_av_clock->UnLock();
m_started = false;
- m_iSleepEndTime = DVD_NOPTS_VALUE;
+ m_nextOverlay = DVD_NOPTS_VALUE;
}
else if (pMsg->IsType(CDVDMsg::GENERAL_FLUSH)) // private message sent by (COMXPlayerVideo::Flush())
{
CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_FLUSH");
m_stalled = true;
m_started = false;
- m_iSleepEndTime = DVD_NOPTS_VALUE;
+ m_nextOverlay = DVD_NOPTS_VALUE;
m_av_clock->Lock();
m_av_clock->OMXStop(false);
m_omxVideo.Reset();
#ifdef _DEBUG
CLog::Log(LOGINFO, "Video: dts:%.0f pts:%.0f size:%d (s:%d f:%d d:%d l:%d) s:%d %d/%d late:%d\n", pPacket->dts, pPacket->pts,
- (int)pPacket->iSize, m_started, m_flush, bPacketDrop, m_stalled, m_speed, 0, 0, m_av_clock->OMXLateCount(1));
+ (int)pPacket->iSize, m_started, m_flush, bPacketDrop, m_stalled, m_speed, 0, 0, 0);
#endif
if (m_messageQueue.GetDataSize() == 0
|| m_speed < 0)
m_av_clock->Lock();
m_av_clock->OMXStop(false);
- bool bVideoDecoderOpen = m_omxVideo.Open(m_hints, m_av_clock, m_Deinterlace, m_hdmi_clock_sync);
+ bool bVideoDecoderOpen = m_omxVideo.Open(m_hints, m_av_clock, CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode, m_hdmi_clock_sync);
m_omxVideo.RegisterResolutionUpdateCallBack((void *)this, ResolutionUpdateCallBack);
if(!bVideoDecoderOpen)
bool m_open;
CDVDStreamInfo m_hints;
double m_iCurrentPts;
- double m_iSleepEndTime;
+ double m_nextOverlay;
OMXClock *m_av_clock;
COMXVideo m_omxVideo;
float m_fFrameRate;
- bool m_Deinterlace;
bool m_hdmi_clock_sync;
double m_iVideoDelay;
int m_speed;
- double m_FlipTimeStamp; // time stamp of last flippage. used to play at a forced framerate
- int m_audio_count;
bool m_stalled;
bool m_started;
bool m_flush;
std::string m_codecname;
- unsigned int m_autosync;
double m_iSubtitleDelay;
bool m_bRenderSubs;
bool m_bAllowFullscreen;
BitstreamStats m_videoStats;
- DVDVideoPicture* m_pTempOverlayPicture;
-
void ProcessOverlays(double pts);
+ double NextOverlay(double pts);
virtual void OnStartup();
virtual void OnExit();
bool OpenDecoder();
int GetDecoderBufferSize();
int GetDecoderFreeSpace();
- double GetCurrentPTS() { return m_iCurrentPts; };
+ double GetCurrentPts() { return m_iCurrentPts; };
double GetFPS() { return m_fFrameRate; };
void SubmitEOS();
bool SubmittedEOS();
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
#endif
#define CLASSNAME "COMXVideo"
-#if 0
-// TODO: These are Nvidia Tegra2 dependent, need to dynamiclly find the
-// right codec matched to video format.
-#define OMX_H264BASE_DECODER "OMX.Nvidia.h264.decode"
-// OMX.Nvidia.h264ext.decode segfaults, not sure why.
-//#define OMX_H264MAIN_DECODER "OMX.Nvidia.h264ext.decode"
-#define OMX_H264MAIN_DECODER "OMX.Nvidia.h264.decode"
-#define OMX_H264HIGH_DECODER "OMX.Nvidia.h264ext.decode"
-#define OMX_MPEG4_DECODER "OMX.Nvidia.mp4.decode"
-#define OMX_MPEG4EXT_DECODER "OMX.Nvidia.mp4ext.decode"
-#define OMX_MPEG2V_DECODER "OMX.Nvidia.mpeg2v.decode"
-#define OMX_VC1_DECODER "OMX.Nvidia.vc1.decode"
-#endif
-
#define OMX_VIDEO_DECODER "OMX.broadcom.video_decode"
#define OMX_H264BASE_DECODER OMX_VIDEO_DECODER
#define OMX_H264MAIN_DECODER OMX_VIDEO_DECODER
COMXVideo::COMXVideo() : m_video_codec_name("")
{
m_is_open = false;
- m_Pause = false;
m_extradata = NULL;
m_extrasize = 0;
m_video_convert = false;
m_deinterlace = false;
+ m_deinterlace_request = VS_DEINTERLACEMODE_OFF;
m_hdmi_clock_sync = false;
m_drop_state = false;
m_decoded_width = 0;
m_res_callback = NULL;
m_res_ctx = NULL;
m_submitted_eos = false;
+ m_settings_changed = false;
+ m_transform = OMX_DISPLAY_ROT0;
}
COMXVideo::~COMXVideo()
return false;
}
-bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, bool hdmi_clock_sync)
+bool COMXVideo::PortSettingsChanged()
+{
+ OMX_ERRORTYPE omx_err = OMX_ErrorNone;
+
+ if (m_settings_changed)
+ {
+ m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
+ }
+
+ OMX_PARAM_PORTDEFINITIONTYPE port_image;
+ OMX_INIT_STRUCTURE(port_image);
+ port_image.nPortIndex = m_omx_decoder.GetOutputPort();
+ omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_image);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ }
+ // let OMXPlayerVideo know about resolution so it can inform RenderManager
+ if (m_res_callback)
+ m_res_callback(m_res_ctx, port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight);
+
+ if (m_settings_changed)
+ {
+ m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
+ return true;
+ }
+
+ OMX_CONFIG_INTERLACETYPE interlace;
+ OMX_INIT_STRUCTURE(interlace);
+ interlace.nPortIndex = m_omx_decoder.GetOutputPort();
+ omx_err = m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace, &interlace);
+
+ if(m_deinterlace_request == VS_DEINTERLACEMODE_FORCE)
+ m_deinterlace = true;
+ else if(m_deinterlace_request == VS_DEINTERLACEMODE_OFF)
+ m_deinterlace = false;
+ else
+ m_deinterlace = interlace.eMode != OMX_InterlaceProgressive;
+
+ if(!m_omx_render.Initialize("OMX.broadcom.video_render", OMX_IndexParamVideoInit))
+ return false;
+
+ m_omx_render.ResetEos();
+
+ CLog::Log(LOGDEBUG, "%s::%s - %dx%d@%.2f interlace:%d deinterlace:%d", CLASSNAME, __func__,
+ port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight,
+ port_image.format.video.xFramerate / (float)(1<<16), interlace.eMode, m_deinterlace);
+
+ if(!m_omx_sched.Initialize("OMX.broadcom.video_scheduler", OMX_IndexParamVideoInit))
+ return false;
+
+ if(m_deinterlace)
+ {
+ if(!m_omx_image_fx.Initialize("OMX.broadcom.image_fx", OMX_IndexParamImageInit))
+ return false;
+ }
+
+ OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
+ OMX_INIT_STRUCTURE(configDisplay);
+ configDisplay.nPortIndex = m_omx_render.GetInputPort();
+
+ configDisplay.set = OMX_DISPLAY_SET_TRANSFORM;
+ configDisplay.transform = m_transform;
+ omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGWARNING, "%s::%s - could not set transform : %d", CLASSNAME, __func__, m_transform);
+ return false;
+ }
+
+ if(m_hdmi_clock_sync)
+ {
+ OMX_CONFIG_LATENCYTARGETTYPE latencyTarget;
+ OMX_INIT_STRUCTURE(latencyTarget);
+ latencyTarget.nPortIndex = m_omx_render.GetInputPort();
+ latencyTarget.bEnabled = OMX_TRUE;
+ latencyTarget.nFilter = 2;
+ latencyTarget.nTarget = 4000;
+ latencyTarget.nShift = 3;
+ latencyTarget.nSpeedFactor = -135;
+ latencyTarget.nInterFactor = 500;
+ latencyTarget.nAdjCap = 20;
+
+ omx_err = m_omx_render.SetConfig(OMX_IndexConfigLatencyTarget, &latencyTarget);
+ if (omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - OMX_IndexConfigLatencyTarget omx_err(0%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ }
+
+ if(m_deinterlace)
+ {
+ OMX_CONFIG_IMAGEFILTERPARAMSTYPE image_filter;
+ OMX_INIT_STRUCTURE(image_filter);
+
+ image_filter.nPortIndex = m_omx_image_fx.GetOutputPort();
+ image_filter.nNumParams = 1;
+ image_filter.nParams[0] = 3;
+ image_filter.eImageFilter = OMX_ImageFilterDeInterlaceAdvanced;
+
+ omx_err = m_omx_image_fx.SetConfig(OMX_IndexConfigCommonImageFilterParameters, &image_filter);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - OMX_IndexConfigCommonImageFilterParameters omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ }
+
+ if(m_deinterlace)
+ {
+ m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_image_fx, m_omx_image_fx.GetInputPort());
+ m_omx_tunnel_image_fx.Initialize(&m_omx_image_fx, m_omx_image_fx.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
+ }
+ else
+ {
+ m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
+ }
+ m_omx_tunnel_sched.Initialize(&m_omx_sched, m_omx_sched.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+
+ m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort() + 1, &m_omx_sched, m_omx_sched.GetOutputPort() + 1);
+
+ omx_err = m_omx_tunnel_clock.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ omx_err = m_omx_tunnel_decoder.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ if(m_deinterlace)
+ {
+ omx_err = m_omx_tunnel_image_fx.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_image_fx.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ omx_err = m_omx_image_fx.SetStateForComponent(OMX_StateExecuting);
+ if (omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_image_fx.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+ }
+
+ omx_err = m_omx_tunnel_sched.Establish(false);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_sched.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ omx_err = m_omx_sched.SetStateForComponent(OMX_StateExecuting);
+ if (omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_sched.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
+ if (omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "%s::%s - m_omx_render.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+ return false;
+ }
+
+ m_settings_changed = true;
+ return true;
+}
+
+bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, EDEINTERLACEMODE deinterlace, bool hdmi_clock_sync)
{
bool vflip = false;
Close();
-
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
std::string decoder_name;
+ m_settings_changed = false;
m_res_ctx = NULL;
m_res_callback = NULL;
m_video_codec_name = "omx-h264";
break;
}
-
- /* check interlaced */
- if(m_extrasize > 9 && m_extradata[0] == 1)
- {
- CBitstreamConverter converter;
- converter.Open(hints.codec, (uint8_t *)hints.extradata, hints.extrasize, true);
-
- int32_t max_ref_frames = 0;
- uint8_t *spc = m_extradata + 6;
- uint32_t sps_size = BS_RB16(spc);
- bool interlaced = true;
- if (sps_size)
- converter.parseh264_sps(spc+3, sps_size-1, &interlaced, &max_ref_frames);
- if(!interlaced && deinterlace)
- deinterlace = false;
-
- converter.Close();
- }
}
break;
case CODEC_ID_MPEG4:
m_video_codec_name = "omx-vc1";
break;
default:
+ CLog::Log(LOGERROR, "COMXVideo::Open : Video codec unknown: %x", hints.codec);
return false;
break;
}
+ m_deinterlace_request = deinterlace;
- /* enable deintelace on SD and 1080i */
- if(m_decoded_width <= 720 && m_decoded_height <=576 && deinterlace)
- m_deinterlace = deinterlace;
- else if(m_decoded_width >= 1920 && m_decoded_height >= 540 && deinterlace)
- m_deinterlace = deinterlace;
-
- if(m_deinterlace)
- CLog::Log(LOGDEBUG, "COMXVideo::Open : enable deinterlace\n");
-
- std::string componentName = decoder_name;
- if(!m_omx_decoder.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
- return false;
-
- componentName = "OMX.broadcom.video_render";
- if(!m_omx_render.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
- return false;
-
- m_omx_render.ResetEos();
-
- componentName = "OMX.broadcom.video_scheduler";
- if(!m_omx_sched.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
- return false;
-
- if(m_deinterlace)
- {
- componentName = "OMX.broadcom.image_fx";
- if(!m_omx_image_fx.Initialize((const std::string)componentName, OMX_IndexParamImageInit))
- return false;
- }
-
- OMX_VIDEO_PARAM_PORTFORMATTYPE formatType;
- /*
- OMX_INIT_STRUCTURE(formatType);
- formatType.nPortIndex = m_omx_decoder.GetInputPort();
- OMX_U32 nIndex = 1;
- bool bFound = false;
-
- omx_err = OMX_ErrorNone;
- do
- {
- formatType.nIndex = nIndex;
- omx_err = m_omx_decoder.GetParameter(OMX_IndexParamVideoPortFormat, &formatType);
- if(formatType.eCompressionFormat == m_codingType)
- {
- bFound = true;
- break;
- }
- nIndex++;
- }
- while(omx_err == OMX_ErrorNone);
-
- if(!bFound)
- {
- CLog::Log(LOGINFO, "COMXVideo::Open coding : %s not supported\n", m_video_codec_name.c_str());
+ if(!m_omx_decoder.Initialize(decoder_name, OMX_IndexParamVideoInit))
return false;
- }
- */
if(clock == NULL)
return false;
return false;
}
- if(m_deinterlace)
- {
- m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_image_fx, m_omx_image_fx.GetInputPort());
- m_omx_tunnel_image_fx.Initialize(&m_omx_image_fx, m_omx_image_fx.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
- }
- else
- {
- m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
- }
- m_omx_tunnel_sched.Initialize(&m_omx_sched, m_omx_sched.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
-
- m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort() + 1, &m_omx_sched, m_omx_sched.GetOutputPort() + 1);
-
- omx_err = m_omx_tunnel_clock.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_clock.Establish\n");
- return false;
- }
-
omx_err = m_omx_decoder.SetStateForComponent(OMX_StateIdle);
if (omx_err != OMX_ErrorNone)
{
return false;
}
+ OMX_VIDEO_PARAM_PORTFORMATTYPE formatType;
OMX_INIT_STRUCTURE(formatType);
formatType.nPortIndex = m_omx_decoder.GetInputPort();
formatType.eCompressionFormat = m_codingType;
return false;
}
- if (m_deinterlace)
+ if (m_deinterlace_request != VS_DEINTERLACEMODE_OFF)
{
// the deinterlace component requires 3 additional video buffers in addition to the DPB (this is normally 2).
OMX_PARAM_U32TYPE extra_buffers;
}
}
+
// broadcom omx entension:
// When enabled, the timestamp fifo mode will change the way incoming timestamps are associated with output images.
// In this mode the incoming timestamps get used without re-ordering on output images.
}
}
- if(m_hdmi_clock_sync)
- {
- OMX_CONFIG_LATENCYTARGETTYPE latencyTarget;
- OMX_INIT_STRUCTURE(latencyTarget);
- latencyTarget.nPortIndex = m_omx_render.GetInputPort();
- latencyTarget.bEnabled = OMX_TRUE;
- latencyTarget.nFilter = 2;
- latencyTarget.nTarget = 4000;
- latencyTarget.nShift = 3;
- latencyTarget.nSpeedFactor = -135;
- latencyTarget.nInterFactor = 500;
- latencyTarget.nAdjCap = 20;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigLatencyTarget, &latencyTarget);
- if (omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open OMX_IndexConfigLatencyTarget error (0%08x)\n", omx_err);
- return false;
- }
- }
// Alloc buffers for the omx intput port.
omx_err = m_omx_decoder.AllocInputBuffers();
return false;
}
- omx_err = m_omx_tunnel_decoder.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_decoder.Establish\n");
- return false;
- }
-
omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
if (omx_err != OMX_ErrorNone)
{
return false;
}
- if(m_deinterlace)
- {
- OMX_CONFIG_IMAGEFILTERPARAMSTYPE image_filter;
- OMX_INIT_STRUCTURE(image_filter);
-
- image_filter.nPortIndex = m_omx_image_fx.GetOutputPort();
- image_filter.nNumParams = 1;
- image_filter.nParams[0] = 3;
- image_filter.eImageFilter = OMX_ImageFilterDeInterlaceAdvanced;
-
- omx_err = m_omx_image_fx.SetConfig(OMX_IndexConfigCommonImageFilterParameters, &image_filter);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open error OMX_IndexConfigCommonImageFilterParameters omx_err(0x%08x)\n", omx_err);
- return false;
- }
-
- omx_err = m_omx_tunnel_image_fx.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_image_fx.Establish\n");
- return false;
- }
-
- omx_err = m_omx_image_fx.SetStateForComponent(OMX_StateExecuting);
- if (omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_image_fx.SetStateForComponent\n");
- return false;
- }
-
- m_omx_image_fx.DisablePort(m_omx_image_fx.GetInputPort(), false);
- m_omx_image_fx.DisablePort(m_omx_image_fx.GetOutputPort(), false);
- }
-
- omx_err = m_omx_tunnel_sched.Establish(false);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_sched.Establish\n");
- return false;
- }
-
- omx_err = m_omx_sched.SetStateForComponent(OMX_StateExecuting);
- if (omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_sched.SetStateForComponent\n");
- return false;
- }
-
- omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
- if (omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_render.SetStateForComponent\n");
- return false;
- }
-
if(!SendDecoderConfig())
return false;
m_is_open = true;
m_drop_state = false;
- OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
- OMX_INIT_STRUCTURE(configDisplay);
- configDisplay.nPortIndex = m_omx_render.GetInputPort();
-
- configDisplay.set = OMX_DISPLAY_SET_TRANSFORM;
-
switch(hints.orientation)
{
case 90:
- configDisplay.transform = OMX_DISPLAY_ROT90;
+ m_transform = OMX_DISPLAY_ROT90;
break;
case 180:
- configDisplay.transform = OMX_DISPLAY_ROT180;
+ m_transform = OMX_DISPLAY_ROT180;
break;
case 270:
- configDisplay.transform = OMX_DISPLAY_ROT270;
+ m_transform = OMX_DISPLAY_ROT270;
break;
default:
- configDisplay.transform = OMX_DISPLAY_ROT0;
+ m_transform = OMX_DISPLAY_ROT0;
break;
}
if (vflip)
- configDisplay.transform = OMX_DISPLAY_MIRROR_ROT180;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGWARNING, "COMXVideo::Open could not set orientation : %d\n", hints.orientation);
- }
-
- /*
- configDisplay.set = OMX_DISPLAY_SET_LAYER;
- configDisplay.layer = 2;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_DEST_RECT;
- configDisplay.dest_rect.x_offset = 100;
- configDisplay.dest_rect.y_offset = 100;
- configDisplay.dest_rect.width = 640;
- configDisplay.dest_rect.height = 480;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_TRANSFORM;
- configDisplay.transform = OMX_DISPLAY_ROT180;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_FULLSCREEN;
- configDisplay.fullscreen = OMX_FALSE;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_MODE;
- configDisplay.mode = OMX_DISPLAY_MODE_FILL; //OMX_DISPLAY_MODE_LETTERBOX;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_LAYER;
- configDisplay.layer = 1;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- configDisplay.set = OMX_DISPLAY_SET_ALPHA;
- configDisplay.alpha = OMX_FALSE;
-
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
- if(omx_err != OMX_ErrorNone)
- return false;
-
- */
+ m_transform = OMX_DISPLAY_MIRROR_ROT180;
if(m_omx_decoder.BadState())
return false;
CLog::Log(LOGDEBUG,
"%s::%s - decoder_component(0x%p), input_port(0x%x), output_port(0x%x) deinterlace %d hdmiclocksync %d\n",
CLASSNAME, __func__, m_omx_decoder.GetComponent(), m_omx_decoder.GetInputPort(), m_omx_decoder.GetOutputPort(),
- m_deinterlace, m_hdmi_clock_sync);
+ m_deinterlace_request, m_hdmi_clock_sync);
// start from assuming all recent frames had valid pts
m_history_valid_pts = ~0;
return true;
}
+
void COMXVideo::Close()
{
m_omx_tunnel_decoder.Flush();
return false;
}
- /*
- CLog::Log(DEBUG, "COMXVideo::Video VDec : pts %lld omx_buffer 0x%08x buffer 0x%08x number %d\n",
- pts, omx_buffer, omx_buffer->pBuffer, (int)omx_buffer->pAppPrivate);
- if(pts == DVD_NOPTS_VALUE)
- {
- CLog::Log(LOGDEBUG, "VDec : pts %f omx_buffer 0x%08x buffer 0x%08x number %d\n",
- (float)pts / AV_TIME_BASE, (int)omx_buffer, (int)omx_buffer->pBuffer, (int)omx_buffer->pAppPrivate);
- }
- */
-
omx_buffer->nFlags = 0;
omx_buffer->nOffset = 0;
// some packed bitstream AVI files set almost all pts values to DVD_NOPTS_VALUE, but have a scattering of real pts values.
}
if(nRetry == 5)
{
- CLog::Log(LOGERROR, "%s::%s - OMX_EmptyThisBuffer() finaly failed\n", CLASSNAME, __func__);
+ CLog::Log(LOGERROR, "%s::%s - OMX_EmptyThisBuffer() finally failed\n", CLASSNAME, __func__);
return false;
}
}
omx_err = m_omx_decoder.WaitForEvent(OMX_EventPortSettingsChanged, 0);
if (omx_err == OMX_ErrorNone)
{
- OMX_PARAM_PORTDEFINITIONTYPE port_image;
- OMX_INIT_STRUCTURE(port_image);
- port_image.nPortIndex = m_omx_decoder.GetOutputPort();
- omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_image);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- // let OMXPlayerVideo know about resolution so it can inform RenderManager
- if (m_res_callback)
- m_res_callback(m_res_ctx, port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight);
-
- m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
- m_omx_sched.DisablePort(m_omx_sched.GetInputPort(), true);
-
- OMX_CONFIG_INTERLACETYPE interlace;
- OMX_INIT_STRUCTURE(interlace);
- interlace.nPortIndex = m_omx_decoder.GetOutputPort();
- omx_err = m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace, &interlace);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
-
- if (m_deinterlace)
- {
- m_omx_image_fx.DisablePort(m_omx_image_fx.GetInputPort(), true);
- port_image.nPortIndex = m_omx_image_fx.GetInputPort();
- omx_err = m_omx_image_fx.SetParameter(OMX_IndexParamPortDefinition, &port_image);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.SetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- omx_err = m_omx_image_fx.WaitForEvent(OMX_EventPortSettingsChanged);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.WaitForEvent(OMX_EventPortSettingsChanged) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- port_image.nPortIndex = m_omx_image_fx.GetOutputPort();
- omx_err = m_omx_image_fx.GetParameter(OMX_IndexParamPortDefinition, &port_image);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- m_omx_image_fx.EnablePort(m_omx_image_fx.GetInputPort(), true);
-
- m_omx_image_fx.DisablePort(m_omx_image_fx.GetOutputPort(), true);
- }
- port_image.nPortIndex = m_omx_sched.GetInputPort();
- omx_err = m_omx_sched.SetParameter(OMX_IndexParamPortDefinition, &port_image);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "%s::%s - error m_omx_sched.SetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- omx_err = m_omx_sched.WaitForEvent(OMX_EventPortSettingsChanged);
- if(omx_err != OMX_ErrorNone)
+ if(!PortSettingsChanged())
{
- CLog::Log(LOGERROR, "%s::%s - error m_omx_sched.WaitForEvent(OMX_EventPortSettingsChanged) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
- }
- if (m_deinterlace)
- {
- m_omx_image_fx.EnablePort(m_omx_image_fx.GetOutputPort(), true);
+ CLog::Log(LOGERROR, "%s::%s - error PortSettingsChanged omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
+ return false;
}
- m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
- m_omx_sched.EnablePort(m_omx_sched.GetInputPort(), true);
}
}
-
return true;
}
m_omx_decoder.FlushInput();
m_omx_tunnel_decoder.Flush();
-
- /*
- OMX_ERRORTYPE omx_err;
- OMX_CONFIG_BOOLEANTYPE configBool;
- OMX_INIT_STRUCTURE(configBool);
- configBool.bEnabled = OMX_TRUE;
-
- omx_err = m_omx_decoder.SetConfig(OMX_IndexConfigRefreshCodec, &configBool);
- if (omx_err != OMX_ErrorNone)
- CLog::Log(LOGERROR, "%s::%s - error reopen codec omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-
- SendDecoderConfig();
-
- */
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-bool COMXVideo::Pause()
-{
- if(m_omx_render.GetComponent() == NULL)
- return false;
-
- if(m_Pause) return true;
- m_Pause = true;
-
- m_omx_sched.SetStateForComponent(OMX_StatePause);
- m_omx_render.SetStateForComponent(OMX_StatePause);
-
- return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-bool COMXVideo::Resume()
-{
- if(m_omx_render.GetComponent() == NULL)
- return false;
-
- if(!m_Pause) return true;
- m_Pause = false;
-
- m_omx_sched.SetStateForComponent(OMX_StateExecuting);
- m_omx_render.SetStateForComponent(OMX_StateExecuting);
-
- return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
return;
OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
- float sx1 = SrcRect.x1, sy1 = SrcRect.y1, sx2 = SrcRect.x2, sy2 = SrcRect.y2;
- float dx1 = DestRect.x1, dy1 = DestRect.y1, dx2 = DestRect.x2, dy2 = DestRect.y2;
- float sw = SrcRect.Width() / DestRect.Width();
- float sh = SrcRect.Height() / DestRect.Height();
-
- // doesn't like negative coordinates on dest_rect. So adjust by increasing src_rect
- if (dx1 < 0.0f) {
- sx1 -= dx1 * sw;
- dx1 = 0;
- }
- if (dy1 < 0.0f) {
- sy1 -= dy1 * sh;
- dy1 = 0;
- }
OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();
configDisplay.noaspect = OMX_TRUE;
configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT);
- configDisplay.dest_rect.x_offset = (int)(dx1+0.5f);
- configDisplay.dest_rect.y_offset = (int)(dy1+0.5f);
- configDisplay.dest_rect.width = (int)(dx2-dx1+0.5f);
- configDisplay.dest_rect.height = (int)(dy2-dy1+0.5f);
-
- configDisplay.src_rect.x_offset = (int)(sx1+0.5f);
- configDisplay.src_rect.y_offset = (int)(sy1+0.5f);
- configDisplay.src_rect.width = (int)(sx2-sx1+0.5f);
- configDisplay.src_rect.height = (int)(sy2-sy1+0.5f);
+ configDisplay.dest_rect.x_offset = (int)(DestRect.x1+0.5f);
+ configDisplay.dest_rect.y_offset = (int)(DestRect.y1+0.5f);
+ configDisplay.dest_rect.width = (int)(DestRect.Width()+0.5f);
+ configDisplay.dest_rect.height = (int)(DestRect.Height()+0.5f);
+
+ configDisplay.src_rect.x_offset = (int)(SrcRect.x1+0.5f);
+ configDisplay.src_rect.y_offset = (int)(SrcRect.y1+0.5f);
+ configDisplay.src_rect.width = (int)(SrcRect.Width()+0.5f);
+ configDisplay.src_rect.height = (int)(SrcRect.Height()+0.5f);
m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
#include "guilib/Geometry.h"
#include "DVDDemuxers/DVDDemux.h"
+#include "xbmc/settings/VideoSettings.h"
#include <string>
#define VIDEO_BUFFERS 60
// Required overrides
bool SendDecoderConfig();
- bool Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace = false, bool hdmi_clock_sync = false);
+ bool Open(CDVDStreamInfo &hints, OMXClock *clock, EDEINTERLACEMODE deinterlace = VS_DEINTERLACEMODE_OFF, bool hdmi_clock_sync = false);
+ bool PortSettingsChanged();
void RegisterResolutionUpdateCallBack(void *ctx, ResolutionUpdateCallBackFn callback) { m_res_ctx = ctx; m_res_callback = callback; }
void Close(void);
unsigned int GetFreeSpace();
int Decode(uint8_t *pData, int iSize, double dts, double pts);
void Reset(void);
void SetDropState(bool bDrop);
- bool Pause();
- bool Resume();
std::string GetDecoderName() { return m_video_codec_name; };
void SetVideoRect(const CRect& SrcRect, const CRect& DestRect);
int GetInputBufferSize();
COMXCoreTunel m_omx_tunnel_image_fx;
bool m_is_open;
- bool m_Pause;
-
uint8_t *m_extradata;
int m_extrasize;
std::string m_video_codec_name;
bool m_deinterlace;
+ EDEINTERLACEMODE m_deinterlace_request;
bool m_hdmi_clock_sync;
uint32_t m_history_valid_pts;
ResolutionUpdateCallBackFn m_res_callback;
void *m_res_ctx;
bool m_submitted_eos;
- bool NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize);
+ OMX_DISPLAYTRANSFORMTYPE m_transform;
+ bool m_settings_changed;
+ static bool NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize);
};
#endif
#include "utils/URIUtils.h"
#include "filesystem/File.h"
+
ASAPCodec::ASAPCodec()
{
m_CodecName = "asap";
CStdString strFileToLoad = strFile;
int song = -1;
- CStdString strExtension = URIUtils::GetExtension(strFile);
- strExtension.MakeLower();
- if (strExtension == ".asapstream")
+ if (URIUtils::HasExtension(strFile, ".asapstream"))
{
CStdString strFileName = URIUtils::GetFileName(strFile);
int iStart = strFileName.ReverseFind('-') + 1;
|| ext == "tmc" || ext == "tm8" || ext == "tm2"
|| ext == "cms" || ext == "cm3" || ext == "dlt";
}
+
CStdString strFileToLoad = strFile;
m_iTrack = 0;
- CStdString strExtension = URIUtils::GetExtension(strFile);
- strExtension.MakeLower();
- if (strExtension==".nsfstream")
+ if (URIUtils::HasExtension(strFile, ".nsfstream"))
{
// Extract the track to play
CStdString strFileName=URIUtils::GetFileName(strFile);
m_CurrentStream=0;
- CStdString strExtension = URIUtils::GetExtension(strFile);
-
// A bitstream inside a ogg file?
- if (strExtension==".oggstream")
+ if (URIUtils::HasExtension(strFile, ".oggstream"))
{
// Extract the bitstream to play
CStdString strFileName=URIUtils::GetFileName(strFile);
CStdString strFileToLoad = strFile;
m_iTrack = 0;
- CStdString strExtension = URIUtils::GetExtension(strFile);
- strExtension.MakeLower();
- if (strExtension==".sidstream")
+ if (URIUtils::HasExtension(strFile, ".sidstream"))
{
// Extract the track to play
CStdString strFileName=URIUtils::GetFileName(strFile);
#include "DynamicDll.h"
#include "Util.h"
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "cores/DllLoader/Win32DllLoader.h"
#endif
m_dll.EmuAPU = NULL;
m_dll.LoadSPCFile = NULL;
m_dll.SeekAPU = NULL;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_dll.ResetAPU = NULL;
m_dll.InitAPU = NULL;
#endif
// coping DLL_PATH_SPC_CODEC into special://temp and using a unique name. Then
// loading this unique named SNESAPU as the library.
// This forces the shared lib loader to load a per-instance copy of SNESAPU.
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_loader_name = CUtil::GetNextFilename("special://temp/SNESAPU-%03d.so", 999);
XFILE::CFile::Cache(DLL_PATH_SPC_CODEC, m_loader_name);
m_loader->ResolveExport("LoadSPCFile",(void**)&m_dll.LoadSPCFile);
m_loader->ResolveExport("EmuAPU",(void**)&m_dll.EmuAPU);
m_loader->ResolveExport("SeekAPU",(void**)&m_dll.SeekAPU);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_loader->ResolveExport("InitAPU",(void**)&m_dll.InitAPU);
m_loader->ResolveExport("ResetAPU",(void**)&m_dll.ResetAPU);
#endif
file.Close();
m_pApuRAM = new u8[65536];
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_dll.InitAPU();
m_dll.ResetAPU();
#endif
virtual int ReadPCM(BYTE *pBuffer, int size, int *actualsize);
virtual bool CanInit();
private:
-#ifdef _LINUX
+#ifdef TARGET_POSIX
typedef void (__cdecl *LoadMethod) ( const void* p1);
typedef void* (__cdecl *EmuMethod) ( void *p1, u32 p2, u32 p3);
typedef void (__cdecl *SeekMethod) ( u32 p1, b8 p2 );
LoadMethod LoadSPCFile;
EmuMethod EmuAPU;
SeekMethod SeekAPU;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
InitMethod InitAPU;
DeInitMethod ResetAPU;
#endif
#include "Util.h"
#include "utils/log.h"
#include "filesystem/SpecialProtocol.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "../DllLoader/Win32DllLoader.h"
#endif
// This forces the shared lib loader to load a per-instance copy of MID_CODEC.
if ( !m_loader )
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_loader_name = CUtil::GetNextFilename("special://temp/libtimidity-%03d.so", 999);
XFILE::CFile::Cache(DLL_PATH_MID_CODEC, m_loader_name);
#include "utils/log.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
#include <mmreg.h>
#include <ks.h>
#include <ksmedia.h>
char sqlCmd[DB_BUFF_MAX+1];
va_start(ap, t);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
_vsnprintf(sqlCmd, DB_BUFF_MAX-1, sqlFrmt, ap);
#else
vsnprintf(sqlCmd, DB_BUFF_MAX-1, sqlFrmt, ap);
va_list vl;
va_start(vl, msg);
char buf[DB_BUFF_MAX]="";
-#ifndef _LINUX
+#ifndef TARGET_POSIX
_vsnprintf(buf, DB_BUFF_MAX-1, msg, vl);
#else
vsnprintf(buf, DB_BUFF_MAX-1, msg, vl);
#ifdef HAS_MYSQL
#include "mysqldataset.h"
#include "mysql/errmsg.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib, "mysqlclient.lib")
#endif
#include "system.h" // for Sleep(), OutputDebugString() and GetLastError()
#include "utils/URIUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib, "sqlite3.lib")
#endif
#include "video/windows/GUIWindowVideoBase.h"
#include "URL.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "WIN32Util.h"
#endif
#include "GUIDialogFavourites.h"
#include "GUIDialogContextMenu.h"
#include "GUIDialogFileBrowser.h"
-#include "Favourites.h"
+#include "filesystem/Directory.h"
+#include "filesystem/FavouritesDirectory.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/GUIKeyboardFactory.h"
#include "guilib/Key.h"
void CGUIDialogFavourites::OnInitWindow()
{
- CFavourites::Load(*m_favourites);
+ XFILE::CDirectory::GetDirectory("favourites://", *m_favourites);
UpdateList();
CGUIWindow::OnInitWindow();
}
if (nextItem < 0) nextItem += m_favourites->Size();
m_favourites->Swap(item, nextItem);
- CFavourites::Save(*m_favourites);
+ CFavouritesDirectory::Save(*m_favourites);
CGUIMessage message(GUI_MSG_ITEM_SELECT, GetID(), FAVOURITES_LIST, nextItem);
OnMessage(message);
if (item < 0 || item >= m_favourites->Size())
return;
m_favourites->Remove(item);
- CFavourites::Save(*m_favourites);
+ CFavouritesDirectory::Save(*m_favourites);
CGUIMessage message(GUI_MSG_ITEM_SELECT, GetID(), FAVOURITES_LIST, item < m_favourites->Size() ? item : item - 1);
OnMessage(message);
if (CGUIKeyboardFactory::ShowAndGetInput(label, g_localizeStrings.Get(16008), false))
(*m_favourites)[item]->SetLabel(label);
- CFavourites::Save(*m_favourites);
+ CFavouritesDirectory::Save(*m_favourites);
UpdateList();
}
return;
(*m_favourites)[item]->SetArt("thumb", thumb);
- CFavourites::Save(*m_favourites);
+ CFavouritesDirectory::Save(*m_favourites);
UpdateList();
}
}
else
return;
- if (URIUtils::GetExtension(path) != ".xsp")
+ if (!URIUtils::HasExtension(path, ".xsp"))
path += ".xsp";
// should we check whether we should overwrite?
CStdString strHeading;
strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel));
pDialog->SetHeading(strHeading);
- pDialog->SetMultiSelection(true);
+ pDialog->SetMultiSelection(m_rule.m_field != FieldPlaylist);
if (!m_rule.m_parameter.empty())
pDialog->SetSelected(m_rule.m_parameter);
#include "FileItem.h"
#include "guilib/GUIControl.h"
#include "guilib/GUIListItemLayout.h"
-#include "guilib/GUIBaseContainer.h"
+#include "guilib/IGUIContainer.h"
namespace PVR
{
// FileAFP.cpp: implementation of the CAFPFile class.
//
//////////////////////////////////////////////////////////////////////
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "system.h"
#if defined(HAS_FILESYSTEM_AFP)
CLog::Log(LOGDEBUG,"CAFPFile::Open - opened %s, fd=%d",url.GetFileName().c_str(), m_pFp ? m_pFp->fileid:-1);
m_url = url;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
struct __stat64 tmpBuffer;
#else
struct stat tmpBuffer;
return true;
}
#endif // HAS_FILESYSTEM_AFP
-#endif // _LINUX
+#endif // TARGET_POSIX
#define FILEAFP_H_
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "IFile.h"
#include "URL.h"
struct afp_volume *m_pAfpVol;
};
}
-#endif // _LINUX
+#endif // TARGET_POSIX
#endif // FILEAFP_H_
return false;
// Open the dvd drive
-#ifdef _LINUX
+#ifdef TARGET_POSIX
m_pCdIo = m_cdio->cdio_open(g_mediaManager.TranslateDevicePath(strURL), DRIVER_UNKNOWN);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
m_pCdIo = m_cdio->cdio_open_win32(g_mediaManager.TranslateDevicePath(strURL, true));
#else
m_pCdIo = m_cdio->cdio_open_win32("D:");
bool CFileCDDA::IsValidFile(const CURL& url)
{
// Only .cdda files are supported
- CStdString strExtension = URIUtils::GetExtension(url.Get());
- strExtension.MakeLower();
-
- return (strExtension == ".cdda");
+ return URIUtils::HasExtension(url.Get(), ".cdda");
}
int CFileCDDA::GetTrackNum(const CURL& url)
#include "threads/SystemClock.h"
#include "CacheStrategy.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformInclude.h"
#endif
#include "Util.h"
#include "threads/SingleLock.h"
#include "utils/TimeUtils.h"
#include "SpecialProtocol.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "PlatformDefs.h" //for PRIdS, PRId64
#endif
}
int64_t nDiff = iTarget - m_nWritePosition;
- if ( nDiff > 500000 || (nDiff > 0 && WaitForData((unsigned int)(iTarget - m_nReadPosition), 5000) == CACHE_RC_TIMEOUT) ) {
- CLog::Log(LOGWARNING,"%s - attempt to seek past read data (seek to %"PRId64". max: %"PRId64". reset read pointer. (%"PRId64")", __FUNCTION__, iTarget, m_nWritePosition, iFilePosition);
- return CACHE_RC_ERROR;
+ if (nDiff > 500000 || (nDiff > 0 && WaitForData((unsigned int)(iTarget - m_nReadPosition), 5000) == CACHE_RC_TIMEOUT))
+ {
+ CLog::Log(LOGDEBUG,"CSimpleFileCache::Seek - Attempt to seek past read data");
+ return CACHE_RC_ERROR;
}
LARGE_INTEGER pos;
#define XFILECACHESTRATEGY_H
#include <stdint.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h"
#include "XHandlePublic.h"
#include "XFileUtils.h"
, m_buf(NULL)
, m_size(front + back)
, m_size_back(back)
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
, m_handle(INVALID_HANDLE_VALUE)
#endif
{
int CCircularCache::Open()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
m_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, m_size, NULL);
if(m_handle == NULL)
return CACHE_RC_ERROR;
void CCircularCache::Close()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
UnmapViewOfFile(m_buf);
CloseHandle(m_handle);
m_handle = INVALID_HANDLE_VALUE;
size_t m_size_back; /**< guaranteed size of back buffer (actual size can be smaller, or larger if front buffer doesn't need it) */
CCriticalSection m_sync;
CEvent m_written;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
HANDLE m_handle;
#endif
};
#include <vector>
#include <climits>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <errno.h>
#include <inttypes.h>
#include "../linux/XFileUtils.h"
long CCurlFile::CReadState::Connect(unsigned int size)
{
+ if (m_filePos != 0)
+ CLog::Log(LOGDEBUG,"CurlFile::CReadState::Connect - Resume from position %"PRId64, m_filePos);
+
SetResume();
g_curlInterface.multi_add_handle(m_multiHandle, m_easyHandle);
#if !defined(AFX_FILEDAAP_H___INCLUDED_)
#define AFX_FILEDAAP_H___INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "lib/libXDAAP/client.h"
#include "CurlFile.h"
auto_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realPath));
if (pDirectory.get())
if(pDirectory->Remove(realPath.c_str()))
+ {
+ g_directoryCache.ClearFile(realPath);
return true;
+ }
}
XBMCCOMMONS_HANDLE_UNCHECKED
catch (...)
#ifdef _DEBUG
m_cacheHits++;
#endif
- return dir->m_Items->Contains(strFile);
+ return (strPath.Equals(storedPath) || dir->m_Items->Contains(strFile));
}
#ifdef _DEBUG
m_cacheMisses++;
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "network/Network.h"
#include "MusicDatabaseDirectory.h"
#include "MusicSearchDirectory.h"
#include "VideoDatabaseDirectory.h"
+#include "FavouritesDirectory.h"
#include "LibraryDirectory.h"
#include "AddonsDirectory.h"
#include "SourcesDirectory.h"
#include "network/WakeOnAccess.h"
#ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "windows/WINSMBDirectory.h"
#else
#include "SMBDirectory.h"
if (strProtocol == "musicsearch") return new CMusicSearchDirectory();
if (strProtocol == "videodb") return new CVideoDatabaseDirectory();
if (strProtocol == "library") return new CLibraryDirectory();
+ if (strProtocol == "favourites") return new CFavouritesDirectory();
if (strProtocol == "filereader")
return CDirectoryFactory::Create(url.GetFileName());
if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPDirectory();
#endif
#ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (strProtocol == "smb") return new CWINSMBDirectory();
#else
if (strProtocol == "smb") return new CSMBDirectory();
*
*/
-#if _WIN32
+#if TARGET_WINDOWS
#define PCRE_STATIC
#endif
#include <pcrecpp.h>
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "FavouritesDirectory.h"
+#include "File.h"
+#include "Util.h"
+#include "profiles/ProfilesManager.h"
+#include "FileItem.h"
+#include "utils/XBMCTinyXML.h"
+#include "utils/log.h"
+#include "utils/StringUtils.h"
+#include "utils/URIUtils.h"
+#include "settings/AdvancedSettings.h"
+#include "video/VideoInfoTag.h"
+#include "URL.h"
+
+namespace XFILE
+{
+
+
+bool CFavouritesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
+{
+ items.Clear();
+ CURL url(strPath);
+
+ if (url.GetProtocol() == "favourites")
+ {
+ Load(items); //load the default favourite files
+ }
+ return LoadFavourites(strPath, items); //directly load the given file
+}
+
+bool CFavouritesDirectory::Exists(const char* strPath)
+{
+ CURL url(strPath);
+
+ if (url.GetProtocol() == "favourites")
+ {
+ return XFILE::CFile::Exists("special://xbmc/system/favourites.xml")
+ || XFILE::CFile::Exists(URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml"));
+ }
+ return XFILE::CFile::Exists(strPath); //directly load the given file
+}
+
+bool CFavouritesDirectory::Load(CFileItemList &items)
+{
+ items.Clear();
+ CStdString favourites;
+
+ favourites = "special://xbmc/system/favourites.xml";
+ if(XFILE::CFile::Exists(favourites))
+ CFavouritesDirectory::LoadFavourites(favourites, items);
+ else
+ CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
+ favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
+ if(XFILE::CFile::Exists(favourites))
+ CFavouritesDirectory::LoadFavourites(favourites, items);
+ else
+ CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");
+
+ return true;
+}
+
+bool CFavouritesDirectory::LoadFavourites(const CStdString& strPath, CFileItemList& items)
+{
+ CXBMCTinyXML doc;
+ if (!doc.LoadFile(strPath))
+ {
+ CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
+ return false;
+ }
+ TiXmlElement *root = doc.RootElement();
+ if (!root || strcmp(root->Value(), "favourites"))
+ {
+ CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
+ return false;
+ }
+
+ TiXmlElement *favourite = root->FirstChildElement("favourite");
+ while (favourite)
+ {
+ // format:
+ // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
+ // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
+ // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
+ const char *name = favourite->Attribute("name");
+ const char *thumb = favourite->Attribute("thumb");
+ if (name && favourite->FirstChild())
+ {
+ if(!items.Contains(favourite->FirstChild()->Value()))
+ {
+ CFileItemPtr item(new CFileItem(name));
+ item->SetPath(favourite->FirstChild()->Value());
+ if (thumb) item->SetArt("thumb", thumb);
+ items.Add(item);
+ }
+ }
+ favourite = favourite->NextSiblingElement("favourite");
+ }
+ return true;
+}
+
+bool CFavouritesDirectory::Save(const CFileItemList &items)
+{
+ CStdString favourites;
+ CXBMCTinyXML doc;
+ TiXmlElement xmlRootElement("favourites");
+ TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
+ if (!rootNode) return false;
+
+ for (int i = 0; i < items.Size(); i++)
+ {
+ const CFileItemPtr item = items[i];
+ TiXmlElement favNode("favourite");
+ favNode.SetAttribute("name", item->GetLabel().c_str());
+ if (item->HasArt("thumb"))
+ favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
+ TiXmlText execute(item->GetPath());
+ favNode.InsertEndChild(execute);
+ rootNode->InsertEndChild(favNode);
+ }
+
+ favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
+ return doc.SaveFile(favourites);
+}
+
+bool CFavouritesDirectory::AddOrRemove(CFileItem *item, int contextWindow)
+{
+ if (!item) return false;
+
+ // load our list
+ CFileItemList items;
+ Load(items);
+
+ CStdString executePath(GetExecutePath(item, contextWindow));
+
+ CFileItemPtr match = items.Get(executePath);
+ if (match)
+ { // remove the item
+ items.Remove(match.get());
+ }
+ else
+ { // create our new favourite item
+ CFileItemPtr favourite(new CFileItem(item->GetLabel()));
+ if (item->GetLabel().IsEmpty())
+ favourite->SetLabel(CUtil::GetTitleFromPath(item->GetPath(), item->m_bIsFolder));
+ favourite->SetArt("thumb", item->GetArt("thumb"));
+ favourite->SetPath(executePath);
+ items.Add(favourite);
+ }
+
+ // and save our list again
+ return Save(items);
+}
+
+bool CFavouritesDirectory::IsFavourite(CFileItem *item, int contextWindow)
+{
+ CFileItemList items;
+ if (!Load(items)) return false;
+
+ return items.Contains(GetExecutePath(item, contextWindow));
+}
+
+CStdString CFavouritesDirectory::GetExecutePath(const CFileItem *item, int contextWindow)
+{
+ CStdString execute;
+ if (item->m_bIsFolder && (g_advancedSettings.m_playlistAsFolders ||
+ !(item->IsSmartPlayList() || item->IsPlayList())))
+ execute.Format("ActivateWindow(%i,%s)", contextWindow, StringUtils::Paramify(item->GetPath()).c_str());
+ else if (item->IsScript())
+ execute.Format("RunScript(%s)", StringUtils::Paramify(item->GetPath().Mid(9)).c_str());
+ else if (item->IsAndroidApp())
+ execute.Format("StartAndroidActivity(%s)", StringUtils::Paramify(item->GetPath().Mid(26)).c_str());
+ else // assume a media file
+ {
+ if (item->IsVideoDb() && item->HasVideoInfoTag())
+ execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath).c_str());
+ else
+ execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetPath()).c_str());
+ }
+ return execute;
+}
+
+}
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "utils/StdString.h"
+#include "IDirectory.h"
+
+class CFileItemList;
+class CFileItem;
+
+namespace XFILE
+{
+
+ class CFavouritesDirectory : public IDirectory
+ {
+ public:
+ virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
+ virtual bool Exists(const char* strPath);
+ static bool Load(CFileItemList &items);
+ static bool LoadFavourites(const CStdString& strPath, CFileItemList& items);
+
+ static bool AddOrRemove(CFileItem *item, int contextWindow);
+ static bool Save(const CFileItemList& items);
+ static bool IsFavourite(CFileItem *item, int contextWindow);
+ private:
+ static CStdString GetExecutePath(const CFileItem *item, int contextWindow);
+ };
+
+}
{
CURL url(strDirectory);
CStdString pathsep;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
pathsep = "\\";
#else
pathsep = "/";
#if !defined(AFX_FILE_H__A7ED6320_C362_49CB_8925_6C6C8CAE7B78__INCLUDED_)
#define AFX_FILE_H__A7ED6320_C362_49CB_8925_6C6C8CAE7B78__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include <iostream>
#include "utils/StdString.h"
bool sourceSeekFailed = false;
if (!cacheReachEOF)
{
- CLog::Log(LOGDEBUG,"CFileCache::Process - Request seek on source to %"PRId64, cacheMaxPos);
m_nSeekResult = m_source.Seek(cacheMaxPos, SEEK_SET);
if (m_nSeekResult != cacheMaxPos)
{
// return NULL + set pItem->m_bIsFolder to remove it completely from list.
IFileDirectory* CFileDirectoryFactory::Create(const CStdString& strPath, CFileItem* pItem, const CStdString& strMask)
{
+ if (URIUtils::IsStack(strPath)) // disqualify stack as we need to work with each of the parts instead
+ return NULL;
+
CStdString strExtension=URIUtils::GetExtension(strPath);
strExtension.MakeLower();
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "network/Network.h"
#include "ShoutcastFile.h"
#include "FileReaderFile.h"
#ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "windows/WINFileSmb.h"
#else
#include "SmbFile.h"
else if (strProtocol == "myth") return new CMythFile();
else if (strProtocol == "cmyth") return new CMythFile();
#ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
else if (strProtocol == "smb") return new CWINFileSMB();
#else
else if (strProtocol == "smb") return new CSmbFile();
#if !defined(AFX_FILEFACTORY1_H__068E3138_B7CB_4BEE_B5CE_8AA8CADAB233__INCLUDED_)
#define AFX_FILEFACTORY1_H__068E3138_B7CB_4BEE_B5CE_8AA8CADAB233__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "IFile.h"
#include "utils/StdString.h"
#include "utils/AliasShortcutUtils.h"
#include "utils/URIUtils.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include "utils/CharsetConverter.h"
#endif
#define INVALID_FILE_ATTRIBUTES ((DWORD) -1)
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
typedef WIN32_FIND_DATAW LOCAL_WIN32_FIND_DATA;
#define LocalFindFirstFile FindFirstFileW
#define LocalFindNextFile FindNextFileW
memset(&wfd, 0, sizeof(wfd));
URIUtils::AddSlashAtEnd(strRoot);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
strRoot.Replace("/", "\\");
#endif
if (URIUtils::IsDVD(strRoot) && m_isoReader.IsScanned())
m_isoReader.Reset();
}
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strSearchMask;
g_charsetConverter.utf8ToW(strRoot, strSearchMask, false);
strSearchMask.Insert(0, L"\\\\?\\");
if (wfd.cFileName[0] != 0)
{
CStdString strLabel;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
g_charsetConverter.wToUTF8(wfd.cFileName,strLabel);
#else
strLabel = wfd.cFileName;
CStdString strPath1 = strPath;
URIUtils::AddSlashAtEnd(strPath1);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (strPath1.size() == 3 && strPath1[1] == ':')
return Exists(strPath); // A drive - we can't "create" a drive
CStdStringW strWPath1;
bool CHDDirectory::Remove(const char* strPath)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWPath;
g_charsetConverter.utf8ToW(strPath, strWPath, false);
strWPath.Replace(L"/", L"\\");
if (!strPath || !*strPath)
return false;
CStdString strReplaced=strPath;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWReplaced;
strReplaced.Replace("/","\\");
URIUtils::AddSlashAtEnd(strReplaced);
#include "Util.h"
#include "URL.h"
#include "utils/AliasShortcutUtils.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XHandle.h"
#endif
#include <sys/stat.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <fcntl.h>
#include <sys/ioctl.h>
#else
{
CStdString strFile = GetLocal(url);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWFile;
g_charsetConverter.utf8ToW(strFile, strWFile, false);
m_hFile.attach(CreateFileW(strWFile.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));
struct __stat64 buffer;
CStdString strFile = GetLocal(url);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWFile;
URIUtils::RemoveSlashAtEnd(strFile);
g_charsetConverter.utf8ToW(strFile, strWFile, false);
int CHDFile::Stat(struct __stat64* buffer)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
return _fstat64((*m_hFile).fd, buffer);
#else
// Duplicate the handle, as retrieving and closing a matching crt handle closes the crt handle AND the original Windows handle.
{
CStdString strFile = GetLocal(url);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWFile;
/* _wstat64 can't handle long paths therefore we remove the \\?\ */
strFile.Replace("\\\\?\\", "");
bool CHDFile::SetHidden(const CURL &url, bool hidden)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW path;
g_charsetConverter.utf8ToW(GetLocal(url), path, false);
DWORD attributes = hidden ? FILE_ATTRIBUTE_HIDDEN : FILE_ATTRIBUTE_NORMAL;
// make sure it's a legal FATX filename (we are writing to the harddisk)
CStdString strPath = GetLocal(url);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWPath;
g_charsetConverter.utf8ToW(strPath, strWPath, false);
m_hFile.attach(CreateFileW(strWPath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
{
CStdString strFile=GetLocal(url);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWFile;
g_charsetConverter.utf8ToW(strFile, strWFile, false);
return ::DeleteFileW(strWFile.c_str()) ? true : false;
CStdString strFile=GetLocal(url);
CStdString strNewFile=GetLocal(urlnew);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strWFile;
CStdStringW strWNewFile;
g_charsetConverter.utf8ToW(strFile, strWFile, false);
int CHDFile::IoControl(EIoControl request, void* param)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if(request == IOCTRL_NATIVE && param)
{
SNativeIoControl* s = (SNativeIoControl*)param;
int CHDFile::Truncate(int64_t size)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// Duplicate the handle, as retrieving and closing a matching crt handle closes the crt handle AND the original Windows handle.
HANDLE hFileDup;
if (0 == DuplicateHandle(GetCurrentProcess(), (HANDLE)m_hFile, GetCurrentProcess(), &hFileDup, 0, FALSE, DUPLICATE_SAME_ACCESS))
#if !defined(AFX_FILEHD_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_)
#define AFX_FILEHD_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "IFile.h"
#include "utils/AutoPtrHandle.h"
* The filename starts with "tuner" and has no extension. This check will cover off requests
* for *.tbn, *.jpg, *.jpeg, *.edl etc. that do not exist.
*/
- if(path.Left(5) == "tuner"
- && URIUtils::GetExtension(path).IsEmpty())
- return true;
-
- return false;
+ return path.Left(5) == "tuner" && !URIUtils::HasExtension(path);
}
int64_t CHomeRunFile::Seek(int64_t iFilePosition, int iWhence)
{}
/*!
- \brief Test a file for an extension specified with SetMask().
+ \brief Test if file have an allowed extension, as specified with SetMask()
\param strFile File to test
- \return Returns \e true, if file is allowed.
+ \return \e true if file is allowed
+ \note If extension is ".ifo", filename format must be "vide_ts.ifo" or
+ "vts_##_0.ifo". If extension is ".dat", filename format must be
+ "AVSEQ##(#).DAT", "ITEM###(#).DAT" or "MUSIC##(#).DAT".
*/
bool IDirectory::IsAllowed(const CStdString& strFile) const
{
- if ( !m_strFileMask.size() ) return true;
- if ( !strFile.size() ) return true;
-
- CStdString strExtension = URIUtils::GetExtension(strFile);
+ if (m_strFileMask.empty() || strFile.empty())
+ return true;
- if (strExtension.empty())
+ // Check if strFile have an allowed extension
+ if (!URIUtils::HasExtension(strFile, m_strFileMask))
return false;
- strExtension.ToLower();
- strExtension += '|'; // ensures that we have a | at the end of it
- if (m_strFileMask.Find(strExtension) != -1)
- { // it's allowed, but we should also ignore all non dvd related ifo files.
- if (strExtension.Equals(".ifo|"))
- {
- CStdString fileName = URIUtils::GetFileName(strFile);
- if (fileName.Equals("video_ts.ifo")) return true;
- if (fileName.length() == 12 && fileName.Left(4).Equals("vts_") && fileName.Right(6).Equals("_0.ifo")) return true;
- return false;
- }
- if (strExtension.Equals(".dat|"))
- {
- CStdString fileName = URIUtils::GetFileName(strFile);
- /* VCD filenames are of the form AVSEQ##(#).DAT, ITEM###(#).DAT, MUSIC##(#).DAT - i.e. all 11 or 12 characters long
- starting with AVSEQ, MUSIC or ITEM */
- if ((fileName.length() == 11 || fileName.length() == 12) &&
- (fileName.Left(5).Equals("AVSEQ") || fileName.Left(5).Equals("MUSIC") || fileName.Left(4).Equals("ITEM")))
- return true;
- return false;
- }
- return true;
+ // We should ignore all non dvd/vcd related ifo and dat files.
+ if (URIUtils::HasExtension(strFile, ".ifo"))
+ {
+ CStdString fileName = URIUtils::GetFileName(strFile);
+
+ // Allow filenames of the form video_ts.ifo or vts_##_0.ifo
+ return fileName == "video_ts.ifo" ||
+ (fileName.length() == 12 && fileName.Left(4) == "vts_" &&
+ fileName.Right(6) == "_0.ifo");
}
- return false;
+
+ if (URIUtils::HasExtension(strFile, ".dat"))
+ {
+ CStdString fileName = URIUtils::GetFileName(strFile);
+
+ // Allow filenames of the form AVSEQ##(#).DAT, ITEM###(#).DAT
+ // and MUSIC##(#).DAT
+ return (fileName.length() == 11 || fileName.length() == 12) &&
+ (fileName.Left(5) == "AVSEQ" || fileName.Left(5) == "MUSIC" ||
+ fileName.Left(4) == "ITEM");
+ }
+
+ return true;
}
/*!
#if !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)
#define AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "PlatformDefs.h" // for __stat64
#endif
#if !defined(AFX_FILEISO_H__C2FB9C6D_3319_4182_AB45_65E57EFAC8D1__INCLUDED_)
#define AFX_FILEISO_H__C2FB9C6D_3319_4182_AB45_65E57EFAC8D1__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "IFile.h"
#include "utils/RingBuffer.h"
if (libNode.IsEmpty())
return false;
- if (URIUtils::GetExtension(libNode).Equals(".xml"))
+ if (URIUtils::HasExtension(libNode, ".xml"))
{ // a filter node
TiXmlElement *node = LoadXML(libNode);
if (node)
SRCS += DirectoryFactory.cpp
SRCS += DirectoryHistory.cpp
SRCS += DllLibCurl.cpp
+SRCS += FavouritesDirectory.cpp
SRCS += File.cpp
SRCS += FileCache.cpp
SRCS += FileDirectoryFactory.cpp
*
*/
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "threads/SystemClock.h"
#include "linux/PlatformDefs.h"
#endif
if (!musicDatabase.GetSong(idSong, song))
return "";
- CStdString strExtensionFromDb = URIUtils::GetExtension(song.strFileName);
-
- if (!strExtensionFromDb.Equals(strExtension))
+ if (!URIUtils::HasExtension(song.strFileName, strExtension))
return "";
return song.strFileName;
*/
return filename.Left(11) == "recordings/" ||
filename.Left(7) == "movies/" ||
- (filename.Left(8) == "tvshows/" && URIUtils::GetExtension(filename) != "");
+ (filename.Left(8) == "tvshows/" && URIUtils::HasExtension(filename));
}
bool CMythDirectory::IsLiveTV(const CStdString& strPath)
return false;
CStdString channel = url.GetFileNameWithoutPath();
- if(!URIUtils::GetExtension(channel).Equals(".ts"))
+ if(!URIUtils::HasExtension(channel, ".ts"))
{
CLog::Log(LOGERROR, "%s - invalid channel url %s", __FUNCTION__, channel.c_str());
return false;
if ((path.Left(11) == "recordings/"
|| path.Left(7) == "movies/"
|| path.Left(8) == "tvshows/")
- && (URIUtils::GetExtension(path).Equals(".mpg")
- || URIUtils::GetExtension(path).Equals(".nuv")))
+ && (URIUtils::HasExtension(path, ".mpg|.nuv")))
{
if(!SetupConnection(url, true, false, false))
return false;
#if !defined(AFX_FILEPIPE_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_)
#define AFX_FILEPIPE_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "IFile.h"
#include "utils/AutoPtrHandle.h"
{
CURL url(strPath);
- if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_PLUGIN) && !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), m_addon))
+ if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_UNKNOWN) &&
+ !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), m_addon))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;
static bool IsPathToMedia(const CStdString& strPath )
{
- CStdString extension = URIUtils::GetExtension(strPath);
-
- if (extension.IsEmpty())
- return false;
-
- extension.ToLower();
-
- if (g_advancedSettings.m_videoExtensions.Find(extension) != -1)
- return true;
-
- if (g_advancedSettings.m_musicExtensions.Find(extension) != -1)
- return true;
-
- if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
- return true;
-
- return false;
+ return URIUtils::HasExtension(strPath,
+ g_advancedSettings.m_videoExtensions + '|' +
+ g_advancedSettings.m_musicExtensions + '|' +
+ g_advancedSettings.m_pictureExtensions);
}
static bool IsPathToThumbnail(const CStdString& strPath )
{
// Currently just check if this is an image, maybe we will add some
// other checks later
- CStdString extension = URIUtils::GetExtension(strPath);
-
- if (extension.IsEmpty())
- return false;
-
- extension.ToLower();
-
- if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
- return true;
-
- return false;
+ return URIUtils::HasExtension(strPath,
+ g_advancedSettings.m_pictureExtensions);
}
static time_t ParseDate(const CStdString & strDate)
#include "utils/log.h"
#include <errno.h>
#include <sys/stat.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "PlatformDefs.h" //for PRIdS
#endif
extern "C"
#if !defined(AFX_FILERTV_H___INCLUDED_)
#define AFX_FILERTV_H___INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "IFile.h"
#include "utils/log.h"
#include "UnrarXLib/rar.hpp"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <process.h>
#endif
}
CStdString strPath = strPathInRar;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
strPath.Replace('/', '\\');
#endif
//g_charsetConverter.unknownToUTF8(strPath);
#if !defined(AFX_RARMANAGER_H__06BA7C2E_3FCA_11D9_8186_0050FC718317__INCLUDED_)
#define AFX_RARMANAGER_H__06BA7C2E_3FCA_11D9_8186_0050FC718317__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
/*
* Copyright (C) 2005-2013 Team XBMC
* http://www.xbmc.org
#if defined(TARGET_DARWIN)
#include "osx/OSXGNUReplacements.h" // strnlen
#endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include "freebsd/FreeBSDGNUReplacements.h"
#endif
if(m_socket == INVALID_SOCKET)
return;
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
unsigned long nonblocking = 1;
ioctlsocket(m_socket, FIONBIO, &nonblocking);
#else
#include <fcntl.h>
#include <sstream>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib, "ssh.lib")
#endif
-#ifdef TARGET_WINDOWS
+#ifndef S_ISDIR
#define S_ISDIR(m) ((m & _S_IFDIR) != 0)
+#endif
+#ifndef S_ISREG
#define S_ISREG(m) ((m & _S_IFREG) != 0)
#endif
-
-#ifdef _MSC_VER
+#ifndef O_RDONLY
#define O_RDONLY _O_RDONLY
#endif
CSMBDirectory::CSMBDirectory(void)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
smb.AddActiveConnection();
#endif
}
CSMBDirectory::~CSMBDirectory(void)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
smb.AddIdleConnection();
#endif
}
CStdString CSMBDirectory::MountShare(const CStdString &smbPath, const CStdString &strType, const CStdString &strName,
const CStdString &strUser, const CStdString &strPass)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
UnMountShare(strType, strName);
CStdString strMountPoint = GetMountPoint(strType, strName);
// Execute command.
CUtil::Command(args);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
CStdString strCmd = "umount " + GetMountPoint(strType, strName);
CUtil::SudoCommand(strCmd);
#endif
{
CFileItemList list;
bool filesExist = false;
- if (playlistType == "songs" || playlistType == "albums")
+ if (playlistType == "songs" || playlistType == "albums" || playlistType == "artists")
filesExist = CDirectory::GetDirectory("special://musicplaylists/", list, ".xsp", false);
else // all others are video
filesExist = CDirectory::GetDirectory("special://videoplaylists/", list, ".xsp", false);
#define NT_STATUS_INVALID_HANDLE long(0xC0000000 | 0x0008)
#define NT_STATUS_ACCESS_DENIED long(0xC0000000 | 0x0022)
#define NT_STATUS_OBJECT_NAME_NOT_FOUND long(0xC0000000 | 0x0034)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define NT_STATUS_INVALID_COMPUTER_NAME long(0xC0000000 | 0x0122)
#endif
void Deinit();
void Purge();
void PurgeEx(const CURL& url);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
void CheckIfIdle();
void SetActivityTime();
void AddActiveConnection();
SMBCCTX *m_context;
CStdString m_strLastHost;
CStdString m_strLastShare;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
int m_OpenConnections;
unsigned int m_IdleTimeout;
#endif
#include "utils/log.h"
#include "utils/URIUtils.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <dirent.h>
#endif
// check for special-protocol, if not, return
if (!url.GetProtocol().Equals("special"))
{
-#if defined(_LINUX) && defined(_DEBUG)
+#if defined(TARGET_POSIX) && defined(_DEBUG)
CStdString path(url.Get());
if (path.length() >= 2 && path[1] == ':')
{
{
CStdString translatedPath = TranslatePath(path);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (translatedPath.Find("://") > 0)
return translatedPath;
static std::map<CStdString, CStdString> m_pathMap;
};
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define PATH_SEPARATOR_CHAR '\\'
#define PATH_SEPARATOR_STRING "\\"
#else
{
CStdString channel = path.Mid(9);
- if(!URIUtils::GetExtension(channel).Equals(".ts"))
+ if(!URIUtils::HasExtension(channel, ".ts"))
{
CLog::Log(LOGERROR, "%s - invalid channel url %s", __FUNCTION__, channel.c_str());
return false;
#include "storage/MediaManager.h"
#include "File.h"
#include "FileItem.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "WIN32Util.h"
#endif
#include "threads/SingleLock.h"
#include "IFile.h"
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
#include "storage/DetectDVDType.h" // for MODE2_DATA_SIZE etc.
#endif
#include <cdio/bytesex.h>
#include <string>
#include "system.h" // for win32 types
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// Ideally we should just be including iso9660.h, but it's not win32-ified at this point,
// and these are all we need
typedef uint32_t iso723_t;
//
//////////////////////////////////////////////////////////////////////
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#include "filesystem/IFile.h"
#include "utils/AutoPtrHandle.h"
#include "filesystem/SpecialProtocol.h"
#include "utils/EndianSwap.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
#else
#define fopen_utf8 fopen
void ParseTextureHeader(D3DTexture *tex, XB_D3DFORMAT &fmt, DWORD &width, DWORD &height, DWORD &pitch, DWORD &offset);
bool IsSwizzledFormat(XB_D3DFORMAT format);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
typedef unsigned __int32 uint32_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
#define SCROLLING_GAP 200U
#define SCROLLING_THRESHOLD 300U
-
-IGUIContainer::IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
-{
-}
-
-void IGUIContainer::SetType(VIEW_TYPE type, const CStdString &label)
-{
- m_type = type;
- m_label = label;
-}
-
CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems)
: IGUIContainer(parentID, controlID, posX, posY, width, height)
, m_scroller(scroller)
*
*/
-#include "GUIControl.h"
+#include "IGUIContainer.h"
#include "GUIListItemLayout.h"
-#include "boost/shared_ptr.hpp"
#include "utils/Stopwatch.h"
-typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
-
/*!
\ingroup controls
\brief
*/
-class IGUIContainer : public CGUIControl
-{
-protected:
- VIEW_TYPE m_type;
- CStdString m_label;
-public:
- IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height);
- virtual bool IsContainer() const { return true; };
-
- VIEW_TYPE GetType() const { return m_type; };
- const CStdString &GetLabel() const { return m_label; };
- void SetType(VIEW_TYPE type, const CStdString &label);
-
- virtual CGUIListItemPtr GetListItem(int offset, unsigned int flag = 0) const = 0;
- virtual CStdString GetLabel(int info) const = 0;
-};
-
class CGUIBaseContainer : public IGUIContainer
{
public:
this also marks the control as dirty (if needed)
*/
void SetOffset(int offset);
+ /*! \brief Returns the index of the first visible row
+ returns the first row. This may be outside of the range of available items. Use GetItemOffset() to retrieve the first visible item in the list.
+ \sa GetItemOffset
+ */
inline int GetOffset() const { return m_offset; };
+ /*! \brief Returns the index of the first visible item
+ returns the first visible item. This will always be in the range of available items. Use GetOffset() to retrieve the first visible row in the list.
+ \sa GetOffset
+ */
+ inline int GetItemOffset() const { return CorrectOffset(GetOffset(), 0); }
private:
int m_cursor;
void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
+ CGUIImage::Process(currentTime, dirtyregions);
if (!m_borderImage.GetFileName().IsEmpty() && m_texture.ReadyToRender())
{
CRect rect = CRect(m_texture.GetXPosition(), m_texture.GetYPosition(), m_texture.GetXPosition() + m_texture.GetWidth(), m_texture.GetYPosition() + m_texture.GetHeight());
if (m_borderImage.Process(currentTime))
MarkDirtyRegion();
}
- CGUIImage::Process(currentTime, dirtyregions);
}
void CGUIBorderedImage::Render()
{
GUIEvent<Cookie>::m_pInstance = (GUIEvent<Cookie>*) ((LPVOID) pInstance);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
// Its dirty but it works!
memcpy(&m_pMethod, &aMethodPtr, sizeof(GUIEvent<Cookie>::m_pMethod));
#else
const char *flipY = pNode->Attribute("flipy");
if (flipY && strcmpi(flipY, "true") == 0) image.orientation = 3 - image.orientation; // either 3 or 2
image.diffuse = pNode->Attribute("diffuse");
+ image.diffuseColor.Parse(pNode->Attribute("colordiffuse"), 0);
const char *background = pNode->Attribute("background");
if (background && strnicmp(background, "true", 4) == 0)
image.useLarge = true;
using namespace std;
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
extern HWND g_hWnd;
#endif
m_cursorPos+=strlen(szStr);
UpdateText();
}
-#elif defined _WIN32
+#elif defined TARGET_WINDOWS
if (OpenClipboard(g_hWnd))
{
HGLOBAL hglb = GetClipboardData(CF_TEXT);
if (!XFILE::CFile::Exists(strPath))
{
strPath = URIUtils::AddFileToFolder(newPath,filename);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
#endif
return false;
else
strPath = strFilename;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
#endif
{
CFileItemPtr pItem = items[i];
- if (!pItem->m_bIsFolder)
+ if (!pItem->m_bIsFolder
+ && URIUtils::HasExtension(pItem->GetLabel(), ".ttf"))
{
- if (!URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf"))
- continue;
-
list.push_back(make_pair(pItem->GetLabel(), pItem->GetLabel()));
}
}
#define USE_RELEASE_LIBS
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib, "freetype246MT.lib")
#endif
enum FILTERING { FILTERING_NONE = 0, FILTERING_CURRENT, FILTERING_SEARCH };
typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString);
-#ifdef _WIN32 // disable 4355: 'this' used in base member initializer list
+#ifdef TARGET_WINDOWS // disable 4355: 'this' used in base member initializer list
#pragma warning(push)
#pragma warning(disable: 4355)
#endif
CTimer m_idleTimer;
};
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma warning(pop)
#endif
return changed;
}
+bool CGUILabel::SetStyledText(const vecText &text, const vecColors &colors)
+{
+ m_textLayout.UpdateStyled(text, colors, m_maxRect.Width());
+ m_invalid = false;
+ return true;
+}
+
bool CGUILabel::SetText(const CStdString &label)
{
if (m_textLayout.Update(label, m_maxRect.Width(), m_invalid))
/*! \brief Set the text to be displayed in the label
Updates the label control and recomputes final position and size
\param text CStdString to set as this labels text
- \sa SetTextW
+ \sa SetTextW, SetStyledText
*/
bool SetText(const CStdString &label);
/*! \brief Set the text to be displayed in the label
Updates the label control and recomputes final position and size
\param text CStdStringW to set as this labels text
- \sa SetText
+ \sa SetText, SetStyledText
*/
bool SetTextW(const CStdStringW &label);
-
+
+ /*! \brief Set styled text to be displayed in the label
+ Updates the label control and recomputes final position and size
+ \param text styled text to set.
+ \param colors colors referenced in the styled text.
+ \sa SetText, SetTextW
+ */
+ bool SetStyledText(const vecText &text, const vecColors &colors);
+
/*! \brief Set the color to use for the label
Sets the color to be used for this label. Takes effect at the next render
\param color color to be used for the label
{
CStdString label(m_infoLabel.GetLabel(m_parentID));
- if (m_startHighlight < m_endHighlight || m_startSelection < m_endSelection)
+ bool changed = false;
+ if (m_startHighlight < m_endHighlight || m_startSelection < m_endSelection || m_bShowCursor)
{
CStdStringW utf16;
g_charsetConverter.utf8ToW(label, utf16);
-
- std::vector<InsertPointInfo> insertPoints;
- if (m_bShowCursor)
- {
- CStdStringW col;
- if ((++m_dwCounter % 50) > 25)
- col.Format(L"[COLOR %x]|[/COLOR]", (color_t)m_label.GetLabelInfo().textColor);
- else
- col = L"[COLOR 00FFFFFF]|[/COLOR]";
- InsertPointInfo info = {m_iCursorPos, InsertPointInfo::HEAD_AND_TAIL, 0, 0, col};
- insertPoints.push_back(info);
- }
- CStdStringW tmp;
- if (m_startHighlight < m_endHighlight)
- {
- if (m_startHighlight > 0 && m_startHighlight <= utf16.size())
- {
- tmp.Format(L"[COLOR %x]", (color_t)m_label.GetLabelInfo().disabledColor);
- InsertPointInfo infoH = {0, InsertPointInfo::HEAD, m_startHighlight, 0, tmp};
- InsertPointInfo infoT = {m_startHighlight, InsertPointInfo::TAIL, m_startHighlight, 0, L"[/COLOR]"};
- insertPoints.push_back(infoH);
- insertPoints.push_back(infoT);
- }
- if (m_endHighlight < utf16.size())
- {
- tmp.Format(L"[COLOR %x]", (color_t)m_label.GetLabelInfo().disabledColor);
- InsertPointInfo infoH = {m_endHighlight, InsertPointInfo::HEAD, utf16.size() - m_endHighlight, 0, tmp};
- InsertPointInfo infoT = {utf16.size(), InsertPointInfo::TAIL, utf16.size() - m_endHighlight, 0, L"[/COLOR]"};
- insertPoints.push_back(infoH);
- insertPoints.push_back(infoT);
- }
- }
- if (m_startSelection < m_endSelection && m_endSelection <= utf16.size())
+ vecText text; text.reserve(utf16.size()+1);
+ vecColors colors;
+ colors.push_back(m_label.GetLabelInfo().textColor);
+ colors.push_back(m_label.GetLabelInfo().disabledColor);
+ color_t select = m_label.GetLabelInfo().selectedColor;
+ if (!select)
+ select = 0xFFFF0000;
+ colors.push_back(select);
+ colors.push_back(0xFF000000);
+ for (unsigned int i = 0; i < utf16.size(); i++)
{
- color_t selectedColor = m_label.GetLabelInfo().selectedColor;
- if (!selectedColor)
- selectedColor = 0xFFFFFF00;
- tmp.Format(L"[COLOR %x]", selectedColor);
- // we set selection insert point higher priority than the highlight disable block, so it is still show the selection
- InsertPointInfo infoH = {m_startSelection, InsertPointInfo::HEAD, m_startSelection - m_endSelection, 1, tmp};
- InsertPointInfo infoT = {m_endSelection, InsertPointInfo::TAIL, m_startSelection - m_endSelection, 1, L"[/COLOR]"};
- insertPoints.push_back(infoH);
- insertPoints.push_back(infoT);
+ unsigned int ch = utf16[i];
+ if ((m_startSelection < m_endSelection) && (m_startSelection <= i && i < m_endSelection))
+ ch |= (2 << 16);
+ else if ((m_startHighlight < m_endHighlight) && (i < m_startHighlight || i >= m_endHighlight))
+ ch |= (1 << 16);
+ text.push_back(ch);
}
-
- // we sort the insert points to make sure small color block is nested in larger block
- std::sort(insertPoints.begin(), insertPoints.end());
-
- // insert the styles from back to front, so we can use the correct insert points.
- for (int i = insertPoints.size() - 1; i >= 0; --i)
+ if (m_bShowCursor && m_iCursorPos >= 0 && (unsigned int)m_iCursorPos <= utf16.size())
{
- const InsertPointInfo &insertPointInfo = insertPoints[i];
- utf16.Insert(insertPointInfo.pos, insertPointInfo.text);
+ unsigned int ch = L'|';
+ if ((++m_dwCounter % 50) <= 25)
+ ch |= (3 << 16);
+ text.insert(text.begin() + m_iCursorPos, ch);
}
- g_charsetConverter.wToUTF8(utf16, label);
+ changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+ changed |= m_label.SetStyledText(text, colors);
}
- else if (m_bShowCursor)
- { // cursor location assumes utf16 text, so deal with that (inefficient, but it's not as if it's a high-use area
- // virtual keyboard only)
- CStdStringW utf16;
- g_charsetConverter.utf8ToW(label, utf16);
- CStdStringW col;
- if ((++m_dwCounter % 50) > 25)
- col = L"|";
- else
- col = L"[COLOR 00FFFFFF]|[/COLOR]";
- utf16.Insert(m_iCursorPos, col);
- g_charsetConverter.wToUTF8(utf16, label);
- }
- else if (m_bHasPath)
- label = ShortenPath(label);
-
- bool changed = false;
-
- changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
- changed |= m_label.SetText(label);
+ else
+ {
+ if (m_bHasPath)
+ label = ShortenPath(label);
+ changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+ changed |= m_label.SetText(label);
+ }
if (changed)
MarkDirtyRegion();
}
if (text.Equals(m_lastText) && !forceUpdate)
return false;
+ // parse the text for style information
vecText parsedText;
+ vecColors colors;
+ ParseText(text, m_font ? m_font->GetStyle() : 0, m_textColor, colors, parsedText);
+
+ // and update
+ UpdateStyled(parsedText, colors, maxWidth, forceLTRReadingOrder);
+ m_lastText = text;
+ return true;
+}
+void CGUITextLayout::UpdateStyled(const vecText &text, const vecColors &colors, float maxWidth, bool forceLTRReadingOrder)
+{
// empty out our previous string
m_lines.clear();
- m_colors.clear();
- m_colors.push_back(m_textColor);
-
- // parse the text into our string objects
- ParseText(text, parsedText);
-
- // add \n to the end of the string
- parsedText.push_back(L'\n');
+ m_colors = colors;
// if we need to wrap the text, then do so
if (m_wrap && maxWidth > 0)
- WrapText(parsedText, maxWidth);
+ WrapText(text, maxWidth);
else
- LineBreakText(parsedText, m_lines);
+ LineBreakText(text, m_lines);
// remove any trailing blank lines
while (!m_lines.empty() && m_lines.back().m_text.empty())
// and cache the width and height for later reading
CalcTextExtent();
-
- m_lastText = text;
- return true;
}
// BidiTransform is used to handle RTL text flipping in the string
utf8ToW(text, utf16);
vecColors colors;
vecText parsedText;
- ParseText(utf16, 0, colors, parsedText);
+ ParseText(utf16, 0, 0xffffffff, colors, parsedText);
utf16.Empty();
for (unsigned int i = 0; i < parsedText.size(); i++)
utf16 += (wchar_t)(0xffff & parsedText[i]);
g_charsetConverter.wToUTF8(utf16, text);
}
-void CGUITextLayout::ParseText(const CStdStringW &text, vecText &parsedText)
-{
- if (!m_font)
- return;
- ParseText(text, m_font->GetStyle(), m_colors, parsedText);
-}
-
-void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText)
+void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText)
{
// run through the string, searching for:
// [B] or [/B] -> toggle bold on and off
uint32_t currentStyle = defaultStyle; // start with the default font's style
color_t currentColor = 0;
+ colors.push_back(defaultColor);
stack<color_t> colorStack;
colorStack.push(0);
}
pos++;
}
+ // handle the last line if non-empty
+ if (lineStart < text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
+ {
+ CGUIString string(lineStart, text.end(), true);
+ lines.push_back(string);
+ }
}
void CGUITextLayout::GetTextExtent(float &width, float &height) const
bool Update(const CStdString &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
bool UpdateW(const CStdStringW &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
+ /*! \brief Update text from a pre-styled vecText/vecColors combination
+ Allows styled text to be passed directly to the text layout.
+ \param text the styled text to set.
+ \param colors the colors used on the text.
+ \param maxWidth the maximum width for wrapping text, defaults to 0 (no max width).
+ \param forceLTRReadingOrder whether to force left to right reading order, defaults to false.
+ */
+ void UpdateStyled(const vecText &text, const vecColors &colors, float maxWidth = 0, bool forceLTRReadingOrder = false);
+
unsigned int GetTextLength() const;
void GetFirstText(vecText &text) const;
void Reset();
static void Filter(CStdString &text);
protected:
- void ParseText(const CStdStringW &text, vecText &parsedText);
void LineBreakText(const vecText &text, std::vector<CGUIString> &lines);
void WrapText(const vecText &text, float maxWidth);
void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder);
};
static void AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32);
static void AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32);
- static void ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText);
+ static void ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText);
static void utf8ToW(const CStdString &utf8, CStdStringW &utf16);
};
diffuse = right.diffuse;
filename = right.filename;
useLarge = right.useLarge;
+ diffuseColor = right.diffuseColor;
return *this;
}
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+
+ // diffuse color
+ color_t color = (m_info.diffuseColor) ? (color_t)m_info.diffuseColor : m_diffuseColor;
+ if (m_alpha != 0xFF)
+ color = MIX_ALPHA(m_alpha, color);
+
color = g_graphicsContext.MergeAlpha(color);
// setup our renderer
{
bool changed = m_diffuseColor != color;
m_diffuseColor = color;
+ changed |= m_info.diffuseColor.Update();
return changed;
}
#include "TextureManager.h"
#include "Geometry.h"
#include "system.h" // HAS_GL, HAS_DX, etc
+#include "GUIInfoTypes.h"
typedef uint32_t color_t;
CTextureInfo(const CStdString &file);
CTextureInfo& operator=(const CTextureInfo &right);
bool useLarge;
- CRect border; // scaled - unneeded if we get rid of scale on load
- int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
- CStdString diffuse; // diffuse overlay texture
- CStdString filename; // main texture file
+ CRect border; // scaled - unneeded if we get rid of scale on load
+ int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
+ CStdString diffuse; // diffuse overlay texture
+ CGUIInfoColor diffuseColor; // diffuse color
+ CStdString filename; // main texture file
};
class CGUITextureBase
if (g_advancedSettings.m_fullScreen)
{
-#if defined (TARGET_DARWIN) || defined (_WIN32)
+#if defined (TARGET_DARWIN) || defined (TARGET_WINDOWS)
bool blankOtherDisplays = CSettings::Get().GetBool("videoscreen.blankdisplays");
g_Windowing.SetFullScreen(true, CDisplaySettings::Get().GetResolutionInfo(res), blankOtherDisplays);
#else
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "GUIControl.h"
+#include "boost/shared_ptr.hpp"
+
+typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
+
+/*!
+ \ingroup controls
+ \brief
+ */
+
+class IGUIContainer : public CGUIControl
+{
+protected:
+ VIEW_TYPE m_type;
+ CStdString m_label;
+public:
+ IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height)
+ : CGUIControl(parentID, controlID, posX, posY, width, height), m_type(VIEW_TYPE_NONE) {}
+
+ virtual bool IsContainer() const { return true; };
+
+ VIEW_TYPE GetType() const { return m_type; };
+ const CStdString &GetLabel() const { return m_label; };
+ void SetType(VIEW_TYPE type, const CStdString &label)
+ {
+ m_type = type;
+ m_label = label;
+ }
+
+ virtual CGUIListItemPtr GetListItem(int offset, unsigned int flag = 0) const = 0;
+ virtual CStdString GetLabel(int info) const = 0;
+};
bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate)
{
#if defined(HAS_OMXPLAYER)
- if (URIUtils::GetExtension(texturePath).Equals(".jpg") ||
- URIUtils::GetExtension(texturePath).Equals(".tbn")
- /*|| URIUtils::GetExtension(texturePath).Equals(".png")*/)
+ if (URIUtils::HasExtension(texturePath, ".jpg|.tbn")
+ /*|| URIUtils::HasExtension(texturePath, ".png")*/)
{
COMXImage omx_image;
omx_image.ClampLimits(maxWidth, maxHeight);
}
#endif
- if (URIUtils::GetExtension(texturePath).Equals(".dds"))
+ if (URIUtils::HasExtension(texturePath, ".dds"))
{ // special case for DDS images
CDDSImage image;
if (image.ReadFile(texturePath))
#include "XBTF.h"
#include <lzo/lzo1x.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib,"liblzo2.lib")
#endif
#include "GraphicContext.h"
#include "DirectXGraphics.h"
#include "utils/log.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <sys/stat.h>
#include "utils/CharsetConverter.h"
#endif
#include "utils/EndianSwap.h"
#include "utils/URIUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib,"liblzo2.lib")
#endif
strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
CStdStringW strPathW;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strPath), strPathW, false);
m_hFile = _wfopen(strPathW.c_str(), L"rb");
if (!buffer || !UnpackedBuf.Set((BYTE*)XPhysicalAlloc(file->second.UnpackedSize, MAXULONG_PTR, 128, PAGE_READWRITE)))
{ // failed due to lack of memory
-#ifndef _LINUX
+#ifndef TARGET_POSIX
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat);
CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %lu bytes, have %"PRIu64" bytes)", name.c_str(),
file->second.UnpackedSize + file->second.PackedSize, stat.ullAvailPhys);
-#elif defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#elif defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %d bytes)", name.c_str(),
file->second.UnpackedSize + file->second.PackedSize);
#else
#include "XBTFReader.h"
#include "utils/EndianSwap.h"
#include "utils/CharsetConverter.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "FileSystem/SpecialProtocol.h"
#endif
{
m_fileName = fileName;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
CStdStringW strPathW;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(m_fileName), strPathW, false);
m_file = _wfopen(strPathW.c_str(), L"rb");
{
return false;
}
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
if (fseeko(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
#else
if (fseeko64(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
*
*/
-#include "system.h" // for WIN32 types
+#include "system.h" // for TARGET_WINDOWS types
#define GAMMA_RAMP_FLAG D3DSGR_CALIBRATE
{ WINDOW_DIALOG_FULLSCREEN_INFO, WINDOW_FULLSCREEN_VIDEO }
};
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
static const ActionMapping appcommands[] =
{
{ "browser_back", APPCOMMAND_BROWSER_BACKWARD },
}
#if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define REMOTEMAP "Lircmap.xml"
#else
#define REMOTEMAP "IRSSmap.xml"
#if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE)
bool CButtonTranslator::LoadLircMap(const CStdString &lircmapPath)
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define REMOTEMAPTAG "lircmap"
#else
#define REMOTEMAPTAG "irssmap"
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
-#ifdef _LINUX
+#ifdef TARGET_POSIX
// Some buttoncodes changed in Hardy
if (action == 0 && (code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
{
uint32_t CButtonTranslator::TranslateAppCommand(const char *szButton)
{
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
CStdString strAppCommand = szButton;
strAppCommand.ToLower();
// Comment OUT, if not really debugging!!!
// #define DEBUG_KEYBOARD_GETCHAR
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/PlatformDefs.h"
-#elif defined (WIN32)
+#elif defined (TARGET_WINDOWS)
#include "windows.h"
#else
#include "xtl.h"
// maximum time between touch down and up (in nanoseconds)
#define SWIPE_MAX_TIME 500000000
// maxmium swipe distance between touch down and up (in multiples of screen DPI)
-#define SWIPE_MIN_DISTANCE 0.5
+#define SWIPE_MIN_DISTANCE 0.5f
// original maximum variance of the touch movement
-#define SWIPE_MAX_VARIANCE 0.2
+#define SWIPE_MAX_VARIANCE 0.2f
// tangens of the maximum angle (20 degrees) the touch movement may vary in a
// direction perpendicular to the swipe direction (in radians)
// => tan(20 deg) = tan(20 * M_PI / 180)
-#define SWIPE_MAX_VARIANCE_ANGLE 0.363970234266
+#define SWIPE_MAX_VARIANCE_ANGLE 0.36397023f
CGenericTouchSwipeDetector::CGenericTouchSwipeDetector(ITouchActionHandler *handler, float dpi)
: IGenericTouchGestureDetector(handler, dpi),
{ "Suspend", false, "Suspends the system" },
{ "InhibitIdleShutdown", false, "Inhibit idle shutdown" },
{ "AllowIdleShutdown", false, "Allow idle shutdown" },
+ { "ActivateScreensaver", false, "Activate Screensaver" },
{ "RestartApp", false, "Restart XBMC" },
{ "Minimize", false, "Minimize XBMC" },
{ "Reset", false, "Reset the system (same as reboot)" },
{ "Mastermode", false, "Control master mode" },
+ { "SetGUILanguage", true, "Set GUI Language" },
{ "ActivateWindow", true, "Activate the specified window" },
{ "ActivateWindowAndFocus", true, "Activate the specified window and sets focus to the specified id" },
{ "ReplaceWindowAndFocus", true, "Replaces the current window with the new one and sets focus to the specified id" },
bool inhibit = (params.size() == 1 && params[0].Equals("true"));
CApplicationMessenger::Get().InhibitIdleShutdown(inhibit);
}
+ else if (execute.Equals("activatescreensaver"))
+ {
+ CApplicationMessenger::Get().ActivateScreensaver();
+ }
else if (execute.Equals("minimize"))
{
CApplicationMessenger::Get().Minimize();
CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
g_windowManager.SendMessage(msg);
}
+ else if (execute.Equals("setguilanguage"))
+ {
+ if (params.size())
+ {
+ CApplicationMessenger::Get().SetGUILanguage(params[0]);
+ }
+ }
else if (execute.Equals("takescreenshot"))
{
CScreenShot::TakeScreenshot();
{
// disable the screensaver
g_application.WakeUpScreenSaverAndDPMS();
-#if defined(__APPLE__) && defined(__arm__)
+#if defined(TARGET_DARWIN_IOS)
if (params[0].Equals("shutdownmenu"))
CBuiltins::Execute("Quit");
#endif
else if (execute.Equals("runscript") && params.size())
{
#if defined(TARGET_DARWIN_OSX)
- if (URIUtils::GetExtension(strParameterCaseIntact) == ".applescript" ||
- URIUtils::GetExtension(strParameterCaseIntact) == ".scpt")
+ if (URIUtils::HasExtension(strParameterCaseIntact, ".applescript|.scpt"))
{
CStdString osxPath = CSpecialProtocol::TranslatePath(strParameterCaseIntact);
Cocoa_DoAppleScriptFile(osxPath.c_str());
*/
#include "FavouritesOperations.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
#include "input/ButtonTranslator.h"
#include "utils/RegExp.h"
#include "utils/StringUtils.h"
using namespace std;
using namespace JSONRPC;
+using namespace XFILE;
JSONRPC_STATUS CFavouritesOperations::GetFavourites(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CFileItemList favourites;
- CFavourites::Load(favourites);
+ CFavouritesDirectory::Load(favourites);
string type = !parameterObject["type"].isNull() ? parameterObject["type"].asString() : "";
if (ParameterNotNull(parameterObject,"thumbnail"))
item.SetArt("thumb", parameterObject["thumbnail"].asString());
- if (CFavourites::AddOrRemove(&item, contextWindow))
+ if (CFavouritesDirectory::AddOrRemove(&item, contextWindow))
return ACK;
else
return FailedToExecute;
#include "Util.h"
#include "URL.h"
#include "utils/URIUtils.h"
+#include "utils/FileUtils.h"
using namespace XFILE;
using namespace JSONRPC;
-static const unsigned int SourcesSize = 5;
-static CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
-
JSONRPC_STATUS CFileOperations::GetRootDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CStdString media = parameterObject["media"].asString();
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
- // Check if this directory is part of a source and whether it's locked
- bool isSource;
- for (unsigned int index = 0; index < SourcesSize; index++)
- {
- VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
- int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource);
- if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2)
- return InvalidParams;
- }
+ if (!CFileUtils::RemoteAccessAllowed(strPath))
+ return InvalidParams;
CStdStringArray regexps;
CStdString extensions = "";
if (!CFile::Exists(file))
return InvalidParams;
+ if (!CFileUtils::RemoteAccessAllowed(file))
+ return InvalidParams;
+
CStdString path;
URIUtils::GetDirectory(file, path);
#include "pvr/channels/PVRChannel.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "cores/IPlayer.h"
+#include "settings/MediaSettings.h"
using namespace JSONRPC;
using namespace PLAYLIST;
if (g_application.m_pPlayer)
{
result = CVariant(CVariant::VariantTypeObject);
- int index = g_application.m_pPlayer->GetSubtitle();
+ int index = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
if (index >= 0)
{
SPlayerSubtitleStreamInfo info;
return value;
}
- void Dialog::notification(const String& heading, const String& message, const String& icon, int time)
+ void Dialog::notification(const String& heading, const String& message, const String& icon, int time, bool sound)
{
DelayedCallGuard dcguard(languageHook);
strIcon = icon;
if (strIcon.Equals(getNOTIFICATION_INFO()))
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, iTime);
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, iTime, sound);
else if (strIcon.Equals(getNOTIFICATION_WARNING()))
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, heading, message, iTime);
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, heading, message, iTime, sound);
else if (strIcon.Equals(getNOTIFICATION_ERROR()))
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, iTime);
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, iTime, sound);
else
- CGUIDialogKaiToast::QueueNotification(strIcon, heading, message, iTime);
+ CGUIDialogKaiToast::QueueNotification(strIcon, heading, message, iTime, sound);
}
DialogProgress::~DialogProgress() { TRACE; deallocating(); }
String numeric(int type, const String& heading, const String& defaultt = emptyString);
/**
- * notification(heading, message[, icon, time]) -- Show a Notification alert.
+ * notification(heading, message[, icon, time, sound]) -- Show a Notification alert.
*
* heading : string - dialog heading.
* message : string - dialog message.
* icon : [opt] string - icon to use. (default xbmcgui.NOTIFICATION_INFO)
* time : [opt] integer - time in milliseconds (default 5000)
+ * sound : [opt] bool - play notification sound (default True)
*
* Builtin Icons:
* xbmcgui.NOTIFICATION_INFO
* - dialog = xbmcgui.Dialog()
* - dialog.notification('Movie Trailers', 'Finding Nemo download finished.', xbmcgui.NOTIFICATION_INFO, 5000)\n
*/
- void notification(const String& heading, const String& message, const String& icon = emptyString, int time = 0);
+ void notification(const String& heading, const String& message, const String& icon = emptyString, int time = 0, bool sound = true);
};
/**
// TODO: Need a uniform way of returning an error status
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "network/Network.h"
#include "AddonUtils.h"
#include "utils/log.h"
#include "cores/IPlayer.h"
+#include "settings/MediaSettings.h"
namespace XBMCAddon
{
if (g_application.m_pPlayer)
{
SPlayerSubtitleStreamInfo info;
- g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info);
+ g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
if (info.language.length() > 0)
return info.language;
* the call will wrongly proceed back to the xbmc core side rather than
* to the Addon API side.
*/
- bool up() { bool ret = (upcallTls.get() != NULL); upcallTls.set(NULL); return ret; }
+ static bool up() { bool ret = (upcallTls.get() != NULL); upcallTls.set(NULL); return ret; }
public:
virtual ~InterceptorBase() { if (window.isNotNull()) { window->interceptorClear(); } }
#include "WindowInterceptor.h"
#include "guilib/GUIWindowManager.h"
+#include "guilib/TextureManager.h"
#include "settings/Settings.h"
#include "addons/Skin.h"
#include "filesystem/File.h"
#pragma once
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "utils/CharsetConverter.h"
#include "PyContext.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
#else
#define fopen_utf8 fopen
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "utils/TimeUtils.h"
#include "Util.h"
#include "guilib/GraphicContext.h"
+#ifdef TARGET_WINDOWS
+#include "utils/Environment.h"
+#endif
#include "threads/SystemClock.h"
#include "addons/Addon.h"
if (!m_bInitialized)
{
// first we check if all necessary files are installed
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if(!FileExist("special://xbmc/system/python/DLLs/_socket.pyd") ||
!FileExist("special://xbmc/system/python/DLLs/_ssl.pyd") ||
!FileExist("special://xbmc/system/python/DLLs/bz2.pyd") ||
// Info about interesting python envvars available
// at http://docs.python.org/using/cmdline.html#environment-variables
-#if !defined(_WIN32) && !defined(TARGET_ANDROID)
+#if !defined(TARGET_WINDOWS) && !defined(TARGET_ANDROID)
/* PYTHONOPTIMIZE is set off intentionally when using external Python.
Reason for this is because we cannot be sure what version of Python
was used to compile the various Python object files (i.e. .pyo,
CLog::Log(LOGDEBUG, "PYTHONPATH -> %s", CSpecialProtocol::TranslatePath("special://frameworks").c_str());
}
setenv("PYTHONCASEOK", "1", 1); //This line should really be removed
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
// because the third party build of python is compiled with vs2008 we need
// a hack to set the PYTHONPATH
- // buf is corrupted after putenv and might need a strdup but it seems to
- // work this way
CStdString buf;
buf = "PYTHONPATH=" + CSpecialProtocol::TranslatePath("special://xbmc/system/python/DLLs") + ";" + CSpecialProtocol::TranslatePath("special://xbmc/system/python/Lib");
- pgwin32_putenv(buf.c_str());
+ CEnvironment::putenv(buf);
buf = "PYTHONOPTIMIZE=1";
- pgwin32_putenv(buf.c_str());
+ CEnvironment::putenv(buf);
buf = "PYTHONHOME=" + CSpecialProtocol::TranslatePath("special://xbmc/system/python");
- pgwin32_putenv(buf.c_str());
+ CEnvironment::putenv(buf);
buf = "OS=win32";
- pgwin32_putenv(buf.c_str());
+ CEnvironment::putenv(buf);
#elif defined(TARGET_ANDROID)
CStdString apkPath = getenv("XBMC_ANDROID_APK");
PyEval_ReleaseLock();
}
-#if !(defined(TARGET_DARWIN) || defined(_WIN32))
+#if !(defined(TARGET_DARWIN) || defined(TARGET_WINDOWS))
UnloadExtensionLibs();
#endif
// first free all dlls loaded by python, after that python24.dll (this is done by UnloadPythonDlls
-#if !(defined(TARGET_DARWIN) || defined(_WIN32))
+#if !(defined(TARGET_DARWIN) || defined(TARGET_WINDOWS))
DllLoaderContainer::UnloadPythonDlls();
#endif
-#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
// we can't release it on windows, as this is done in UnloadPythonDlls() for win32 (see above).
// The implementation for linux needs looking at - UnloadPythonDlls() currently only searches for "python24.dll"
// The implementation for osx can never unload the python dylib.
#include "PlatformDefs.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <stdio.h>
#include <ctype.h>
#if defined(TARGET_DARWIN)
#include "osx/OSXGNUReplacements.h"
#endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include "freebsd/FreeBSDGNUReplacements.h"
#endif
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
#include "OMXClock.h"
#include "utils/MathUtils.h"
-int64_t OMXClock::m_systemOffset;
-int64_t OMXClock::m_systemFrequency;
-bool OMXClock::m_ismasterclock;
-
#define OMX_PRE_ROLL 800
OMXClock::OMXClock()
m_audio_start = false;
m_pause = false;
- m_systemOffset = 0;
- m_systemFrequency = 0;
- m_startClock = 0;
-
- CheckSystemClock();
-
- m_systemUsed = m_systemFrequency;
- m_pauseClock = 0;
- m_bReset = true;
- m_iDisc = 0;
- m_maxspeedadjust = 0.0;
- m_speedadjust = false;
- m_ismasterclock = true;
- m_ClockOffset = 0;
m_fps = 25.0f;
m_omx_speed = DVD_PLAYSPEED_NORMAL;
m_audio_buffer = false;
+ m_clock = NULL;
pthread_mutex_init(&m_lock, NULL);
}
pthread_mutex_unlock(&m_lock);
}
-double OMXClock::GetAbsoluteClock(bool interpolated /*= true*/)
-{
- Lock();
- CheckSystemClock();
-
- int64_t current;
- current = g_VideoReferenceClock.GetTime(interpolated);
-
- UnLock();
- return SystemToAbsolute(current);
-}
-
-double OMXClock::WaitAbsoluteClock(double target)
-{
- Lock();
- CheckSystemClock();
-
- int64_t systemtarget, freq, offset;
- freq = m_systemFrequency;
- offset = m_systemOffset;
- UnLock();
-
- systemtarget = (int64_t)(target / DVD_TIME_BASE * (double)freq);
- systemtarget += offset;
- systemtarget = g_VideoReferenceClock.Wait(systemtarget);
- systemtarget -= offset;
- return (double)systemtarget / freq * DVD_TIME_BASE;
-}
-
-// Returns the current absolute clock in units of DVD_TIME_BASE (usually microseconds).
-void OMXClock::CheckSystemClock()
-{
- if(!m_systemFrequency)
- m_systemFrequency = g_VideoReferenceClock.GetFrequency();
-
- if(!m_systemOffset)
- m_systemOffset = g_VideoReferenceClock.GetTime();
-}
-
-double OMXClock::GetClock(bool interpolated /*= true*/)
-{
- Lock();
- double clock = SystemToPlaying(g_VideoReferenceClock.GetTime(interpolated));
- UnLock();
- return clock;
-}
-
-double OMXClock::GetClock(double& absolute, bool interpolated /*= true*/)
-{
- int64_t current = g_VideoReferenceClock.GetTime(interpolated);
-
- Lock();
- CheckSystemClock();
- absolute = SystemToAbsolute(current);
- current = SystemToPlaying(current);
- UnLock();
-
- return current;
-}
-
-void OMXClock::SetSpeed(int iSpeed)
-{
- // this will sometimes be a little bit of due to rounding errors, ie clock might jump abit when changing speed
- Lock();
-
- if(iSpeed == DVD_PLAYSPEED_PAUSE)
- {
- if(!m_pauseClock)
- m_pauseClock = g_VideoReferenceClock.GetTime();
- UnLock();
- return;
- }
-
- int64_t current;
- int64_t newfreq = m_systemFrequency * DVD_PLAYSPEED_NORMAL / iSpeed;
-
- current = g_VideoReferenceClock.GetTime();
- if( m_pauseClock )
- {
- m_startClock += current - m_pauseClock;
- m_pauseClock = 0;
- }
-
- m_startClock = current - (int64_t)((double)(current - m_startClock) * newfreq / m_systemUsed);
- m_systemUsed = newfreq;
- UnLock();
-}
-
-void OMXClock::Discontinuity(double currentPts)
-{
- Lock();
- m_startClock = g_VideoReferenceClock.GetTime();
- if(m_pauseClock)
- m_pauseClock = m_startClock;
- m_iDisc = currentPts;
- m_bReset = false;
- UnLock();
-}
-
-void OMXClock::Pause()
-{
- Lock();
- if(!m_pauseClock)
- m_pauseClock = g_VideoReferenceClock.GetTime();
- UnLock();
-}
-
-void OMXClock::Resume()
-{
- Lock();
- if( m_pauseClock )
- {
- int64_t current;
- current = g_VideoReferenceClock.GetTime();
-
- m_startClock += current - m_pauseClock;
- m_pauseClock = 0;
- }
- UnLock();
-}
-
-bool OMXClock::SetMaxSpeedAdjust(double speed)
-{
- Lock();
- m_maxspeedadjust = speed;
- UnLock();
- return m_speedadjust;
-}
-
-//returns the refreshrate if the videoreferenceclock is running, -1 otherwise
-int OMXClock::UpdateFramerate(double fps, double* interval /*= NULL*/)
-{
- //sent with fps of 0 means we are not playing video
- if(fps == 0.0)
- {
- Lock();
- m_speedadjust = false;
- UnLock();
- return -1;
- }
-
- //check if the videoreferenceclock is running, will return -1 if not
- int rate = g_VideoReferenceClock.GetRefreshRate(interval);
-
- if (rate <= 0)
- return -1;
-
- Lock();
-
- m_speedadjust = true;
-
- double weight = (double)rate / (double)MathUtils::round_int(fps);
-
- //set the speed of the videoreferenceclock based on fps, refreshrate and maximum speed adjust set by user
- if (m_maxspeedadjust > 0.05)
- {
- if (weight / MathUtils::round_int(weight) < 1.0 + m_maxspeedadjust / 100.0
- && weight / MathUtils::round_int(weight) > 1.0 - m_maxspeedadjust / 100.0)
- weight = MathUtils::round_int(weight);
- }
- double speed = (double)rate / (fps * weight);
- UnLock();
-
- g_VideoReferenceClock.SetSpeed(speed);
-
- return rate;
-}
-
-double OMXClock::SystemToAbsolute(int64_t system)
-{
- return DVD_TIME_BASE * (double)(system - m_systemOffset) / m_systemFrequency;
-}
-
-double OMXClock::SystemToPlaying(int64_t system)
-{
- int64_t current;
-
- if (m_bReset)
- {
- m_startClock = system;
- m_systemUsed = m_systemFrequency;
- m_pauseClock = 0;
- m_iDisc = 0;
- m_bReset = false;
- }
-
- if (m_pauseClock)
- current = m_pauseClock;
- else
- current = system;
-
- return DVD_TIME_BASE * (double)(current - m_startClock) / m_systemUsed + m_iDisc;
-}
-
void OMXClock::OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock)
{
if(m_omx_clock.GetComponent() == NULL)
return ret;
}
-bool OMXClock::OMXInitialize(bool has_video, bool has_audio)
+bool OMXClock::OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio)
{
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
std::string componentName = "";
m_has_video = has_video;
m_pause = false;
m_audio_buffer = false;
+ m_clock = clock;
+
componentName = "OMX.broadcom.clock";
if(!m_omx_clock.Initialize((const std::string)componentName, OMX_IndexParamOtherInit))
return false;
m_omx_clock.DisableAllPorts();
- /*
- if(!OMXSetReferenceClock(false))
- return false;
-
- OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
- OMX_INIT_STRUCTURE(clock);
-
- clock.eState = OMX_TIME_ClockStateWaitingForStartTime;
- clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
- if(omx_err != OMX_ErrorNone)
- CLog::Log(LOGWARNING, "OMXClock::OMXInitialize setting OMX_IndexConfigTimeClockState\n");
- */
-
return true;
}
m_omx_speed = DVD_PLAYSPEED_NORMAL;
}
-bool OMXClock::OMXStatePause(bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return false;
-
- if(lock)
- Lock();
-
- if(m_omx_clock.GetState() != OMX_StatePause)
- {
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- omx_err = m_omx_clock.SetStateForComponent(OMX_StatePause);
- if (omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::StatePause m_omx_clock.SetStateForComponent\n");
- if(lock)
- UnLock();
- return false;
- }
- }
-
- if(lock)
- UnLock();
-
- return true;
-}
-
bool OMXClock::OMXStateExecute(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
}
}
- /*
- if(m_has_audio)
- {
- omx_err = m_omx_clock.EnablePort(m_omx_clock.GetInputPort(), true);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::StateExecute - Error enable port %d on component %s omx_err(0x%08x)",
- m_omx_clock.GetInputPort(), m_omx_clock.GetName().c_str(), (int)omx_err);
- }
- }
-
- if(m_has_video)
- {
- omx_err = m_omx_clock.EnablePort(m_omx_clock.GetInputPort() + 1, true);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::StateExecute - Error enable port %d on component %s omx_err(0x%08x)",
- m_omx_clock.GetInputPort(), m_omx_clock.GetName().c_str(), (int)omx_err);
- }
- }
-
- OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
- OMX_INIT_STRUCTURE(clock);
-
- clock.eState = OMX_TIME_ClockStateWaitingForStartTime;
- clock.nStartTime = ToOMXTime(0LL);
- clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);
- clock.nWaitMask = 0;
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::OMXStateExecute error setting OMX_IndexConfigTimeClockState\n");
- }
- */
-
- //OMXStart(lock);
-
if(lock)
UnLock();
return &m_omx_clock;
}
-void OMXClock::OMXSaveState(bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return;
-
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_INIT_STRUCTURE(m_clock_state);
-
- omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeClockState, &m_clock_state);
- if(omx_err != OMX_ErrorNone)
- CLog::Log(LOGERROR, "OMXClock::SaveState error geting OMX_IndexConfigTimeClockState\n");
-
- if(lock)
- UnLock();
-}
-
-void OMXClock::OMXRestoreState(bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return;
-
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &m_clock_state);
- if(omx_err != OMX_ErrorNone)
- CLog::Log(LOGERROR, "OMXClock::RestoreState error setting OMX_IndexConfigTimeClockState\n");
-
- if(lock)
- UnLock();
-}
-
bool OMXClock::OMXStop(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
-
+
if(lock)
Lock();
UnLock();
};
+bool OMXClock::OMXStep(int steps /* = 1 */, bool lock /* = true */)
+{
+ if(m_omx_clock.GetComponent() == NULL)
+ return false;
+
+ if(lock)
+ Lock();
+
+ OMX_ERRORTYPE omx_err = OMX_ErrorNone;
+ OMX_PARAM_U32TYPE param;
+ OMX_INIT_STRUCTURE(param);
+
+ param.nPortIndex = OMX_ALL;
+ param.nU32 = steps;
+
+ omx_err = m_omx_clock.SetConfig(OMX_IndexConfigSingleStep, ¶m);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "OMXClock::Error setting OMX_IndexConfigSingleStep\n");
+ if(lock)
+ UnLock();
+ return false;
+ }
+
+ if(lock)
+ UnLock();
+
+ return true;
+}
+
bool OMXClock::OMXReset(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return true;
}
-double OMXClock::OMXWallTime(bool lock /* = true */)
+double OMXClock::OMXMediaTime(bool fixPreroll /* true */ , bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return 0;
OMX_INIT_STRUCTURE(timeStamp);
timeStamp.nPortIndex = m_omx_clock.GetInputPort();
- omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentWallTime, &timeStamp);
+ omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp);
if(omx_err != OMX_ErrorNone)
{
- CLog::Log(LOGERROR, "OMXClock::WallTime error getting OMX_IndexConfigTimeCurrentWallTime\n");
+ CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime\n");
if(lock)
UnLock();
return 0;
pts = FromOMXTime(timeStamp.nTimestamp);
+ if(fixPreroll)
+ pts += (OMX_PRE_ROLL * 1000);
+
if(lock)
UnLock();
return pts;
}
-double OMXClock::OMXMediaTime(bool fixPreroll /* true */ , bool lock /* = true */)
+double OMXClock::OMXClockAdjustment(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return 0;
OMX_INIT_STRUCTURE(timeStamp);
timeStamp.nPortIndex = m_omx_clock.GetInputPort();
- omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp);
+ omx_err = m_omx_clock.GetConfig(OMX_IndexConfigClockAdjustment, &timeStamp);
if(omx_err != OMX_ErrorNone)
{
- CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime\n");
+ CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigClockAdjustment\n");
if(lock)
UnLock();
return 0;
}
- pts = FromOMXTime(timeStamp.nTimestamp);
-
- if(fixPreroll)
- pts += (OMX_PRE_ROLL * 1000);
-
+ pts = (double)FromOMXTime(timeStamp.nTimestamp);
+ //CLog::Log(LOGINFO, "OMXClock::ClockAdjustment %.0f %.0f\n", (double)FromOMXTime(timeStamp.nTimestamp), pts);
if(lock)
UnLock();
-
+
return pts;
}
+
// Set the media time, so calls to get media time use the updated value,
// useful after a seek so mediatime is updated immediately (rather than waiting for first decoded packet)
bool OMXClock::OMXMediaTime(double pts, bool fixPreroll /* = true*/, bool lock /* = true*/)
return true;
}
-// gets count of late frames, indicating underrun has occurred
-int OMXClock::OMXLateCount(int port /* true */ , bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return 0;
-
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-
- OMX_PARAM_U32TYPE late;
- OMX_INIT_STRUCTURE(late);
- late.nPortIndex = m_omx_clock.GetInputPort()+port;
-
- omx_err = m_omx_clock.GetConfig(OMX_IndexConfigBrcmClockMissCount, &late);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::OMXLateCount error getting OMX_IndexConfigBrcmClockMissCount(%d)\n", port);
- if(lock)
- UnLock();
- return 0;
- }
-
- //CLog::Log(LOGINFO, "OMXClock::OMXLateCount(%d)=%d", port, late.nU32);
-
- if(lock)
- UnLock();
-
- return late.nU32;
-}
-
bool OMXClock::OMXPause(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_TIME_CONFIG_SCALETYPE scaleType;
- OMX_INIT_STRUCTURE(scaleType);
-
- scaleType.xScale = 0; // pause
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
- if(omx_err != OMX_ErrorNone)
+ if(!m_pause)
{
- CLog::Log(LOGERROR, "OMXClock::Pause error setting OMX_IndexConfigTimeClockState\n");
if(lock)
- UnLock();
- return false;
- }
+ Lock();
- CLog::Log(LOGDEBUG, "OMXClock::OMXPause\n");
+ if (OMXSetSpeed(0, false, true))
+ m_pause = true;
- m_pause = true;
-
- if(lock)
- UnLock();
-
- return true;
-}
-
-bool OMXClock::OMXResume(bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return false;
-
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_TIME_CONFIG_SCALETYPE scaleType;
- OMX_INIT_STRUCTURE(scaleType);
-
- scaleType.xScale = ((m_omx_speed / DVD_PLAYSPEED_NORMAL) << 16);
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::Resume error setting OMX_IndexConfigTimeClockState\n");
if(lock)
UnLock();
- return false;
}
-
- m_pause = false;
-
- CLog::Log(LOGDEBUG, "OMXClock::OMXResume\n");
-
- if(lock)
- UnLock();
-
- return true;
+ return m_pause == true;
}
-bool OMXClock::OMXUpdateClock(double pts, bool lock /* = true */)
+bool OMXClock::OMXResume(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_TIME_CONFIG_TIMESTAMPTYPE ts;
- OMX_INIT_STRUCTURE(ts);
-
- ts.nPortIndex = OMX_ALL;
- ts.nTimestamp = ToOMXTime((uint64_t)pts);
-
- CLog::Log(LOGDEBUG, "OMXClock::OMXUpdateClock %f", pts / DVD_TIME_BASE);
-
- if(m_has_audio)
- {
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeCurrentAudioReference, &ts);
- if(omx_err != OMX_ErrorNone)
- CLog::Log(LOGERROR, "OMXClock::OMXUpdateClock error setting OMX_IndexConfigTimeCurrentAudioReference\n");
- }
- else
+ if(m_pause)
{
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeCurrentVideoReference, &ts);
- if(omx_err != OMX_ErrorNone)
- CLog::Log(LOGERROR, "OMXClock::OMXUpdateClock error setting OMX_IndexConfigTimeCurrentVideoReference\n");
- }
-
- if(lock)
- UnLock();
-
- return true;
-}
-
-bool OMXClock::OMXWaitStart(double pts, bool lock /* = true */)
-{
- if(m_omx_clock.GetComponent() == NULL)
- return false;
-
- if(lock)
- Lock();
-
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
- OMX_INIT_STRUCTURE(clock);
+ if(lock)
+ Lock();
- clock.eState = OMX_TIME_ClockStateWaitingForStartTime;
- clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);
- OMXSetClockPorts(&clock);
- clock.nStartTime = ToOMXTime((uint64_t)pts);
+ if (OMXSetSpeed(m_omx_speed, false, true))
+ m_pause = false;
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::OMXWaitStart error setting OMX_IndexConfigTimeClockState\n");
if(lock)
UnLock();
- return false;
- }
-
- if(lock)
- UnLock();
-
- return true;
-}
-
-void OMXClock::OMXHandleBackward(bool lock /* = true */)
-{
- /*
- if(m_omx_clock.GetComponent() == NULL)
- return;
-
- if(lock)
- Lock();
-
- if(m_omx_speed < 0)
- {
- OMX_ERRORTYPE omx_err = OMX_ErrorNone;
- OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
- OMX_INIT_STRUCTURE(clock);
-
- clock.eState = OMX_TIME_ClockStateRunning;
- clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-
- omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "OMXClock::OMXHandleBackward error setting OMX_IndexConfigTimeClockState\n");
- }
}
-
- if(lock)
- UnLock();
- */
+ return m_pause == false;
}
-bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */)
+bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */, bool pause_resume /* = false */)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
if(lock)
Lock();
- m_omx_speed = speed;
-
m_audio_buffer = false;
- CLog::Log(LOGDEBUG, "OMXClock::OMXSetSpeed %d buffering %d", m_omx_speed / DVD_PLAYSPEED_NORMAL, m_audio_buffer);
+ CLog::Log(LOGDEBUG, "OMXClock::OMXSetSpeed(%.2f) pause_resume:%d audio_buffer:%d", (float)m_omx_speed / (float)DVD_PLAYSPEED_NORMAL, pause_resume, m_audio_buffer);
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_TIME_CONFIG_SCALETYPE scaleType;
OMX_INIT_STRUCTURE(scaleType);
- scaleType.xScale = ((m_omx_speed / DVD_PLAYSPEED_NORMAL) << 16);
-
+ scaleType.xScale = (speed << 16) / DVD_PLAYSPEED_NORMAL;
omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
if(omx_err != OMX_ErrorNone)
{
return false;
}
+ if (!pause_resume)
+ m_omx_speed = speed;
+
if(lock)
UnLock();
return true;
}
-void OMXClock::AddTimespecs(struct timespec &time, long millisecs)
-{
- time.tv_sec += millisecs / 1000;
- time.tv_nsec += (millisecs % 1000) * 1000000;
- if (time.tv_nsec > 1000000000)
- {
- time.tv_sec += 1;
- time.tv_nsec -= 1000000000;
- }
-}
-
bool OMXClock::HDMIClockSync(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return( (int64_t)1000000000L );
}
-void OMXClock::AddTimeSpecNano(struct timespec &time, uint64_t nanoseconds)
-{
- time.tv_sec += nanoseconds / 1000000000;
- time.tv_nsec += (nanoseconds % 1000000000);
- if (time.tv_nsec > 1000000000)
- {
- time.tv_sec += 1;
- time.tv_nsec -= 1000000000;
- }
-}
-
int OMXClock::GetRefreshRate(double* interval)
{
if(!interval)
bool m_has_audio;
int m_play_speed;
pthread_mutex_t m_lock;
- double SystemToAbsolute(int64_t system);
- double SystemToPlaying(int64_t system);
- int64_t m_systemUsed;
- int64_t m_startClock;
- int64_t m_pauseClock;
- double m_iDisc;
- bool m_bReset;
- static int64_t m_systemFrequency;
- static int64_t m_systemOffset;
- int64_t m_ClockOffset;
- double m_maxspeedadjust;
- bool m_speedadjust;
- static bool m_ismasterclock;
double m_fps;
int m_omx_speed;
bool m_video_start;
bool m_audio_start;
bool m_audio_buffer;
- CDVDClock m_clock;
- OMX_TIME_CONFIG_CLOCKSTATETYPE m_clock_state;
+ CDVDClock *m_clock;
private:
COMXCoreComponent m_omx_clock;
public:
~OMXClock();
void Lock();
void UnLock();
- double GetAbsoluteClock(bool interpolated = true);
- double GetFrequency() { return (double)m_systemFrequency ; }
- double WaitAbsoluteClock(double target);
- double GetClock(bool interpolated = true);
- double GetClock(double& absolute, bool interpolated = true);
- void CheckSystemClock();
- void SetSpeed(int iSpeed);
- void SetMasterClock(bool ismasterclock) { m_ismasterclock = ismasterclock; }
- bool IsMasterClock() { return m_ismasterclock; }
- void Discontinuity(double currentPts = 0LL);
-
- void Reset() { m_bReset = true; }
- void Pause();
- void Resume();
-
- int UpdateFramerate(double fps, double* interval = NULL);
- bool SetMaxSpeedAdjust(double speed);
-
+ double GetAbsoluteClock(bool interpolated = true) { return m_clock ? m_clock->GetAbsoluteClock(interpolated):0; }
+ double GetClock(bool interpolated = true) { return m_clock ? m_clock->GetClock(interpolated):0; }
+ double GetClock(double& absolute, bool interpolated = true) { return m_clock ? m_clock->GetClock(absolute, interpolated):0; }
+ void Discontinuity(double currentPts = 0LL) { if (m_clock) m_clock->Discontinuity(currentPts); }
void OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock);
bool OMXSetReferenceClock(bool lock = true);
- bool OMXInitialize(bool has_video, bool has_audio);
+ bool OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio);
void OMXDeinitialize();
bool OMXIsPaused() { return m_pause; };
- void OMXSaveState(bool lock = true);
- void OMXRestoreState(bool lock = true);
bool OMXStop(bool lock = true);
bool OMXStart(bool lock = true);
+ bool OMXStep(int steps = 1, bool lock = true);
bool OMXReset(bool lock = true);
- double OMXWallTime(bool lock = true);
double OMXMediaTime(bool fixPreroll = true, bool lock = true);
+ double OMXClockAdjustment(bool lock = true);
bool OMXMediaTime(double pts, bool fixPreroll = true, bool lock = true);
- int OMXLateCount(int port, bool lock = true);
bool OMXPause(bool lock = true);
bool OMXResume(bool lock = true);
- bool OMXUpdateClock(double pts, bool lock = true);
- bool OMXWaitStart(double pts, bool lock = true);
- void OMXHandleBackward(bool lock = true);
- bool OMXSetSpeed(int speed, bool lock = true);
+ bool OMXSetSpeed(int speed, bool lock = true, bool pause_resume = false);
int OMXPlaySpeed() { return m_omx_speed; };
- int OMXGetPlaySpeed() { return m_omx_speed; };
COMXCoreComponent *GetOMXClock();
- bool OMXStatePause(bool lock = true);
bool OMXStateExecute(bool lock = true);
void OMXStateIdle(bool lock = true);
- static void AddTimespecs(struct timespec &time, long millisecs);
bool HDMIClockSync(bool lock = true);
static int64_t CurrentHostCounter(void);
static int64_t CurrentHostFrequency(void);
bool AudioStart() { return m_audio_start; };
void VideoStart(bool video_start);
void AudioStart(bool audio_start);
- static void AddTimeSpecNano(struct timespec &time, uint64_t nanoseconds);
-
void OMXAudioBufferStart();
void OMXAudioBufferStop();
bool OMXAudioBuffer() { return m_audio_buffer; };
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "system.h"
#endif
#include "OMXClock.h"
-#ifdef _LINUX
+#ifdef TARGET_LINUX
#include "XMemUtils.h"
#endif
if(!m_handle)
return;
- if(GetState() == OMX_StateExecuting)
- SetStateForComponent(OMX_StatePause);
-
if(GetState() != OMX_StateIdle)
SetStateForComponent(OMX_StateIdle);
*
*/
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define LINE_ENDING "\n"
#if defined(TARGET_DARWIN_OSX)
#include <libkern/OSTypes.h>
#endif
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
#include <stdio.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <stdint.h>
#ifndef PRId64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
#define PRId64 "I64d"
#else
#if __WORDSIZE == 64
#endif
#ifndef PRIu64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
#define PRIu64 "I64u"
#else
#if __WORDSIZE == 64
#endif
#ifndef PRIx64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
#define PRIx64 "I64x"
#else
#if __WORDSIZE == 64
#define PRIuS "zu"
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define XXLog(a,b) printf("%s", (b))
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define WINAPIV __cdecl
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
#define APIENTRY WINAPI
#else
#define APIENTRY
#if defined(TARGET_DARWIN)
FILE* pipe = popen("df -hT ufs,cd9660,hfs,udf", "r");
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
FILE* pipe = popen("df -h -t ufs,cd9660,hfs,udf,zfs", "r");
#else
FILE* pipe = popen("df -h", "r");
#include "XTimeUtils.h"
#include "filesystem/SpecialProtocol.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XHandle.h"
#include <sys/types.h>
#include <sys/stat.h>
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID)
#include <sys/vfs.h>
#else
#include <sys/param.h>
#include <dirent.h>
#include <errno.h>
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
#include <sys/file.h>
#include <sys/statfs.h>
strPath.Replace("\\","/");
// if the file name is a directory then we add a * to look for all files in this directory
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
DIR *testDir = opendir(strPath.c_str());
#else
DIR *testDir = opendir(szPath);
return(INVALID_HANDLE_VALUE);
struct dirent **namelist = NULL;
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
// android is more strict with the sort function. Let's hope it is implemented correctly.
typedef int (*sortFunc)(const struct dirent ** a, const struct dirent **b);
int n = scandir(strDir, &namelist, 0, (sortFunc)alphasort);
nMode = SEEK_END;
off64_t currOff;
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
currOff = lseek(hFile->fd, offset, nMode);
#else
currOff = lseek64(hFile->fd, offset, nMode);
)
{
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
struct statfs fsInfo;
// is 64-bit on android
if (statfs(CSpecialProtocol::TranslatePath(lpDirectoryName), &fsInfo) != 0)
return false;
// get the current offset
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
off64_t currOff = lseek(hFile->fd, 0, SEEK_CUR);
#else
off64_t currOff = lseek64(hFile->fd, 0, SEEK_CUR);
off64_t toMove = liDistanceToMove.QuadPart;
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
off64_t currOff = lseek(hFile->fd, toMove, nMode);
#else
off64_t currOff = lseek64(hFile->fd, toMove, nMode);
#include "PlatformDefs.h"
#include "XHandlePublic.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define XBMC_FILE_SEP '/'
#else
#define XBMC_FILE_SEP '\\'
*
*/
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
#include <list>
// simulate mutex and critical section
CCriticalSection *m_hMutex;
- int RecursionCount; // for mutex - for compatibility with WIN32 critical section
+ int RecursionCount; // for mutex - for compatibility with TARGET_WINDOWS critical section
int fd;
bool m_bManualEvent;
time_t m_tmCreation;
free(pFull);
}
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
static FILE* procMeminfoFP = NULL;
#endif
lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys; // FIXME.
}
}
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
/* sysctl hw.physmem */
size_t physmem = 0, mem_free = 0, pagesize = 0, swap_free = 0;
size_t mem_avail = 0, mem_inactive = 0, mem_cache = 0, len = 0;
#include "threads/Atomics.h"
#endif
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
#include <time64.h>
#endif
*/
#define IsLeapYear(y) ((!(y % 4)) ? (((!(y % 400)) && (y % 100)) ? 1 : 0) : 0)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
void WINAPI Sleep(DWORD dwMilliSeconds)
{
CAtomicSpinLock lock(timegm_lock);
#endif
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
time64_t t = timegm64(&sysTime);
#else
time_t t = timegm(&sysTime);
#include "PlayListPlayer.h"
#include "utils/log.h"
#include "xbmc.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <sys/resource.h>
#include <signal.h>
#endif
#endif
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#if defined(DEBUG)
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
setlocale(LC_NUMERIC, "C");
g_advancedSettings.Initialize();
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
#endif
CLog::Log(LOGINFO, "create song index3");
m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
CLog::Log(LOGINFO, "create song index6");
- m_pDS->exec("CREATE UNIQUE INDEX idxSong6 ON song( idPath, strFileName(255) )");
+ m_pDS->exec("CREATE INDEX idxSong6 ON song( idPath, strFileName(255) )");
CLog::Log(LOGINFO, "create song index7");
m_pDS->exec("CREATE UNIQUE INDEX idxSong7 ON song( idAlbum, strMusicBrainzTrackID(36) )");
// Special case for streams inside an ogg file. (oggstream)
// The last dir in the path is the ogg file that
// contains the stream, so test if its there
- CStdString strExtension=URIUtils::GetExtension(strFileName);
- if (strExtension==".oggstream" || strExtension==".nsfstream")
+ if (URIUtils::HasExtension(strFileName, ".oggstream|.nsfstream"))
{
CStdString strFileAndPath=strFileName;
URIUtils::GetDirectory(strFileAndPath, strFileName);
return false;
}
+bool CMusicDatabase::InsideScannedPath(const CStdString& path)
+{
+ CStdString sql = PrepareSQL("select idPath from path where SUBSTR(strPath,1,%i)='%s' LIMIT 1", path.size(), path.c_str());
+ return !GetSingleValue(sql).empty();
+}
+
bool CMusicDatabase::CleanupArtists()
{
try
if (version < 33)
{
m_pDS->exec("DROP INDEX idxSong6 ON song");
- m_pDS->exec("CREATE UNIQUE INDEX idxSong6 on song( idPath, strFileName(255) )");
+ m_pDS->exec("CREATE INDEX idxSong6 on song( idPath, strFileName(255) )");
}
if (version < 34)
}
}
}
+
+ if (version < 37)
+ {
+ m_pDS->exec("DROP INDEX idxSong6 ON song");
+ m_pDS->exec("CREATE INDEX idxSong6 on song( idPath, strFileName(255) )");
+ }
+
// always recreate the views after any table change
CreateViews();
int CMusicDatabase::GetMinVersion() const
{
- return 36;
+ return 37;
}
unsigned int CMusicDatabase::GetSongIDs(const Filter &filter, vector<pair<int,int> > &songIDs)
bool GetAlbum(int idAlbum, CAlbum& album);
int UpdateAlbum(int idAlbum, const CAlbum &album);
bool DeleteAlbum(int idAlbum);
+ /*! \brief Checks if the given path is inside a folder that has already been scanned into the library
+ \param path the path we want to check
+ */
+ bool InsideScannedPath(const CStdString& path);
//// Misc Album
int GetAlbumIdByPath(const CStdString& path);
#include "guilib/GUIKeyboardFactory.h"
#include "guilib/Key.h"
#include "GUIUserMessages.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
#include "profiles/ProfilesManager.h"
#include "settings/MediaSettings.h"
#include "settings/Settings.h"
buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With...
buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info
- if (CFavourites::IsFavourite(item.get(), GetID()))
+ if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite
else
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites;
case CONTEXT_BUTTON_ADD_FAVOURITE:
{
CFileItemPtr item = m_vecItems->Get(itemNumber);
- CFavourites::AddOrRemove(item.get(), GetID());
+ XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
return true;
}
if(g_DNSCache.GetCached(strHostName, strIpAddress))
return true;
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
// perform netbios lookup (win32 is handling this via gethostbyname)
char nmb_ip[100];
char line[200];
#include "GUIDialogAccessPoints.h"
#include "guilib/GUIKeyboardFactory.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/NetworkLinux.h"
#endif
#include "Application.h"
return true;
}
+int NetworkAccessPoint::getQuality() const
+{
+ // Cisco dBm lookup table (partially nonlinear)
+ // Source: "Converting Signal Strength Percentage to dBm Values, 2002"
+ int quality;
+ if (m_dBm >= -10) quality = 100;
+ else if (m_dBm >= -20) quality = 85 + (m_dBm + 20);
+ else if (m_dBm >= -30) quality = 77 + (m_dBm + 30);
+ else if (m_dBm >= -60) quality = 48 + (m_dBm + 60);
+ else if (m_dBm >= -98) quality = 13 + (m_dBm + 98);
+ else if (m_dBm >= -112) quality = 1 + (m_dBm + 112);
+ else quality = 0;
+ return quality;
+}
+
+int NetworkAccessPoint::FreqToChannel(float frequency)
+{
+ int IEEE80211Freq[] = {2412, 2417, 2422, 2427, 2432,
+ 2437, 2442, 2447, 2452, 2457,
+ 2462, 2467, 2472, 2484,
+ 5180, 5200, 5210, 5220, 5240, 5250,
+ 5260, 5280, 5290, 5300, 5320,
+ 5745, 5760, 5765, 5785, 5800, 5805, 5825};
+ int IEEE80211Ch[] = { 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10,
+ 11, 12, 13, 14,
+ 36, 40, 42, 44, 48, 50,
+ 52, 56, 58, 60, 64,
+ 149, 152, 153, 157, 160, 161, 165};
+ // Round frequency to the nearest MHz
+ int mod_chan = (int)(frequency / 1000000 + 0.5f);
+ for (unsigned int i = 0; i < sizeof(IEEE80211Freq) / sizeof(int); ++i)
+ {
+ if (IEEE80211Freq[i] == mod_chan)
+ return IEEE80211Ch[i];
+ }
+ return 0; // unknown
+}
+
+
CNetwork::CNetwork()
{
CApplicationMessenger::Get().NetworkMessage(SERVICES_UP, 0);
static const char* ConnectHostPort(SOCKET soc, const struct sockaddr_in& addr, struct timeval& timeOut, bool tryRead)
{
// set non-blocking
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
u_long nonblocking = 1;
int result = ioctlsocket(soc, FIONBIO, &nonblocking);
#else
if (result < 0)
{
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
if (WSAGetLastError() != WSAEWOULDBLOCK)
#else
if (errno != EINPROGRESS)
if (err_msg && *err_msg)
{
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
CStdString sock_err = WUSysMsg(WSAGetLastError());
#else
CStdString sock_err = strerror(errno);
class NetworkAccessPoint
{
public:
- NetworkAccessPoint(CStdString& essId, int quality, EncMode encryption)
+ NetworkAccessPoint(const CStdString &essId, const CStdString &macAddress, int signalStrength, EncMode encryption, int channel = 0)
{
- m_essId = essId;
- m_quality = quality;
+ m_essId = essId;
+ m_macAddress = macAddress;
+ m_dBm = signalStrength;
m_encryptionMode = encryption;
+ m_channel = channel;
}
- CStdString getEssId() { return m_essId; }
- int getQuality() { return m_quality; }
- EncMode getEncryptionMode() { return m_encryptionMode; }
+ const CStdString &getEssId() const { return m_essId; }
+ const CStdString &getMacAddress() const { return m_macAddress; }
+ int getSignalStrength() const { return m_dBm; }
+ EncMode getEncryptionMode() const { return m_encryptionMode; }
+ int getChannel() const { return m_channel; }
+
+ /*!
+ \brief Returns the quality, normalized as a percentage, of the network access point
+ \return The quality as an integer between 0 and 100
+ */
+ int getQuality() const;
+
+ /*!
+ \brief Translates a 802.11a+g frequency into the corresponding channel
+ \param frequency The frequency of the channel in units of Hz
+ \return The channel as an integer between 1 and 14 (802.11b+g) or
+ between 36 and 165 (802.11a), or 0 if unknown.
+ */
+ static int FreqToChannel(float frequency);
private:
- CStdString m_essId;
- int m_quality;
- EncMode m_encryptionMode;
+ CStdString m_essId;
+ CStdString m_macAddress;
+ int m_dBm;
+ EncMode m_encryptionMode;
+ int m_channel;
};
class CNetworkInterface
if (m_iSock == INVALID_SOCKET)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int ierr = WSAGetLastError();
CLog::Log(LOGERROR, "UDP: Could not create socket %d", ierr);
// hack for broken third party libs
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include <netinet/in.h>
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
typedef int SOCKET;
#endif
#include "threads/SystemClock.h"
#include "UdpClient.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <sys/ioctl.h>
#endif
#include "Network.h"
{
// read data
int messageLength = sizeof(messageBuffer) - 1 ;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
int remoteAddressSize;
#else
socklen_t remoteAddressSize;
class NetworkStartWaiter : public WaitCondition
{
public:
- NetworkStartWaiter (unsigned settle_time_ms) : m_settle_time_ms (settle_time_ms)
+ NetworkStartWaiter (unsigned settle_time_ms, const CStdString& host) : m_settle_time_ms (settle_time_ms), m_host(host)
{
}
virtual bool SuccessWaiting () const
{
- CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
-
- bool online = iface && iface->IsEnabled();
+ unsigned long address = ntohl(HostToIP(m_host));
+ bool online = g_application.getNetwork().HasInterfaceForIP(address);
if (!online) // setup endtime so we dont return true until network is consistently connected
m_end.Set (m_settle_time_ms);
private:
mutable XbmcThreads::EndTime m_end;
unsigned m_settle_time_ms;
+ const CStdString m_host;
};
class PingResponseWaiter : public WaitCondition, private IJobCallback
ProgressDialogHelper dlg (heading);
{
- NetworkStartWaiter waitObj (m_netsettle_ms); // wait until network connected before sending wake-on-lan
+ NetworkStartWaiter waitObj (m_netsettle_ms, server.host); // wait until network connected before sending wake-on-lan
if (dlg.ShowAndWait (waitObj, m_netinit_sec, LOCALIZED(13028)) != ProgressDialogHelper::Success)
{
//#define WEBSERVER_DEBUG
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#pragma comment(lib, "libmicrohttpd.dll.lib")
#endif
#include "Zeroconf.h"
#include "settings/Settings.h"
-#ifdef _LINUX
-#if !defined(TARGET_DARWIN)
+#if defined(HAS_AVAHI)
#include "linux/ZeroconfAvahi.h"
-#else
+#elif defined(TARGET_DARWIN)
//on osx use the native implementation
#include "osx/ZeroconfOSX.h"
-#endif
-#elif defined(TARGET_WINDOWS)
-#include "windows/ZeroconfWIN.h"
+#elif defined(HAS_MDNS)
+#include "mdns/ZeroconfMDNS.h"
#endif
#include "threads/CriticalSection.h"
#else
#if defined(TARGET_DARWIN)
smp_instance = new CZeroconfOSX;
-#elif defined(_LINUX)
+#elif defined(HAS_AVAHI)
smp_instance = new CZeroconfAvahi;
-#elif defined(TARGET_WINDOWS)
- smp_instance = new CZeroconfWIN;
+#elif defined(HAS_MDNS)
+ smp_instance = new CZeroconfMDNS;
#endif
#endif
}
#include <stdexcept>
#include "utils/log.h"
-#ifdef _LINUX
-#if !defined(TARGET_DARWIN)
+#if defined (HAS_AVAHI)
#include "linux/ZeroconfBrowserAvahi.h"
-#else
+#elif defined(TARGET_DARWIN)
//on osx use the native implementation
#include "osx/ZeroconfBrowserOSX.h"
-#endif
-#elif defined(TARGET_WINDOWS)
-#include "windows/ZeroconfBrowserWIN.h"
+#elif defined(HAS_MDNS)
+#include "mdns/ZeroconfBrowserMDNS.h"
#endif
#include "threads/CriticalSection.h"
#include "threads/SingleLock.h"
#include "threads/Atomics.h"
-#if !defined(HAS_ZEROCONF)
+// FIXME - once zeroconf browser with mdnsembedded is fixed -remove that condition here
+#if !defined(HAS_ZEROCONF) || defined(HAS_MDNS_EMBEDDED)
//dummy implementation used if no zeroconf is present
//should be optimized away
class CZeroconfBrowserDummy : public CZeroconfBrowser
CAtomicSpinLock lock(sm_singleton_guard);
if(!smp_instance)
{
-#if !defined(HAS_ZEROCONF)
+// FIXME - once zeroconf browser with mdnsembedded is fixed -remove that condition here
+#if !defined(HAS_ZEROCONF) || defined(HAS_MDNS_EMBEDDED)
smp_instance = new CZeroconfBrowserDummy;
#else
#if defined(TARGET_DARWIN)
smp_instance = new CZeroconfBrowserOSX;
-#elif defined(_LINUX)
+#elif defined(HAS_AVAHI)
smp_instance = new CZeroconfBrowserAvahi;
-#elif defined(TARGET_WINDOWS)
- smp_instance = new CZeroconfBrowserWIN;
+#elif defined(HAS_MDNS)
+ smp_instance = new CZeroconfBrowserMDNS;
#endif
#endif
}
#include "utils/StdString.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#undef SetPort // WIN32INCLUDES this is defined as SetPortA in WinSpool.h which is being included _somewhere_
#endif
#include <sstream>
#include <iostream>
#include <map>
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <strstream>
#endif
#include "storage/cdioSupport.h"
for (VECSOURCES::const_iterator source = sources->begin(); source != sources->end() && !accessible; source++)
{
- // don't allow access to locked sources
- if (source->m_iHasLock == 2)
+ // don't allow access to locked / disabled sharing sources
+ if (source->m_iHasLock == 2 || !source->m_allowSharing)
continue;
for (vector<CStdString>::const_iterator path = source->vecPaths.begin(); path != source->vecPaths.end(); path++)
void CNetworkLinux::SetNameServers(std::vector<CStdString> nameServers)
{
-#if !defined(__ANDROID__)
+#if !defined(TARGET_ANDROID)
FILE* fp = fopen("/etc/resolv.conf", "w");
if (fp != NULL)
{
return result;
#if defined(TARGET_LINUX)
- // Query the wireless extentsions version number. It will help us when we
+ // Query the wireless extension's version number. It will help us when we
// parse the resulting events
struct iwreq iwr;
char rangebuffer[sizeof(iw_range) * 2]; /* Large enough */
iwr.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(m_network->GetSocket(), SIOCSIWSCAN, &iwr) < 0)
{
- CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s", strerror(errno));
+ // Triggering scanning is a privileged operation (root only)
+ if (errno == EPERM)
+ CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s. Try running as root", strerror(errno));
+ else
+ CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s", strerror(errno));
return result;
}
// Get the results of the scanning. Three scenarios:
// 1. There's not enough room in the result buffer (E2BIG)
// 2. The scanning is not complete (EAGAIN) and we need to try again. We cap this with 15 seconds.
- // 3. Were'e good.
+ // 3. We're good.
int duration = 0; // ms
unsigned char* res_buf = NULL;
int res_buf_len = IW_SCAN_MAX_DATA;
}
}
- size_t len = iwr.u.data.length;
- char* pos = (char *) res_buf;
- char* end = (char *) res_buf + len;
- char* custom;
- struct iw_event iwe_buf, *iwe = &iwe_buf;
+ size_t len = iwr.u.data.length; // total length of the wireless events from the scan results
+ unsigned char* pos = res_buf; // pointer to the current event (about 10 per wireless network)
+ unsigned char* end = res_buf + len; // marks the end of the scan results
+ unsigned char* custom; // pointer to the event payload
+ struct iw_event iwe_buf, *iwe = &iwe_buf; // buffer to hold individual events
CStdString essId;
- int quality = 0;
+ CStdString macAddress;
+ int signalLevel = 0;
EncMode encryption = ENC_NONE;
- bool first = true;
+ int channel = 0;
while (pos + IW_EV_LCP_LEN <= end)
{
/* Event data may be unaligned, so make a local, aligned copy
* before processing. */
+
+ // copy event prefix (size of event minus IOCTL fixed payload)
memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
if (iwe->len <= IW_EV_LCP_LEN)
break;
+ // if the payload is nontrivial (i.e. > 16 octets) assume it comes after a pointer
custom = pos + IW_EV_POINT_LEN;
if (range->we_version_compiled > 18 &&
(iwe->cmd == SIOCGIWESSID ||
iwe->cmd == IWEVGENIE ||
iwe->cmd == IWEVCUSTOM))
{
- /* Wireless extentsions v19 removed the pointer from struct iw_point */
- char *dpos = (char *) &iwe_buf.u.data.length;
- int dlen = dpos - (char *) &iwe_buf;
- memcpy(dpos, pos + IW_EV_LCP_LEN, sizeof(struct iw_event) - dlen);
+ /* Wireless extensions v19 removed the pointer from struct iw_point */
+ char *data_pos = (char *) &iwe_buf.u.data.length;
+ int data_len = data_pos - (char *) &iwe_buf;
+ memcpy(data_pos, pos + IW_EV_LCP_LEN, sizeof(struct iw_event) - data_len);
}
else
{
+ // copy the rest of the event and point custom toward the payload offset
memcpy(&iwe_buf, pos, sizeof(struct iw_event));
custom += IW_EV_POINT_OFF;
}
+ // Interpret the payload based on event type. Each access point generates ~12 different events
switch (iwe->cmd)
{
+ // Get access point MAC addresses
case SIOCGIWAP:
- if (first)
- first = false;
- else
- {
- result.push_back(NetworkAccessPoint(essId, quality, encryption));
- encryption = ENC_NONE;
- }
+ {
+ // This event marks a new access point, so push back the old information
+ if (!macAddress.IsEmpty())
+ result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
+ unsigned char* mac = (unsigned char*)iwe->u.ap_addr.sa_data;
+ // macAddress is big-endian, write in byte chunks
+ macAddress.Format("%02x-%02x-%02x-%02x-%02x-%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ // Reset the remaining fields
+ essId = "";
+ encryption = ENC_NONE;
+ signalLevel = 0;
+ channel = 0;
break;
+ }
+
+ // Get operation mode
+ case SIOCGIWMODE:
+ {
+ // Ignore Ad-Hoc networks (1 is the magic number for this)
+ if (iwe->u.mode == 1)
+ macAddress = "";
+ break;
+ }
+ // Get ESSID
case SIOCGIWESSID:
{
char essid[IW_ESSID_MAX_SIZE+1];
break;
}
+ // Quality part of statistics
case IWEVQUAL:
- quality = iwe->u.qual.qual;
- break;
+ {
+ // u.qual.qual is scaled to a vendor-specific RSSI_Max, so use u.qual.level
+ signalLevel = iwe->u.qual.level - 0x100; // and remember we use 8-bit arithmetic
+ break;
+ }
+ // Get channel/frequency (Hz)
+ // This gets called twice per network, what's the difference between the two?
+ case SIOCGIWFREQ:
+ {
+ float freq = ((float)iwe->u.freq.m) * pow(10, iwe->u.freq.e);
+ if (freq > 1000)
+ channel = NetworkAccessPoint::FreqToChannel(freq);
+ else
+ channel = (int)freq; // Some drivers report channel instead of frequency
+ break;
+ }
+
+ // Get encoding token & mode
case SIOCGIWENCODE:
- if (!(iwe->u.data.flags & IW_ENCODE_DISABLED) && encryption == ENC_NONE)
- encryption = ENC_WEP;
- break;
+ {
+ if (!(iwe->u.data.flags & IW_ENCODE_DISABLED) && encryption == ENC_NONE)
+ encryption = ENC_WEP;
+ break;
+ }
+ // Generic IEEE 802.11 information element (IE) for WPA, RSN, WMM, ...
case IWEVGENIE:
{
int offset = 0;
- while (offset <= iwe_buf.u.data.length)
+ // Loop on each IE, each IE is minimum 2 bytes
+ while (offset <= (iwe_buf.u.data.length - 2))
{
- switch ((unsigned char)custom[offset])
+ switch (custom[offset])
{
case 0xdd: /* WPA1 */
if (encryption != ENC_WPA2)
case 0x30: /* WPA2 */
encryption = ENC_WPA2;
}
-
+ // Skip over this IE to the next one in the list
offset += custom[offset+1] + 2;
}
}
pos += iwe->len;
}
- if (!first)
- result.push_back(NetworkAccessPoint(essId, quality, encryption));
+ if (!macAddress.IsEmpty())
+ result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
free(res_buf);
res_buf = NULL;
--- /dev/null
+SRCS=ZeroconfMDNS.cpp \
+ ZeroconfBrowserMDNS.cpp \
+
+LIB=mdns.a
+
+include ../../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
--- /dev/null
+/*
+ * Copyright (C) 2012-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ZeroconfBrowserMDNS.h"
+#include <utils/log.h>
+#include <threads/SingleLock.h>
+#include "guilib/GUIWindowManager.h"
+#include "guilib/GUIMessage.h"
+#include "GUIUserMessages.h"
+#if defined(TARGET_WINDOWS)
+#include "win32/WIN32Util.h"
+#endif //TARGET_WINDOWS
+#include "network/DNSNameCache.h"
+
+#pragma comment(lib, "dnssd.lib")
+
+extern HWND g_hWnd;
+
+
+CZeroconfBrowserMDNS::CZeroconfBrowserMDNS()
+{
+ m_browser = NULL;
+}
+
+CZeroconfBrowserMDNS::~CZeroconfBrowserMDNS()
+{
+ CSingleLock lock(m_data_guard);
+ //make sure there are no browsers anymore
+ for(tBrowserMap::iterator it = m_service_browsers.begin(); it != m_service_browsers.end(); ++it )
+ doRemoveServiceType(it->first);
+
+#if defined(TARGET_WINDOWS)
+ WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 );
+#endif //TARGET_WINDOWS
+
+ if (m_browser)
+ DNSServiceRefDeallocate(m_browser);
+ m_browser = NULL;
+}
+
+void DNSSD_API CZeroconfBrowserMDNS::BrowserCallback(DNSServiceRef browser,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *serviceName,
+ const char *regtype,
+ const char *replyDomain,
+ void *context)
+{
+
+ if (errorCode == kDNSServiceErr_NoError)
+ {
+ //get our instance
+ CZeroconfBrowserMDNS* p_this = reinterpret_cast<CZeroconfBrowserMDNS*>(context);
+ //store the service
+ ZeroconfService s(serviceName, regtype, replyDomain);
+
+ if (flags & kDNSServiceFlagsAdd)
+ {
+ CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback found service named: %s, type: %s, domain: %s", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
+ p_this->addDiscoveredService(browser, s);
+ }
+ else
+ {
+ CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback service named: %s, type: %s, domain: %s disappeared", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
+ p_this->removeDiscoveredService(browser, s);
+ }
+ if(! (flags & kDNSServiceFlagsMoreComing) )
+ {
+ CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH);
+ message.SetStringParam("zeroconf://");
+ g_windowManager.SendThreadMessage(message);
+ CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback sent gui update for path zeroconf://");
+ }
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS::BrowserCallback returned (error = %ld)\n", (int)errorCode);
+ }
+}
+
+void DNSSD_API CZeroconfBrowserMDNS::ResolveCallback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *fullname,
+ const char *hosttarget,
+ uint16_t port, /* In network byte order */
+ uint16_t txtLen,
+ const unsigned char *txtRecord,
+ void *context
+ )
+{
+
+ if (errorCode)
+ {
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: ResolveCallback failed with error = %ld", (int) errorCode);
+ return;
+ }
+
+ DNSServiceErrorType err;
+ CZeroconfBrowser::ZeroconfService::tTxtRecordMap recordMap;
+ CStdString strIP;
+ CZeroconfBrowserMDNS* p_instance = static_cast<CZeroconfBrowserMDNS*> ( context );
+
+ if(!CDNSNameCache::Lookup(hosttarget, strIP))
+ {
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: Could not resolve hostname %s",hosttarget);
+ p_instance->m_resolved_event.Set();
+ return;
+ }
+ p_instance->m_resolving_service.SetIP(strIP);
+
+ for(uint16_t i = 0; i < TXTRecordGetCount(txtLen, txtRecord); ++i)
+ {
+ char key[256];
+ uint8_t valueLen;
+ const void *value;
+ std::string strvalue;
+ err = TXTRecordGetItemAtIndex(txtLen, txtRecord,i ,sizeof(key) , key, &valueLen, &value);
+ if(err != kDNSServiceErr_NoError)
+ continue;
+
+ if(value != NULL && valueLen > 0)
+ strvalue.append((const char *)value, valueLen);
+
+ recordMap.insert(std::make_pair(key, strvalue));
+ }
+ p_instance->m_resolving_service.SetTxtRecords(recordMap);
+ p_instance->m_resolving_service.SetPort(ntohs(port));
+ p_instance->m_resolved_event.Set();
+}
+
+/// adds the service to list of found services
+void CZeroconfBrowserMDNS::addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
+{
+ CSingleLock lock(m_data_guard);
+ tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
+ if(browserIt == m_discovered_services.end())
+ {
+ //first service by this browser
+ browserIt = m_discovered_services.insert(make_pair(browser, std::vector<std::pair<ZeroconfService, unsigned int> >())).first;
+ }
+ //search this service
+ std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
+ std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
+ for( ; serviceIt != services.end(); ++serviceIt)
+ {
+ if(serviceIt->first == fcr_service)
+ break;
+ }
+ if(serviceIt == services.end())
+ services.push_back(std::make_pair(fcr_service, 1));
+ else
+ ++serviceIt->second;
+}
+
+void CZeroconfBrowserMDNS::removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
+{
+ CSingleLock lock(m_data_guard);
+ tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
+ //search this service
+ std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
+ std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
+ for( ; serviceIt != services.end(); ++serviceIt)
+ if(serviceIt->first == fcr_service)
+ break;
+ if(serviceIt != services.end())
+ {
+ //decrease refCount
+ --serviceIt->second;
+ if(!serviceIt->second)
+ {
+ //eventually remove the service
+ services.erase(serviceIt);
+ }
+ } else
+ {
+ //looks like we missed the announce, no problem though..
+ }
+}
+
+
+bool CZeroconfBrowserMDNS::doAddServiceType(const CStdString& fcr_service_type)
+{
+ DNSServiceErrorType err;
+ DNSServiceRef browser = NULL;
+
+#if !defined(HAS_MDNS_EMBEDDED)
+ if(m_browser == NULL)
+ {
+ err = DNSServiceCreateConnection(&m_browser);
+ if (err != kDNSServiceErr_NoError)
+ {
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceCreateConnection failed with error = %ld", (int) err);
+ return false;
+ }
+#if defined(TARGET_WINDOWS)
+ err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE );
+ if (err != kDNSServiceErr_NoError)
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: WSAAsyncSelect failed with error = %ld", (int) err);
+#endif //TARGET_WINDOWS
+ }
+#endif //!HAS_MDNS_EMBEDDED
+
+ {
+ CSingleLock lock(m_data_guard);
+ browser = m_browser;
+ err = DNSServiceBrowse(&browser, kDNSServiceFlagsShareConnection, kDNSServiceInterfaceIndexAny, fcr_service_type.c_str(), NULL, BrowserCallback, this);
+ }
+
+ if( err != kDNSServiceErr_NoError )
+ {
+ if (browser)
+ DNSServiceRefDeallocate(browser);
+
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceBrowse returned (error = %ld)", (int) err);
+ return false;
+ }
+
+ //store the browser
+ {
+ CSingleLock lock(m_data_guard);
+ m_service_browsers.insert(std::make_pair(fcr_service_type, browser));
+ }
+
+ return true;
+}
+
+bool CZeroconfBrowserMDNS::doRemoveServiceType(const CStdString& fcr_service_type)
+{
+ //search for this browser and remove it from the map
+ DNSServiceRef browser = 0;
+ {
+ CSingleLock lock(m_data_guard);
+ tBrowserMap::iterator it = m_service_browsers.find(fcr_service_type);
+ if(it == m_service_browsers.end())
+ {
+ return false;
+ }
+ browser = it->second;
+ m_service_browsers.erase(it);
+ }
+
+ //remove the services of this browser
+ {
+ CSingleLock lock(m_data_guard);
+ tDiscoveredServicesMap::iterator it = m_discovered_services.find(browser);
+ if(it != m_discovered_services.end())
+ m_discovered_services.erase(it);
+ }
+
+ if (browser)
+ DNSServiceRefDeallocate(browser);
+
+ return true;
+}
+
+std::vector<CZeroconfBrowser::ZeroconfService> CZeroconfBrowserMDNS::doGetFoundServices()
+{
+ std::vector<CZeroconfBrowser::ZeroconfService> ret;
+ CSingleLock lock(m_data_guard);
+ for(tDiscoveredServicesMap::const_iterator it = m_discovered_services.begin();
+ it != m_discovered_services.end(); ++it)
+ {
+ const std::vector<std::pair<CZeroconfBrowser::ZeroconfService, unsigned int> >& services = it->second;
+ for(unsigned int i = 0; i < services.size(); ++i)
+ {
+ ret.push_back(services[i].first);
+ }
+ }
+ return ret;
+}
+
+bool CZeroconfBrowserMDNS::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
+{
+ DNSServiceErrorType err;
+ DNSServiceRef sdRef = NULL;
+
+ //start resolving
+ m_resolving_service = fr_service;
+ m_resolved_event.Reset();
+
+ err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, this);
+
+ if( err != kDNSServiceErr_NoError )
+ {
+ if (sdRef)
+ DNSServiceRefDeallocate(sdRef);
+
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceResolve returned (error = %ld)", (int) err);
+ return false;
+ }
+
+ err = DNSServiceProcessResult(sdRef);
+
+ if (err != kDNSServiceErr_NoError)
+ CLog::Log(LOGERROR, "ZeroconfBrowserMDNS::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);
+
+ if (sdRef)
+ DNSServiceRefDeallocate(sdRef);
+
+#if defined(HAS_MDNS_EMBEDDED)
+ // when using the embedded mdns service the call to DNSServiceProcessResult
+ // above will not block until the resolving was finished - instead we have to
+ // wait for resolve to return or timeout
+ m_resolved_event.WaitMSec(f_timeout * 1000);
+#endif //HAS_MDNS_EMBEDDED
+ fr_service = m_resolving_service;
+ return (!fr_service.GetIP().empty());
+}
+
+void CZeroconfBrowserMDNS::ProcessResults()
+{
+ CSingleLock lock(m_data_guard);
+ DNSServiceErrorType err = DNSServiceProcessResult(m_browser);
+ if (err != kDNSServiceErr_NoError)
+ CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
+}
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2012-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <memory>
+#include <map>
+
+#include "network/ZeroconfBrowser.h"
+#include "threads/Thread.h"
+#include "threads/CriticalSection.h"
+#include <dns_sd.h>
+
+//platform specific implementation of zeroconfbrowser interface using native os x APIs
+class CZeroconfBrowserMDNS : public CZeroconfBrowser
+{
+public:
+ CZeroconfBrowserMDNS();
+ ~CZeroconfBrowserMDNS();
+
+private:
+ ///implementation if CZeroconfBrowser interface
+ ///@{
+ virtual bool doAddServiceType(const CStdString& fcr_service_type);
+ virtual bool doRemoveServiceType(const CStdString& fcr_service_type);
+
+ virtual std::vector<CZeroconfBrowser::ZeroconfService> doGetFoundServices();
+ virtual bool doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout);
+ ///@}
+
+ /// browser callback
+ static void DNSSD_API BrowserCallback(DNSServiceRef browser,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *serviceName,
+ const char *regtype,
+ const char *replyDomain,
+ void *context);
+ /// resolve callback
+ static void DNSSD_API ResolveCallback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *fullname,
+ const char *hosttarget,
+ uint16_t port, /* In network byte order */
+ uint16_t txtLen,
+ const unsigned char *txtRecord,
+ void *context
+ );
+
+ /// adds the service to list of found services
+ void addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
+ /// removes the service from list of found services
+ void removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
+ // win32: process replies from the bonjour daemon
+ void ProcessResults();
+
+ //shared variables (with guard)
+ CCriticalSection m_data_guard;
+ // tBrowserMap maps service types the corresponding browser
+ typedef std::map<std::string, DNSServiceRef> tBrowserMap;
+ tBrowserMap m_service_browsers;
+ //tDiscoveredServicesMap maps browsers to their discovered services + a ref-count for each service
+ //ref-count is needed, because a service might pop up more than once, if there's more than one network-iface
+ typedef std::map<DNSServiceRef, std::vector<std::pair<ZeroconfService, unsigned int> > > tDiscoveredServicesMap;
+ tDiscoveredServicesMap m_discovered_services;
+ DNSServiceRef m_browser;
+ CZeroconfBrowser::ZeroconfService m_resolving_service;
+ CEvent m_resolved_event;
+};
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ZeroconfMDNS.h"
+
+#include <string>
+#include <sstream>
+#include <threads/SingleLock.h>
+#include <utils/log.h>
+#include "dialogs/GUIDialogKaiToast.h"
+#include "guilib/LocalizeStrings.h"
+#if defined(TARGET_WINDOWS)
+#include "win32/WIN32Util.h"
+#endif //TARGET_WINDOWS
+
+#if defined(HAS_MDNS_EMBEDDED)
+#include <mDnsEmbedded.h>
+#endif //HAS_MDNS_EMBEDDED
+
+#pragma comment(lib, "dnssd.lib")
+
+extern HWND g_hWnd;
+
+void CZeroconfMDNS::Process()
+{
+#if defined(HAS_MDNS_EMBEDDED)
+ CLog::Log(LOGDEBUG, "ZeroconfEmbedded - processing...");
+ struct timeval timeout;
+ timeout.tv_sec = 1;
+ while (( !m_bStop ))
+ embedded_mDNSmainLoop(timeout);
+#endif //HAS_MDNS_EMBEDDED
+
+}
+
+
+CZeroconfMDNS::CZeroconfMDNS() : CThread("ZerocconfEmbedded")
+{
+ m_service = NULL;
+#if defined(HAS_MDNS_EMBEDDED)
+ embedded_mDNSInit();
+ Create();
+#endif //HAS_MDNS_EMBEDDED
+}
+
+CZeroconfMDNS::~CZeroconfMDNS()
+{
+ doStop();
+#if defined(HAS_MDNS_EMBEDDED)
+ StopThread();
+ embedded_mDNSExit();
+#endif //HAS_MDNS_EMBEDDED
+}
+
+bool CZeroconfMDNS::IsZCdaemonRunning()
+{
+#if !defined(HAS_MDNS_EMBEDDED)
+ uint32_t version;
+ uint32_t size = sizeof(version);
+ DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
+ if(err != kDNSServiceErr_NoError)
+ {
+ CLog::Log(LOGERROR, "ZeroconfMDNS: Zeroconf can't be started probably because Apple's Bonjour Service isn't installed. You can get it by either installing Itunes or Apple's Bonjour Print Service for Windows (http://support.apple.com/kb/DL999)");
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(34300), g_localizeStrings.Get(34301), 10000, true);
+ return false;
+ }
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS:Bonjour version is %d.%d", version / 10000, version / 100 % 100);
+#endif //!HAS_MDNS_EMBEDDED
+ return true;
+}
+
+//methods to implement for concrete implementations
+bool CZeroconfMDNS::doPublishService(const std::string& fcr_identifier,
+ const std::string& fcr_type,
+ const std::string& fcr_name,
+ unsigned int f_port,
+ const std::vector<std::pair<std::string, std::string> >& txt)
+{
+ DNSServiceRef netService = NULL;
+ TXTRecordRef txtRecord;
+ DNSServiceErrorType err;
+ TXTRecordCreate(&txtRecord, 0, NULL);
+
+#if !defined(HAS_MDNS_EMBEDDED)
+ if(m_service == NULL)
+ {
+ err = DNSServiceCreateConnection(&m_service);
+ if (err != kDNSServiceErr_NoError)
+ {
+ CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceCreateConnection failed with error = %ld", (int) err);
+ return false;
+ }
+ err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE );
+ if (err != kDNSServiceErr_NoError)
+ CLog::Log(LOGERROR, "ZeroconfMDNS: WSAAsyncSelect failed with error = %ld", (int) err);
+ }
+#endif //!HAS_MDNS_EMBEDDED
+
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port);
+
+ //add txt records
+ if(!txt.empty())
+ {
+ for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
+ {
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: key:%s, value:%s",it->first.c_str(),it->second.c_str());
+ uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
+ TXTRecordSetValue(&txtRecord, it->first.c_str(), txtLen, it->second.c_str());
+ }
+ }
+
+ {
+ CSingleLock lock(m_data_guard);
+ netService = m_service;
+ err = DNSServiceRegister(&netService, kDNSServiceFlagsShareConnection, 0, fcr_name.c_str(), fcr_type.c_str(), NULL, NULL, htons(f_port), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), registerCallback, NULL);
+ }
+
+ if (err != kDNSServiceErr_NoError)
+ {
+ // Something went wrong so lets clean up.
+ if (netService)
+ DNSServiceRefDeallocate(netService);
+
+ CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceRegister returned (error = %ld)", (int) err);
+ }
+ else
+ {
+ CSingleLock lock(m_data_guard);
+ m_services.insert(make_pair(fcr_identifier, netService));
+ }
+
+ TXTRecordDeallocate(&txtRecord);
+
+ return err == kDNSServiceErr_NoError;
+}
+
+bool CZeroconfMDNS::doRemoveService(const std::string& fcr_ident)
+{
+ CSingleLock lock(m_data_guard);
+ tServiceMap::iterator it = m_services.find(fcr_ident);
+ if(it != m_services.end())
+ {
+ DNSServiceRefDeallocate(it->second);
+ m_services.erase(it);
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: Removed service %s", fcr_ident.c_str());
+ return true;
+ }
+ else
+ return false;
+}
+
+void CZeroconfMDNS::doStop()
+{
+ {
+ CSingleLock lock(m_data_guard);
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: Shutdown services");
+ for(tServiceMap::iterator it = m_services.begin(); it != m_services.end(); ++it)
+ {
+ DNSServiceRefDeallocate(it->second);
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: Removed service %s", it->first.c_str());
+ }
+ m_services.clear();
+ }
+ {
+ CSingleLock lock(m_data_guard);
+#if defined(TARGET_WINDOWS)
+ WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, 0 );
+#endif //TARGET_WINDOWS
+
+ if (m_service)
+ DNSServiceRefDeallocate(m_service);
+ m_service = NULL;
+ }
+}
+
+void DNSSD_API CZeroconfMDNS::registerCallback(DNSServiceRef sdref, const DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context)
+{
+ (void)sdref; // Unused
+ (void)flags; // Unused
+ (void)context; // Unused
+
+ if (errorCode == kDNSServiceErr_NoError)
+ {
+ if (flags & kDNSServiceFlagsAdd)
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s now registered and active", name, regtype, domain);
+ else
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s registration removed", name, regtype, domain);
+ }
+ else if (errorCode == kDNSServiceErr_NameConflict)
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s Name in use, please choose another", name, regtype, domain);
+ else
+ CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s error code %d", name, regtype, domain, errorCode);
+}
+
+void CZeroconfMDNS::ProcessResults()
+{
+ CSingleLock lock(m_data_guard);
+ DNSServiceErrorType err = DNSServiceProcessResult(m_service);
+ if (err != kDNSServiceErr_NoError)
+ CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceProcessResult returned (error = %ld)", (int) err);
+}
+
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <memory>
+
+#include "network/Zeroconf.h"
+#include "threads/CriticalSection.h"
+#include <dns_sd.h>
+#include "threads/Thread.h"
+
+class CZeroconfMDNS : public CZeroconf,public CThread
+{
+public:
+ CZeroconfMDNS();
+ ~CZeroconfMDNS();
+
+protected:
+
+ //CThread interface
+ void Process();
+
+ //implement base CZeroConf interface
+ bool doPublishService(const std::string& fcr_identifier,
+ const std::string& fcr_type,
+ const std::string& fcr_name,
+ unsigned int f_port,
+ const std::vector<std::pair<std::string, std::string> >& txt);
+
+ bool doRemoveService(const std::string& fcr_ident);
+
+ virtual void doStop();
+
+ bool IsZCdaemonRunning();
+
+ void ProcessResults();
+
+private:
+
+ static void DNSSD_API registerCallback(DNSServiceRef sdref,
+ const DNSServiceFlags flags,
+ DNSServiceErrorType errorCode,
+ const char *name,
+ const char *regtype,
+ const char *domain,
+ void *context);
+
+
+ //lock + data (accessed from runloop(main thread) + the rest)
+ CCriticalSection m_data_guard;
+ typedef std::map<std::string, DNSServiceRef> tServiceMap;
+ tServiceMap m_services;
+ DNSServiceRef m_service;
+};
CTextureCache::GetWrappedImageURL(thumb).c_str());
// Set DLNA profileID by extension, defaulting to JPEG.
- NPT_String ext = URIUtils::GetExtension(thumb).c_str();
- if (strcmp(ext, ".png") == 0) {
+ if (URIUtils::HasExtension(thumb, ".png")) {
art.dlna_profile = "PNG_TN";
} else {
art.dlna_profile = "JPEG_TN";
"/thumb",
query.ToString()).ToString();
// Set DLNA profileID by extension, defaulting to JPEG.
- NPT_String ext = URIUtils::GetExtension(item.GetArt("thumb")).c_str();
- if (strcmp(ext, ".png") == 0) {
+ if (URIUtils::HasExtension(item.GetArt("thumb"), ".png")) {
art.dlna_profile = "PNG_TN";
} else {
art.dlna_profile = "JPEG_TN";
#include "video/VideoDatabase.h"
#include "guilib/GUIWindowManager.h"
#include "xbmc/GUIUserMessages.h"
+#include "utils/FileUtils.h"
using namespace std;
using namespace ANNOUNCEMENT;
NPT_Result
ObjectIDValidate(const NPT_String& id)
{
- if(id.Find("..") != -1)
- return NPT_ERROR_NO_SUCH_FILE;
- if(id.StartsWith("virtualpath://upnproot/"))
- return NPT_SUCCESS;
- else if(id.StartsWith("musicdb://"))
- return NPT_SUCCESS;
- else if(id.StartsWith("videodb://"))
- return NPT_SUCCESS;
- else if(id.StartsWith("library://video"))
- return NPT_SUCCESS;
- else if(id.StartsWith("sources://video"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://musicplaylists"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://profile/playlists"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://videoplaylists"))
+ if (CFileUtils::RemoteAccessAllowed(id.GetChars()))
return NPT_SUCCESS;
return NPT_ERROR_NO_SUCH_FILE;
}
return sUPnPSettings;
}
-void CUPnPSettings::OnSettingsCleared()
+void CUPnPSettings::OnSettingsUnloaded()
{
Clear();
}
public:
static CUPnPSettings& Get();
- virtual void OnSettingsCleared();
+ virtual void OnSettingsUnloaded();
bool Load(const std::string &file);
bool Save(const std::string &file) const;
// undefine if you want to build without the wlan stuff
// might be needed for VS2003
-//#define HAS_WIN32_WLAN_API
+#define HAS_WIN32_WLAN_API
#ifdef HAS_WIN32_WLAN_API
#include "Wlanapi.h"
PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
{
- for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
+ for(unsigned int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
{
GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
WCHAR wcguid[64];
std::vector<NetworkAccessPoint> CNetworkInterfaceWin32::GetAccessPoints(void)
{
std::vector<NetworkAccessPoint> result;
+#ifdef HAS_WIN32_WLAN_API
+ if (!IsWireless())
+ return result;
+
+ // According to Mozilla: "We could be executing on either Windows XP or Windows
+ // Vista, so use the lower version of the client WLAN API. It seems that the
+ // negotiated version is the Vista version irrespective of what we pass!"
+ // http://dxr.mozilla.org/mozilla-central/source/netwerk/wifi/nsWifiScannerWin.cpp#l51
+ static const int xpWlanClientVersion = 1;
+ DWORD negotiated_version;
+ DWORD dwResult;
+ HANDLE wlan_handle = NULL;
+
+ // Get the handle to the WLAN API
+ dwResult = WlanOpenHandle(xpWlanClientVersion, NULL, &negotiated_version, &wlan_handle);
+ if (dwResult != ERROR_SUCCESS || !wlan_handle)
+ {
+ CLog::Log(LOGERROR, "Could not load the client WLAN API");
+ return result;
+ }
+
+ // Get the list of interfaces (WlanEnumInterfaces allocates interface_list)
+ WLAN_INTERFACE_INFO_LIST *interface_list = NULL;
+ dwResult = WlanEnumInterfaces(wlan_handle, NULL, &interface_list);
+ if (dwResult != ERROR_SUCCESS || !interface_list)
+ {
+ WlanCloseHandle(wlan_handle, NULL);
+ CLog::Log(LOGERROR, "Failed to get the list of interfaces");
+ return result;
+ }
+
+ for (unsigned int i = 0; i < interface_list->dwNumberOfItems; ++i)
+ {
+ GUID guid = interface_list->InterfaceInfo[i].InterfaceGuid;
+ WCHAR wcguid[64];
+ StringFromGUID2(guid, (LPOLESTR)&wcguid, 64);
+ CStdStringW strGuid = wcguid;
+ CStdStringW strAdaptername = m_adapter.AdapterName;
+ if (strGuid == strAdaptername)
+ {
+ WLAN_BSS_LIST *bss_list;
+ HRESULT rv = WlanGetNetworkBssList(wlan_handle,
+ &interface_list->InterfaceInfo[i].InterfaceGuid,
+ NULL, // Get all SSIDs
+ dot11_BSS_type_any, // unused
+ false, // bSecurityEnabled - unused
+ NULL, // reserved
+ &bss_list);
+ if (rv != ERROR_SUCCESS || !bss_list)
+ break;
+ for (unsigned int j = 0; j < bss_list->dwNumberOfItems; ++j)
+ {
+ const WLAN_BSS_ENTRY bss_entry = bss_list->wlanBssEntries[j];
+ // Add the access point info to the list of results
+ CStdString essId((char*)bss_entry.dot11Ssid.ucSSID, (unsigned int)bss_entry.dot11Ssid.uSSIDLength);
+ CStdString macAddress;
+ // macAddress is big-endian, write in byte chunks
+ macAddress.Format("%02x-%02x-%02x-%02x-%02x-%02x",
+ bss_entry.dot11Bssid[0], bss_entry.dot11Bssid[1], bss_entry.dot11Bssid[2],
+ bss_entry.dot11Bssid[3], bss_entry.dot11Bssid[4], bss_entry.dot11Bssid[5]);
+ int signalLevel = bss_entry.lRssi;
+ EncMode encryption = ENC_NONE; // TODO
+ int channel = NetworkAccessPoint::FreqToChannel((float)bss_entry.ulChCenterFrequency * 1000);
+ result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
+ }
+ WlanFreeMemory(bss_list);
+ break;
+ }
+ }
- return result;
+ // Free the interface list
+ WlanFreeMemory(interface_list);
+
+ // Close the handle
+ WlanCloseHandle(wlan_handle, NULL);
+
+#endif
+
+ return result;
}
void CNetworkInterfaceWin32::GetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
{
- for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
+ for(unsigned int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
{
GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
WCHAR wcguid[64];
+++ /dev/null
-/*
- * Copyright (C) 2012-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ZeroconfBrowserWIN.h"
-#include <utils/log.h>
-#include <threads/SingleLock.h>
-#include "guilib/GUIWindowManager.h"
-#include "guilib/GUIMessage.h"
-#include "GUIUserMessages.h"
-#include "win32/WIN32Util.h"
-#include "network/DNSNameCache.h"
-
-#pragma comment(lib, "dnssd.lib")
-
-extern HWND g_hWnd;
-
-CZeroconfBrowserWIN::CZeroconfBrowserWIN()
-{
- m_browser = NULL;
-}
-
-CZeroconfBrowserWIN::~CZeroconfBrowserWIN()
-{
- CSingleLock lock(m_data_guard);
- //make sure there are no browsers anymore
- for(tBrowserMap::iterator it = m_service_browsers.begin(); it != m_service_browsers.end(); ++it )
- doRemoveServiceType(it->first);
-
- WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 );
- DNSServiceRefDeallocate(m_browser);
- m_browser = NULL;
-}
-
-void DNSSD_API CZeroconfBrowserWIN::BrowserCallback(DNSServiceRef browser,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
- DNSServiceErrorType errorCode,
- const char *serviceName,
- const char *regtype,
- const char *replyDomain,
- void *context)
-{
-
- if (errorCode == kDNSServiceErr_NoError)
- {
- //get our instance
- CZeroconfBrowserWIN* p_this = reinterpret_cast<CZeroconfBrowserWIN*>(context);
- //store the service
- ZeroconfService s(serviceName, regtype, replyDomain);
-
- if (flags & kDNSServiceFlagsAdd)
- {
- CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback found service named: %s, type: %s, domain: %s", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
- p_this->addDiscoveredService(browser, s);
- }
- else
- {
- CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback service named: %s, type: %s, domain: %s disappeared", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
- p_this->removeDiscoveredService(browser, s);
- }
- if(! (flags & kDNSServiceFlagsMoreComing) )
- {
- CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH);
- message.SetStringParam("zeroconf://");
- g_windowManager.SendThreadMessage(message);
- CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback sent gui update for path zeroconf://");
- }
- }
- else
- {
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN::BrowserCallback returned (error = %ld)\n", (int)errorCode);
- }
-}
-
-void DNSSD_API CZeroconfBrowserWIN::ResolveCallback(DNSServiceRef sdRef,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
- DNSServiceErrorType errorCode,
- const char *fullname,
- const char *hosttarget,
- uint16_t port, /* In network byte order */
- uint16_t txtLen,
- const unsigned char *txtRecord,
- void *context
- )
-{
-
- if (errorCode)
- {
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: ResolveCallback failed with error = %ld", (int) errorCode);
- return;
- }
-
- DNSServiceErrorType err;
- CZeroconfBrowser::ZeroconfService::tTxtRecordMap recordMap;
- CStdString strIP;
- CZeroconfBrowser::ZeroconfService* service = (CZeroconfBrowser::ZeroconfService*) context;
-
- if(!CDNSNameCache::Lookup(hosttarget, strIP))
- {
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: Could not resolve hostname %s",hosttarget);
- return;
- }
- service->SetIP(strIP);
-
- for(uint16_t i = 0; i < TXTRecordGetCount(txtLen, txtRecord); ++i)
- {
- char key[256];
- uint8_t valueLen;
- const void *value;
- std::string strvalue;
- err = TXTRecordGetItemAtIndex(txtLen, txtRecord,i ,sizeof(key) , key, &valueLen, &value);
- if(err != kDNSServiceErr_NoError)
- continue;
-
- if(value != NULL && valueLen > 0)
- strvalue.append((const char *)value, valueLen);
-
- recordMap.insert(std::make_pair(key, strvalue));
- }
- service->SetTxtRecords(recordMap);
- service->SetPort(ntohs(port));
-}
-
-/// adds the service to list of found services
-void CZeroconfBrowserWIN::addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
-{
- CSingleLock lock(m_data_guard);
- tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
- if(browserIt == m_discovered_services.end())
- {
- //first service by this browser
- browserIt = m_discovered_services.insert(make_pair(browser, std::vector<std::pair<ZeroconfService, unsigned int> >())).first;
- }
- //search this service
- std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
- std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
- for( ; serviceIt != services.end(); ++serviceIt)
- {
- if(serviceIt->first == fcr_service)
- break;
- }
- if(serviceIt == services.end())
- services.push_back(std::make_pair(fcr_service, 1));
- else
- ++serviceIt->second;
-}
-
-void CZeroconfBrowserWIN::removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
-{
- CSingleLock lock(m_data_guard);
- tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
- //search this service
- std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
- std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
- for( ; serviceIt != services.end(); ++serviceIt)
- if(serviceIt->first == fcr_service)
- break;
- if(serviceIt != services.end())
- {
- //decrease refCount
- --serviceIt->second;
- if(!serviceIt->second)
- {
- //eventually remove the service
- services.erase(serviceIt);
- }
- } else
- {
- //looks like we missed the announce, no problem though..
- }
-}
-
-
-bool CZeroconfBrowserWIN::doAddServiceType(const CStdString& fcr_service_type)
-{
- DNSServiceErrorType err;
- DNSServiceRef browser = NULL;
-
- if(m_browser == NULL)
- {
- err = DNSServiceCreateConnection(&m_browser);
- if (err != kDNSServiceErr_NoError)
- {
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceCreateConnection failed with error = %ld", (int) err);
- return false;
- }
- err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE );
- if (err != kDNSServiceErr_NoError)
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: WSAAsyncSelect failed with error = %ld", (int) err);
- }
-
- {
- CSingleLock lock(m_data_guard);
- browser = m_browser;
- err = DNSServiceBrowse(&browser, kDNSServiceFlagsShareConnection, kDNSServiceInterfaceIndexAny, fcr_service_type.c_str(), NULL, BrowserCallback, this);
- }
-
- if( err != kDNSServiceErr_NoError )
- {
- if (browser)
- DNSServiceRefDeallocate(browser);
-
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceBrowse returned (error = %ld)", (int) err);
- return false;
- }
-
- //store the browser
- {
- CSingleLock lock(m_data_guard);
- m_service_browsers.insert(std::make_pair(fcr_service_type, browser));
- }
-
- return true;
-}
-
-bool CZeroconfBrowserWIN::doRemoveServiceType(const CStdString& fcr_service_type)
-{
- //search for this browser and remove it from the map
- DNSServiceRef browser = 0;
- {
- CSingleLock lock(m_data_guard);
- tBrowserMap::iterator it = m_service_browsers.find(fcr_service_type);
- if(it == m_service_browsers.end())
- {
- return false;
- }
- browser = it->second;
- m_service_browsers.erase(it);
- }
-
- //remove the services of this browser
- {
- CSingleLock lock(m_data_guard);
- tDiscoveredServicesMap::iterator it = m_discovered_services.find(browser);
- if(it != m_discovered_services.end())
- m_discovered_services.erase(it);
- }
-
- DNSServiceRefDeallocate(browser);
-
- return true;
-}
-
-std::vector<CZeroconfBrowser::ZeroconfService> CZeroconfBrowserWIN::doGetFoundServices()
-{
- std::vector<CZeroconfBrowser::ZeroconfService> ret;
- CSingleLock lock(m_data_guard);
- for(tDiscoveredServicesMap::const_iterator it = m_discovered_services.begin();
- it != m_discovered_services.end(); ++it)
- {
- const std::vector<std::pair<CZeroconfBrowser::ZeroconfService, unsigned int> >& services = it->second;
- for(unsigned int i = 0; i < services.size(); ++i)
- {
- ret.push_back(services[i].first);
- }
- }
- return ret;
-}
-
-bool CZeroconfBrowserWIN::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
-{
- DNSServiceErrorType err;
- DNSServiceRef sdRef = NULL;
-
- err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, &fr_service);
-
- if( err != kDNSServiceErr_NoError )
- {
- if (sdRef)
- DNSServiceRefDeallocate(sdRef);
-
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceResolve returned (error = %ld)", (int) err);
- return false;
- }
-
- err = DNSServiceProcessResult(sdRef);
-
- if (err != kDNSServiceErr_NoError)
- CLog::Log(LOGERROR, "ZeroconfBrowserWIN::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);
-
- if (sdRef)
- DNSServiceRefDeallocate(sdRef);
-
- return true;
-}
-
-void CZeroconfBrowserWIN::ProcessResults()
-{
- CSingleLock lock(m_data_guard);
- DNSServiceErrorType err = DNSServiceProcessResult(m_browser);
- if (err != kDNSServiceErr_NoError)
- CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
-}
\ No newline at end of file
+++ /dev/null
-#pragma once
-/*
- * Copyright (C) 2012-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <memory>
-#include <map>
-
-#include "network/ZeroconfBrowser.h"
-#include "threads/Thread.h"
-#include "threads/CriticalSection.h"
-#include <dns_sd.h>
-
-//platform specific implementation of zeroconfbrowser interface using native os x APIs
-class CZeroconfBrowserWIN : public CZeroconfBrowser
-{
-public:
- CZeroconfBrowserWIN();
- ~CZeroconfBrowserWIN();
-
-private:
- ///implementation if CZeroconfBrowser interface
- ///@{
- virtual bool doAddServiceType(const CStdString& fcr_service_type);
- virtual bool doRemoveServiceType(const CStdString& fcr_service_type);
-
- virtual std::vector<CZeroconfBrowser::ZeroconfService> doGetFoundServices();
- virtual bool doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout);
- ///@}
-
- /// browser callback
- static void DNSSD_API BrowserCallback(DNSServiceRef browser,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
- DNSServiceErrorType errorCode,
- const char *serviceName,
- const char *regtype,
- const char *replyDomain,
- void *context);
- /// resolve callback
- static void DNSSD_API ResolveCallback(DNSServiceRef sdRef,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
- DNSServiceErrorType errorCode,
- const char *fullname,
- const char *hosttarget,
- uint16_t port, /* In network byte order */
- uint16_t txtLen,
- const unsigned char *txtRecord,
- void *context
- );
-
- /// adds the service to list of found services
- void addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
- /// removes the service from list of found services
- void removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
- // win32: process replies from the bonjour daemon
- void ProcessResults();
-
- //shared variables (with guard)
- CCriticalSection m_data_guard;
- // tBrowserMap maps service types the corresponding browser
- typedef std::map<std::string, DNSServiceRef> tBrowserMap;
- tBrowserMap m_service_browsers;
- //tDiscoveredServicesMap maps browsers to their discovered services + a ref-count for each service
- //ref-count is needed, because a service might pop up more than once, if there's more than one network-iface
- typedef std::map<DNSServiceRef, std::vector<std::pair<ZeroconfService, unsigned int> > > tDiscoveredServicesMap;
- tDiscoveredServicesMap m_discovered_services;
- DNSServiceRef m_browser;
-};
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ZeroconfWIN.h"
-
-#include <string>
-#include <sstream>
-#include <threads/SingleLock.h>
-#include <utils/log.h>
-#include "dialogs/GUIDialogKaiToast.h"
-#include "guilib/LocalizeStrings.h"
-#include "win32/WIN32Util.h"
-
-#pragma comment(lib, "dnssd.lib")
-
-extern HWND g_hWnd;
-
-CZeroconfWIN::CZeroconfWIN()
-{
- m_service = NULL;
-}
-
-CZeroconfWIN::~CZeroconfWIN()
-{
- doStop();
-}
-
-bool CZeroconfWIN::IsZCdaemonRunning()
-{
- uint32_t version;
- uint32_t size = sizeof(version);
- DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
- if(err != kDNSServiceErr_NoError)
- {
- CLog::Log(LOGERROR, "ZeroconfWIN: Zeroconf can't be started probably because Apple's Bonjour Service isn't installed. You can get it by either installing Itunes or Apple's Bonjour Print Service for Windows (http://support.apple.com/kb/DL999)");
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(34300), g_localizeStrings.Get(34301), 10000, true);
- return false;
- }
- CLog::Log(LOGDEBUG, "ZeroconfWIN:Bonjour version is %d.%d", version / 10000, version / 100 % 100);
- return true;
-}
-
-//methods to implement for concrete implementations
-bool CZeroconfWIN::doPublishService(const std::string& fcr_identifier,
- const std::string& fcr_type,
- const std::string& fcr_name,
- unsigned int f_port,
- const std::vector<std::pair<std::string, std::string> >& txt)
-{
- DNSServiceRef netService = NULL;
- TXTRecordRef txtRecord;
- DNSServiceErrorType err;
- TXTRecordCreate(&txtRecord, 0, NULL);
-
- if(m_service == NULL)
- {
- err = DNSServiceCreateConnection(&m_service);
- if (err != kDNSServiceErr_NoError)
- {
- CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceCreateConnection failed with error = %ld", (int) err);
- return false;
- }
- err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE );
- if (err != kDNSServiceErr_NoError)
- CLog::Log(LOGERROR, "ZeroconfWIN: WSAAsyncSelect failed with error = %ld", (int) err);
- }
-
- CLog::Log(LOGDEBUG, "ZeroconfWIN: identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port);
-
- //add txt records
- if(!txt.empty())
- {
- for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
- {
- CLog::Log(LOGDEBUG, "ZeroconfWIN: key:%s, value:%s",it->first.c_str(),it->second.c_str());
- uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
- TXTRecordSetValue(&txtRecord, it->first.c_str(), txtLen, it->second.c_str());
- }
- }
-
- {
- CSingleLock lock(m_data_guard);
- netService = m_service;
- err = DNSServiceRegister(&netService, kDNSServiceFlagsShareConnection, 0, fcr_name.c_str(), fcr_type.c_str(), NULL, NULL, htons(f_port), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), registerCallback, NULL);
- }
-
- if (err != kDNSServiceErr_NoError)
- {
- // Something went wrong so lets clean up.
- if (netService)
- DNSServiceRefDeallocate(netService);
-
- CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceRegister returned (error = %ld)", (int) err);
- }
- else
- {
- CSingleLock lock(m_data_guard);
- m_services.insert(make_pair(fcr_identifier, netService));
- }
-
- TXTRecordDeallocate(&txtRecord);
-
- return err == kDNSServiceErr_NoError;
-}
-
-bool CZeroconfWIN::doRemoveService(const std::string& fcr_ident)
-{
- CSingleLock lock(m_data_guard);
- tServiceMap::iterator it = m_services.find(fcr_ident);
- if(it != m_services.end())
- {
- DNSServiceRefDeallocate(it->second);
- m_services.erase(it);
- CLog::Log(LOGDEBUG, "ZeroconfWIN: Removed service %s", fcr_ident.c_str());
- return true;
- }
- else
- return false;
-}
-
-void CZeroconfWIN::doStop()
-{
- {
- CSingleLock lock(m_data_guard);
- CLog::Log(LOGDEBUG, "ZeroconfWIN: Shutdown services");
- for(tServiceMap::iterator it = m_services.begin(); it != m_services.end(); ++it)
- {
- DNSServiceRefDeallocate(it->second);
- CLog::Log(LOGDEBUG, "ZeroconfWIN: Removed service %s", it->first.c_str());
- }
- m_services.clear();
- }
- {
- CSingleLock lock(m_data_guard);
- WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, 0 );
- DNSServiceRefDeallocate(m_service);
- m_service = NULL;
- }
-}
-
-void DNSSD_API CZeroconfWIN::registerCallback(DNSServiceRef sdref, const DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context)
-{
- (void)sdref; // Unused
- (void)flags; // Unused
- (void)context; // Unused
-
- if (errorCode == kDNSServiceErr_NoError)
- {
- if (flags & kDNSServiceFlagsAdd)
- CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s now registered and active", name, regtype, domain);
- else
- CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s registration removed", name, regtype, domain);
- }
- else if (errorCode == kDNSServiceErr_NameConflict)
- CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s Name in use, please choose another", name, regtype, domain);
- else
- CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s error code %d", name, regtype, domain, errorCode);
-}
-
-void CZeroconfWIN::ProcessResults()
-{
- CSingleLock lock(m_data_guard);
- DNSServiceErrorType err = DNSServiceProcessResult(m_service);
- if (err != kDNSServiceErr_NoError)
- CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
-}
\ No newline at end of file
+++ /dev/null
-#pragma once
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <memory>
-
-#include "network/Zeroconf.h"
-#include "threads/CriticalSection.h"
-#include <dns_sd.h>
-
-class CZeroconfWIN : public CZeroconf
-{
-public:
- CZeroconfWIN();
- ~CZeroconfWIN();
-protected:
- //implement base CZeroConf interface
- bool doPublishService(const std::string& fcr_identifier,
- const std::string& fcr_type,
- const std::string& fcr_name,
- unsigned int f_port,
- const std::vector<std::pair<std::string, std::string> >& txt);
-
- bool doRemoveService(const std::string& fcr_ident);
-
- virtual void doStop();
-
- bool IsZCdaemonRunning();
-
- void ProcessResults();
-
-private:
-
- static void DNSSD_API registerCallback(DNSServiceRef sdref,
- const DNSServiceFlags flags,
- DNSServiceErrorType errorCode,
- const char *name,
- const char *regtype,
- const char *domain,
- void *context);
-
-
- //lock + data (accessed from runloop(main thread) + the rest)
- CCriticalSection m_data_guard;
- typedef std::map<std::string, DNSServiceRef> tServiceMap;
- tServiceMap m_services;
- DNSServiceRef m_service;
-};
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <winsock.h>
#else
#include <sys/socket.h>
static void Clean()
{
- #ifdef _WIN32
+ #ifdef TARGET_WINDOWS
WSACleanup();
#endif
}
static bool Initialize()
{
- #ifdef _WIN32
+ #ifdef TARGET_WINDOWS
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData))
return false;
#include <map>
#include <stdio.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "PlatformDefs.h"
#endif
#include "utils/StdString.h"
using namespace std;
using namespace PERIPHERALS;
-#define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 1000
+#define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 5000
-CPeripheralBus::CPeripheralBus(CPeripherals *manager, PeripheralBusType type) :
- CThread("PeripheralBus"),
+CPeripheralBus::CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type) :
+ CThread(threadname),
m_iRescanTime(PERIPHERAL_DEFAULT_RESCAN_INTERVAL),
m_bInitialised(false),
m_bIsStarted(false),
/*!
* @class CPeripheralBus
- * This represents a bus on the system. By default, this bus instance will scan for changes every second.
+ * This represents a bus on the system. By default, this bus instance will scan for changes every 5 seconds.
* If this bus only has to be updated after a notification sent by the system, set m_bNeedsPolling to false
* in the constructor, and implement the OnDeviceAdded(), OnDeviceChanged() and OnDeviceRemoved() methods.
*
class CPeripheralBus : protected CThread
{
public:
- CPeripheralBus(CPeripherals *manager, PeripheralBusType type);
+ CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type);
virtual ~CPeripheralBus(void) { Clear(); }
/*!
using namespace PERIPHERALS;
CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
- CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+ CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
{
usb_init();
usb_find_busses();
dev->config[0].bNumInterfaces > 0 && dev->config[0].interface[0].num_altsetting > 0) ?
GetType(dev->config[0].interface[0].altsetting[0].bInterfaceClass) :
GetType(dev->descriptor.bDeviceClass);
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
result.m_strLocation.Format("%s", dev->filename);
#else
result.m_strLocation.Format("/bus%s/dev%s", bus->dirname, dev->filename);
using namespace PERIPHERALS;
CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
- CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+ CPeripheralBus("PeripBusUSBUdev", manager, PERIPHERAL_BUS_USB)
{
/* the Process() method in this class overrides the one in CPeripheralBus, so leave this set to true */
m_bNeedsPolling = true;
#endif
CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
- CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+ CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
{
m_bNeedsPolling = false;
};
CPeripheralBusCEC::CPeripheralBusCEC(CPeripherals *manager) :
- CPeripheralBus(manager, PERIPHERAL_BUS_CEC),
+ CPeripheralBus("PeripBusCEC", manager, PERIPHERAL_BUS_CEC),
m_dll(new DllLibCEC),
m_cecAdapter(NULL)
{
- m_iRescanTime = 1000;
+ m_iRescanTime = 5000;
if (!m_dll->Load() || !m_dll->IsLoaded())
{
delete m_dll;
using namespace PERIPHERALS;
CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
- CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+ CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
{
/* device removals aren't always triggering OnDeviceRemoved events, so poll for changes every 5 seconds to be sure we don't miss anything */
m_iRescanTime = 5000;
#undef LoadImage
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
typedef struct tagRGBQUAD {
BYTE rgbBlue;
BYTE rgbGreen;
{
CURL url(m_slides->Get(m_iCurrentSlide)->GetPath());
CStdString strHostName = url.GetHostName();
- if (URIUtils::GetExtension(strHostName).Equals(".cbr", false) || URIUtils::GetExtension(strHostName).Equals(".cbz", false))
+ if (URIUtils::HasExtension(strHostName, ".cbr|.cbz"))
{
m_Image[iPic].m_bIsComic = true;
m_Image[iPic].Move((float)m_Image[iPic].GetOriginalWidth(),(float)m_Image[iPic].GetOriginalHeight());
*/
#include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile)
{
CLog::Log(LOGDEBUG, "cached image '%s' size %dx%d", thumbFile.c_str(), width, height);
- if (URIUtils::GetExtension(thumbFile).Equals(".jpg"))
+ if (URIUtils::HasExtension(thumbFile, ".jpg"))
{
#if defined(HAS_OMXPLAYER)
COMXImage *omxImage = new COMXImage();
{
// try to read as a string
CStdString data;
-#if _MSC_VER > 1500
+#if TARGET_WINDOWS
std::stringstream _stream(data);
_stream << stream;
#else
bool CPlayListFactory::IsPlaylist(const CStdString& filename)
{
- CStdString extension = URIUtils::GetExtension(filename);
- extension.ToLower();
-
- if (extension == ".m3u") return true;
- if (extension == ".b4s") return true;
- if (extension == ".pls") return true;
- if (extension == ".strm") return true;
- if (extension == ".wpl") return true;
- if (extension == ".asx") return true;
- if (extension == ".ram") return true;
- if (extension == ".url") return true;
- if (extension == ".pxml") return true;
- return false;
+ return URIUtils::HasExtension(filename,
+ ".m3u|.b4s|.pls|.strm|.wpl|.asx|.ram|.url|.pxml");
}
if (m_playlistName.empty())
{
m_playlistName = CUtil::GetTitleFromPath(path);
- if (URIUtils::GetExtension(m_playlistName) == ".xsp")
+ if (URIUtils::HasExtension(m_playlistName, ".xsp"))
URIUtils::RemoveExtension(m_playlistName);
}
#include "utils/SystemInfo.h"
#include <assert.h>
#include <string>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "guilib/GraphicContext.h"
#endif
}
///// Add other platforms here.
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
void DPMSSupport::PlatformSpecificInit()
{
// Assume we support DPMS. Is there a way to test it?
#include "osx/CocoaPowerSyscall.h"
#elif defined(TARGET_ANDROID)
#include "android/AndroidPowerSyscall.h"
-#elif defined(_LINUX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
#include "linux/ConsoleUPowerSyscall.h"
#include "linux/ConsoleDeviceKitPowerSyscall.h"
#include "linux/SystemdUPowerSyscall.h"
#ifdef HAS_HAL
#include "linux/HALPowerSyscall.h"
#endif
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
#include "powermanagement/windows/Win32PowerSyscall.h"
extern HWND g_hWnd;
#endif
m_instance = new CCocoaPowerSyscall();
#elif defined(TARGET_ANDROID)
m_instance = new CAndroidPowerSyscall();
-#elif defined(_LINUX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
if (CConsoleUPowerSyscall::HasConsoleKitAndUPower())
m_instance = new CConsoleUPowerSyscall();
else if (CConsoleDeviceKitPowerSyscall::HasDeviceConsoleKit())
else
m_instance = new CHALPowerSyscall();
#endif
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
m_instance = new CWin32PowerSyscall();
#endif
#if defined(HAS_SDL) || defined(TARGET_WINDOWS)
if (g_Windowing.IsFullScreen())
{
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
ShowWindow(g_hWnd,SW_RESTORE);
SetForegroundWindow(g_hWnd);
#elif !defined(TARGET_DARWIN_OSX)
#include "Win32PowerSyscall.h"
#include "powermanagement/PowerManager.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "WIN32Util.h"
bool CWin32PowerSyscall::m_OnResume = false;
*
*/
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#ifndef _WIN32_POWER_SYSCALL_H_
#define _WIN32_POWER_SYSCALL_H_
#include "powermanagement/IPowerSyscall.h"
else if (settingId == "pvrclient.menuhook")
{
if (IsStarted())
- Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING);
+ Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING, NULL);
}
}
return PVR_ERROR_UNKNOWN;
}
-void CPVRClient::CallMenuHook(const PVR_MENUHOOK &hook)
+void CPVRClient::CallMenuHook(const PVR_MENUHOOK &hook, const CFileItem *item)
{
if (!m_bReadyToUse)
return;
- try { m_pStruct->MenuHook(hook); }
+ try {
+ PVR_MENUHOOK_DATA hookData;
+ hookData.cat = PVR_MENUHOOK_UNKNOWN;
+
+ if (item)
+ {
+ if (item->IsEPG())
+ {
+ hookData.cat = PVR_MENUHOOK_EPG;
+ hookData.data.iEpgUid = item->GetEPGInfoTag()->BroadcastId();
+ }
+ else if (item->IsPVRChannel())
+ {
+ hookData.cat = PVR_MENUHOOK_CHANNEL;
+ WriteClientChannelInfo(*item->GetPVRChannelInfoTag(), hookData.data.channel);
+ }
+ else if (item->IsPVRRecording())
+ {
+ hookData.cat = PVR_MENUHOOK_RECORDING;
+ WriteClientRecordingInfo(*item->GetPVRRecordingInfoTag(), hookData.data.recording);
+ }
+ else if (item->IsPVRTimer())
+ {
+ hookData.cat = PVR_MENUHOOK_TIMER;
+ WriteClientTimerInfo(*item->GetPVRTimerInfoTag(), hookData.data.timer);
+ }
+ }
+
+ m_pStruct->MenuHook(hook, hookData);
+ }
catch (exception &e) { LogException(e, __FUNCTION__); }
}
/*!
* @brief Call one of the menu hooks of this client.
* @param hook The hook to call.
+ * @param item The selected file item for which the hook was called.
*/
- void CallMenuHook(const PVR_MENUHOOK &hook);
+ void CallMenuHook(const PVR_MENUHOOK &hook, const CFileItem *item);
//@}
/** @name PVR EPG methods */
return bReturn;
}
-void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat)
+void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item)
{
PVR_MENUHOOKS *hooks = NULL;
int selection = pDialog->GetSelectedLabel();
if (selection >= 0)
- client->CallMenuHook(hooks->at(selection));
+ client->CallMenuHook(hooks->at(selection), item);
}
}
/*!
* @brief Open selection and progress PVR actions.
* @param iClientId The ID of the client to process the menu entries for. Process the menu entries for the active channel if iClientId < 0.
+ * @param item The selected file item for which the hook was called.
*/
- void ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat);
+ void ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item);
//@}
bReturn = true;
if (item->IsEPG() && item->GetEPGInfoTag()->HasPVRChannel())
- g_PVRClients->ProcessMenuHooks(item->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG);
+ g_PVRClients->ProcessMenuHooks(item->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG, item);
else if (item->IsPVRChannel())
- g_PVRClients->ProcessMenuHooks(item->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL);
+ g_PVRClients->ProcessMenuHooks(item->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL, item);
else if (item->IsPVRRecording())
- g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_RECORDING);
+ g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_RECORDING, item);
else if (item->IsPVRTimer())
- g_PVRClients->ProcessMenuHooks(item->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER);
+ g_PVRClients->ProcessMenuHooks(item->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER, item);
}
return bReturn;
vector<int> stack;
for (int i = 0; i < items.Size(); ++i)
{
- if (URIUtils::GetExtension(items[i]->GetPath()) == ext)
+ if (URIUtils::HasExtension(items[i]->GetPath(), ext))
stack.push_back(i);
}
void CRenderSystemGL::CheckOpenGLQuirks()
{
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
if (m_RenderVendor.Find("NVIDIA") > -1)
{
// Nvidia 7300 (AppleTV) and 7600 cannot do DXT with NPOT under OSX
}
}
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
// Max Texture size reported on some apple machines seems incorrect
// Displaying a picture with that resolution results in a corrupted output
// So force it to a lower value
CLog::SetLogLevel(m_logLevel);
}
+void CAdvancedSettings::OnSettingsUnloaded()
+{
+ m_initialized = false;
+}
+
void CAdvancedSettings::OnSettingChanged(const CSetting *setting)
{
if (setting == NULL)
void CAdvancedSettings::Initialize()
{
+ if (m_initialized)
+ return;
+
m_audioHeadRoom = 0;
m_ac3Gain = 12.0f;
m_audioApplyDrc = true;
m_bVirtualShares = true;
//caused lots of jerks
-//#ifdef _WIN32
+//#ifdef TARGET_WINDOWS
// m_ForcedSwapTime = 2.0;
//#else
m_ForcedSwapTime = 0.0;
m_measureRefreshrate = false;
m_cacheMemBufferSize = 1024 * 1024 * 20;
+ m_alwaysForceBuffer = false;
m_addonPackageFolderSize = 200;
m_jsonOutputCompact = true;
XMLUtils::GetInt(pElement, "curlretries", m_curlretries, 0, 10);
XMLUtils::GetBoolean(pElement,"disableipv6", m_curlDisableIPV6);
XMLUtils::GetUInt(pElement, "cachemembuffersize", m_cacheMemBufferSize);
+ XMLUtils::GetBoolean(pElement, "alwaysforcebuffer", m_alwaysForceBuffer);
}
pElement = pRootElement->FirstChildElement("jsonrpc");
}
}
CStdString regExp = pRegExp->FirstChild()->Value();
- regExp.MakeLower();
if (iAction == 2)
settings.insert(settings.begin() + i++, 1, TVShowRegexp(bByDate,regExp,iDefaultSeason));
else
static CAdvancedSettings* getInstance();
virtual void OnSettingsLoaded();
+ virtual void OnSettingsUnloaded();
virtual void OnSettingChanged(const CSetting *setting);
unsigned int m_addonPackageFolderSize;
unsigned int m_cacheMemBufferSize;
+ bool m_alwaysForceBuffer;
bool m_jsonOutputCompact;
unsigned int m_jsonTcpPort;
void CDisplaySettings::SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t)
{
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
list.push_back(make_pair(g_localizeStrings.Get(13101), VSYNC_DRIVER));
#endif
list.push_back(make_pair(g_localizeStrings.Get(13106), VSYNC_DISABLED));
*/
virtual void OnSettingsSaved() const { }
/*!
+ \brief Setting values have been unloaded.
+
+ This callback can be used to trigger uninitializing any state variables
+ (e.g. before re-loading the settings).
+ */
+ virtual void OnSettingsUnloaded() { }
+ /*!
\brief Settings have been cleared.
- This callback can be used to trigger clearing any state variables (e.g.
- before re-loading the settings).
+ This callback can be used to trigger clearing any state variables.
*/
virtual void OnSettingsCleared() { }
};
Load();
}
-void CMediaSourceSettings::OnSettingsCleared()
+void CMediaSourceSettings::OnSettingsUnloaded()
{
Clear();
}
if (pThumbnailNode && pThumbnailNode->FirstChild())
share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value();
+ XMLUtils::GetBoolean(source, "allowsharing", share.m_allowSharing);
+
return true;
}
XMLUtils::SetString(&source, "lockcode", share.m_strLockCode);
XMLUtils::SetInt(&source, "badpwdcount", share.m_iBadPwdCount);
}
+
if (!share.m_strThumbnailImage.empty())
XMLUtils::SetPath(&source, "thumbnail", share.m_strThumbnailImage);
+ XMLUtils::SetBoolean(&source, "allowsharing", share.m_allowSharing);
+
sectionNode->InsertEndChild(source);
}
static std::string GetSourcesFile();
virtual void OnSettingsLoaded();
- virtual void OnSettingsCleared();
+ virtual void OnSettingsUnloaded();
bool Load();
bool Load(const std::string &file);
#elif defined(HAS_SDL_JOYSTICK)
#include "input/SDLJoystick.h"
#endif // defined(HAS_SDL_JOYSTICK)
-#if defined(TARGET_LINUX)
+#if defined(TARGET_POSIX)
#include "linux/LinuxTimezone.h"
-#endif // defined(TARGET_LINUX)
+#endif // defined(TARGET_POSIX)
#include "network/NetworkServices.h"
#include "network/upnp/UPnPSettings.h"
#include "network/WakeOnAccess.h"
if (!InitializeDefinitions())
return false;
- InitializeVisibility();
- InitializeDefaults();
m_settingsManager->SetInitialized();
InitializeISettingsHandlers();
#if defined(TARGET_WINDOWS)
if (CFile::Exists(SETTINGS_XML_FOLDER "win32.xml") && !Initialize(SETTINGS_XML_FOLDER "win32.xml"))
CLog::Log(LOGFATAL, "Unable to load win32-specific settings definitions");
-#elif defined(TARGET_LINUX)
- if (CFile::Exists(SETTINGS_XML_FOLDER "linux.xml") && !Initialize(SETTINGS_XML_FOLDER "linux.xml"))
- CLog::Log(LOGFATAL, "Unable to load linux-specific settings definitions");
#elif defined(TARGET_ANDROID)
if (CFile::Exists(SETTINGS_XML_FOLDER "android.xml") && !Initialize(SETTINGS_XML_FOLDER "android.xml"))
CLog::Log(LOGFATAL, "Unable to load android-specific settings definitions");
#elif defined(TARGET_FREEBSD)
if (CFile::Exists(SETTINGS_XML_FOLDER "freebsd.xml") && !Initialize(SETTINGS_XML_FOLDER "freebsd.xml"))
CLog::Log(LOGFATAL, "Unable to load freebsd-specific settings definitions");
+#elif defined(TARGET_LINUX)
+ if (CFile::Exists(SETTINGS_XML_FOLDER "linux.xml") && !Initialize(SETTINGS_XML_FOLDER "linux.xml"))
+ CLog::Log(LOGFATAL, "Unable to load linux-specific settings definitions");
#elif defined(TARGET_DARWIN)
if (CFile::Exists(SETTINGS_XML_FOLDER "darwin.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin.xml"))
CLog::Log(LOGFATAL, "Unable to load darwin-specific settings definitions");
#endif
#endif
#endif
+
+ // load any custom visibility and default values before loading the special
+ // appliance.xml so that appliances are able to overwrite even those values
+ InitializeVisibility();
+ InitializeDefaults();
+
if (CFile::Exists(SETTINGS_XML_FOLDER "appliance.xml") && !Initialize(SETTINGS_XML_FOLDER "appliance.xml"))
CLog::Log(LOGFATAL, "Unable to load appliance-specific settings definitions");
void CSettings::InitializeVisibility()
{
// hide some settings if necessary
-#if defined(TARGET_LINUX) || defined(TARGET_DARWIN)
+#if defined(TARGET_DARWIN)
CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry");
CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone");
-#if defined(TARGET_DARWIN)
if (!g_sysinfo.IsAppleTV2() || GetIOSVersion() >= 4.3)
{
timezonecountry->SetVisible(false);
timezone->SetVisible(false);
}
#endif
-
-#if defined(TARGET_LINUX)
- if (timezonecountry->IsVisible())
- timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone()));
- if (timezone->IsVisible())
- timezone->SetDefault(g_timezone.GetOSConfiguredTimezone());
-#endif
-#endif
}
void CSettings::InitializeDefaults()
((CSettingAddon*)m_settingsManager->GetSetting("lookandfeel.skin"))->SetDefault("skin.touched");
#endif
+#if defined(TARGET_POSIX)
+ CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry");
+ CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone");
+
+ if (timezonecountry->IsVisible())
+ timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone()));
+ if (timezone->IsVisible())
+ timezone->SetDefault(g_timezone.GetOSConfiguredTimezone());
+#endif // defined(TARGET_POSIX)
+
#if defined(TARGET_WINDOWS)
#if defined(HAS_DX)
((CSettingString*)m_settingsManager->GetSetting("musicplayer.visualisation"))->SetDefault("visualization.milkdrop");
#ifdef HAVE_LIBVA
m_settingsManager->AddCondition("have_libva");
#endif
-#ifdef TARGET_DARWIN_OSX
- m_settingsManager->AddCondition("have_libvdadecoder");
- m_settingsManager->AddCondition("hasvdadecoder");
-#endif
#ifdef HAVE_LIBVDPAU
m_settingsManager->AddCondition("have_libvdpau");
#endif
void CSettingsManager::Unload()
{
CSingleLock lock(m_critical);
+ if (!m_loaded)
+ return;
+
+ // needs to be set before calling CSetting::Reset() to avoid calls to
+ // OnSettingChanging() and OnSettingChanged()
m_loaded = false;
+
for (SettingMap::iterator setting = m_settings.begin(); setting != m_settings.end(); setting++)
setting->second.setting->Reset();
+
+ OnSettingsUnloaded();
}
void CSettingsManager::Clear()
{
CSingleLock lock(m_critical);
+ Unload();
+
m_settings.clear();
for (SettingSectionMap::iterator section = m_sections.begin(); section != m_sections.end(); section++)
delete section->second;
for (std::set<ISubSettings*>::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++)
(*it)->Clear();
- m_loaded = false;
m_initialized = false;
}
#if !defined(AFX_VIDEOSETTINGS_H__562A722A_CD2A_4B4A_8A67_32DE8088A7D3__INCLUDED_)
#define AFX_VIDEOSETTINGS_H__562A722A_CD2A_4B4A_8A67_32DE8088A7D3__INCLUDED_
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
enum EDEINTERLACEMODE
{
#define CONTROL_SETTINGS_LABEL 2
#define CATEGORY_GROUP_ID 3
#define SETTINGS_GROUP_ID 5
+#define CONTROL_DESCRIPTION 6
#define CONTROL_DEFAULT_BUTTON 7
#define CONTROL_DEFAULT_RADIOBUTTON 8
#define CONTROL_DEFAULT_SPIN 9
}
// check if we have changed the category and need to create new setting controls
- if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()) &&
- focusedControl - CONTROL_START_BUTTONS != m_iCategory)
+ if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()))
{
- if (!m_categories[focusedControl - CONTROL_START_BUTTONS]->CanAccess())
+ int categoryIndex = focusedControl - CONTROL_START_BUTTONS;
+ if (categoryIndex != m_iCategory)
{
- // unable to go to this category - focus the previous one
- SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0);
- return false;
+ if (!m_categories[categoryIndex]->CanAccess())
+ {
+ // unable to go to this category - focus the previous one
+ SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0);
+ return false;
+ }
+
+ m_iCategory = categoryIndex;
+ CreateSettings();
}
-
- m_iCategory = focusedControl - CONTROL_START_BUTTONS;
- CreateSettings();
+ }
+ else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size()))
+ {
+ CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
+ if (setting != NULL)
+ SetDescription(setting->GetHelp());
}
}
return true;
return true;
}
- case ACTION_SHOW_INFO:
- {
- int label = -1;
- int help = -1;
- int focusedControl = GetFocusedControlID();
- // check if we are focusing a category
- if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()))
- {
- CSettingCategory *category = m_categories[focusedControl - CONTROL_START_BUTTONS];
- label = category->GetLabel();
- help = category->GetHelp();
- }
- else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size()))
- {
- CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
- if (setting != NULL)
- {
- label = setting->GetLabel();
- help = setting->GetHelp();
- }
- }
- else
- break;
-
- if (help >= 0)
- {
- CGUIDialogTextViewer *dialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
- if (dialog != NULL)
- {
- if (label < 0)
- label = 10043; // "Help"
- dialog->SetHeading(g_localizeStrings.Get(label));
- dialog->SetText(g_localizeStrings.Get(help));
- dialog->DoModal();
- }
- }
- else
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(10043), g_localizeStrings.Get(10044), 2000U);
- return true;
- }
-
default:
break;
}
if (category == NULL)
return;
+ // set the description of the current category
+ SetDescription(category->GetHelp());
+
std::set<std::string> settingMap;
const SettingGroupList& groups = category->GetGroups(CViewStateSettings::Get().GetSettingLevel());
}
}
+void CGUIWindowSettingsCategory::SetDescription(const CVariant &label)
+{
+ if (GetControl(CONTROL_DESCRIPTION) == NULL)
+ return;
+
+ if (label.isString())
+ SET_CONTROL_LABEL(CONTROL_DESCRIPTION, label.asString());
+ else if (label.isInteger() && label.asInteger() >= 0)
+ SET_CONTROL_LABEL(CONTROL_DESCRIPTION, (int)label.asInteger());
+ else
+ SET_CONTROL_LABEL(CONTROL_DESCRIPTION, "");
+}
+
CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID)
{
if (pSetting == NULL)
void CreateSettings();
void UpdateSettings();
+ void SetDescription(const CVariant &label);
CGUIControl* AddSetting(CSetting *pSetting, float width, int &iControlID);
CGUIControl* AddSeparator(float width, int &iControlID);
CGUIControl* AddSettingControl(CGUIControl *pControl, BaseSettingControlPtr pSettingControl, float width, int &iControlID);
#include "cdioSupport.h"
#include "filesystem/iso9660.h"
#include "threads/SingleLock.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
#include <linux/cdrom.h>
#endif
#endif
DWORD CDetectDVDMedia::GetTrayState()
{
-#ifdef _LINUX
+#ifdef TARGET_POSIX
char* dvdDevice = m_cdio->GetDeviceFileName();
if (strlen(dvdDevice) == 0)
return DRIVE_NOT_READY;
#endif // USING_CDIO78
-#endif // _LINUX
+#endif // TARGET_POSIX
if (m_dwTrayState == TRAY_CLOSED_MEDIA_PRESENT)
{
#include "system.h"
#include "IoSupport.h"
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "my_ntddcdrm.h"
#include "WIN32Util.h"
#include "utils/CharsetConverter.h"
#endif
-#if defined (_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
#include <linux/limits.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <IOKit/storage/IOStorageDeviceCharacteristics.h>
#endif
#endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include <sys/syslimits.h>
#endif
#include "cdioSupport.h"
#include "filesystem/iso9660.h"
#include "MediaManager.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "XHandle.h"
#endif
HANDLE hDevice = 0;
#ifdef HAS_DVD_DRIVE
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
int fd = open(CLibcdio::GetInstance()->GetDeviceFileName(), O_RDONLY | O_NONBLOCK);
hDevice = new CXHandle(CXHandle::HND_FILE);
hDevice->fd = fd;
hDevice->m_bCDROM = true;
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
hDevice = CreateFile(g_mediaManager.TranslateDevicePath("",true), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, NULL );
void CIoSupport::AllocReadBuffer()
{
-#ifndef _LINUX
+#ifndef TARGET_POSIX
m_rawXferBuffer = GlobalAlloc(GPTR, RAW_SECTOR_SIZE);
#endif
}
void CIoSupport::FreeReadBuffer()
{
-#ifndef _LINUX
+#ifndef TARGET_POSIX
GlobalFree(m_rawXferBuffer);
#endif
}
return -1;
}
return 2048;
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
if (hDevice->m_bCDROM)
{
int fd = hDevice->fd;
return -1;
}
return MODE2_DATA_SIZE;
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
// NYI
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
if (hDevice->m_bCDROM)
{
int fd = hDevice->fd;
#include "system.h" // for Win32 types
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
#define MODE1_DATA_SIZE 2048 // Mode1 sector has 2048 bytes of data
#include "guilib/LocalizeStrings.h"
#include "URL.h"
#include "utils/URIUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "WIN32Util.h"
#include "utils/CharsetConverter.h"
#endif
#include "guilib/GUIWindowManager.h"
#ifdef HAS_DVD_DRIVE
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
// TODO: switch all ports to use auto sources
#include "DetectDVDType.h"
#include "filesystem/iso9660.h"
#include "android/AndroidStorageProvider.h"
#elif defined(TARGET_FREEBSD)
#include "linux/LinuxStorageProvider.h"
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
#include "linux/LinuxStorageProvider.h"
#include <sys/ioctl.h>
#include <linux/cdrom.h>
-#elif _WIN32
+#elif TARGET_WINDOWS
#include "windows/Win32StorageProvider.h"
#endif
m_platformStorage = new CDarwinStorageProvider();
#elif defined(TARGET_ANDROID)
m_platformStorage = new CAndroidStorageProvider();
- #elif defined(_LINUX)
+ #elif defined(TARGET_POSIX)
m_platformStorage = new CLinuxStorageProvider();
- #elif _WIN32
+ #elif TARGET_WINDOWS
m_platformStorage = new CWin32StorageProvider();
#endif
}
strDevice = m_strFirstAvailDrive;
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return "";
bool CMediaManager::IsDiscInDrive(const CStdString& devicePath)
{
#ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return false;
bool CMediaManager::IsAudio(const CStdString& devicePath)
{
#ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return false;
DWORD CMediaManager::GetDriveStatus(const CStdString& devicePath)
{
#ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return DRIVE_NOT_READY;
#ifdef HAS_DVD_DRIVE
CCdInfo* CMediaManager::GetCdInfo(const CStdString& devicePath)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return NULL;
CStdString CMediaManager::GetDiskLabel(const CStdString& devicePath)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return "";
if (strDevice.IsEmpty()) // if no value passed, use the current default disc path.
strDevice = GetDiscPath(); // in case of non-Windows we must obtain the disc path
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (!m_bhasoptical)
return "";
strDevice = TranslateDevicePath(strDevice);
CStdString strDrive = g_mediaManager.TranslateDevicePath(strDevice);
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
{
CSingleLock waitLock(m_muAutoSource);
CCdInfo* pInfo = g_mediaManager.GetCdInfo();
CStdString CMediaManager::GetDiscPath()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
return g_mediaManager.TranslateDevicePath("");
#else
#ifdef HAS_DVD_DRIVE
#if defined(TARGET_DARWIN)
// FIXME...
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
// NYI
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
char* dvdDevice = CLibcdio::GetInstance()->GetDeviceFileName();
if (strlen(dvdDevice) != 0)
{
#include "cdioSupport.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
+#include "utils/Environment.h"
#include <cdio/logging.h>
#include <cdio/util.h>
#include <cdio/mmc.h>
#include <cdio/cd_types.h>
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
#pragma comment(lib, "libcdio.dll.lib")
#endif
if (s_defaultDevice == NULL)
{
- if (getenv("XBMC_DVD_DEVICE") != NULL)
- s_defaultDevice = strdup(getenv("XBMC_DVD_DEVICE"));
+ std::string strEnvDvd = CEnvironment::getenv("XBMC_DVD_DEVICE");
+ if (!strEnvDvd.empty())
+ s_defaultDevice = strdup(strEnvDvd.c_str());
else
{
CdIo_t *p_cdio = ::cdio_open(NULL, DRIVER_UNKNOWN);
#define HAS_UPNP
#endif
+#if defined(HAVE_LIBMDNSEMBEDDED)
+ #define HAS_ZEROCONF
+ #define HAS_MDNS
+ #define HAS_MDNS_EMBEDDED
+#endif
+
/**********************
* Non-free Components
**********************/
#define HAS_FILESYSTEM_SMB
#define HAS_FILESYSTEM_NFS
#define HAS_ZEROCONF
+#define HAS_MDNS
#define HAS_AIRPLAY
#define HAS_AIRTUNES
#define HAVE_LIBSHAIRPLAY
/* Create a temporary directory and set it to be used throughout the
* test suite run.
*/
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
TCHAR lpTempPathBuffer[MAX_PATH];
if (!GetTempPath(MAX_PATH, lpTempPathBuffer))
SetUpError();
#include "filesystem/SpecialProtocol.h"
#include "utils/StringUtils.h"
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
#include <windows.h>
#else
#include <cstdlib>
}
strcpy(tmp, m_ptempFilePath.c_str());
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
if (!GetTempFileName(CSpecialProtocol::TranslatePath("special://temp/"),
"xbmctempfile", 0, tmp))
{
}
-std::vector<CStdString> &CXBMCTestUtils::getTestDownloadQueueUrls()
-{
- return TestDownloadQueueUrls;
-}
-
std::vector<CStdString> &CXBMCTestUtils::getTestFileFactoryReadUrls()
{
return TestFileFactoryReadUrls;
"\n"
"The following options are recognized by the xbmc-test program.\n"
"\n"
-" --add-testdownloadqueue-url [URL]\n"
-" Add a url to be used in the TestDownloadQueue tests.\n"
-"\n"
-" --add-testdownloadqueue-urls [URLS]\n"
-" Add multiple urls from a ',' delimited string of urls. to be used\n"
-" in the TestDownloadQueue tests.\n"
-"\n"
" --add-testfilefactory-readurl [URL]\n"
" Add a url to be used int the TestFileFactory read tests.\n"
"\n"
for (i = 1; i < argc; i++)
{
arg = argv[i];
- if (arg == "--add-testdownloadqueue-url")
- {
- TestDownloadQueueUrls.push_back(argv[++i]);
- }
- else if (arg == "--add-testdownloadqueue-urls")
- {
- arg = argv[++i];
- std::vector<std::string> urls = StringUtils::Split(arg, ",");
- std::vector<std::string>::iterator it;
- for (it = urls.begin(); it < urls.end(); it++)
- TestDownloadQueueUrls.push_back(*it);
- }
- else if (arg == "--add-testfilefactory-readurl")
+ if (arg == "--add-testfilefactory-readurl")
{
TestFileFactoryReadUrls.push_back(argv[++i]);
}
/* Function to get path of a tempfile */
CStdString TempFilePath(XFILE::CFile const* const tempfile);
- /* Functions to get variables used in the TestDownloadQueue tests. */
- std::vector<CStdString> &getTestDownloadQueueUrls();
-
/* Functions to get variables used in the TestFileFactory tests. */
std::vector<CStdString> &getTestFileFactoryReadUrls();
CXBMCTestUtils(CXBMCTestUtils const&);
void operator=(CXBMCTestUtils const&);
- std::vector<CStdString> TestDownloadQueueUrls;
std::vector<CStdString> TestFileFactoryReadUrls;
std::vector<CStdString> TestFileFactoryWriteUrls;
CStdString TestFileFactoryWriteInputFile;
#error atomic cas undefined for mips
return prev;
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
long prev;
__asm
{
// Hack to allow compilation
throw "cas2 is not implemented";
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
long long prev;
__asm
{
#error AtomicIncrement undefined for mips
return val;
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
long val;
__asm
{
#error AtomicAdd undefined for mips
return val;
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
__asm
{
mov eax, amount;
#error AtomicDecrement undefined for mips
return val;
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
long val;
__asm
{
#error AtomicSubtract undefined for mips
return val;
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
amount *= -1;
__asm
{
#endif
#include <sys/resource.h>
#include <string.h>
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#include <sys/param.h>
#if __FreeBSD_version < 900031
#include <sys/thr.h>
void CThread::SetThreadInfo()
{
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
#if __FreeBSD_version < 900031
long lwpid;
thr_self(&lwpid);
#if defined(TARGET_DARWIN_OSX)
#include <CoreServices/CoreServices.h>
#include "utils/URIUtils.h"
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
#else
#endif
#if defined(TARGET_DARWIN_OSX)
// Note: regular files that have an .alias extension can be
// reported as an alias when clearly, they are not. Trap them out.
- if (URIUtils::GetExtension(path) != ".alias")
+ if (!URIUtils::HasExtension(path, ".alias"))
{
FSRef fileRef;
Boolean targetIsFolder, wasAliased;
}
}
}
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
// Linux does not use alias or shortcut methods
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
/* Needs testing under Windows platform so ignore shortcuts for now
if (CUtil::GetExtension(path) == ".lnk")
{
}
}
}
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
// Linux does not use alias or shortcut methods
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
/* Needs testing under Windows platform so ignore shortcuts for now
CComPtr<IShellLink> ipShellLink;
*/
#include <string>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/PlatformDefs.h"
#endif
#include "android/activity/AndroidFeatures.h"
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <intrin.h>
// Defines to help with calls to CPUID
// In milliseconds
#define MINIMUM_TIME_BETWEEN_READS 500
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
/* replacement gettimeofday implementation, copy from dvdnav_internal.h */
#include <sys/timeb.h>
static inline int _private_gettimeofday( struct timeval *tv, void *tz )
m_cores[core.m_id] = core;
}
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
char rgValue [128];
HKEY hKey;
DWORD dwSize=128;
idleTicks -= m_idleTicks;
ioTicks -= m_ioTicks;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if(userTicks + systemTicks == 0)
return m_lastUsedPercentage;
int result = (int) ((userTicks + systemTicks - idleTicks) * 100 / (userTicks + systemTicks));
if (sysctlbyname("hw.cpufrequency", &hz, &len, NULL, 0) == -1)
return 0.f;
return hz / 1000000.0;
-#elif defined _WIN32
+#elif defined TARGET_WINDOWS
HKEY hKey;
DWORD dwMHz=0;
DWORD dwSize=sizeof(dwMHz);
unsigned long long& system, unsigned long long& idle, unsigned long long& io)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
FILETIME idleTime;
FILETIME kernelTime;
FILETIME userTime;
while (iter != m_cores.end())
{
CStdString strCore;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
// atm we get only the average over all cores
strCore.Format("CPU %d core(s) average: %3.1f%% ",m_cpuCount, iter->second.m_fPct);
#else
void CCPUInfo::ReadCPUFeatures()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
int CPUInfo[4]; // receives EAX, EBX, ECD and EDX in that order
#define WCHAR_CHARSET "UTF-32LE"
#endif
#define UTF8_SOURCE "UTF-8-MAC"
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
#define WCHAR_CHARSET "UTF-16LE"
#define UTF8_SOURCE "UTF-8"
#pragma comment(lib, "libfribidi.lib")
#include "threads/Thread.h"
#include "utils/log.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#else
#define HAVE_OPENSSL
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "URIUtils.h"
-#include "log.h"
-
-#include "filesystem/File.h"
-#include "filesystem/CurlFile.h"
-#include "threads/SingleLock.h"
-
-using namespace std;
-using namespace XFILE;
-
-WORD CDownloadQueue::m_wNextQueueId = 0;
-
-CDownloadQueue::CDownloadQueue(void) : CThread("DownloadQueue")
-{
- m_bStop = false;
- m_wQueueId = m_wNextQueueId++;
- m_dwNextItemId = 0;
- CThread::Create(false);
-}
-
-void CDownloadQueue::OnStartup()
-{
- SetPriority( GetMinPriority() );
-}
-
-CDownloadQueue::~CDownloadQueue(void)
-{
-}
-
-
-TICKET CDownloadQueue::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- Command request = {ticket, aUrl, "", aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
-
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- Command request = {ticket, aUrl, aFilePath, aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-void CDownloadQueue::CancelRequests(IDownloadQueueObserver *aObserver)
-{
- CSingleLock lock(m_critical);
-
- CLog::Log(LOGDEBUG, "CancelRequests from observer at %p", aObserver);
- // run through our queue, and create a new queue with the requests
- // from aObserver NULL'd out.
- queue<Command> newQueue;
- while (m_queue.size())
- {
- Command request = m_queue.front();
- m_queue.pop();
- if (request.observer == aObserver)
- request.observer = NULL;
- newQueue.push(request);
- }
- m_queue = newQueue;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
-
- CLog::Log(LOGDEBUG, "RequestFile from observer at %p", aObserver);
- // create a temporary destination
- CStdString strExtension = URIUtils::GetExtension(aUrl);
-
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- CStdString strFilePath;
- strFilePath.Format("special://temp/q%d-item%u%s", ticket.wQueueId, ticket.dwItemId, strExtension.c_str());
-
- Command request = {ticket, aUrl, strFilePath, aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-VOID CDownloadQueue::Flush()
-{
- CSingleLock lock(m_critical);
-
- m_queue.empty();
-
-}
-
-void CDownloadQueue::Process()
-{
- CLog::Log(LOGNOTICE, "DownloadQueue ready.");
-
- CCurlFile http;
- bool bSuccess;
-
- while ( !m_bStop )
- {
- while ( CDownloadQueue::Size() > 0 )
- {
- CSingleLock lock(m_critical);
-
- // get the first item, but don't pop it from our queue
- // so that the download can be interrupted
- Command request = m_queue.front();
- lock.Leave();
-
- bool bFileRequest = request.content.length() > 0;
- DWORD dwSize = 0;
-
- if (bFileRequest)
- {
- CFile::Delete(request.content);
- bSuccess = http.Download(request.location, request.content, &dwSize);
- }
- else
- {
- bSuccess = http.Get(request.location, request.content);
- }
-
- // now re-grab the item as we may have cancelled our download
- // while we were working
- { CSingleLock lock2(m_critical); // open lock2 scope
-
- request = m_queue.front();
- m_queue.pop();
-
- // if the request has been cancelled our observer will be NULL
- if (NULL != request.observer)
- {
- try
- {
- if (bFileRequest)
- {
- request.observer->OnFileComplete(request.ticket, request.content, dwSize,
- bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
- }
- else
- {
- request.observer->OnContentComplete(request.ticket, request.content,
- bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
- }
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "exception while updating download observer.");
-
- if (bFileRequest)
- {
- CFile::Delete(request.content);
- }
- }
- }
- } // close lock2 scope
- }
-
- Sleep(500);
- }
-
- CLog::Log(LOGNOTICE, "DownloadQueue terminated.");
-}
-
-INT CDownloadQueue::Size()
-{
- CSingleLock lock(m_critical);
-
- int sizeOfQueue = m_queue.size();
-
- return sizeOfQueue;
-}
-
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <queue>
-#include "threads/Thread.h"
-#include "threads/CriticalSection.h"
-#include "StdString.h"
-
-#include "system.h"
-
-struct TICKET
-{
- TICKET(WORD aQueueId, DWORD aItemId)
- {
- wQueueId = aQueueId;
- dwItemId = aItemId;
- };
-
- WORD wQueueId;
- DWORD dwItemId;
-};
-
-class IDownloadQueueObserver
-{
-public:
- enum Result {Succeeded, Failed};
- virtual ~IDownloadQueueObserver() {};
- virtual void OnContentComplete(TICKET aTicket, CStdString& aContentString, Result aResult){};
- virtual void OnFileComplete(TICKET aTicket, CStdString& aFilePath, INT aByteRxCount, Result aResult){};
-};
-
-
-class CDownloadQueue: CThread
-{
-public:
- CDownloadQueue();
- virtual ~CDownloadQueue(void);
-
- TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
- void CancelRequests(IDownloadQueueObserver* aObserver);
-
- VOID Flush();
- INT Size();
-
-protected:
-
- void OnStartup();
- void Process();
-
- struct Command
- {
- TICKET ticket;
- CStdString location;
- CStdString content;
- IDownloadQueueObserver* observer;
- };
-
- typedef std::queue<Command> COMMANDQUEUE;
- COMMANDQUEUE m_queue;
- CCriticalSection m_critical;
-
- WORD m_wQueueId;
- DWORD m_dwNextItemId;
-
- static WORD m_wNextQueueId;
-};
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueueManager.h"
-#include "threads/SingleLock.h"
-#include <assert.h>
-
-CDownloadQueueManager::CDownloadQueueManager()
-{
-}
-
-CDownloadQueueManager::~CDownloadQueueManager(void)
-{
-}
-
-VOID CDownloadQueueManager::Initialize()
-{
-}
-
-
-TICKET CDownloadQueueManager::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestContent(aUrl, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestFile(aUrl, aFilePath, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestFile(aUrl, aObserver);
-}
-
-void CDownloadQueueManager::CancelRequests(IDownloadQueueObserver *aObserver)
-{
- CSingleLock lock(m_critical);
- // run through all our queues and remove all requests from this observer
- for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
- {
- CDownloadQueue* downloadQueue = *it;
- downloadQueue->CancelRequests(aObserver);
- }
-}
-
-CDownloadQueue* CDownloadQueueManager::GetNextDownloadQueue()
-{
- CDownloadQueue* pQueueAvailable = NULL;
-
- // if we haven't added any queues to the pool, add one.
- if (m_queues.size() < 1)
- {
- m_queues.push_back( new CDownloadQueue() );
- }
-
- // return the queue with the least number of items pending
- for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
- {
- // always choose the first queue if we haven't selected one yet
- if (!pQueueAvailable)
- {
- pQueueAvailable = *it;
- }
- else
- {
- // pick this queue if it has less items pending than our previous selection
- if ( pQueueAvailable->Size() > (*it)->Size() )
- {
- pQueueAvailable = *it;
- }
- }
- }
-
- // if we picked a queue with pending items and we haven't reached out max pool limit
- if (pQueueAvailable && pQueueAvailable->Size() > 0 && m_queues.size() < MAX_DOWNLOAD_QUEUES)
- {
- // spawn a new queue
- pQueueAvailable = new CDownloadQueue();
- m_queues.push_back(pQueueAvailable);
- }
-
- assert(pQueueAvailable != NULL);
-
- return pQueueAvailable;
-}
-
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "system.h"
-
-#define MAX_DOWNLOAD_QUEUES 3
-
-class CDownloadQueueManager
-{
-public:
- CDownloadQueueManager();
- virtual ~CDownloadQueueManager(void);
-
- VOID Initialize();
- TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
- void CancelRequests(IDownloadQueueObserver *aObserver);
-
-protected:
-
- CDownloadQueue* GetNextDownloadQueue();
-
- typedef std::vector<CDownloadQueue*> QUEUEPOOL;
- QUEUEPOOL m_queues;
-
- CCriticalSection m_critical;
-};
-
-// Single global instance of class is in cpp file
-extern CDownloadQueueManager g_DownloadManager;
/* Include config.h to define (or not) WORDS_BIGENDIAN
File created by configure */
-#if defined(__linux__) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
+#if defined(TARGET_POSIX)
#include "config.h"
#include <inttypes.h>
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define __inline__ __inline
#include <stdint.h>
#endif
#include <stdlib.h>
#ifdef TARGET_WINDOWS
#include <Windows.h>
+#include "utils\SystemInfo.h"
#endif
// --------------------- Helper Functions ---------------------
if (resultSuccessful != NULL)
*resultSuccessful = false;
- int bufSize = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, NULL, 0, NULL, NULL);
+ static const DWORD convFlags = (CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionVista)) ?
+ /*WC_ERR_INVALID_CHARS*/ 0x80 : 0;
+ int bufSize = WideCharToMultiByte(CP_UTF8, convFlags, text.c_str(), -1, NULL, 0, NULL, NULL);
if (bufSize == 0)
return "";
char * converted = new char[bufSize];
- if (WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, converted, bufSize, NULL, NULL) != bufSize)
+ if (WideCharToMultiByte(CP_UTF8, convFlags, text.c_str(), -1, converted, bufSize, NULL, NULL) != bufSize)
{
delete[] converted;
return "";
if (resultSuccessful != NULL)
*resultSuccessful = true;
- return converted;
+ return ret;
}
// --------------------- Internal Function ---------------------
{ L"msvcr100d.dll" },// Visual Studio 2010 (debug)
#endif
{ L"msvcr110.dll" }, // Visual Studio 2012
+#ifdef _DEBUG
+ { L"msvcr110d.dll" },// Visual Studio 2012 (debug)
+#endif
{ NULL } // Terminating NULL for list
};
if (Wname.empty())
return "";
- std::wstring Wvalue (::_wgetenv(Wname.c_str()));
- if (!Wvalue.empty())
- return win32ConvertWToUtf8(Wvalue);
+ wchar_t * wStr = ::_wgetenv(Wname.c_str());
+ if (wStr != NULL)
+ return win32ConvertWToUtf8(wStr);
// Not found in Environment of runtime library
// Try Environment of process as fallback
- int varSize = GetEnvironmentVariableW(Wname.c_str(), NULL, 0);
+ unsigned int varSize = GetEnvironmentVariableW(Wname.c_str(), NULL, 0);
if (varSize == 0)
return ""; // Not found
wchar_t * valBuf = new wchar_t[varSize];
delete[] valBuf;
return "";
}
- Wvalue = valBuf;
+ std::wstring Wvalue (valBuf);
delete[] valBuf;
return win32ConvertWToUtf8(Wvalue);
#else
- return ::getenv(name.c_str());
+ char * str = ::getenv(name.c_str());
+ if (str == NULL)
+ return "";
+ return str;
#endif
}
// get filename from label instead of path
strFileName = pItem->GetLabel();
- if(!pItem->m_bIsFolder && URIUtils::GetExtension(strFileName).length() == 0)
+ if(!pItem->m_bIsFolder && !URIUtils::HasExtension(strFileName))
{
// FIXME: for now we only work well if the url has the extension
// we should map the content type to the extension otherwise
inline bool CFileOperationJob::CanBeRenamed(const CStdString &strFileA, const CStdString &strFileB)
{
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if (strFileA[1] == ':' && strFileA[0] == strFileB[0])
return true;
#else
#include "URIUtils.h"
#include "filesystem/MultiPathDirectory.h"
#include <vector>
+#include "settings/MediaSourceSettings.h"
+#include "Util.h"
+#include "StringUtils.h"
+#include "URL.h"
using namespace XFILE;
using namespace std;
}
return false;
}
+
+bool CFileUtils::RemoteAccessAllowed(const CStdString &strPath)
+{
+ const unsigned int SourcesSize = 5;
+ CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
+
+ string realPath = URIUtils::GetRealPath(strPath);
+ // for rar:// and zip:// paths we need to extract the path to the archive
+ // instead of using the VFS path
+ while (URIUtils::IsInArchive(realPath))
+ realPath = CURL(realPath).GetHostName();
+
+ if (StringUtils::StartsWith(realPath, "virtualpath://upnproot/"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "musicdb://"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "videodb://"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "library://video"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "sources://video"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://musicplaylists"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://profile/playlists"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://videoplaylists"))
+ return true;
+
+ bool isSource;
+ for (unsigned int index = 0; index < SourcesSize; index++)
+ {
+ VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
+ int sourceIndex = CUtil::GetMatchingSource(realPath, *sources, isSource);
+ if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock != 2 && sources->at(sourceIndex).m_allowSharing)
+ return true;
+ }
+ return false;
+}
\ No newline at end of file
static bool DeleteItem(const CFileItemPtr &item, bool force=false);
static bool DeleteItem(const CStdString &strPath, bool force=false);
static bool RenameFile(const CStdString &strFile);
+ static bool RemoteAccessAllowed(const CStdString &strPath);
};
m_processing.clear();
}
+
+bool CJobQueue::QueueEmpty() const
+{
+ CSingleLock lock(m_section);
+ return m_jobQueue.empty();
+}
+
CJobManager &CJobManager::GetInstance()
{
static CJobManager sJobManager;
*/
virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
+protected:
+ /*!
+ \brief Returns if we still have jobs waiting to be processed
+ NOTE: This function does not take into account the jobs that are currently processing
+ */
+ bool QueueEmpty() const;
+
private:
void QueueNextJob();
{
if (strTwoCharCodeLower.Equals(CharCode2To3[index].old))
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (localeHack && CharCode2To3[index].win_id)
{
strThreeCharCode = CharCode2To3[index].win_id;
SRCS += Crc32.cpp
SRCS += CryptThreading.cpp
SRCS += DatabaseUtils.cpp
-SRCS += DownloadQueue.cpp
-SRCS += DownloadQueueManager.cpp
SRCS += EndianSwap.cpp
SRCS += EdenVideoArtUpdater.cpp
SRCS += Environment.cpp
#if defined(__ppc__) || \
defined(__powerpc__) || \
- (defined(__APPLE__) && defined(__arm__) && defined(__llvm__)) || \
- (defined(__ANDROID__) && defined(__arm__)) || \
+ (defined(TARGET_DARWIN_IOS) && defined(__llvm__)) || \
+ (defined(TARGET_ANDROID) && defined(__arm__)) || \
defined(TARGET_RASPBERRY_PI)
#define DISABLE_MATHUTILS_ASM_ROUND_INT
#endif
#if defined(__ppc__) || \
defined(__powerpc__) || \
- (defined(__APPLE__) && defined(__llvm__)) || \
- (defined(__ANDROID__) && defined(__arm__)) || \
+ (defined(TARGET_DARWIN) && defined(__llvm__)) || \
+ (defined(TARGET_ANDROID) && defined(__arm__)) || \
defined(TARGET_RASPBERRY_PI)
#define DISABLE_MATHUTILS_ASM_TRUNCATE_INT
#endif
const float round_dn_to_nearest = 0.4999999f;
i = (x > 0) ? _mm_cvttsd_si32(_mm_set_sd(x + round_to_nearest)) : _mm_cvttsd_si32(_mm_set_sd(x - round_dn_to_nearest));
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
__asm
{
fld x
);
return i;
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
const float round_towards_m_i = -0.5f;
__asm
{
#include "system.h"
#include "PerformanceSample.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/PlatformInclude.h"
#endif
void CPerformanceSample::Reset()
{
m_tmStart = CurrentHostCounter();
-#ifdef _LINUX
+#ifdef TARGET_POSIX
if (getrusage(RUSAGE_SELF, &m_usage) == -1)
CLog::Log(LOGERROR,"error %d in getrusage", errno);
#endif
double elapsed = (double)(tmNow - m_tmStart) / (double)m_tmFreq.QuadPart;
double dUser=0.0, dSys=0.0;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage) == -1)
CLog::Log(LOGERROR,"error %d in getrusage", errno);
*
*/
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/PlatformDefs.h"
#include <sys/time.h>
#include <sys/times.h>
std::string m_statName;
bool m_bCheckWhenDone;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
struct rusage m_usage;
#endif
#include <vector>
namespace PCRE {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define PCRE_STATIC
#include "lib/win32/pcre/pcre.h"
#else
Load();
}
-void CRssManager::OnSettingsCleared()
+void CRssManager::OnSettingsUnloaded()
{
Clear();
}
static CRssManager& Get();
virtual void OnSettingsLoaded();
- virtual void OnSettingsCleared();
+ virtual void OnSettingsUnloaded();
virtual void OnSettingAction(const CSetting *setting);
#include <stdint.h>
#include <vector>
-#if defined(_WIN32) && !defined(va_copy)
+#if defined(TARGET_WINDOWS) && !defined(va_copy)
#define va_copy(dst, src) ((dst) = (src))
#endif
PWSTR pNextDstW = pDstW;
SSCodeCvt::result res = SSCodeCvt::ok;
const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
SSCodeCvt::state_type st= { { 0 } };
#else
SSCodeCvt::state_type st= { 0 };
res = conv.in(st,
pSrcA, pSrcA + nSrc, pNextSrcA,
pDstW, pDstW + nDst, pNextDstW);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
#else
#define ASSERT2 ASSERT
PCWSTR pNextSrcW = pSrcW;
SSCodeCvt::result res = SSCodeCvt::ok;
const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
SSCodeCvt::state_type st= { { 0 } };
#else
SSCodeCvt::state_type st= { 0 };
res = conv.out(st,
pSrcW, pSrcW + nSrc, pNextSrcW,
pDstA, pDstA + nDst, pNextDstA);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
#else
#define ASSERT2 ASSERT
#include "threads/SystemClock.h"
#include "Stopwatch.h"
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
#include <sys/sysinfo.h>
#endif
#include "utils/TimeUtils.h"
else
{
// Get the timer frequency (ticks per second)
-#ifndef _LINUX
+#ifndef TARGET_POSIX
m_timerPeriod = 1.0f / (float)CurrentHostFrequency();
#else
m_timerPeriod = 1.0f / 1000.0f; // we want seconds
{
if (m_useFrameTime)
return CTimeUtils::GetFrameTime();
-#ifndef _LINUX
+#ifndef TARGET_POSIX
return CurrentHostCounter();
#else
return XbmcThreads::SystemClockMillis();
#include "threads/SystemClock.h"
#include "system.h"
#include "SystemInfo.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#include <conio.h>
#else
#include <sys/utsname.h>
#include "CPUInfo.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "dwmapi.h"
#endif
#if defined(TARGET_DARWIN)
double CSysInfoJob::GetCPUFrequency()
{
-#if defined (_LINUX) || defined(_WIN32)
+#if defined (TARGET_POSIX) || defined(TARGET_WINDOWS)
return double (g_cpuInfo.getCPUFrequency());
#else
return 0;
if( !drive.IsEmpty() && !drive.Equals("*") )
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
UINT uidriveType = GetDriveType(( drive + ":\\" ));
if(uidriveType != DRIVE_UNKNOWN && uidriveType != DRIVE_NO_ROOT_DIR)
#endif
{
ULARGE_INTEGER ULTotalTmp= { { 0 } };
ULARGE_INTEGER ULTotalFreeTmp= { { 0 } };
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
char* pcBuffer= NULL;
DWORD dwStrLength= GetLogicalDriveStrings( 0, pcBuffer );
if( dwStrLength != 0 )
bool CSysInfo::IsAeroDisabled()
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (IsWindowsVersionAtLeast(CSysInfo::WindowsVersionVista))
{
BOOL aeroEnabled = FALSE;
CStdString CSysInfo::GetKernelVersion()
{
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
struct utsname un;
if (uname(&un)==0)
{
return strRet;
}
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
CStdString CSysInfo::GetLinuxDistro()
{
#if defined(TARGET_ANDROID)
}
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
CStdString CSysInfo::GetUnameVersion()
{
CStdString result = "";
{
CStdString result;
result = "XBMC/" + g_infoManager.GetLabel(SYSTEM_BUILD_VERSION) + " (";
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
result += GetUAWindowsVersion();
#elif defined(TARGET_DARWIN)
#if defined(TARGET_DARWIN_IOS)
result += "Mac OS X; ";
#endif
result += GetUnameVersion();
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
result += "FreeBSD; ";
result += GetUnameVersion();
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
result += "Linux; ";
result += GetLinuxDistro();
result += "; ";
bool GetHDDInfo(CStdString& strHDDModel, CStdString& strHDDSerial,CStdString& strHDDFirmware,CStdString& strHDDpw,CStdString& strHDDLockState);
bool GetRefurbInfo(CStdString& rfi_FirstBootTime, CStdString& rfi_PowerCycleCount);
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
CStdString GetLinuxDistro();
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
CStdString GetUnameVersion();
#endif
#if defined(TARGET_WINDOWS)
return strFileName.substr(period);
}
+bool URIUtils::HasExtension(const CStdString& strFileName)
+{
+ if (IsURL(strFileName))
+ {
+ CURL url(strFileName);
+ return HasExtension(url.GetFileName());
+ }
+
+ size_t iPeriod = strFileName.find_last_of("./\\");
+ return iPeriod != string::npos && strFileName[iPeriod] == '.';
+}
+
+bool URIUtils::HasExtension(const CStdString& strFileName, const CStdString& strExtensions)
+{
+ if (IsURL(strFileName))
+ {
+ CURL url(strFileName);
+ return HasExtension(url.GetFileName(), strExtensions);
+ }
+
+ // Search backwards so that '.' can be used as a search terminator.
+ CStdString::const_reverse_iterator itExtensions = strExtensions.rbegin();
+ while (itExtensions != strExtensions.rend())
+ {
+ // Iterate backwards over strFileName untill we hit a '.' or a mismatch
+ for (CStdString::const_reverse_iterator itFileName = strFileName.rbegin();
+ itFileName != strFileName.rend(), itExtensions != strExtensions.rend(),
+ tolower(*itFileName) == *itExtensions;
+ ++itFileName, ++itExtensions)
+ {
+ if (*itExtensions == '.')
+ return true; // Match
+ }
+
+ // No match. Look for more extensions to try.
+ while (itExtensions != strExtensions.rend() && *itExtensions != '|')
+ ++itExtensions;
+
+ while (itExtensions != strExtensions.rend() && *itExtensions == '|')
+ ++itExtensions;
+ }
+
+ return false;
+}
+
void URIUtils::RemoveExtension(CStdString& strFileName)
{
if(IsURL(strFileName))
}
int iPos = strFile.ReverseFind('/');
-#ifndef _LINUX
+#ifndef TARGET_POSIX
if (iPos < 0)
{
iPos = strFile.ReverseFind('\\');
bool URIUtils::IsOnDVD(const CStdString& strFile)
{
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
if (strFile.Mid(1,1) == ":")
return (GetDriveType(strFile.Left(2)) == DRIVE_CDROM);
#endif
if (strFileLow.Find("video_ts.ifo") != -1 && IsOnDVD(strFile))
return true;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
if (strFile.Left(6).Equals("dvd://"))
return true;
bool URIUtils::IsAPK(const CStdString& strFile)
{
- return GetExtension(strFile).CompareNoCase(".apk") == 0;
+ return HasExtension(strFile, ".apk");
}
bool URIUtils::IsZIP(const CStdString& strFile) // also checks for comic books!
{
- CStdString strExtension = GetExtension(strFile);
-
- if (strExtension.CompareNoCase(".zip") == 0)
- return true;
-
- if (strExtension.CompareNoCase(".cbz") == 0)
- return true;
-
- return false;
+ return HasExtension(strFile, ".zip|.cbz");
}
bool URIUtils::IsArchive(const CStdString& strFile)
{
- CStdString extension = GetExtension(strFile);
-
- return (extension.CompareNoCase(".zip") == 0 ||
- extension.CompareNoCase(".rar") == 0 ||
- extension.CompareNoCase(".apk") == 0 ||
- extension.CompareNoCase(".cbz") == 0 ||
- extension.CompareNoCase(".cbr") == 0);
+ return HasExtension(strFile, ".zip|.rar|.apk|.cbz|.cbr");
}
bool URIUtils::IsSpecial(const CStdString& strFile)
static const CStdString GetFileName(const CStdString& strFileNameAndPath);
static CStdString GetExtension(const CStdString& strFileName);
+
+ /*!
+ \brief Check if there is a file extension
+ \param strFileName Path or URL to check
+ \return \e true if strFileName have an extension.
+ \note Returns false when strFileName is empty.
+ \sa GetExtension
+ */
+ static bool HasExtension(const CStdString& strFileName);
+
+ /*!
+ \brief Check if filename have any of the listed extensions
+ \param strFileName Path or URL to check
+ \param strExtensions List of '.' prefixed lowercase extensions seperated with '|'
+ \return \e true if strFileName have any one of the extensions.
+ \note The check is case insensitive for strFileName, but requires
+ strExtensions to be lowercase. Returns false when strFileName or
+ strExtensions is empty.
+ \sa GetExtension
+ */
+ static bool HasExtension(const CStdString& strFileName, const CStdString& strExtensions);
+
static void RemoveExtension(CStdString& strFileName);
static CStdString ReplaceExtension(const CStdString& strFile,
const CStdString& strNewExtension);
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#include "Weather.h"
*
*/
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
#endif
#ifdef TARGET_WINDOWS
#include "XMLUtils.h"
#include "URL.h"
#include "StringUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include "PlatformDefs.h" //for strcasecmp
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#if !defined(_WIN32) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__)
+#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__)
#define HAVE_MMX2
#define HAVE_SSE
extern "C" {
#endif
-#if !defined(_WIN32) && !defined(__ppc__) && !defined(__powerpc__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
+#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
void * fast_memcpy(void * to, const void * from, size_t len);
//#define fast_memcpy memcpy
#else
#include <sys/types.h> /* for stupid systems */
#include <string.h> /* for memcpy() */
-#if defined(HAVE_CONFIG_H) && !defined(_WIN32)
+#if defined(HAVE_CONFIG_H) && !defined(TARGET_WINDOWS)
#include "../config.h"
#endif
TestCrc32.cpp \
TestCryptThreading.cpp \
TestDatabaseUtils.cpp \
- TestDownloadQueue.cpp \
- TestDownloadQueueManager.cpp \
TestEndianSwap.cpp \
Testfastmemcpy.cpp \
Testfft.cpp \
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueue.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueThread : public CThread
-{
-public:
- CTestDownloadQueueThread() :
- CThread("TestDownloadQueue"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueue : public testing::Test
-{
-protected:
- TestDownloadQueue()
- {
- CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
- CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
- CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
- EDIT_CONTROL_NUMBER_INPUT, false, 707);
- CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
- EDIT_CONTROL_HIDDEN_INPUT,true,733);
- CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
- SPIN_CONTROL_INT_PLUS, 14048, 351);
- }
-
- ~TestDownloadQueue()
- {
- CSettings::Get().Clear();
- }
-};
-
-TEST_F(TestDownloadQueue, RequestContent)
-{
- IDownloadQueueObserver observer;
- CDownloadQueue queue;
- CTestDownloadQueueThread thread;
- unsigned int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = queue.RequestContent(*it, &observer);
- EXPECT_EQ(count, t.dwItemId);
- count++;
- }
-
- thread.Sleep(1000);
- queue.Flush();
- EXPECT_EQ(0, queue.Size());
-}
-
-TEST_F(TestDownloadQueue, RequestFile)
-{
- IDownloadQueueObserver observer;
- CDownloadQueue queue;
- CTestDownloadQueueThread thread;
- unsigned int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = queue.RequestFile(*it, &observer);
- EXPECT_EQ(count, t.dwItemId);
- count++;
- }
-
- thread.Sleep(1000);
- queue.Flush();
- EXPECT_EQ(0, queue.Size());
-}
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueueManager.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueManagerThread : public CThread
-{
-public:
- CTestDownloadQueueManagerThread() :
- CThread("TestDownloadQueueManager"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueueManager : public testing::Test
-{
-protected:
- TestDownloadQueueManager()
- {
- /* TODO
- CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
- CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
- CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
- EDIT_CONTROL_NUMBER_INPUT, false, 707);
- CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
- EDIT_CONTROL_HIDDEN_INPUT,true,733);
- CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
- SPIN_CONTROL_INT_PLUS, 14048, 351);
- */
- }
-
- ~TestDownloadQueueManager()
- {
- CSettings::Get().Unload();
- }
-};
-
-TEST_F(TestDownloadQueueManager, RequestContent)
-{
- IDownloadQueueObserver observer;
- CTestDownloadQueueManagerThread thread;
- int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = g_DownloadManager.RequestContent(*it, &observer);
- std::cout << " Ticket Item ID: " << t.dwItemId << std::endl;
- count++;
- }
-
- thread.Sleep(1000);
-}
-
-TEST_F(TestDownloadQueueManager, RequestFile)
-{
- IDownloadQueueObserver observer;
- CTestDownloadQueueManagerThread thread;
- int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = g_DownloadManager.RequestFile(*it, &observer);
- std::cout << " Ticket Item ID: " << t.dwItemId << std::endl;
- count++;
- }
-
- thread.Sleep(1000);
-}
TEST(TestMime, GetMimeType_string)
{
- std::string refstr, varstr;
-
- refstr = "video/x-msvideo";
- varstr = CMime::GetMimeType("avi");
- EXPECT_STREQ(refstr.c_str(), varstr.c_str());
+ EXPECT_STREQ("video/avi", CMime::GetMimeType("avi").c_str());
+ EXPECT_STRNE("video/x-msvideo", CMime::GetMimeType("avi").c_str());
+ EXPECT_STRNE("video/avi", CMime::GetMimeType("xvid").c_str());
}
TEST(TestMime, GetMimeType_CFileItem)
protected:
TestSystemInfo()
{
- CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
+/* CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
EDIT_CONTROL_INPUT);
CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
EDIT_CONTROL_HIDDEN_INPUT,true,733);
CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
- SPIN_CONTROL_INT_PLUS, 14048, 351);
+ SPIN_CONTROL_INT_PLUS, 14048, 351);*/
}
~TestSystemInfo()
{
- CSettings::Get().Clear();
+// CSettings::Get().Clear();
}
};
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
TEST_F(TestSystemInfo, GetLinuxDistro)
{
std::cout << "GetLinuxDistro(): " << g_sysinfo.GetLinuxDistro() << std::endl;
}
#endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
TEST_F(TestSystemInfo, GetUnameVersion)
{
std::cout << "GetUnameVersion(): " << g_sysinfo.GetUnameVersion() << std::endl;
testing::PrintToString(g_sysinfo.IsAeroDisabled()) << std::endl;
}
-TEST_F(TestSystemInfo, IsVistaOrHigher)
+TEST_F(TestSystemInfo, IsWindowsVersionAtLeast_Vista)
{
- std::cout << "IsVistaOrHigher(): " <<
- testing::PrintToString(g_sysinfo.IsVistaOrHigher()) << std::endl;
+ std::cout << "IsWindowsVersionAtLeast(WindowsVersionVista): " <<
+ testing::PrintToString(g_sysinfo.IsWindowsVersionAtLeast(
+ CSysInfo::WindowsVersionVista)) << std::endl;
}
TEST_F(TestSystemInfo, GetKernelVersion)
URIUtils::GetExtension("/path/to/movie.avi").c_str());
}
+TEST_F(TestURIUtils, HasExtension)
+{
+ EXPECT_TRUE (URIUtils::HasExtension("/path/to/movie.AvI"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path/to/movie"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path/.to/movie"));
+ EXPECT_FALSE(URIUtils::HasExtension(""));
+
+ EXPECT_TRUE (URIUtils::HasExtension("/path/to/movie.AvI", ".avi"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path/to/movie.AvI", ".mkv"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path/.avi/movie", ".avi"));
+ EXPECT_FALSE(URIUtils::HasExtension("", ".avi"));
+
+ EXPECT_TRUE (URIUtils::HasExtension("/path/movie.AvI", ".avi|.mkv|.mp4"));
+ EXPECT_TRUE (URIUtils::HasExtension("/path/movie.AvI", ".mkv|.avi|.mp4"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path/movie.AvI", ".mpg|.mkv|.mp4"));
+ EXPECT_FALSE(URIUtils::HasExtension("/path.mkv/movie.AvI", ".mpg|.mkv|.mp4"));
+ EXPECT_FALSE(URIUtils::HasExtension("", ".avi|.mkv|.mp4"));
+}
+
TEST_F(TestURIUtils, GetFileName)
{
EXPECT_STREQ("movie.avi",
if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn)
{
SPlayerSubtitleStreamInfo info;
- g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info);
+ g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
if (!g_LangCodeExpander.Lookup(lang, info.language))
lang = g_localizeStrings.Get(13205); // Unknown
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = 0;
g_application.m_pPlayer->SetAudioStream(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream); // Set the audio stream to the one selected
CStdString aud;
+ CStdString lan;
SPlayerAudioStreamInfo info;
g_application.m_pPlayer->GetAudioStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream, info);
- aud = info.name;
+ if (!g_LangCodeExpander.Lookup(lan, info.language))
+ lan = g_localizeStrings.Get(13205); // Unknown
+ if (info.name.empty())
+ aud = lan;
+ else
+ aud.Format("%s - %s", lan.c_str(), info.name.c_str());
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(460), aud, DisplTime, false, MsgTime);
return true;
}
}
#ifndef my_offsetof
-#ifndef _LINUX
+#ifndef TARGET_POSIX
#define my_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER)
#else
/*
INFO_RET CVideoInfoScanner::RetrieveInfoForMovie(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
{
if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
- (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+ (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
return INFO_NOT_NEEDED;
if (ProgressCancelled(pDlgProgress, 198, pItem->GetLabel()))
INFO_RET CVideoInfoScanner::RetrieveInfoForMusicVideo(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
{
if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
- (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+ (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
return INFO_NOT_NEEDED;
if (ProgressCancelled(pDlgProgress, 20394, pItem->GetLabel()))
// Find a matching .nfo file
if (!item->m_bIsFolder)
{
- // file
- CStdString strExtension = URIUtils::GetExtension(item->GetPath());
-
if (URIUtils::IsInRAR(item->GetPath())) // we have a rarred item - we want to check outside the rars
{
CFileItem item2(*item);
else
{
// already an .nfo file?
- if ( strcmpi(strExtension.c_str(), ".nfo") == 0 )
+ if (URIUtils::HasExtension(item->GetPath(), ".nfo"))
nfoFile = item->GetPath();
// no, create .nfo file
else
#include "osx/CocoaInterface.h"
#elif defined(TARGET_DARWIN_IOS)
#include "windowing/WindowingFactory.h"
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
#pragma comment (lib,"d3d9.lib")
#if (D3DX_SDK_VERSION >= 42) //aug 2009 sdk and up there is no dxerr9 anymore
#include <Dxerr.h>
using namespace std;
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
void CD3DCallback::Reset()
{
bool SetupSuccess = false;
int64_t Now;
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
//register callback
m_D3dCallback.Reset();
g_Windowing.Register(&m_D3dCallback);
//set up the vblank clock
#if defined(HAS_GLX) && defined(HAS_XRANDR)
SetupSuccess = SetupGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
SetupSuccess = SetupD3D();
#elif defined(TARGET_DARWIN)
SetupSuccess = SetupCocoa();
#elif defined(HAS_GLX)
CLog::Log(LOGDEBUG, "CVideoReferenceClock: compiled without RandR support");
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
CLog::Log(LOGDEBUG, "CVideoReferenceClock: only available on directx build");
#else
CLog::Log(LOGDEBUG, "CVideoReferenceClock: no implementation available");
//run the clock
#if defined(HAS_GLX) && defined(HAS_XRANDR)
RunGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
RunD3D();
#elif defined(TARGET_DARWIN)
RunCocoa();
//clean up the vblank clock
#if defined(HAS_GLX) && defined(HAS_XRANDR)
CleanupGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
CleanupD3D();
#elif defined(TARGET_DARWIN)
CleanupCocoa();
if (!SetupSuccess) break;
}
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
g_Windowing.Unregister(&m_D3dCallback);
#endif
}
}
}
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
void CVideoReferenceClock::RunD3D()
{
return true;
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
D3DDISPLAYMODE DisplayMode;
m_D3dDev->GetDisplayMode(0, &DisplayMode);
#include <X11/X.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
#include <d3d9.h>
#include "guilib/D3DResource.h"
bool m_UseNvSettings;
bool m_bIsATI;
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
bool SetupD3D();
double MeasureRefreshrate(int MSecs);
void RunD3D();
setting.type = SettingInfo::SPIN;
setting.min = 0;
setting.data = &m_subtitleStream;
- m_subtitleStream = g_application.m_pPlayer->GetSubtitle();
+ m_subtitleStream = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
if(m_subtitleStream < 0) m_subtitleStream = 0;
}
if (CGUIDialogFileBrowser::ShowAndGetFile(shares,strMask,g_localizeStrings.Get(293),strPath,false,true)) // "subtitles"
{
- if (URIUtils::GetExtension(strPath) == ".sub")
+ if (URIUtils::HasExtension(strPath, ".sub"))
if (CFile::Exists(URIUtils::ReplaceExtension(strPath, ".idx")))
strPath = URIUtils::ReplaceExtension(strPath, ".idx");
return;
if (pItem->IsParentFolder() || pItem->m_bIsShareOrDrive || pItem->GetPath().Equals("add") ||
- (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+ (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
return;
// ShowIMDB can kill the item as this window can be closed while we do it,
CFileItemPtr item = m_vecItems->Get(iItem);
if (item->GetPath().Equals("add") || item->IsParentFolder() ||
- (item->IsPlayList() && !URIUtils::GetExtension(item->GetPath()).Equals(".strm")))
+ (item->IsPlayList() && !URIUtils::HasExtension(item->GetPath(), ".strm")))
return false;
if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
}
}
- CStdString ext = URIUtils::GetExtension(item->GetPath());
- ext.ToLower();
- if (ext == ".iso" || ext == ".img")
+ if (URIUtils::HasExtension(item->GetPath(), ".iso|.img"))
{
CURL url2("udf://");
url2.SetHostName(item->GetPath());
vector<int> stack;
for (int i = 0; i < items.Size(); ++i)
{
- if (URIUtils::GetExtension(items[i]->GetPath()) == ext)
+ if (URIUtils::HasExtension(items[i]->GetPath(), ext))
stack.push_back(i);
}
#include "guilib/GUIWindowManager.h"
#include "guilib/GUIKeyboardFactory.h"
#include "GUIUserMessages.h"
-#include "Favourites.h"
-#include "settings/MediaSettings.h"
+#include "filesystem/FavouritesDirectory.h"
#include "settings/Settings.h"
+#include "settings/MediaSettings.h"
#include "guilib/Key.h"
#include "guilib/LocalizeStrings.h"
#include "utils/log.h"
if (vecCores.size() > 1)
buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With...
- if (CFavourites::IsFavourite(item.get(), GetID()))
+ if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite
else
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites;
case CONTEXT_BUTTON_ADD_FAVOURITE:
{
CFileItemPtr item = m_vecItems->Get(itemNumber);
- CFavourites::AddOrRemove(item.get(), GetID());
+ XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
return true;
}
case CONTEXT_BUTTON_CANCEL_PARTYMODE:
#include "guilib/LocalizeStrings.h"
#include "GUIInfoManager.h"
#include "guilib/WindowIDs.h"
+#include "guilib/IGUIContainer.h"
CGUIViewControl::CGUIViewControl(void)
{
*
*/
-#include "view/GUIViewState.h"
+#include <vector>
+#include "utils/StdString.h"
+#include "guilib/GraphicContext.h" // for VIEW_TYPE
-#include "guilib/GUIBaseContainer.h"
+class CGUIControl;
+class CFileItemList;
class CGUIViewControl
{
#include "utils/LegacyPathTranslation.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/ConvUtils.h" // GetLastError()
#endif
#include "dbwrappers/dataset.h"
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">.vis</TargetExt>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">$(DXSDK_DIR)Lib\x86;$(LibraryPath)</LibraryPath>
- <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">false</PostBuildEventUseInBuild>
+ <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</PostBuildEventUseInBuild>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;_USRDLL;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
*
*/
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#endif//__APPLE__
+#endif
#include <string.h>
#include <vector>
*
*/
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#endif//__APPLE__
+#endif
#include <vector>
#include <string>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<WarningLevel>Level3</WarningLevel>
//
//////////////////////////////////////////////////////////////////////
-#if _MSC_VER > 1000
#pragma once
-#endif // _MSC_VER > 1000
//#include <xtl.h>
#include <windows.h>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">
<ClCompile>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
*
*/
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#define LINE_ENDING "\r\n"
extern "C" char * strptime(const char *buf, const char *fmt, struct tm *tm);
extern "C" int strverscmp (const char *s1, const char *s2);
extern "C" char * strcasestr(const char* haystack, const char* needle);
-extern int pgwin32_putenv(const char *envval);
-#endif // _WIN32
+#endif // TARGET_WINDOWS
#endif //__PLATFORM_DEFS_H__
*
*/
-#if !defined(_DEBUG) && _MSC_VER >= 1500 && !defined(_LIB)
+#if !defined(_DEBUG) && defined(TARGET_WINDOWS) && !defined(_LIB)
#include "git_rev.h" //generated file
#endif
#include <errno.h> // for ENOENT and EINVAL
#include <shlobj.h>
#include "filesystem/SpecialProtocol.h"
#include "my_ntddscsi.h"
-#if _MSC_VER > 1400
#include "Setupapi.h"
-#endif
#include "storage/MediaManager.h"
#include "windowing/WindowingFactory.h"
#include "guilib/LocalizeStrings.h"
#include "utils/URIUtils.h"
#include "powermanagement\PowerManager.h"
#include "utils/SystemInfo.h"
+#include "utils/Environment.h"
// default Broadcom registy bits (setup when installing a CrystalHD card)
#define BC_REG_PATH "Software\\Broadcom\\MediaPC"
bool CWIN32Util::PowerManagement(PowerState State)
{
-// SetSuspendState not available in vs2003
-#if _MSC_VER > 1400
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
return false;
break;
}
-#else
- return false;
-#endif
}
int CWIN32Util::BatteryLevel()
void CWIN32Util::ExtendDllPath()
{
- CStdStringW strEnvW;
+ CStdString strEnv;
CStdStringArray vecEnv;
- WCHAR wctemp[32768];
- if(GetEnvironmentVariableW(L"PATH",wctemp,32767) != 0)
- strEnvW = wctemp;
+ strEnv = CEnvironment::getenv("PATH");
+ if (strEnv.IsEmpty())
+ CLog::Log(LOGWARNING, "Can get system env PATH or PATH is empty");
StringUtils::SplitString(DLL_ENV_PATH, ";", vecEnv);
for (int i=0; i<(int)vecEnv.size(); ++i)
- {
- CStdStringW strFileW;
- g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(vecEnv[i]), strFileW, false);
- strEnvW.append(L";" + strFileW);
- }
- if(SetEnvironmentVariableW(L"PATH",strEnvW.c_str())!=0)
- CLog::Log(LOGDEBUG,"Setting system env PATH to %S",strEnvW.c_str());
+ strEnv.append(";" + CSpecialProtocol::TranslatePath(vecEnv[i]));
+
+ if (CEnvironment::setenv("PATH", strEnv) == 0)
+ CLog::Log(LOGDEBUG,"Setting system env PATH to %S",strEnv.c_str());
else
- CLog::Log(LOGDEBUG,"Can't set system env PATH to %S",strEnvW.c_str());
+ CLog::Log(LOGDEBUG,"Can't set system env PATH to %S",strEnv.c_str());
}
// http://www.codeproject.com/KB/system/RemoveDriveByLetter.aspx
// http://www.techtalkz.com/microsoft-device-drivers/250734-remove-usb-device-c-3.html
-#if _MSC_VER > 1400
DEVINST CWIN32Util::GetDrivesDevInstByDiskNumber(long DiskNumber)
{
SetupDiDestroyDeviceInfoList(hDevInfo);
return 0;
}
-#endif
bool CWIN32Util::EjectDrive(const char cDriveLetter)
{
-#if _MSC_VER > 1400
if( !cDriveLetter )
return false;
}
return bSuccess;
-#else
- return false;
-#endif
}
#ifdef HAS_GL
* POSSIBILITY OF SUCH DAMAGE.
*/
- #if !defined(_WIN32)
+ #if !defined(TARGET_WINDOWS)
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: strptime.c,v 1.25 2005/11/29 03:12:00 christos Exp $");
#endif
- #if !defined(_WIN32)
+ #if !defined(TARGET_WINDOWS)
#include "namespace.h"
#include <sys/localedef.h>
#else
#include <locale.h>
#include <string.h>
#include <time.h>
- #if !defined(_WIN32)
+ #if !defined(TARGET_WINDOWS)
#include <tzfile.h>
#endif
__weak_alias(strptime,_strptime)
#endif
- #if !defined(_WIN32)
+ #if !defined(TARGET_WINDOWS)
#define _ctloc(x) (_CurrentTimeLocale->x)
#else
#define _ctloc(x) (x)
*/
#include "URL.h"
-#if _MSC_VER > 1400
#include "Cfgmgr32.h"
-#endif
#include "MediaSource.h"
#include "guilib/Geometry.h"
#include "powermanagement/PowerManager.h"
static bool IsUsbDevice(const CStdStringW &strWdrive);
private:
-#if _MSC_VER > 1400
static DEVINST GetDrivesDevInstByDiskNumber(long DiskNumber);
-#endif
};
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * win32env.c
- * putenv() and unsetenv() for win32, that updates both process
- * environment and the cached versions in (potentially multiple)
- * MSVCRT.
- *
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/win32env.c
- *
- *-------------------------------------------------------------------------
- */
-
-//#include "windows.h"
-
-int
-pgwin32_wputenv(const wchar_t *envval)
-{
- wchar_t *envcpy;
- wchar_t *cp;
-
- /*
- * Each version of MSVCRT has its own _putenv() call in the runtime
- * library.
- *
- * mingw always uses MSVCRT.DLL, but if we are in a Visual C++
- * environment, attempt to update the environment in all MSVCRT modules
- * that are currently loaded, to work properly with any third party
- * libraries linked against a different MSVCRT but still relying on
- * environment variables.
- *
- * Also separately update the system environment that gets inherited by
- * subprocesses.
- */
-#ifdef _MSC_VER
- typedef int (_cdecl * PUTENVPROC) (const wchar_t *name);
- static struct
- {
- char *modulename;
- HMODULE hmodule;
- PUTENVPROC putenvFunc;
- } rtmodules[] =
- {
- {
- "msvcrt", 0, NULL
- }, /* Visual Studio 6.0 / mingw */
- {
- "msvcr70", 0, NULL
- }, /* Visual Studio 2002 */
- {
- "msvcr71", 0, NULL
- }, /* Visual Studio 2003 */
- {
- "msvcr80", 0, NULL
- }, /* Visual Studio 2005 */
- {
- "msvcr90", 0, NULL
- }, /* Visual Studio 2008 */
- {
- "msvcr100", 0, NULL
- }, /* Visual Studio 2010 */
- {
- NULL, 0, NULL
- }
- };
- int i;
-
- for (i = 0; rtmodules[i].modulename; i++)
- {
- if (rtmodules[i].putenvFunc == NULL)
- {
- if (rtmodules[i].hmodule == 0)
- {
- /* Not attempted before, so try to find this DLL */
- rtmodules[i].hmodule = GetModuleHandle(rtmodules[i].modulename);
- if (rtmodules[i].hmodule == NULL)
- {
- /*
- * Set to INVALID_HANDLE_VALUE so we know we have tried
- * this one before, and won't try again.
- */
- rtmodules[i].hmodule = ((HMODULE)(LONG_PTR)-1);
- continue;
- }
- else
- {
- rtmodules[i].putenvFunc = (PUTENVPROC) GetProcAddress(rtmodules[i].hmodule, "_wputenv");
- if (rtmodules[i].putenvFunc == NULL)
- {
- CloseHandle(rtmodules[i].hmodule);
- rtmodules[i].hmodule = ((HMODULE)(LONG_PTR)-1);
- continue;
- }
- }
- }
- else
- {
- /*
- * Module loaded, but we did not find the function last time.
- * We're not going to find it this time either...
- */
- continue;
- }
- }
- /* At this point, putenvFunc is set or we have exited the loop */
- rtmodules[i].putenvFunc(envval);
- }
-#endif /* _MSC_VER */
-
- /*
- * Update the process environment - to make modifications visible to child
- * processes.
- *
- * Need a copy of the string so we can modify it.
- */
- envcpy = wcsdup(envval);
- if (!envcpy)
- return -1;
- cp = wcschr(envcpy, '=');
- if (cp == NULL)
- {
- free(envcpy);
- return -1;
- }
- *cp = '\0';
- cp++;
- if (wcslen(cp))
- {
- /*
- * Only call SetEnvironmentVariable() when we are adding a variable,
- * not when removing it. Calling it on both crashes on at least
- * certain versions of MingW.
- */
- if (!SetEnvironmentVariableW(envcpy, cp))
- {
- free(envcpy);
- return -1;
- }
- }
- free(envcpy);
-
- /* Finally, update our "own" cache */
- return _wputenv(envval);
-}
-
-/*takes utf8 encoding*/
-int pgwin32_putenv(const char *envval)
-{
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, envval, strlen(envval), NULL, 0);
- std::wstring strTo(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, envval, strlen(envval), &strTo[0], size_needed);
- return pgwin32_wputenv(strTo.c_str());
-}
-
-void
-pgwin32_unsetenv(const wchar_t *name)
-{
- wchar_t *envbuf;
-
- envbuf = (wchar_t *) malloc(wcslen(name) + 2);
- if (!envbuf)
- return;
-
- wsprintfW(envbuf, L"%s=", name);
- pgwin32_wputenv(envbuf);
- free(envbuf);
-}
#include "WinEventsSDL.h"
#include "Application.h"
#include "ApplicationMessenger.h"
+#include "GUIUserMessages.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/Key.h"
#ifdef HAS_SDL_JOYSTICK
#endif
#include "input/MouseStat.h"
#include "WindowingFactory.h"
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
#include "osx/CocoaInterface.h"
#endif
-#if defined(_LINUX) && !defined(__APPLE__) && !defined(__ANDROID__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include "input/XBMC_keysym.h"
#include "utils/log.h"
#endif
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
// The following chunk of code is Linux specific. For keys that have
// with keysym.sym set to zero it checks the scan code, and sets the sym
// for some known scan codes. This is mostly the multimedia keys.
case SDL_KEYDOWN:
{
// process any platform specific shortcuts before handing off to XBMC
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
if (ProcessOSXShortcuts(event))
{
ret = true;
mod |= XBMCKMOD_LSUPER;
newEvent.key.keysym.mod = (XBMCMod) mod;
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
// If the keysym.sym is zero try to get it from the scan code
if (newEvent.key.keysym.sym == 0)
newEvent.key.keysym.sym = (XBMCKey) SymFromScancode(newEvent.key.keysym.scancode);
if (0 == (SDL_GetAppState() & SDL_APPMOUSEFOCUS))
{
g_Mouse.SetActive(false);
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN_OSX)
// See CApplication::ProcessSlow() for a description as to why we call Cocoa_HideMouse.
// this is here to restore the pointer when toggling back to window mode from fullscreen.
Cocoa_ShowMouse();
return ret;
}
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event)
{
static bool shift = false, cmd = false;
CApplicationMessenger::Get().Minimize();
return true;
+ case SDLK_v: // CMD-v to paste clipboard text
+ if (g_Windowing.IsTextInputEnabled())
+ {
+ const char *szStr = Cocoa_Paste();
+ if (szStr)
+ {
+ CGUIMessage msg(GUI_MSG_INPUT_TEXT, 0, 0);
+ msg.SetLabel(szStr);
+ g_windowManager.SendMessage(msg, g_windowManager.GetFocusedWindow());
+ }
+ }
+ return true;
+
default:
return false;
}
return false;
}
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
bool CWinEventsSDL::ProcessLinuxShortcuts(SDL_Event& event)
{
static bool MessagePump();
protected:
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN
static bool ProcessOSXShortcuts(SDL_Event& event);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
static bool ProcessLinuxShortcuts(SDL_Event& event);
#endif
};
#include "utils/XBMCTinyXML.h"
#include "../xbmc/utils/log.h"
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
#include <sys/types.h>
#include <sys/wait.h>
#endif
*
*/
-#if defined(__APPLE__) && !defined(__arm__)
+#if defined(TARGET_DARWIN_OSX)
//hack around problem with xbmc's typedef int BOOL
// and obj-c's typedef unsigned char BOOL
#include "network/Zeroconf.h"
#include "network/ZeroconfBrowser.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
using namespace PERIPHERALS;
#include "settings/Settings.h"
#include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <tpcshrd.h>
CWinSystemWin32::CWinSystemWin32()
#include "PartyModeManager.h"
#include "dialogs/GUIDialogMediaSource.h"
#include "GUIWindowFileManager.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
#include "utils/LabelFormatter.h"
#include "dialogs/GUIDialogProgress.h"
#include "profiles/ProfilesManager.h"
if (!item->IsParentFolder() && !item->GetPath().Equals("add") && !item->GetPath().Equals("newplaylist://") &&
!item->GetPath().Left(19).Equals("newsmartplaylist://") && !item->GetPath().Left(9).Equals("newtag://"))
{
- if (CFavourites::IsFavourite(item.get(), GetID()))
+ if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite
else
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites;
case CONTEXT_BUTTON_ADD_FAVOURITE:
{
CFileItemPtr item = m_vecItems->Get(itemNumber);
- CFavourites::AddOrRemove(item.get(), GetID());
+ XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
return true;
}
case CONTEXT_BUTTON_PLUGIN_SETTINGS:
#include "filesystem/VirtualDirectory.h"
#include "filesystem/DirectoryHistory.h"
#include "view/GUIViewControl.h"
+#include "view/GUIViewState.h"
#include "dialogs/GUIDialogContextMenu.h"
#include "playlists/SmartPlayList.h"
GlobalMemoryStatusEx(&stat);
CStdString profiling = CGUIControlProfiler::IsRunning() ? " (profiling)" : "";
CStdString strCores = g_cpuInfo.GetCoresUsageString();
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
info.Format("LOG: %sxbmc.log\nMEM: %"PRIu64"/%"PRIu64" KB - FPS: %2.1f fps\nCPU: %s%s", g_advancedSettings.m_logFolder.c_str(),
stat.ullAvailPhys/1024, stat.ullTotalPhys/1024, g_infoManager.GetFPS(), strCores.c_str(), profiling.c_str());
#else
*/
#include "guilib/GUIDialog.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
#include "linux/LinuxResourceCounter.h"
#endif
virtual void UpdateVisibility();
private:
CGUITextLayout *m_layout;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
CLinuxResourceCounter m_resourceCounter;
#endif
};
#include "guilib/GUIKeyboardFactory.h"
#include "dialogs/GUIDialogProgress.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
#include "playlists/PlayList.h"
#include "utils/AsyncFileCopy.h"
#include "storage/MediaManager.h"
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
if (pItem->IsHD() &&
- URIUtils::GetExtension(pItem->GetPath()).CompareNoCase(".tbn") == 0)
+ URIUtils::HasExtension(pItem->GetPath(), ".tbn"))
{
pItem->SetArt("thumb", pItem->GetPath());
}
{
choices.Add(1, 188); // SelectAll
if (!pItem->IsParentFolder())
- choices.Add(2, CFavourites::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
+ choices.Add(2, XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
if (vecCores.size() > 1)
choices.Add(3, 15213); // Play Using...
if (CanRename(list) && !pItem->IsParentFolder())
}
if (btnid == 2)
{
- CFavourites::AddOrRemove(pItem.get(), GetID());
+ XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID());
return;
}
if (btnid == 3)