本文整理汇总了C++中PLT_DeviceDataReference类的典型用法代码示例。如果您正苦于以下问题:C++ PLT_DeviceDataReference类的具体用法?C++ PLT_DeviceDataReference怎么用?C++ PLT_DeviceDataReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PLT_DeviceDataReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
/*----------------------------------------------------------------------
| PLT_MediaBrowser::OnDeviceRemoved
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::OnDeviceRemoved(PLT_DeviceDataReference& device)
{
PLT_DeviceDataReference data;
{
NPT_AutoLock lock(m_MediaServers);
// only release if we have kept it around
NPT_String uuid = device->GetUUID();
// is it a new device?
if (NPT_FAILED(NPT_ContainerFind(m_MediaServers, PLT_DeviceDataFinder(uuid), data))) {
NPT_LOG_WARNING_1("Device (%s) not found in our list!", (const char*)uuid);
return NPT_FAILURE;
}
NPT_LOG_FINE("Device Removed:");
device->ToLog(NPT_LOG_LEVEL_FINE);
m_MediaServers.Remove(device);
}
if (m_Listener) {
m_Listener->OnMSAddedRemoved(device, 0);
}
return NPT_SUCCESS;
}
示例2: FindDeviceWait
static bool FindDeviceWait(CUPnP* upnp, const char* uuid, PLT_DeviceDataReference& device)
{
bool client_started = upnp->IsClientStarted();
upnp->StartClient();
// 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;
for (;;) {
if (NPT_SUCCEEDED(upnp->m_MediaBrowser->FindServer(uuid, device)) && !device.IsNull())
break;
// fail right away if device not found and upnp client was already running
if (client_started)
return false;
// otherwise check if we've waited long enough without success
NPT_TimeStamp now;
NPT_System::GetCurrentTimeStamp(now);
if (now > watchdog)
return false;
// sleep a bit and try again
NPT_System::Sleep(NPT_TimeInterval((double)1));
}
return !device.IsNull();
}
示例3: OnMRAdded
virtual bool OnMRAdded(PLT_DeviceDataReference& device )
{
CPlayerCoreFactory::Get().OnPlayerDiscovered((const char*)device->GetUUID()
,(const char*)device->GetFriendlyName()
, EPC_UPNPPLAYER);
return true;
}
示例4: 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;
}
}
}
示例5: lock
/*----------------------------------------------------------------------
| PLT_MediaBrowser::OnDeviceRemoved
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::OnDeviceRemoved(PLT_DeviceDataReference& device)
{
if (!device->GetType().StartsWith("urn:schemas-upnp-org:device:MediaServer"))
return NPT_FAILURE;
{
NPT_AutoLock lock(m_MediaServers);
// only release if we have kept it around
PLT_DeviceDataReference data;
NPT_String uuid = device->GetUUID();
// Have we seen that device?
if (NPT_FAILED(NPT_ContainerFind(m_MediaServers, PLT_DeviceDataFinder(uuid), data))) {
NPT_LOG_WARNING_1("Device (%s) not found in our list!", (const char*)uuid);
return NPT_FAILURE;
}
NPT_LOG_FINE_1("Device Removed: %s", (const char*)*device);
m_MediaServers.Remove(device);
}
if (m_Delegate) {
m_Delegate->OnMSRemoved(device);
}
return NPT_SUCCESS;
}
示例6: 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();
}
示例7: InvokeUpdateObject
bool InvokeUpdateObject(const char* id, const char* curr_value, const char* new_value)
{
CURL url(id);
PLT_DeviceDataReference device;
PLT_Service* cds;
PLT_ActionReference action;
CLog::Log(LOGDEBUG, "UPNP: attempting to invoke UpdateObject for %s", id);
// check this server supports UpdateObject action
NPT_CHECK_LABEL(FindServer(url.GetHostName().c_str(), device),failed);
NPT_CHECK_LABEL(device->FindServiceById("urn:upnp-org:serviceId:ContentDirectory", cds),failed);
NPT_CHECK_LABEL(m_CtrlPoint->CreateAction(
device,
"urn:schemas-upnp-org:service:ContentDirectory:1",
"UpdateObject",
action), failed);
NPT_CHECK_LABEL(action->SetArgumentValue("ObjectID", url.GetFileName().c_str()), failed);
NPT_CHECK_LABEL(action->SetArgumentValue("CurrentTagValue", curr_value), failed);
NPT_CHECK_LABEL(action->SetArgumentValue("NewTagValue", new_value), failed);
NPT_CHECK_LABEL(m_CtrlPoint->InvokeAction(action, NULL),failed);
CLog::Log(LOGDEBUG, "UPNP: invoked UpdateObject successfully");
return true;
failed:
CLog::Log(LOGINFO, "UPNP: invoking UpdateObject failed");
return false;
}
示例8: url
/*----------------------------------------------------------------------
| PLT_DeviceData::SetDescription
+---------------------------------------------------------------------*/
NPT_Result
PLT_DeviceData::SetDescription(PLT_DeviceDataReference& root_device,
NPT_TimeInterval leasetime,
NPT_HttpUrl description_url,
const char* description,
const NPT_HttpRequestContext& context)
{
NPT_XmlParser parser;
NPT_XmlNode* tree = NULL;
NPT_Result res;
NPT_XmlElementNode* root = NULL;
NPT_String URLBase;
// create new device if none passed
if (root_device.IsNull()) {
root_device = new PLT_DeviceData(description_url, "", leasetime);
}
res = parser.Parse(description, tree);
NPT_CHECK_LABEL_SEVERE(res, cleanup);
root = tree->AsElementNode();
if (!root ||
root->GetTag() != "root" ||
!root->GetNamespace() ||
*root->GetNamespace() != "urn:schemas-upnp-org:device-1-0") {
NPT_LOG_INFO_1("root namespace is invalid: %s",
(root&&root->GetNamespace())?root->GetNamespace()->GetChars():"null");
NPT_CHECK_LABEL_SEVERE(NPT_FAILURE, cleanup);
}
// look for optional URLBase element
if (NPT_SUCCEEDED(PLT_XmlHelper::GetChildText(root, "URLBase", URLBase))) {
NPT_HttpUrl url(URLBase);
// Some devices like Connect360 try to be funny - not so
if (url.GetHost().ToLowercase() == "localhost" ||
url.GetHost().ToLowercase() == "127.0.0.1") {
url.SetHost(context.GetRemoteAddress().GetIpAddress().ToString());
}
root_device->SetURLBase(url);
} else {
// No URLBase, derive from description url
root_device->SetURLBase(description_url);
}
// at least one root device child element is required
NPT_XmlElementNode* device;
if (!(device = PLT_XmlHelper::GetChild(root, "device"))) {
NPT_CHECK_LABEL_SEVERE(NPT_FAILURE, cleanup);
}
res = SetDescriptionDevice(root_device, device, context);
cleanup:
// delete the tree
delete tree;
return res;
}
示例9: GetCurMediaRenderer
/*----------------------------------------------------------------------
| PLT_MicroMediaController::HandleCmd_stop
+---------------------------------------------------------------------*/
void
PLT_MicroMediaController::HandleCmd_stop()
{
PLT_DeviceDataReference device;
GetCurMediaRenderer(device);
if (!device.IsNull()) {
Stop(device, 0, NULL);
}
}
示例10: OnMRRemoved
virtual void OnMRRemoved(PLT_DeviceDataReference& device )
{
if (device->GetUUID().IsEmpty() || device->GetUUID().GetChars() == NULL)
return;
std::string uuid(device->GetUUID().GetChars());
unregisterRenderer(uuid);
m_registeredRenderers.erase(uuid);
}
示例11: 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;
}
示例12: lock
/*----------------------------------------------------------------------
| PLT_SyncMediaBrowser::OnDeviceAdded
+---------------------------------------------------------------------*/
NPT_Result
PLT_SyncMediaBrowser::OnDeviceAdded(PLT_DeviceDataReference& device)
{
NPT_String uuid = device->GetUUID();
// test if it's a media server
PLT_Service* service;
if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:ContentDirectory:*", service))) {
NPT_AutoLock lock(m_MediaServers);
m_MediaServers.Put(uuid, device);
}
return PLT_MediaBrowser::OnDeviceAdded(device);
}
示例13:
bool
GPAC_MediaController::OnMSAdded(PLT_DeviceDataReference& device)
{
NPT_String uuid = device->GetUUID();
gf_mx_p(m_ControlPointLock);
// test if it's a media server
PLT_Service* service;
if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:ContentDirectory:1", service))) {
gf_list_add(m_MediaServers, new GPAC_MediaServerItem(device, uuid) );
}
m_pUPnP->OnMediaServerAdd(device, 1);
gf_mx_v(m_ControlPointLock);
return true;
}
示例14:
/*----------------------------------------------------------------------
| PLT_MediaBrowser::Search
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::Search(PLT_DeviceDataReference& device,
const char* container_id,
const char* search_criteria,
NPT_UInt32 start_index,
NPT_UInt32 count,
const char* filter,
void* userdata)
{
// verify device still in our list
PLT_DeviceDataReference device_data;
NPT_CHECK_WARNING(FindServer(device->GetUUID(), device_data));
// create action
PLT_ActionReference action;
NPT_CHECK_SEVERE(m_CtrlPoint->CreateAction(
device,
"urn:schemas-upnp-org:service:ContentDirectory:1",
"Search",
action));
// Set the container id
PLT_Arguments args;
if (NPT_FAILED(action->SetArgumentValue("ContainerID", container_id))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// set the Search Criteria
if (NPT_FAILED(action->SetArgumentValue("SearchCriteria", search_criteria))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// set the Filter
if (NPT_FAILED(action->SetArgumentValue("Filter", filter))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// set the Starting Index
if (NPT_FAILED(action->SetArgumentValue("StartingIndex", NPT_String::FromInteger(start_index)))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// set the Requested Count
if (NPT_FAILED(action->SetArgumentValue("RequestedCount", NPT_String::FromInteger(count)))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// set the Requested Count
if (NPT_FAILED(action->SetArgumentValue("SortCriteria", ""))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
// invoke the action
if (NPT_FAILED(m_CtrlPoint->InvokeAction(action, userdata))) {
return NPT_ERROR_INVALID_PARAMETERS;
}
return NPT_SUCCESS;
}
示例15: NPT_LOG_WARNING_1
/*----------------------------------------------------------------------
| 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;
type = "urn:schemas-upnp-org:service:ContentDirectory:1";
if (NPT_FAILED(device->FindServiceByType(type, serviceCDS))) {
NPT_LOG_WARNING_1("Service %s not found", (const char*)type);
return NPT_FAILURE;
}
type = "urn:schemas-upnp-org:service:ConnectionManager:1";
if (NPT_FAILED(device->FindServiceByType(type, serviceCMR))) {
NPT_LOG_WARNING_1("Service %s not found", (const char*)type);
return NPT_FAILURE;
}
{
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("Device Found:");
device->ToLog(NPT_LOG_LEVEL_FINE);
m_MediaServers.Add(device);
}
if (m_Listener) {
m_Listener->OnMSAddedRemoved(device, 1);
}
m_CtrlPoint->Subscribe(serviceCDS);
m_CtrlPoint->Subscribe(serviceCMR);
return NPT_SUCCESS;
}