merged: Platinum from linuxport branches
[xbmc:xbmc-antiquated.git] / xbmc / lib / libUPnP / Platinum / Source / Devices / MediaRenderer / PltMediaController.h
1 /*****************************************************************\r
2 |\r
3 |   Platinum - AV Media Controller (Media Renderer Control Point)\r
4 |\r
5 |   Copyright (c) 2004-2008 Sylvain Rebaud\r
6 |   Author: Sylvain Rebaud (sylvain@rebaud.com)\r
7 |\r
8  ****************************************************************/\r
9 \r
10 #ifndef _PLT_MEDIA_CONTROLLER_H_\r
11 #define _PLT_MEDIA_CONTROLLER_H_\r
12 \r
13 /*----------------------------------------------------------------------\r
14 |   includes\r
15 +---------------------------------------------------------------------*/\r
16 #include "PltCtrlPoint.h"\r
17 #include "PltMediaControllerListener.h"\r
18 \r
19 /*----------------------------------------------------------------------\r
20 |   PLT_MediaController class\r
21 +---------------------------------------------------------------------*/\r
22 class PLT_MediaController : public PLT_CtrlPointListener\r
23 {\r
24 public:\r
25     PLT_MediaController(PLT_CtrlPointReference& ctrl_point, PLT_MediaControllerListener* listener);\r
26     virtual ~PLT_MediaController();\r
27 \r
28     // PLT_CtrlPointListener methods\r
29     virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device);\r
30     virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device);\r
31     virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata);\r
32     virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars);\r
33 \r
34     // AVTransport\r
35     NPT_Result GetCurrentTransportActions(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
36     NPT_Result GetDeviceCapabilities(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
37     NPT_Result GetMediaInfo(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
38     NPT_Result GetPositionInfo(PLT_DeviceDataReference& device,  NPT_UInt32 instance_id, void* userdata);\r
39     NPT_Result GetTransportInfo(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
40     NPT_Result GetTransportSettings(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
41     NPT_Result Next(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
42     NPT_Result Pause(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
43     NPT_Result Play(PLT_DeviceDataReference&  device, NPT_UInt32 instance_id, NPT_String speed, void* userdata);\r
44     NPT_Result Previous(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
45     NPT_Result Seek(PLT_DeviceDataReference&  device, NPT_UInt32 instance_id, NPT_String unit, NPT_String target, void* userdata);\r
46     NPT_Result SetAVTransportURI(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, const char* uri, const char* metadata, void* userdata);\r
47     NPT_Result SetPlayMode(PLT_DeviceDataReference&  device, NPT_UInt32 instance_id, NPT_String new_play_mode, void* userdata);\r
48     NPT_Result Stop(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata);\r
49 \r
50     // ConnectionManager\r
51     NPT_Result GetCurrentConnectionIDs(PLT_DeviceDataReference& device, void* userdata);\r
52     NPT_Result GetCurrentConnectionInfo(PLT_DeviceDataReference& device, NPT_UInt32 connection_id, void* userdata);\r
53     NPT_Result GetProtocolInfo(PLT_DeviceDataReference& device, void* userdata);\r
54 \r
55 private:\r
56     NPT_Result FindActionDesc(PLT_DeviceDataReference& device, \r
57         const char*              service_type,\r
58         const char*              action_name,\r
59         PLT_ActionDesc*&         action_desc);\r
60 \r
61     NPT_Result CreateAction(PLT_DeviceDataReference& device, \r
62         const char*              service_type,\r
63         const char*              action_name,\r
64         PLT_ActionReference&     action);\r
65 \r
66     NPT_Result CallAVTransportAction(PLT_ActionReference& action,\r
67         NPT_UInt32               instance_id,\r
68         void*                    userdata = NULL);\r
69 \r
70     NPT_Result OnGetCurrentTransportActionsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
71     NPT_Result OnGetDeviceCapabilitiesResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
72     NPT_Result OnGetMediaInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
73     NPT_Result OnGetPositionInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
74     NPT_Result OnGetTransportInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
75     NPT_Result OnGetTransportSettingsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
76 \r
77     NPT_Result OnGetCurrentConnectionIDsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
78     NPT_Result OnGetCurrentConnectionInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
79     NPT_Result OnGetProtocolInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata);\r
80 \r
81     static void ParseCSV(const char* csv, PLT_StringList& values) {\r
82         const char* start = csv;\r
83         const char* p = start;\r
84 \r
85         // look for the , character\r
86         while (*p) {\r
87             if (*p == ',') {\r
88                 NPT_String val(start, (int)(p-start));\r
89                 val.Trim(' ');\r
90                 values.Add(val);\r
91                 start = p + 1;\r
92             }\r
93             p++;\r
94         }\r
95 \r
96         // last one\r
97         NPT_String last(start, (int)(p-start));\r
98         last.Trim(' ');\r
99         if (last.GetLength()) {\r
100             values.Add(last);\r
101         }\r
102     }\r
103 \r
104 protected:\r
105     PLT_CtrlPointReference       m_CtrlPoint;\r
106     PLT_MediaControllerListener* m_Listener;\r
107 \r
108 private:\r
109     NPT_List<PLT_DeviceDataReference> m_MediaRenderers;\r
110 };\r
111 \r
112 #endif /* _PLT_MEDIA_CONTROLLER_H_ */\r