コード例 #1
0
THandle STDCALL SongcastCreate(const char* aDomain, uint32_t aSubnet, uint32_t aChannel, uint32_t aTtl, uint32_t aLatency, uint32_t aMulticast, uint32_t aEnabled, uint32_t aPreset, ReceiverCallback aReceiverCallback, void* aReceiverPtr, SubnetCallback aSubnetCallback, void* aSubnetPtr, ConfigurationChangedCallback aConfigurationChangedCallback, void* aConfigurationChangedPtr, MessageCallback aFatalErrorCallback, void* aFatalErrorPtr, MessageCallback aLogOutputCallback, void* aLogOutputPtr, const char* aManufacturer, const char* aManufacturerUrl, const char* aModelUrl, void* aImagePtr, uint32_t aImageBytes, const char* aMimeType)
{
	try {
        printf("%s\n", aDomain);
        
        // get the computer name
        Bws<Songcast::kMaxUdnBytes> computer;
        TUint bytes = computer.MaxBytes();

        if (!GetComputerName((LPSTR)computer.Ptr(), (LPDWORD)&bytes)) {
            THROW(SongcastError);
        }
        
        computer.SetBytes(bytes);
        
		TBool enabled = (aEnabled == 0) ? false : true;
		TBool multicast = (aMulticast == 0) ? false : true;

        // create the sender driver
        OhmSenderDriverWindows* driver = new OhmSenderDriverWindows(aDomain, aManufacturer, enabled);

        // create the soundcard
		Songcast* songcast = new Songcast(aSubnet, aChannel, aTtl, aLatency, multicast, enabled, aPreset, aReceiverCallback, aReceiverPtr, aSubnetCallback, aSubnetPtr, aConfigurationChangedCallback, aConfigurationChangedPtr, aFatalErrorCallback, aFatalErrorPtr, aLogOutputCallback, aLogOutputPtr, computer, driver, aManufacturer, aManufacturerUrl, aModelUrl, Brn((TByte*) aImagePtr, aImageBytes), Brn(aMimeType));

		driver->SetSongcast(*songcast);

		return (songcast);
	}
	catch (SongcastError)
    {
	}

	return (0);
}
コード例 #2
0
ファイル: CpiService.cpp プロジェクト: Montellese/ohNet
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]));
        }
    }
}
コード例 #3
0
void NetworkAdapterList::TraceAdapter(const TChar* aPrefix, NetworkAdapter& aAdapter)
{ // static
    Endpoint ep(0, aAdapter.Address());
    Bws<Endpoint::kMaxAddressBytes> addr;
    ep.AppendAddress(addr);
    LOG(kTrace, "%s: %s(%s)\n", aPrefix, aAdapter.Name(), (const TChar*)addr.Ptr());
}
コード例 #4
0
ファイル: CpiService.cpp プロジェクト: Montellese/ohNet
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();
}
コード例 #5
0
ファイル: Error.cpp プロジェクト: ACDN/ohNet
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());
}    
コード例 #6
0
ファイル: EventUpnp.cpp プロジェクト: Montellese/ohNet
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));
    }
}
コード例 #7
0
ファイル: EventUpnp.cpp プロジェクト: sewood/ohNet
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));
    }
}
コード例 #8
0
ファイル: XmlFetcher.cpp プロジェクト: fuzzy01/ohNet
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();
}
コード例 #9
0
ファイル: MdnsPlatform.cpp プロジェクト: ACDN/ohNet
void LogMsg(const char *format, ...)
{
#ifdef DEFINE_TRACE
    va_list args;
    va_start(args, format);
    // not all messages are errors but enough are that its handy to log everything here if we're interested in errors
    if(Debug::TestLevel(Debug::kBonjour) || Debug::TestLevel(Debug::kError)) {
        Bws<kMaxLogMsgBytes> msg;
        TUint written = mDNS_vsnprintf((char*)msg.Ptr(), msg.MaxBytes(), format, args);
        msg.SetBytes(written);
        Log::Print(msg);
        Log::Print("\n");
    }
    va_end(args);
#endif
}
コード例 #10
0
ファイル: DviServerLpec.cpp プロジェクト: Montellese/ohNet
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;
}
コード例 #11
0
ファイル: TestDviDiscovery.cpp プロジェクト: Jacik/ohNet
TChar* CpListenerMsearch::CreateTypeString(const Brx& aDomain, const Brx& aType, TUint aVersion)
{
    TChar* type = (TChar*)malloc(aDomain.Bytes() + aType.Bytes() + 2 + Ascii::kMaxUintStringBytes + 1);
    TChar* ptr = type;
    (void)strncpy(ptr, (const TChar*)aDomain.Ptr(), aDomain.Bytes());
    ptr += aDomain.Bytes();
    *ptr = ':';
    ptr++;
    (void)strncpy(ptr, (const TChar*)aType.Ptr(), aType.Bytes());
    ptr += aType.Bytes();
    *ptr = ':';
    ptr++;
    Bws<Ascii::kMaxUintStringBytes> ver;
    Ascii::AppendDec(ver, aVersion);
    (void)strncpy(ptr, (const TChar*)ver.Ptr(), ver.Bytes());
    ptr += ver.Bytes();
    *ptr = '\0';
    return type;
}
コード例 #12
0
ファイル: DviSubscription.cpp プロジェクト: sewood/ohNet
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();
}
コード例 #13
0
ファイル: XmlFetcher.cpp プロジェクト: DoomHammer/ohNet
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();
}
コード例 #14
0
ファイル: TestNetwork.cpp プロジェクト: chinshou/ohNet
void SuiteUnicast::Receiver()
{
    TBool first = true;
    iLastVal = 0;
    TUint val;
    Bws<kMsgBytes> recv;
    do {
        recv.SetBytes(0);
        (void)iReceiver->Receive(recv);
        ASSERT(recv.Bytes() >= sizeof(TUint32));
        val = *((TUint32*)recv.Ptr());
        if (val != kQuit) {
            if (first) {
                TEST(val == 0);
                first = false;
            }
            else {
                TEST(val == iLastVal+1);
            }
        }
        //Print("Received %u, last sent %u\n", val, iSendVal);
        iLastVal = val;
    } while (val != kQuit);
}
コード例 #15
0
ファイル: Soundcard.cpp プロジェクト: wifigeek/ohNet
Soundcard::Soundcard(TIpAddress /* aSubnet */, TUint aChannel, TUint aTtl, TBool aMulticast, TBool aEnabled, TUint aPreset, ReceiverCallback aReceiverCallback, void* aReceiverPtr)
	: iReceiverCallback(aReceiverCallback)
	, iReceiverPtr(aReceiverPtr)
{
	InitialisationParams* initParams = InitialisationParams::Create();

	UpnpLibrary::Initialise(initParams);

	std::vector<NetworkInterface*>* list = UpnpLibrary::SubnetList();

	ASSERT(list->size() > 0);

	NetworkInterface* iface = *list->begin();

	delete (list);

	UpnpLibrary::SetCurrentSubnet(*iface);

	printf("Using %x\n", iface->Address());
    
    UpnpLibrary::StartCombined();

	Bws<kMaxUdnBytes> computer;
	Bws<kMaxUdnBytes> udn;
	Bws<kMaxUdnBytes + 1> friendly;

	TUint bytes = computer.MaxBytes();

	if (!GetComputerName((LPSTR)computer.Ptr(), (LPDWORD)&bytes)) {
		THROW(SoundcardError);
	}

	computer.SetBytes(bytes);
	udn.Replace("ohSoundcard-");
	udn.Append(computer);
	friendly.Replace(udn);
	friendly.Append('\0');

	iDevice = new DvDeviceStandard(udn);
    
	iDevice->SetAttribute("Upnp.Domain", "av.openhome.org");
    iDevice->SetAttribute("Upnp.Type", "Soundcard");
    iDevice->SetAttribute("Upnp.Version", "1");
    iDevice->SetAttribute("Upnp.FriendlyName", (TChar*)friendly.Ptr());
    iDevice->SetAttribute("Upnp.Manufacturer", "Openhome");
    iDevice->SetAttribute("Upnp.ManufacturerUrl", "http://www.openhome.org");
    iDevice->SetAttribute("Upnp.ModelDescription", "OpenHome Soundcard");
    iDevice->SetAttribute("Upnp.ModelName", "ohSoundcard");
    iDevice->SetAttribute("Upnp.ModelNumber", "1");
    iDevice->SetAttribute("Upnp.ModelUrl", "http://www.openhome.org");
    iDevice->SetAttribute("Upnp.SerialNumber", "");
    iDevice->SetAttribute("Upnp.Upc", "");

    iDriver = new OhmSenderDriverWindows();
    
	Brn icon(icon_png, icon_png_len);

	iSender = new OhmSender(*iDevice, *iDriver, computer, aChannel, iface->Address(), aTtl, aMulticast, aEnabled, icon, Brn("image/png"), aPreset);
	
    iDevice->SetEnabled();

	iReceiverManager = new ReceiverManager3(*this, iSender->SenderUri(), iSender->SenderMetadata());
}
コード例 #16
0
ファイル: Exception.cpp プロジェクト: tata-/ohNet-1
void OpenHome::UnhandledExceptionHandler(std::exception& aException)
{
    Bws<5> thName;
    GetThreadName(thName);
    char buf[1024];
    (void)snprintf(buf, sizeof(buf), "Unhandled exception %s in thread %s\n", aException.what(), thName.Ptr());
    CallFatalErrorHandler(buf);
}
コード例 #17
0
ファイル: Exception.cpp プロジェクト: tata-/ohNet-1
void OpenHome::UnhandledExceptionHandler(Exception& aException)
{
    Bws<5> thName;
    GetThreadName(thName);
    char buf[1024];
    (void)snprintf(buf, sizeof(buf), "Unhandled exception %s at %s:%lu in thread %s\n", aException.Message(), aException.File(), (unsigned long)aException.Line(), thName.Ptr());

    TInt len = 8*1024;
    char* msg = new char[len];
    if (msg != NULL) {
        (void)strncpy(msg, buf, len);
        len -= (TInt)strlen(buf);
        (void)strncat(msg, "\n", len);
        len -= 2;

        THandle stackTrace = aException.StackTrace();
        TUint count = Os::StackTraceNumEntries(stackTrace);
        for (TUint i=0; i<count; i++) {
            const char* entry = Os::StackTraceEntry(stackTrace, i);
            (void)strncat(msg, entry, len);
            len -= (TInt)strlen(entry) + 2;
            if (len < 0) {
                break;
            }
            (void)strncat(msg, "\n", len);
        }
    }
    if (len > 0) {
        (void)strncat(msg, "\n", len);
    }

    CallFatalErrorHandler((msg!=NULL? msg : buf));
    delete msg;
}
コード例 #18
0
ファイル: Exception.cpp プロジェクト: tata-/ohNet-1
void OpenHome::UnhandledExceptionHandler(const TChar* aExceptionMessage, const TChar* aFile, TUint aLine)
{
    Bws<5> thName;
    GetThreadName(thName);
    char buf[1024];
    (void)snprintf(buf, sizeof(buf), "Unhandled exception %s at %s:%lu in thread %s\n", aExceptionMessage, aFile, (unsigned long)aLine, thName.Ptr());
    CallFatalErrorHandler(buf);
}