bool CUPnPPlayer::QueueNextFile(const CFileItem& file) { CFileItem item(file); NPT_Reference<CThumbLoader> thumb_loader; NPT_Reference<PLT_MediaObject> obj; NPT_String path(file.GetPath().c_str()); NPT_String tmp; if (file.IsVideoDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CVideoThumbLoader()); else if (item.IsMusicDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CMusicThumbLoader()); obj = BuildObject(item, path, 0, thumb_loader, NULL, CUPnP::GetServer(), UPnPPlayer); if(!obj.IsNull()) { NPT_CHECK_LABEL_SEVERE(PLT_Didl::ToDidl(*obj, "", tmp), failed); tmp.Insert(didl_header, 0); tmp.Append(didl_footer); } NPT_CHECK_LABEL_WARNING(m_control->SetNextAVTransportURI(m_delegate->m_device , m_delegate->m_instance , file.GetPath().c_str() , (const char*)tmp , m_delegate), failed); if(!m_delegate->m_resevent.WaitMSec(10000)) goto failed; NPT_CHECK_LABEL_WARNING(m_delegate->m_resstatus, failed); return true; failed: CLog::Log(LOGERROR, "UPNP: CUPnPPlayer::QueueNextFile - unable to queue file %s", file.GetPath().c_str()); return false; }
/*---------------------------------------------------------------------- | NPT_Uri::PercentEncode +---------------------------------------------------------------------*/ NPT_String NPT_Uri::PercentEncode(const char* str, const char* chars, bool encode_percents) { NPT_String encoded; // check args if (str == NULL) return encoded; // reserve at least the size of the current uri encoded.Reserve(NPT_StringLength(str)); // process each character char escaped[3]; escaped[0] = '%'; while (unsigned char c = *str++) { bool encode = false; if (encode_percents && c == '%') { encode = true; } else if (c < ' ' || c > '~') { encode = true; } else { const char* match = chars; while (*match) { if (c == *match) { encode = true; break; } ++match; } } if (encode) { // encode NPT_ByteToHex(c, &escaped[1], true); encoded.Append(escaped, 3); } else { // no encoding required encoded += c; } } return encoded; }
NPT_String RootContainer::generateContainerId() { static const char ab[] = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const NPT_UInt32 ac = sizeof(ab) - 1; NPT_UInt64 seq = m_seq++; NPT_UInt64 q; NPT_UInt64 r; NPT_String result; for (;;) { q = seq / ac; r = seq - (q * ac); result.Append(ab + r, 1); if (q == 0) { break; } seq = q; } return result; }