1 /*****************************************************************
2 |
3 | Platinum - main
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
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.
13 |
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
21 |
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.
26 |
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
32 |
33 ****************************************************************/
34
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "PltMicroMediaController.h"
39 #include "PltFileMediaServer.h"
40 #include "PltMediaRenderer.h"
41 #include "PltXbox360.h"
42 #include "PltVersion.h"
43
44 #include <stdio.h>
45 #include <string.h>
46 #include <stdlib.h>
47
48 //#define HAS_RENDERER 1
49 //#define HAS_SERVER 1
50 //#define SIMULATE_XBOX_360 1
51 //#define SIMULATE_PS3 1
52 //#define BROADCAST_EXTRA 1
53
54 /*----------------------------------------------------------------------
55 | main
56 +---------------------------------------------------------------------*/
main(void)57 int main(void)
58 {
59 // setup Neptune logging
60 NPT_LogManager::GetDefault().Configure("plist:.level=INFO;.handlers=ConsoleHandler;.ConsoleHandler.colors=off;.ConsoleHandler.filter=24");
61
62 // Create upnp engine
63 PLT_UPnP upnp;
64
65 // Create control point
66 PLT_CtrlPointReference ctrlPoint(new PLT_CtrlPoint());
67
68 // Create controller
69 PLT_MicroMediaController controller(ctrlPoint);
70
71 #ifdef HAS_SERVER
72 // create device
73 PLT_DeviceHostReference server(
74 new PLT_FileMediaServer("/Users/sylvain/Documents/AudioFileTests",
75 "Platinum UPnP Media Server"));
76
77 server->m_ModelDescription = "Platinum File Media Server";
78 server->m_ModelURL = "http://www.plutinosoft.com/";
79 server->m_ModelNumber = "1.0";
80 server->m_ModelName = "Platinum File Media Server";
81 server->m_Manufacturer = "Plutinosoft";
82 server->m_ManufacturerURL = "http://www.plutinosoft.com/";
83
84 // add device
85 upnp.AddDevice(server);
86
87 // remove device uuid from ctrlpoint
88 ctrlPoint->IgnoreUUID(server->GetUUID());
89 #endif
90
91 // add control point to upnp engine and start it
92 upnp.AddCtrlPoint(ctrlPoint);
93 upnp.Start();
94
95 #ifdef BROADCAST_EXTRA
96 // tell control point to perform extra broadcast discover every 6 secs
97 // in case our device doesn't support multicast
98 ctrlPoint->Discover(NPT_HttpUrl("255.255.255.255", 1900, "*"), "upnp:rootdevice", 1, 6000);
99 ctrlPoint->Discover(NPT_HttpUrl("239.255.255.250", 1900, "*"), "upnp:rootdevice", 1, 6000);
100 #endif
101
102 #ifdef SIMULATE_XBOX_360
103 // override default headers
104 PLT_Constants::GetInstance().SetDefaultUserAgent("Xbox/2.0.8955.0 UPnP/1.0 Xbox/2.0.8955.0");
105 // NPT_HttpServer::m_ServerHeader = "Xbox/2.0.8955.0 UPnP/1.0 Xbox/2.0.8955.0";
106
107 // create device
108 PLT_DeviceHostReference xbox(new PLT_Xbox360("30848576-1775-2000-0000-00125a8fefad"));
109 xbox->SetByeByeFirst(false);
110 xbox->m_SerialNumber = "308485761776";
111
112 // add device
113 upnp.AddDevice(xbox);
114 ctrlPoint->IgnoreUUID(xbox->GetUUID());
115
116 // xbox issues a search for the content directory service
117 // 10 secs after announcing itself to make sure
118 // it got detected and inspected first
119
120 ctrlPoint->Search(
121 NPT_HttpUrl("239.255.255.250", 1900, "*"),
122 "urn:schemas-microsoft-com:service:MSContentDirectory:1", 2, NPT_TimeInterval(10.), NPT_TimeInterval(10.));
123 ctrlPoint->Search(
124 NPT_HttpUrl("239.255.255.250", 1900, "*"),
125 "urn:schemas-upnp-org:service:ContentDirectory:1", 2, NPT_TimeInterval(10.), NPT_TimeInterval(10.));
126
127 #endif
128
129 // start to process commands
130 controller.ProcessCommandLoop();
131
132 // stop everything
133 upnp.Stop();
134
135 return 0;
136 }
137