本文整理汇总了C++中PLT_DeviceDataReference::GetFriendlyName方法的典型用法代码示例。如果您正苦于以下问题:C++ PLT_DeviceDataReference::GetFriendlyName方法的具体用法?C++ PLT_DeviceDataReference::GetFriendlyName怎么用?C++ PLT_DeviceDataReference::GetFriendlyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PLT_DeviceDataReference
的用法示例。
在下文中一共展示了PLT_DeviceDataReference::GetFriendlyName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
/*----------------------------------------------------------------------
| PLT_MediaBrowser::OnDeviceAdded
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::OnDeviceAdded(PLT_DeviceDataReference& device)
{
// verify the device implements the function we need
PLT_Service* serviceCDS;
PLT_Service* serviceCMR;
NPT_String type;
if (!device->GetType().StartsWith("urn:schemas-upnp-org:device:MediaServer"))
return NPT_FAILURE;
type = "urn:schemas-upnp-org:service:ContentDirectory:*";
if (NPT_FAILED(device->FindServiceByType(type, serviceCDS))) {
NPT_LOG_WARNING_2("Service %s not found in device \"%s\"",
type.GetChars(),
device->GetFriendlyName().GetChars());
return NPT_FAILURE;
} else {
// in case it's a newer upnp implementation, force to 1
serviceCDS->ForceVersion(1);
}
type = "urn:schemas-upnp-org:service:ConnectionManager:*";
if (NPT_FAILED(device->FindServiceByType(type, serviceCMR))) {
NPT_LOG_WARNING_2("Service %s not found in device \"%s\"",
type.GetChars(),
device->GetFriendlyName().GetChars());
return NPT_FAILURE;
} else {
// in case it's a newer upnp implementation, force to 1
serviceCMR->ForceVersion(1);
}
{
NPT_AutoLock lock(m_MediaServers);
PLT_DeviceDataReference data;
NPT_String uuid = device->GetUUID();
// is it a new device?
if (NPT_SUCCEEDED(NPT_ContainerFind(m_MediaServers, PLT_DeviceDataFinder(uuid), data))) {
NPT_LOG_WARNING_1("Device (%s) is already in our list!", (const char*)uuid);
return NPT_FAILURE;
}
NPT_LOG_FINE_1("Device Found: %s", (const char*)*device);
m_MediaServers.Add(device);
}
if (m_Delegate && m_Delegate->OnMSAdded(device)) {
m_CtrlPoint->Subscribe(serviceCDS);
m_CtrlPoint->Subscribe(serviceCMR);
}
return NPT_SUCCESS;
}
示例2: if
/*----------------------------------------------------------------------
| CUPnPDirectory::GetFriendlyName
+---------------------------------------------------------------------*/
const char*
CUPnPDirectory::GetFriendlyName(const char* url)
{
NPT_String path = url;
if (!path.EndsWith("/")) path += "/";
if (path.Left(7).Compare("upnp://", true) != 0) {
return NULL;
} else if (path.Compare("upnp://", true) == 0) {
return "UPnP Media Servers (Auto-Discover)";
}
// look for nextslash
int next_slash = path.Find('/', 7);
if (next_slash == -1)
return NULL;
NPT_String uuid = path.SubString(7, next_slash-7);
NPT_String object_id = path.SubString(next_slash+1, path.GetLength()-next_slash-2);
// look for device
PLT_DeviceDataReference device;
if(!FindDeviceWait(CUPnP::GetInstance(), uuid, device))
return NULL;
return (const char*)device->GetFriendlyName();
}
示例3: lock
void
PLT_MicroMediaController::SetEmbeddedServer(const char* embeddedServerName){
NPT_AutoLock lock(m_CurMediaServerLock);
PopDirectoryStackToRoot();
NPT_Result res = NPT_FAILURE;
//const char embeddedServerName[]="Embedded Media Server";
while(res!=NPT_SUCCESS){
//printf("waiting for the embedded server to come up!\n");
const NPT_Lock<PLT_DeviceMap>& deviceList = GetMediaServersMap();
const NPT_List<PLT_DeviceMapEntry*>& entries = deviceList.GetEntries();
NPT_List<PLT_DeviceMapEntry*>::Iterator entry = entries.GetFirstItem();
while (entry) {
PLT_DeviceDataReference device = (*entry)->GetValue();
NPT_String name = device->GetFriendlyName();
if(0 == strcmp(embeddedServerName, name)){
printf("****server discovered and set****\n");
m_CurMediaServer = device;
res = NPT_SUCCESS;
break;
}
++entry;
}
}
}
示例4: OnMRAdded
virtual bool OnMRAdded(PLT_DeviceDataReference& device )
{
CPlayerCoreFactory::Get().OnPlayerDiscovered((const char*)device->GetUUID()
,(const char*)device->GetFriendlyName()
, EPC_UPNPPLAYER);
return true;
}
示例5: GetCurMediaRenderer
/*----------------------------------------------------------------------
| PLT_MicroMediaController::HandleCmd_getmr
+---------------------------------------------------------------------*/
void
PLT_MicroMediaController::HandleCmd_getmr()
{
PLT_DeviceDataReference device;
GetCurMediaRenderer(device);
if (!device.IsNull()) {
printf("Current media renderer: %s\n", (const char*)device->GetFriendlyName());
} else {
// this output is taken care of by the GetCurMediaRenderer call
}
}
示例6: OnMRAdded
virtual bool OnMRAdded(PLT_DeviceDataReference& device )
{
if (device->GetUUID().IsEmpty() || device->GetUUID().GetChars() == NULL)
return false;
CPlayerCoreFactory::GetInstance().OnPlayerDiscovered((const char*)device->GetUUID()
,(const char*)device->GetFriendlyName()
, EPC_UPNPPLAYER);
m_registeredRenderers.insert(std::string(device->GetUUID().GetChars()));
return true;
}
示例7: pItem
/*----------------------------------------------------------------------
| CUPnPDirectory::GetDirectory
+---------------------------------------------------------------------*/
bool
CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CUPnP* upnp = CUPnP::GetInstance();
/* upnp should never be cached, it has internal cache */
items.SetCacheToDisc(CFileItemList::CACHE_NEVER);
// We accept upnp://devuuid/[item_id/]
NPT_String path = strPath.c_str();
if (!path.StartsWith("upnp://", true)) {
return false;
}
if (path.Compare("upnp://", true) == 0) {
upnp->StartClient();
// root -> get list of devices
const NPT_Lock<PLT_DeviceDataReferenceList>& devices = upnp->m_MediaBrowser->GetMediaServers();
NPT_List<PLT_DeviceDataReference>::Iterator device = devices.GetFirstItem();
while (device) {
NPT_String name = (*device)->GetFriendlyName();
NPT_String uuid = (*device)->GetUUID();
CFileItemPtr pItem(new CFileItem((const char*)name));
pItem->SetPath(CStdString((const char*) "upnp://" + uuid + "/"));
pItem->m_bIsFolder = true;
pItem->SetArt("thumb", (const char*)(*device)->GetIconUrl("image/png"));
items.Add(pItem);
++device;
}
} else {
if (!path.EndsWith("/")) path += "/";
// look for nextslash
int next_slash = path.Find('/', 7);
NPT_String uuid = (next_slash==-1)?path.SubString(7):path.SubString(7, next_slash-7);
NPT_String object_id = (next_slash==-1)?"":path.SubString(next_slash+1);
object_id.TrimRight("/");
if (object_id.GetLength()) {
CStdString tmp = (char*) object_id;
CURL::Decode(tmp);
object_id = tmp;
}
// try to find the device with wait on startup
PLT_DeviceDataReference device;
if (!FindDeviceWait(upnp, uuid, device))
goto failure;
// issue a browse request with object_id
// if object_id is empty use "0" for root
object_id = object_id.IsEmpty()?"0":object_id;
// remember a count of object classes
std::map<NPT_String, int> classes;
// just a guess as to what types of files we want
bool video = true;
bool audio = true;
bool image = true;
m_strFileMask.TrimLeft("/");
if (!m_strFileMask.IsEmpty()) {
video = m_strFileMask.Find(".wmv") >= 0;
audio = m_strFileMask.Find(".wma") >= 0;
image = m_strFileMask.Find(".jpg") >= 0;
}
// special case for Windows Media Connect and WMP11 when looking for root
// We can target which root subfolder we want based on directory mask
if (object_id == "0" && ((device->GetFriendlyName().Find("Windows Media Connect", 0, true) >= 0) ||
(device->m_ModelName == "Windows Media Player Sharing"))) {
// look for a specific type to differentiate which folder we want
if (audio && !video && !image) {
// music
object_id = "1";
} else if (!audio && video && !image) {
// video
object_id = "2";
} else if (!audio && !video && image) {
// pictures
object_id = "3";
}
}
#ifdef DISABLE_SPECIALCASE
// same thing but special case for XBMC
if (object_id == "0" && ((device->m_ModelName.Find("XBMC", 0, true) >= 0) ||
(device->m_ModelName.Find("Xbox Media Center", 0, true) >= 0))) {
// look for a specific type to differentiate which folder we want
if (audio && !video && !image) {
// music
object_id = "virtualpath://upnpmusic";
//.........这里部分代码省略.........
示例8: pItem
/*----------------------------------------------------------------------
| CUPnPDirectory::GetDirectory
+---------------------------------------------------------------------*/
bool
CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CGUIDialogProgress* dlgProgress = NULL;
CUPnP* upnp = CUPnP::GetInstance();
/* upnp should never be cached, it has internal cache */
items.SetCacheToDisc(CFileItemList::CACHE_NEVER);
// start client if it hasn't been done yet
bool client_started = upnp->IsClientStarted();
upnp->StartClient();
// We accept upnp://devuuid/[item_id/]
NPT_String path = strPath.c_str();
if (!path.StartsWith("upnp://", true)) {
return false;
}
if (path.Compare("upnp://", true) == 0) {
// root -> get list of devices
const NPT_Lock<PLT_DeviceMap>& devices = upnp->m_MediaBrowser->GetMediaServers();
const NPT_List<PLT_DeviceMapEntry*>& entries = devices.GetEntries();
NPT_List<PLT_DeviceMapEntry*>::Iterator entry = entries.GetFirstItem();
while (entry) {
PLT_DeviceDataReference device = (*entry)->GetValue();
NPT_String name = device->GetFriendlyName();
NPT_String uuid = (*entry)->GetKey();
CFileItemPtr pItem(new CFileItem((const char*)name));
pItem->m_strPath = (const char*) "upnp://" + uuid + "/";
pItem->m_bIsFolder = true;
pItem->SetThumbnailImage((const char*)device->GetIconUrl("image/jpeg"));
items.Add(pItem);
++entry;
}
} else {
if (!path.EndsWith("/")) path += "/";
// look for nextslash
int next_slash = path.Find('/', 7);
NPT_String uuid = (next_slash==-1)?path.SubString(7):path.SubString(7, next_slash-7);
NPT_String object_id = (next_slash==-1)?"":path.SubString(next_slash+1);
object_id.TrimRight("/");
if (object_id.GetLength()) {
CStdString tmp = (char*) object_id;
CUtil::UrlDecode(tmp);
object_id = tmp;
}
// look for device in our list
// (and wait for it to respond for 5 secs if we're just starting upnp client)
NPT_TimeStamp watchdog;
NPT_System::GetCurrentTimeStamp(watchdog);
watchdog += 5.f;
PLT_DeviceDataReference* device;
for (;;) {
const NPT_Lock<PLT_DeviceMap>& devices = upnp->m_MediaBrowser->GetMediaServers();
if (NPT_SUCCEEDED(devices.Get(uuid, device)) && device)
break;
// fail right away if device not found and upnp client was already running
if (client_started)
goto failure;
// otherwise check if we've waited long enough without success
NPT_TimeStamp now;
NPT_System::GetCurrentTimeStamp(now);
if (now > watchdog)
goto failure;
// sleep a bit and try again
NPT_System::Sleep(NPT_TimeInterval(1, 0));
}
// issue a browse request with object_id
// if object_id is empty use "0" for root
object_id = object_id.IsEmpty()?"0":object_id;
// just a guess as to what types of files we want
bool video = true;
bool audio = true;
bool image = true;
m_strFileMask.TrimLeft("/");
if (!m_strFileMask.IsEmpty()) {
video = m_strFileMask.Find(".wmv") >= 0;
audio = m_strFileMask.Find(".wma") >= 0;
image = m_strFileMask.Find(".jpg") >= 0;
}
// special case for Windows Media Connect and WMP11 when looking for root
// We can target which root subfolder we want based on directory mask
//.........这里部分代码省略.........
示例9: GetMediaServers
/*----------------------------------------------------------------------
| CMediaCrawler::OnBrowseRoot
+---------------------------------------------------------------------*/
NPT_Result
CMediaCrawler::OnBrowseRoot(PLT_ActionReference& action)
{
NPT_String browseFlagValue;
if (NPT_FAILED(action->GetArgumentValue("BrowseFlag", browseFlagValue))) {
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowse - invalid arguments.");
return NPT_FAILURE;
}
/* extract browseFlag */
BrowseFlags browseFlag;
if (NPT_FAILED(GetBrowseFlag(browseFlagValue, browseFlag))) {
/* error */
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowseRoot - BrowseFlag value not allowed.");
action->SetError(402,"Invalid BrowseFlag arg.");
return NPT_FAILURE;
}
if (browseFlag == BROWSEMETADATA) {
PLT_MediaContainer item;
item.m_Title = "Root";
item.m_ParentID = "-1";
item.m_ObjectID = "0";
item.m_ChildrenCount = GetMediaServers().GetItemCount();
item.m_ObjectClass.type = "object.container";
/* convert item to didl */
NPT_String filter;
action->GetArgumentValue("Filter", filter);
NPT_String tmp;
NPT_CHECK_SEVERE(PLT_Didl::ToDidl(item, filter, tmp));
/* add didl header and footer */
NPT_String didl = didl_header + tmp + didl_footer;
action->SetArgumentValue("Result", didl);
action->SetArgumentValue("NumberReturned", "1");
action->SetArgumentValue("TotalMatches", "1");
// update ID may be wrong here, it should be the one of the container?
action->SetArgumentValue("UpdateId", "1");
// TODO: We need to keep track of the overall updateID of the CDS
} else {
NPT_String startingInd;
NPT_String reqCount;
NPT_String filter;
NPT_CHECK_SEVERE(action->GetArgumentValue("StartingIndex", startingInd));
NPT_CHECK_SEVERE(action->GetArgumentValue("RequestedCount", reqCount));
NPT_CHECK_SEVERE(action->GetArgumentValue("Filter", filter));
unsigned long start_index, req_count;
if (NPT_FAILED(startingInd.ToInteger(start_index)) ||
NPT_FAILED(reqCount.ToInteger(req_count))) {
return NPT_FAILURE;
}
unsigned long cur_index = 0;
unsigned long num_returned = 0;
unsigned long total_matches = 0;
//unsigned long update_id = 0;
PLT_MediaContainer item;
NPT_String tmp;
NPT_String didl = didl_header;
// populate a list of containers (one container per known servers)
const NPT_Lock<PLT_DeviceDataReferenceList>& devices = GetMediaServers();
NPT_Lock<PLT_DeviceDataReferenceList>::Iterator entry = devices.GetFirstItem();
while (entry) {
PLT_DeviceDataReference device = (*entry);
item.m_Title = device->GetFriendlyName();
item.m_ObjectID = FormatObjectId(device->GetUUID(), "0");
item.m_ParentID = "0";
item.m_ObjectClass.type = "object.container";
if ((cur_index >= start_index) && ((num_returned < req_count) || (req_count == 0))) {
NPT_CHECK_SEVERE(PLT_Didl::ToDidl(item, filter, tmp));
didl += tmp;
num_returned++;
}
cur_index++;
total_matches++;
++entry;
}
didl += didl_footer;
action->SetArgumentValue("Result", didl);
action->SetArgumentValue("NumberReturned", NPT_String::FromInteger(num_returned));
action->SetArgumentValue("TotalMatches", NPT_String::FromInteger(total_matches));
action->SetArgumentValue("UpdateId", "1");
}
return NPT_SUCCESS;
}