Merge pull request #4314 from MartijnKaijser/beta1
[vuplus_xbmc] / xbmc / network / upnp / UPnPInternal.h
1 /*
2  *      Copyright (C) 2012-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20 #pragma once
21 #include "system.h"
22 #include "utils/StdString.h"
23 #include "NptTypes.h"
24 #include "NptReferences.h"
25 #include "NptStrings.h"
26 #include "FileItem.h"
27
28 class CUPnPServer;
29 class CFileItem;
30 class CThumbLoader;
31 class PLT_DeviceData;
32 class PLT_HttpRequestContext;
33 class PLT_MediaItemResource;
34 class PLT_MediaObject;
35 class NPT_String;
36 namespace MUSIC_INFO {
37   class CMusicInfoTag;
38 }
39 class CVideoInfoTag;
40
41 namespace UPNP
42 {
43   class CResourceFinder {
44   public:
45     CResourceFinder(const char* protocol, const char* content = NULL);
46     bool operator()(const PLT_MediaItemResource& resource) const;
47   private:
48     NPT_String m_Protocol;
49     NPT_String m_Content;
50   };
51
52   enum EClientQuirks
53   {
54     ECLIENTQUIRKS_NONE = 0x0
55
56     /* Client requires folder's to be marked as storageFolers as verndor type (360)*/
57   , ECLIENTQUIRKS_ONLYSTORAGEFOLDER = 0x01
58
59     /* Client can't handle subtypes for videoItems (360) */
60   , ECLIENTQUIRKS_BASICVIDEOCLASS = 0x02
61
62     /* Client requires album to be set to [Unknown Series] to show title (WMP) */
63   , ECLIENTQUIRKS_UNKNOWNSERIES = 0x04
64   };
65
66   EClientQuirks GetClientQuirks(const PLT_HttpRequestContext* context);
67
68   enum EMediaControllerQuirks
69   {
70     EMEDIACONTROLLERQUIRKS_NONE   = 0x00
71
72     /* Media Controller expects MIME type video/x-mkv instead of video/x-matroska (Samsung) */
73   , EMEDIACONTROLLERQUIRKS_X_MKV  = 0x01
74   };
75
76   EMediaControllerQuirks GetMediaControllerQuirks(const PLT_DeviceData *device);
77
78   const char* GetMimeTypeFromExtension(const char* extension, const PLT_HttpRequestContext* context = NULL);
79   NPT_String  GetMimeType(const CFileItem& item, const PLT_HttpRequestContext* context = NULL);
80   NPT_String  GetMimeType(const char* filename, const PLT_HttpRequestContext* context = NULL);
81   const NPT_String GetProtocolInfo(const CFileItem& item, const char* protocol, const PLT_HttpRequestContext* context = NULL);
82
83
84   const CStdString& CorrectAllItemsSortHack(const CStdString &item);
85
86   NPT_Result PopulateTagFromObject(MUSIC_INFO::CMusicInfoTag& tag,
87                                    PLT_MediaObject&           object,
88                                    PLT_MediaItemResource*     resource = NULL);
89   NPT_Result PopulateTagFromObject(CVideoInfoTag&             tag,
90                                    PLT_MediaObject&           object,
91                                    PLT_MediaItemResource*     resource = NULL);
92
93   NPT_Result PopulateObjectFromTag(MUSIC_INFO::CMusicInfoTag&         tag,
94                                           PLT_MediaObject&       object,
95                                           NPT_String*            file_path,
96                                           PLT_MediaItemResource* resource,
97                                           EClientQuirks          quirks);
98   NPT_Result PopulateObjectFromTag(CVideoInfoTag&         tag,
99                                           PLT_MediaObject&       object,
100                                           NPT_String*            file_path,
101                                           PLT_MediaItemResource* resource,
102                                           EClientQuirks          quirks);
103
104   PLT_MediaObject* BuildObject(CFileItem&              item,
105                                       NPT_String&                   file_path,
106                                       bool                          with_count,
107                                       NPT_Reference<CThumbLoader>&  thumb_loader,
108                                       const PLT_HttpRequestContext* context = NULL,
109                                       CUPnPServer*                  upnp_server = NULL);
110
111   CFileItemPtr     BuildObject(PLT_MediaObject* entry);
112
113   bool             GetResource(const PLT_MediaObject* entry, CFileItem& item);
114   CFileItemPtr     GetFileItem(const NPT_String& uri, const NPT_String& meta);
115 }
116