void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], Net::InitialisationParams* aInitParams) { static const Brn kLocalhost("127.0.0.1"); Net::Library* lib = new Net::Library(aInitParams); std::vector<Brn> args = OptionParser::ConvertArgs(aArgc, aArgv); Log::Print( "\n======================================================\n" "Overriding server name to '127.0.0.1'\n" "Temp hack to avoid DNS issues with OSX and Windows\n" "This won't be applied to Tests when run on Core platform" "\n======================================================\n\n" ); // Note, getaddrinfo() in Windows OS port requires "127.0.0.1" be passed. // "localhost" is resolved to 0.0.0.0 if(std::find(args.begin(), args.end(), Brn("-s")) != args.end() ) // only if found (ie already specified) { args.emplace_back("-s"); args.emplace_back(kLocalhost); } TestTopology3(lib->Env(), args); delete lib; }
int main(int aArgc, char* aArgv[]) { OptionParser parser; OptionString optionRenderer("-r", "--renderer", Brn("dummy"), "Renderer module name."); parser.AddOption(&optionRenderer); if (!parser.Parse(aArgc, aArgv)) { return (1); } Net::InitialisationParams* initParams = Net::InitialisationParams::Create(); Net::Library* lib = new Net::Library(initParams); Net::DvStack* dvStack = lib->StartDv(); Brhz udn("device1"); Net::DvDeviceStandard* device = new Net::DvDeviceStandard(*dvStack, udn); SourceIndexHandler* sourceIndexHandler = new SourceIndexHandler(); StandbyHandler* standbyHandler = new StandbyHandler(); IRenderer* renderer = NULL; if (0 == strcmp((const char*)optionRenderer.Value().Ptr(), "dummy")) { renderer = new Dummy(lib->Env()); } #ifdef HAVE_VLC_VLC_H else { renderer = new Vlc(lib->Env()); } #endif std::vector<OpenHome::NetworkAdapter*>* subnetList = lib->CreateSubnetList(); TIpAddress adapter = (*subnetList)[0]->Address(); OpenHome::Net::Library::DestroySubnetList(subnetList); char url[1024]; char attributes[1024]; sprintf(url, "%d.%d.%d.%d", adapter&0xff, (adapter>>8)&0xff, (adapter>>16)&0xff, (adapter>>24)&0xff); Config::GetInstance().GetAbout().SetUrl(url); sprintf(url, "http://%s:%s/", url, kHttpPort); sprintf(attributes, "Info Time App:Config=%s Volume", url); Config::GetInstance().GetAbout().SetVersion(VERSION); unsigned long long size; const char* res = getResource("/renderer.js", &size); Config::GetInstance().RegisterController(res, size); Config::GetInstance().GetDataMapper().Append("/data/renderer.json", "renderer"); Player* player = new Player( renderer, *device, *standbyHandler, *sourceIndexHandler, true, attributes, "OpenHome", "OpenHome Consortium", "http://openhome.org", "", "OpenHome Media Player", "", "", "", Config::GetInstance().GetString("device", "room").c_str(), Config::GetInstance().GetString("device", "name").c_str(), "", url, ""); SourcePlaylist* sourcePlaylist = new SourcePlaylist(*device, kTracksMax, kProtocolInfo, *player); player->AddSource(sourcePlaylist); device->SetEnabled(); char c = '\0'; while (c != 'q') { if(scanf("%c", &c)) ; } Log::Print("Quiting...\n"); delete sourcePlaylist; delete device; delete sourceIndexHandler; delete standbyHandler; delete player; Log::Print("Exit complete\n"); return (0); }
OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TUint32 preferredSubnet) { TUint index = 0; InitialisationParams *initParams = InitialisationParams::Create(); TIpAddress lastSubnet = InitArgs::NO_SUBNET;; const TChar *lastSubnetStr = "Subnet.LastUsed"; //initParams->SetDvEnableBonjour(); Net::Library* lib = new Net::Library(initParams); Debug::SetLevel(/*Debug::kError | */Debug::kPipeline); std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList(); if (subnetList->size() == 0) { Log::Print("ERROR: No adapters found\n"); ASSERTS(); } Configuration::ConfigRegStore iConfigRegStore; // Check the configuration store for the last subnet joined. try { Bwn lastSubnetBuf = Bwn((TByte *)&lastSubnet, sizeof(lastSubnet)); iConfigRegStore.Read(Brn(lastSubnetStr), lastSubnetBuf); } catch (StoreKeyNotFound&) { // No previous subnet stored. } catch (StoreReadBufferUndersized&) { // This shouldn't happen. Log::Print("ERROR: Invalid 'Subnet.LastUsed' property in Config " "Store\n"); } for (TUint i=0; i<subnetList->size(); ++i) { TIpAddress subnet = (*subnetList)[i]->Subnet(); // If the requested subnet is available, choose it. if (subnet == preferredSubnet) { index = i; break; } // If the last used subnet is available, note it. // We'll fall back to it if the requested subnet is not available. if (subnet == lastSubnet) { index = i; } } // Choose the required adapter. TIpAddress subnet = (*subnetList)[index]->Subnet(); Library::DestroySubnetList(subnetList); lib->SetCurrentSubnet(subnet); // Store the selected subnet in persistent storage. iConfigRegStore.Write(Brn(lastSubnetStr), Brn((TByte *)&subnet, sizeof(subnet))); Log::Print("Using Subnet %d.%d.%d.%d\n", subnet&0xff, (subnet>>8)&0xff, (subnet>>16)&0xff, (subnet>>24)&0xff); return lib; }