InvocationManager::InvocationManager(CpStack& aCpStack) : Thread("InvocationManager") , iCpStack(aCpStack) , iLock("INVM") , iFreeInvocations(aCpStack.Env().InitParams()->NumInvocations()) , iWaitingInvocations(aCpStack.Env().InitParams()->NumInvocations()) , iFreeInvokers(aCpStack.Env().InitParams()->NumActionInvokerThreads()) { TUint i; iInvokers = (Invoker**)malloc(sizeof(*iInvokers) * iCpStack.Env().InitParams()->NumActionInvokerThreads()); for (i=0; i<iCpStack.Env().InitParams()->NumActionInvokerThreads(); i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("ActionInvoker %d", i); thName.PtrZ(); iInvokers[i] = new Invoker((const TChar*)thName.Ptr(), iFreeInvokers); iFreeInvokers.Write(iInvokers[i]); iInvokers[i]->Start(); } for (i=0; i<iCpStack.Env().InitParams()->NumInvocations(); i++) { iFreeInvocations.Write(new OpenHome::Net::Invocation(iCpStack, iFreeInvocations)); } iActive = true; Start(); }
void OpenHome::Net::Invocation::Output(IAsyncOutput& aConsole) { AutoMutex a(iLock); /* using iLock doesn't prevent logging for multiple invocations overlapping Using iCpStack.Env().Mutex() causes problems though as the call to ServiceType().FullName() below also uses the Environment's mutex and we can't easily use a different mutex there. If we later want to prevent overlapped output, it'd be best to add a shared logging mutex to Environment */ Bws<Ascii::kMaxUintStringBytes+1> buf; (void)Ascii::AppendDec(buf, iSequenceNumber); buf.PtrZ(); aConsole.Output("SequenceNumber", (const TChar*)buf.Ptr()); aConsole.Output("Service", (const TChar*)ServiceType().FullName().Ptr()); aConsole.Output("Action", (const TChar*)iAction->Name().Ptr()); TUint count = (TUint)iInput.size(); for (TUint i=0; i<count; i++) { OutputArgument(aConsole, "InputArg", *(iInput[i])); } if (Error()) { iError.Output(aConsole); } else if (iCompleted) { count = (TUint)iOutput.size(); for (TUint i=0; i<count; i++) { OutputArgument(aConsole, "OutputArg", *(iOutput[i])); } } }
void Error::Output(IAsyncOutput& aConsole) { aConsole.Output("ErrorLevel", LevelName()); Bws<Ascii::kMaxUintStringBytes+1> buf; (void)Ascii::AppendDec(buf, iCode); buf.PtrZ(); aConsole.Output("ErrorCode", (const TChar*)buf.Ptr()); aConsole.Output("ErrorDescription", Description()); }
EventServerUpnp::EventServerUpnp(CpStack& aCpStack, TIpAddress aInterface) : iTcpServer(aCpStack.Env(), "EventServer", aCpStack.Env().InitParams()->CpUpnpEventServerPort(), aInterface) { const TUint numThread = aCpStack.Env().InitParams()->NumEventSessionThreads(); for (TUint i=0; i<numThread; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("EventSession %d", i); thName.PtrZ(); iTcpServer.Add((const TChar*)thName.Ptr(), new EventSessionUpnp(aCpStack)); } }
EventServerUpnp::EventServerUpnp(CpStack& aCpStack, TIpAddress aInterface) : iTcpServer(aCpStack.Env(), "EventServer", aCpStack.Env().InitParams()->CpUpnpEventServerPort(), aInterface) { const TUint numThread = aCpStack.Env().InitParams()->NumEventSessionThreads(); #ifndef _WIN32 // nothing terribly bad would happen if this assertion failed so its not worth a separate Windows implementation ASSERT(numThread < 10); #endif for (TUint i=0; i<numThread; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("EventSession %d", i); thName.PtrZ(); iTcpServer.Add((const TChar*)thName.Ptr(), new EventSessionUpnp(aCpStack)); } }
SocketTcpServer* DviServerLpec::CreateServer(const NetworkAdapter& aNif) { SocketTcpServer* server = new SocketTcpServer(iDvStack.Env(), "LpecServer", iPort, aNif.Address()); const TUint numThreads = iDvStack.Env().InitParams()->DvNumLpecThreads(); AdapterData* ad = new AdapterData(aNif.Address()); iAdapterData.push_back(ad); for (TUint i=0; i<numThreads; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("LpecSession %d", i); thName.PtrZ(); DviSessionLpec* session = new DviSessionLpec(iDvStack, aNif.Address(), iPort); server->Add((const TChar*)thName.Ptr(), session); ad->iSessions.push_back(session); } return server; }
void XmlFetch::Output(IAsyncOutput& aConsole) { Mutex& lock = iCpStack.Env().Mutex(); lock.Wait(); Bws<Ascii::kMaxUintStringBytes+1> buf; (void)Ascii::AppendDec(buf, iSequenceNumber); buf.PtrZ(); aConsole.Output("SequenceNumber", (const TChar*)buf.Ptr()); Bws<Uri::kMaxUriBytes+1> uri(iUri->AbsoluteUri()); uri.PtrZ(); aConsole.Output("XmlFetch", (const TChar*)uri.Ptr()); if (Error()) { iError.Output(aConsole); } lock.Signal(); }
DviSubscriptionManager::DviSubscriptionManager(DvStack& aDvStack) : Thread("DvSubscriptionMgr") , iDvStack(aDvStack) , iLock("DSBM") , iFree(aDvStack.Env().InitParams()->DvNumPublisherThreads()) { const TUint numPublisherThreads = iDvStack.Env().InitParams()->DvNumPublisherThreads(); LOG(kDvEvent, "> DviSubscriptionManager: creating %u publisher threads\n", numPublisherThreads); iPublishers = (Publisher**)malloc(sizeof(*iPublishers) * numPublisherThreads); for (TUint i=0; i<numPublisherThreads; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("Publisher %d", i); thName.PtrZ(); iPublishers[i] = new Publisher((const TChar*)thName.Ptr(), iFree); iFree.Write(iPublishers[i]); iPublishers[i]->Start(); } Start(); }
XmlFetchManager::XmlFetchManager(CpStack& aCpStack) : Thread("XmlFetchManager") , iCpStack(aCpStack) , iLock("FETL") , iFree(iCpStack.Env().InitParams()->NumXmlFetcherThreads()) { const TUint numThreads = iCpStack.Env().InitParams()->NumXmlFetcherThreads(); iFetchers = (XmlFetcher**)malloc(sizeof(*iFetchers) * numThreads); for (TUint i=0; i<numThreads; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("XmlFetcher %d", i); thName.PtrZ(); iFetchers[i] = new XmlFetcher((const TChar*)thName.Ptr(), iFree); iFree.Write(iFetchers[i]); iFetchers[i]->Start(); } iActive = true; Start(); }
ExampleMediaPlayer::ExampleMediaPlayer(HWND hwnd, Net::DvStack& aDvStack, const Brx& aUdn, const TChar* aRoom, const TChar* aProductName, const Brx& aUserAgent) : iSemShutdown("TMPS", 0) , iDisabled("test", 0) , iHwnd(hwnd) , iCpProxy(NULL) , iTxTimestamper(NULL) , iRxTimestamper(NULL) , iTxTsMapper(NULL) , iRxTsMapper(NULL) , iUserAgent(aUserAgent) { iShell = new Shell(aDvStack.Env(), kShellPort); iShellDebug = new ShellCommandDebug(*iShell); Bws<256> friendlyName; friendlyName.Append(aRoom); friendlyName.Append(':'); friendlyName.Append(aProductName); // create UPnP device iDevice = new DvDeviceStandard(aDvStack, aUdn, *this); iDevice->SetAttribute("Upnp.Domain", "av.openhome.org"); iDevice->SetAttribute("Upnp.Type", "Source"); iDevice->SetAttribute("Upnp.Version", "1"); iDevice->SetAttribute("Upnp.FriendlyName", friendlyName.PtrZ()); iDevice->SetAttribute("Upnp.Manufacturer", "OpenHome"); iDevice->SetAttribute("Upnp.ModelName", "ExampleMediaPlayer"); // create separate UPnP device for standard MediaRenderer Bws<256> buf(aUdn); buf.Append("-MediaRenderer"); // The renderer name should be <room name>:<UPnP AV source name> to allow // our control point to match the renderer device to the upnp av source. Bws<256> rendererName(aRoom); rendererName.Append(":"); rendererName.Append(SourceUpnpAv::kSourceName); iDeviceUpnpAv = new DvDeviceStandard(aDvStack, buf); iDeviceUpnpAv->SetAttribute("Upnp.Domain", "upnp.org"); iDeviceUpnpAv->SetAttribute("Upnp.Type", "MediaRenderer"); iDeviceUpnpAv->SetAttribute("Upnp.Version", "1"); friendlyName.Append(":MediaRenderer"); iDeviceUpnpAv->SetAttribute("Upnp.FriendlyName", rendererName.PtrZ()); iDeviceUpnpAv->SetAttribute("Upnp.Manufacturer", "OpenHome"); iDeviceUpnpAv->SetAttribute("Upnp.ModelName", "ExampleMediaPlayer"); // create read/write store. This creates a number of static (constant) // entries automatically iRamStore = new RamStore(); // create a read/write store using the new config framework iConfigRegStore = new ConfigRegStore(); iConfigRegStore->Write(Brn("Product.Room"), Brn(aRoom)); iConfigRegStore->Write(Brn("Product.Name"), Brn(aProductName)); // Volume Control VolumeProfile volumeProfile; VolumeConsumer volumeInit; volumeInit.SetVolume(iVolume); volumeInit.SetBalance(iVolume); volumeInit.SetFade(iVolume); // Set pipeline thread priority just below the pipeline animator. iInitParams = PipelineInitParams::New(); iInitParams->SetThreadPriorityMax(kPriorityHighest); iInitParams->SetStarvationMonitorMaxSize(Jiffies::kPerMs * 100); // create MediaPlayer iMediaPlayer = new MediaPlayer(aDvStack, *iDevice, *iShell, *iRamStore, *iConfigRegStore, iInitParams, volumeInit, volumeProfile, aUdn, Brn(aRoom), Brn(aProductName)); iPipelineStateLogger = new LoggingPipelineObserver(); iMediaPlayer->Pipeline().AddObserver(*iPipelineStateLogger); // Set up config app. static const TUint addr = 0; // Bind to all addresses. static const TUint port = 0; // Bind to whatever free port the OS // allocates to the framework server. iAppFramework = new WebAppFramework(aDvStack.Env(), addr, port, kMaxUiTabs, kUiSendQueueSize); }
static void GetThreadName(Bws<5>& aThName) { aThName.SetBytes(0); aThName.Append(Thread::CurrentThreadName()); aThName.PtrZ(); }