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); }
void InvocationDv::InvocationWriteBool(const TChar* aName, TBool aValue) { Bws<1> buf; buf.SetBytes(1); buf[0] = (aValue? 1 : 0); OutputProcessorDv procDv; OutputArgument(aName)->ProcessOutput(procDv, buf); }
void PropertyWriterDv::PropertyWriteBool(const Brx& aName, TBool aValue) { Bws<1> buf; buf.SetBytes(1); buf[0] = (aValue? 1 : 0); OutputProcessorDv procDv; iEventProcessor.EventUpdate(aName, buf, procDv); }
void SuiteFileStream::Test() { const TUint kBytes = 256; Bws<kBytes> b; // Populate each position in the buffer with it's index. for (TUint i=0; i<kBytes; i++) { b.Append((TChar)i); } FileBrx f(b); FileStream stream; stream.SetFile(&f); TEST(stream.Bytes() == kBytes); // test basic reading Bws<kBytes> buf; stream.Read(buf); TEST(buf == b); TEST(stream.Tell() == kBytes); // test that reads on a full buffer and at the end of a file throw TEST_THROWS(stream.Read(buf), ReaderError); buf.SetBytes(0); TEST_THROWS(stream.Read(buf), ReaderError); // test seeking stream.Seek(0); TEST(stream.Tell() == 0); // test a stream can be (un)interrupted stream.ReadInterrupt(); Bws<10> buf2; TEST_THROWS(stream.Read(buf2), ReaderError); stream.Interrupt(false); stream.Read(buf2); TEST(buf2.Bytes() == buf2.MaxBytes()); for (TUint i=0; i<10; i++) { TEST(buf2[i] == b[i]); } // test that Read appends to a buffer buf.SetBytes(0); buf.Append(buf2); stream.Read(buf); TEST(buf.Bytes() == kBytes); TEST(buf == b); }
void SuiteFileBrx::Test() { const TUint kBytes = 256; Bws<kBytes> b; // Populate each position in the buffer with it's index. for (TUint i=0; i<kBytes; i++) { b.Append((TChar)i); } FileBrx f(b); Bws<kBytes> buff; f.Read(buff); // Read full buffer TEST(buff == b); buff.SetBytes(0); TEST_THROWS(f.Read(buff), FileReadError); // Attempt full buffer from end f.Seek(0, eSeekFromStart); buff.SetBytes(0); f.Read(buff, 10); TEST(buff[0] == 0); TEST(buff[9] == 9); f.Seek(10, eSeekFromStart); buff.SetBytes(0); f.Read(buff, 10); TEST(buff[0] == 10); TEST(buff[9] == 19); f.Seek(10, eSeekFromCurrent); buff.SetBytes(0); f.Read(buff, 10); TEST(buff[0] == 30); TEST(buff[9] == 39); }
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 }
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); }
static void GetThreadName(Bws<5>& aThName) { aThName.SetBytes(0); aThName.Append(Thread::CurrentThreadName()); aThName.PtrZ(); }
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()); }