void SourcesCallback(MockCbData<ITopology2Source*>* aArgs)
    {
        // w("Source " + v.Index + " " + v.Name + " " + v.Type + " " + v.Visible));
        ITopology2Source* src = aArgs->iData;
        FunctorGeneric<const Brx&> f = aArgs->iCallback;

        Bws<100> buf;
        buf.Replace(Brn("Source "));
        Ascii::AppendDec(buf, src->Index());
        buf.Append(Brn(" "));

        Brn name(src->Name());

        buf.Append(src->Name());
        buf.Append(Brn(" "));
        buf.Append(src->Type());
        buf.Append(Brn(" "));
        if (src->Visible())
        {
            buf.Append(Brn("True"));
        }
        else
        {
            buf.Append(Brn("False"));
        }
        f(buf);
        delete aArgs;
    }
 void SourceIndexCallback(MockCbData<TUint>* aArgs)
 {
     TUint i = aArgs->iData;
     FunctorGeneric<const Brx&> f = aArgs->iCallback;
     Bws<100> buf;
     buf.Replace(Brn("SourceIndex "));
     Ascii::AppendDec(buf, i);
     f(buf);
     delete aArgs;
 }
 void NameCallback(MockCbData<Brn>* aArgs)
 {
     Brn str = aArgs->iData;
     FunctorGeneric<const Brx&> f = aArgs->iCallback;
     Bws<100> buf;
     buf.Replace(Brn("Name "));
     buf.Append(str);
     f(buf);
     delete aArgs;
 }
Exemple #4
0
Brn DeviceXml::ServiceVersion(const Brx& aServiceType) const
{
    const TUint kMaxDomainBytes = 64;
    const TUint kMaxTypeBytes = 64;
    
    Bws<kMaxDomainBytes> domain;
    Bws<kMaxTypeBytes> upnpType;
    
    Parser parser(aServiceType);
    
    TUint count = 0;
    
    while (!parser.Finished()) {
        upnpType.Replace(parser.Next('.'));
        count++;
    }

    parser.Restart();
        
    while (--count) {
        Brn element = parser.Next('.');
        
        if (domain.Bytes() > 0) {
            domain.Append('.');
        }
        
        domain.Append(element);
    }
    
    Bws<kMaxDomainBytes> upnpDomain;
    
    Ssdp::CanonicalDomainToUpnp(domain, upnpDomain);
    
    Brn serviceList = XmlParserBasic::Find("serviceList", iXml);
    
    for (;;) {
        Brn service = XmlParserBasic::Find("service", serviceList, serviceList);
        Brn type = XmlParserBasic::Find("serviceType", service);

        Parser parser(type);
        
        if (parser.Next(':') == Brn("urn")) {
            if (parser.Next(':') == upnpDomain) {
                if (parser.Next(':') == Brn("service")) {
                    if (parser.Next(':') == upnpType) {
                        return (parser.Remaining());
                    }
                }
            }
        }
    }
}
 void StandbyCallback(MockCbData<TBool>* aArgs)
 {
     TBool i = aArgs->iData;
     FunctorGeneric<const Brx&> f = aArgs->iCallback;
     Bws<100> buf;
     buf.Replace(Brn("Standby "));
     if (i)
     {
         buf.Append(Brn("True"));
     }
     else
     {
         buf.Append(Brn("False"));
     }
     f(buf);
     delete aArgs;
 }
Exemple #6
0
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());
}
int CDECL main(int aArgc, char* aArgv[])
{
    OptionParser parser;
    OptionUint optionAdapter("-a", "--adapter", 0, "[adapter] index of network adapter to use");
    parser.AddOption(&optionAdapter);
    OptionString optionRoom("-r", "--room", Brx::Empty(), "Room containing the receiver to play/stop");
    parser.AddOption(&optionRoom);

    if (!parser.Parse(aArgc, aArgv)) {
        return 1;
    }

    gRoom.Replace(optionRoom.Value());

    InitialisationParams* initParams = InitialisationParams::Create();
	UpnpLibrary::Initialise(initParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[optionAdapter.Value()]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::Close();

    TUint channel = 0;
    TUint ttl = 4;
	TUint latency = 100;
    TBool multicast = false;
    TBool disabled = false;
    TUint preset = 99;

	THandle Songcast = SongcastCreate("av.openhome.org", subnet, channel, ttl, latency, multicast, !disabled, preset, loggerReceiver, 0, loggerSubnet, 0, loggerConfigurationChanged, 0, NULL, 0, "OpenHome", "http://www.openhome.org", "http://www.openhome.org", icon_png, icon_png_len, "image/png");

	if (Songcast == 0) {
		printf("Songcast error\n");
		return(1);
	}

	printf("preset = %d\n", preset);

    if (multicast) {
        printf("multicast\n");
    }
    else {
        printf("unicast\n");
    }

    if (disabled) {
        printf("disabled\n");
    }
    else {
        printf("enabled\n");
    }

	printf("q = quit, m = toggle multicast, e = toggle enabled\n");
	
    for (;;) {
    	int key = mygetch();
    	
    	if (key == 'q') {
    		break;
    	}

        if (key == 'm') {
            if (multicast) {
                multicast = false;
                SongcastSetMulticast(Songcast, false);
            }
            else {
                multicast = true;
                SongcastSetMulticast(Songcast, true);
            }
        }

        if (key == 'e') {
            if (disabled) {
                disabled = false;
                SongcastSetEnabled(Songcast, true);
            }
            else {
                disabled = true;
                SongcastSetEnabled(Songcast, false);
            }
        }

        if (key == 'a') {
            SongcastSetSubnet(Songcast, 43200); // 192.168.0.0
        }

        if (gRecv != 0)
        {
            if (key == 'p') {
                SongcastSetEnabled(Songcast, true);
                ReceiverPlay(gRecv);
            }

            if (key == 's') {
                ReceiverStop(gRecv);
                ReceiverStandby(gRecv);
                SongcastSetEnabled(Songcast, false);
            }
        }
	}
    
    if (gRecv != 0) {
        ReceiverRemoveRef(gRecv);
    }

	SongcastDestroy(Songcast);

	printf("\n");
	
    return (0);
}