1 /*****************************************************************
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
7 | http://www.plutinosoft.com
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
33 ****************************************************************/
35 /*----------------------------------------------------------------------
37 +---------------------------------------------------------------------*/
39 #include "PltXbox360.h"
40 #include "PltService.h"
41 #include "PltUtilities.h"
44 /*----------------------------------------------------------------------
46 +---------------------------------------------------------------------*/
47 extern NPT_UInt8 Platinum_48x48_png
[4681];
49 /*----------------------------------------------------------------------
50 | PLT_Xbox360::PLT_Xbox360
51 +---------------------------------------------------------------------*/
52 PLT_Xbox360::PLT_Xbox360(const char* uuid
/* = NULL */,
53 unsigned int port
/* = 0 */,
54 bool port_rebind
/* = false */) :
55 PLT_MediaRenderer("Xbox 360", false, uuid
, port
, port_rebind
)
59 /*----------------------------------------------------------------------
60 | PLT_Xbox360::~PLT_Xbox360
61 +---------------------------------------------------------------------*/
62 PLT_Xbox360::~PLT_Xbox360()
66 /*----------------------------------------------------------------------
67 | PLT_Xbox360::SetupServices
68 +---------------------------------------------------------------------*/
70 PLT_Xbox360::SetupServices()
72 NPT_CHECK(PLT_MediaRenderer::SetupServices());
74 m_ModelDescription
= "Xbox 360";
75 m_ModelName
= "Xbox 360";
76 m_ModelURL
= "http://www.xbox.com";
77 m_Manufacturer
= "Microsoft Corporation";
78 m_ManufacturerURL
= "http://www.microsoft.com";
80 NPT_Array
<PLT_Service
*>::Iterator service
;
82 if (NPT_SUCCEEDED(NPT_ContainerFind(
84 PLT_ServiceTypeFinder("urn:schemas-upnp-org:service:RenderingControl:1"),
86 InitServiceURLs(*service
, "RenderingControl");
89 if (NPT_SUCCEEDED(NPT_ContainerFind(
91 PLT_ServiceTypeFinder("urn:schemas-upnp-org:service:ConnectionManager:1"),
93 InitServiceURLs(*service
, "ConnectionManager");
97 if (NPT_SUCCEEDED(NPT_ContainerFind(
99 PLT_ServiceTypeFinder("urn:schemas-upnp-org:service:AVTransport:1"),
101 m_Services
.Erase(service
);
106 /*----------------------------------------------------------------------
107 | PLT_Service::InitServiceURLs
108 +---------------------------------------------------------------------*/
110 PLT_Xbox360::InitServiceURLs(PLT_Service
* service
, const char* service_name
)
112 service
->SetSCPDURL("/Content/" + NPT_String(service_name
));
113 service
->SetControlURL("/Control/" + NPT_String(service_name
));
114 service
->SetEventSubURL("/Event/" + NPT_String(service_name
));
119 /*----------------------------------------------------------------------
120 | PLT_Xbox360::GetDescription
121 +---------------------------------------------------------------------*/
123 PLT_Xbox360::GetDescription(NPT_XmlElementNode
* root
, NPT_XmlElementNode
** device_out
)
125 // if no device out passed, pass one
126 NPT_XmlElementNode
* device_out_local
;
127 if (!device_out
) device_out
= &device_out_local
;
129 NPT_CHECK(PLT_MediaRenderer::GetDescription(root
, device_out
));
132 root
->SetNamespaceUri("ms", " urn:microsoft-com:wmc-1-0");
133 root
->SetNamespaceUri("microsoft", "urn-schemas-microsoft-com:WMPNSS-1-0");
136 (*device_out
)->SetAttribute("ms", "X_MS_SupportsWMDRM", "true");
137 NPT_XmlElementNode
* device_caps
= new NPT_XmlElementNode("microsoft", "X_DeviceCaps");
138 device_caps
->AddText("4754");
139 (*device_out
)->AddChild(device_caps
);
141 NPT_XmlElementNode
* handshake
= new NPT_XmlElementNode("microsoft", "HandshakeFlags");
142 handshake
->AddText("1");
143 (*device_out
)->AddChild(handshake
);
149 /*----------------------------------------------------------------------
150 | PLT_Xbox360::SetupIcons
151 +---------------------------------------------------------------------*/
153 PLT_Xbox360::SetupIcons()
156 PLT_DeviceIcon("image/png", 48, 48, 32, "/xbox360.png"),
157 Platinum_48x48_png
, sizeof(Platinum_48x48_png
), false);
161 /*----------------------------------------------------------------------
162 | PLT_DeviceHost::Announce
163 +---------------------------------------------------------------------*/
165 PLT_Xbox360::Announce(PLT_DeviceData
* device
,
166 NPT_HttpRequest
& req
,
167 NPT_UdpSocket
& socket
,
168 PLT_SsdpAnnounceType type
)
170 AnnouncePresence(socket
, "");
172 return PLT_MediaRenderer::Announce(device
, req
, socket
, type
);
175 /*----------------------------------------------------------------------
176 | PLT_DeviceHost::AnnouncePresence
177 +---------------------------------------------------------------------*/
179 PLT_Xbox360::AnnouncePresence(NPT_UdpSocket
& socket
,
180 const char* serial_number
)
182 NPT_COMPILER_UNUSED(serial_number
);
185 NPT_HttpUrl("239.255.255.250", 1900, "*"),
187 NPT_HTTP_PROTOCOL_1_1
);
188 PLT_HttpHelper::SetHost(req
, "239.255.255.250:1900");
190 NPT_Result res
= NPT_SUCCESS
;
191 // get location URL based on ip address of interface
192 PLT_UPnPMessageHelper::SetNTS(req
, "ssdp:alive");
193 PLT_UPnPMessageHelper::SetLeaseTime(req
, NPT_TimeInterval(4.));
194 PLT_UPnPMessageHelper::SetServer(req
, "dashboard/1.0 UpnP/1.0 xbox/2.0", true);
195 req
.GetHeaders().SetHeader("AL",
196 "<urn:schemas-microsoft-com:nhed:attributes?type=X02&firmwarever=8955.0&udn=uuid:10000000-0000-0000-0200-00125A8FEFAC>");
197 PLT_UPnPMessageHelper::SetLocation(req
, "*");
201 if (NPT_FAILED(res
= ip
.ResolveName(req
.GetUrl().GetHost()))) {
204 NPT_SocketAddress
addr(ip
, req
.GetUrl().GetPort());
206 PLT_SsdpSender::SendSsdp(req
,
207 "uuid:00000000-0000-0000-0200-00125A8FEFAC::urn:schemas-microsoft-com:nhed:presence:1",
208 "urn:schemas-microsoft-com:nhed:presence:1",