xbmc
UPnPInternal.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <memory>
12 #include <string>
13 
14 #include <Neptune/Source/Core/NptReferences.h>
15 #include <Neptune/Source/Core/NptStrings.h>
16 #include <Neptune/Source/Core/NptTypes.h>
17 
18 class CUPnPServer;
19 class CFileItem;
20 class CThumbLoader;
21 class PLT_DeviceData;
24 class PLT_MediaObject;
25 class NPT_String;
26 namespace MUSIC_INFO {
27  class CMusicInfoTag;
28 }
29 class CVideoInfoTag;
30 
31 namespace UPNP
32 {
33  enum UPnPService {
34  UPnPServiceNone = 0,
35  UPnPClient,
36  UPnPContentDirectory,
37  UPnPPlayer,
38  UPnPRenderer
39  };
40 
42  public:
43  CResourceFinder(const char* protocol, const char* content = NULL);
44  bool operator()(const PLT_MediaItemResource& resource) const;
45  private:
46  NPT_String m_Protocol;
47  NPT_String m_Content;
48  };
49 
50  enum EClientQuirks
51  {
52  ECLIENTQUIRKS_NONE = 0x0
53 
54  /* Client requires folder's to be marked as storageFolders as vendor type (360)*/
55  , ECLIENTQUIRKS_ONLYSTORAGEFOLDER = 0x01
56 
57  /* Client can't handle subtypes for videoItems (360) */
58  , ECLIENTQUIRKS_BASICVIDEOCLASS = 0x02
59 
60  /* Client requires album to be set to [Unknown Series] to show title (WMP) */
61  , ECLIENTQUIRKS_UNKNOWNSERIES = 0x04
62  };
63 
64  EClientQuirks GetClientQuirks(const PLT_HttpRequestContext* context);
65 
66  enum EMediaControllerQuirks
67  {
68  EMEDIACONTROLLERQUIRKS_NONE = 0x00
69 
70  /* Media Controller expects MIME type video/x-mkv instead of video/x-matroska (Samsung) */
71  , EMEDIACONTROLLERQUIRKS_X_MKV = 0x01
72  };
73 
74  EMediaControllerQuirks GetMediaControllerQuirks(const PLT_DeviceData *device);
75 
76  const char* GetMimeTypeFromExtension(const char* extension, const PLT_HttpRequestContext* context = NULL);
77  NPT_String GetMimeType(const CFileItem& item, const PLT_HttpRequestContext* context = NULL);
78  NPT_String GetMimeType(const char* filename, const PLT_HttpRequestContext* context = NULL);
79  const NPT_String GetProtocolInfo(const CFileItem& item, const char* protocol, const PLT_HttpRequestContext* context = NULL);
80 
81 
82  const std::string& CorrectAllItemsSortHack(const std::string &item);
83 
84  NPT_Result PopulateTagFromObject(MUSIC_INFO::CMusicInfoTag& tag,
85  PLT_MediaObject& object,
86  PLT_MediaItemResource* resource = NULL,
87  UPnPService service = UPnPServiceNone);
88 
89  NPT_Result PopulateTagFromObject(CVideoInfoTag& tag,
90  PLT_MediaObject& object,
91  PLT_MediaItemResource* resource = NULL,
92  UPnPService service = UPnPServiceNone);
93 
94  NPT_Result PopulateObjectFromTag(MUSIC_INFO::CMusicInfoTag& tag,
95  PLT_MediaObject& object,
96  NPT_String* file_path,
97  PLT_MediaItemResource* resource,
98  EClientQuirks quirks,
99  UPnPService service = UPnPServiceNone);
100 
101  NPT_Result PopulateObjectFromTag(CVideoInfoTag& tag,
102  PLT_MediaObject& object,
103  NPT_String* file_path,
104  PLT_MediaItemResource* resource,
105  EClientQuirks quirks,
106  UPnPService service = UPnPServiceNone);
107 
108  PLT_MediaObject* BuildObject(CFileItem& item,
109  NPT_String& file_path,
110  bool with_count,
111  NPT_Reference<CThumbLoader>& thumb_loader,
112  const PLT_HttpRequestContext* context = NULL,
113  CUPnPServer* upnp_server = NULL,
114  UPnPService upnp_service = UPnPServiceNone);
115 
116  std::shared_ptr<CFileItem> BuildObject(PLT_MediaObject* entry,
117  UPnPService upnp_service = UPnPServiceNone);
118 
119  bool GetResource(const PLT_MediaObject* entry, CFileItem& item);
120  std::shared_ptr<CFileItem> GetFileItem(const NPT_String& uri, const NPT_String& meta);
121 
128  NPT_String EncodeObjectId(const std::string& id);
129 
136  NPT_String DecodeObjectId(const std::string& id);
137 }
138 
Definition: UPnPInternal.h:41
Definition: PltMediaItem.h:187
Definition: UPnP.cpp:118
The PLT_DeviceData class holds information about a device being advertised or found by a control poin...
Definition: PltDeviceData.h:93
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
Definition: UPnPServer.h:31
The PLT_MediaObject class is any data entity that can be returned by a ContentDirectory Service from ...
Definition: PltMediaItem.h:217
Definition: NptReferences.h:45
Definition: NptStrings.h:57
Definition: VideoInfoTag.h:53
Definition: MusicInfoTag.h:27
Represents a file on a share.
Definition: FileItem.h:102
Definition: ThumbLoader.h:17
Definition: Application.h:77