本文整理汇总了C++中NPT_List::GetItemCount方法的典型用法代码示例。如果您正苦于以下问题:C++ NPT_List::GetItemCount方法的具体用法?C++ NPT_List::GetItemCount怎么用?C++ NPT_List::GetItemCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPT_List
的用法示例。
在下文中一共展示了NPT_List::GetItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMediaServerStateVariablesChanged
void JNICore::onMediaServerStateVariablesChanged(DeviceDesc *deviceDesc, ServiceDesc *serviceDesc, const NPT_List<NPT_String>& nameList, const NPT_List<NPT_String>& valueList)
{
NPT_LOG_FINEST("onMediaServerStateVariablesChanged aaaa");
VMGuard vmguard;
if (JNIEnv *env = vmguard.env()) {
NPT_UInt64 u1, u2;
deviceDesc->uuid().getData(u1, u2);
jobject uuidObj = env->NewObject(CG::c_UUID, CG::m_UUID_Init, u1, u2);
jstring serviceIdObj = env->NewStringUTF(serviceDesc->serviceId().GetChars());
jobjectArray nameArr = env->NewObjectArray(nameList.GetItemCount(), CG::c_String, NULL);
jobjectArray valueArr = env->NewObjectArray(valueList.GetItemCount(), CG::c_String, NULL);
jstring sObj;
for (NPT_Ordinal i = 0; i < nameList.GetItemCount(); i++) {
sObj = env->NewStringUTF(nameList.GetItem(i)->GetChars());
env->SetObjectArrayElement(nameArr, i, sObj);
env->DeleteLocalRef(sObj);
sObj = env->NewStringUTF(valueList.GetItem(i)->GetChars());
env->SetObjectArrayElement(valueArr, i, sObj);
env->DeleteLocalRef(sObj);
}
NPT_LOG_FINEST("onMediaServerStateVariablesChanged bbbb");
env->CallVoidMethod(m_delegateObj, CG::f_DLNACore_hookMSSVC, uuidObj, serviceIdObj, nameArr, valueArr);
env->DeleteLocalRef(uuidObj);
env->DeleteLocalRef(serviceIdObj);
env->DeleteLocalRef(nameArr);
env->DeleteLocalRef(valueArr);
}
}
示例2: while
/*----------------------------------------------------------------------
| NPT_PosixQueue::Push
+---------------------------------------------------------------------*/
NPT_Result
NPT_PosixQueue::Push(NPT_QueueItem* item, NPT_Timeout timeout)
{
struct timespec timed;
struct timeval now;
// get current time from system
if (gettimeofday(&now, NULL)) {
return NPT_FAILURE;
}
now.tv_usec += timeout * 1000;
if (now.tv_usec >= 1000000) {
now.tv_sec += now.tv_usec / 1000000;
now.tv_usec = now.tv_usec % 1000000;
}
// setup timeout
timed.tv_sec = now.tv_sec;
timed.tv_nsec = now.tv_usec * 1000;
// lock the mutex that protects the list
if (pthread_mutex_lock(&m_Mutex)) {
return NPT_FAILURE;
}
NPT_Result result = NPT_SUCCESS;
// check that we have not exceeded the max
if (m_MaxItems) {
while (m_Items.GetItemCount() >= m_MaxItems) {
// wait until some items have been removed
//NPT_Debug(":: NPT_PosixQueue::Push - waiting for queue to empty\n");
if (timeout == NPT_TIMEOUT_INFINITE) {
pthread_cond_wait(&m_CanPushOrPopCondition, &m_Mutex);
} else {
int wait_res = pthread_cond_timedwait(&m_CanPushOrPopCondition, &m_Mutex, &timed);
if (wait_res == ETIMEDOUT) {
result = NPT_ERROR_TIMEOUT;
break;
}
}
}
}
// add the item to the list
if (result == NPT_SUCCESS) {
m_Items.Add(item);
// if the list was previously empty, signal the condition
// to wake up the waiting thread
if (m_Items.GetItemCount() == 1) {
pthread_cond_signal(&m_CanPushOrPopCondition);
}
}
// unlock the mutex
pthread_mutex_unlock(&m_Mutex);
return result;
}
示例3: GetInfo
/*----------------------------------------------------------------------
| NPT_File::GetSize
+---------------------------------------------------------------------*/
NPT_Result
NPT_File::GetSize(NPT_LargeSize& size)
{
// default value
size = 0;
// get the file info
NPT_FileInfo info;
GetInfo(info);
switch (info.m_Type) {
case NPT_FileInfo::FILE_TYPE_DIRECTORY: {
NPT_List<NPT_String> entries;
NPT_CHECK_WARNING(ListDir(entries));
size = entries.GetItemCount();
break;
}
case NPT_FileInfo::FILE_TYPE_REGULAR:
case NPT_FileInfo::FILE_TYPE_OTHER:
size = info.m_Size;
return NPT_SUCCESS;
default:
break;
}
return NPT_SUCCESS;
}
示例4: if
/*----------------------------------------------------------------------
| CUPnP::CUPnP
+---------------------------------------------------------------------*/
CUPnP::CUPnP() :
m_MediaBrowser(NULL),
m_MediaController(NULL),
m_LogHandler(NULL),
m_ServerHolder(new CDeviceHostReferenceHolder()),
m_RendererHolder(new CRendererReferenceHolder()),
m_CtrlPointHolder(new CCtrlPointReferenceHolder())
{
NPT_LogManager::GetDefault().Configure("plist:.level=FINE;.handlers=CustomHandler;");
NPT_LogHandler::Create("xbmc", "CustomHandler", m_LogHandler);
m_LogHandler->SetCustomHandlerFunction(&UPnPLogger);
// initialize upnp context
m_UPnP = new PLT_UPnP();
// keep main IP around
if (g_application.getNetwork().GetFirstConnectedInterface()) {
m_IP = g_application.getNetwork().GetFirstConnectedInterface()->GetCurrentIPAddress().c_str();
}
NPT_List<NPT_IpAddress> list;
if (NPT_SUCCEEDED(PLT_UPnPMessageHelper::GetIPAddresses(list)) && list.GetItemCount()) {
m_IP = (*(list.GetFirstItem())).ToString();
}
else if(m_IP.empty())
m_IP = "localhost";
// start upnp monitoring
m_UPnP->Start();
}
示例5: MapGetAddrInfoErrorCode
/*----------------------------------------------------------------------
| NPT_NetworkNameResolver::Resolve
+---------------------------------------------------------------------*/
NPT_Result
NPT_NetworkNameResolver::Resolve(const char* name,
NPT_List<NPT_IpAddress>& addresses,
NPT_Timeout /*timeout*/)
{
// empty the list first
addresses.Clear();
// get the addr list
//struct addrinfo hints;
//NPT_SetMemory(&hints, 0, sizeof(hints));
//hints.ai_family = PF_UNSPEC;
//hints.ai_socktype = SOCK_STREAM;
//hints.ai_flags = AI_DEFAULT;
struct addrinfo *infos = NULL;
int result = getaddrinfo(name, /* hostname */
NULL, /* servname */
NULL, /* hints */
&infos /* res */);
if (result != 0) {
return MapGetAddrInfoErrorCode(result);
}
for (struct addrinfo* info = infos;
info && addresses.GetItemCount() < NPT_BSD_NETWORK_MAX_ADDR_LIST_LENGTH;
info = info->ai_next) {
unsigned int expected_length;
if (info->ai_family == AF_INET) {
expected_length = sizeof(struct sockaddr_in);
#if defined(NPT_CONFIG_ENABLE_IPV6)
} else if (info->ai_family == AF_INET6) {
expected_length = sizeof(struct sockaddr_in6);
#endif
} else {
continue;
}
if ((unsigned int)info->ai_addrlen < expected_length) continue;
if (info->ai_protocol != 0 && info->ai_protocol != IPPROTO_TCP) continue;
if (info->ai_family == AF_INET) {
struct sockaddr_in* inet_addr = (struct sockaddr_in*)info->ai_addr;
NPT_IpAddress address(ntohl(inet_addr->sin_addr.s_addr));
addresses.Add(address);
}
#if defined(NPT_CONFIG_ENABLE_IPV6)
else if (info->ai_family == AF_INET6) {
struct sockaddr_in6* inet_addr = (struct sockaddr_in6*)info->ai_addr;
NPT_IpAddress address(NPT_IpAddress::IPV6, inet_addr->sin6_addr.s6_addr, 16, inet_addr->sin6_scope_id);
addresses.Add(address);
}
#endif
}
freeaddrinfo(infos);
return NPT_SUCCESS;
}
示例6: while
/*----------------------------------------------------------------------
| NPT_PosixQueue::Push
+---------------------------------------------------------------------*/
NPT_Result
NPT_PosixQueue::Push(NPT_QueueItem* item, NPT_Timeout timeout)
{
struct timespec timed;
if (timeout != NPT_TIMEOUT_INFINITE) {
NPT_CHECK(GetTimeOut(timeout, timed));
}
// lock the mutex that protects the list
if (pthread_mutex_lock(&m_Mutex)) {
return NPT_FAILURE;
}
NPT_Result result = NPT_SUCCESS;
// check that we have not exceeded the max
if (m_MaxItems) {
while (m_Items.GetItemCount() >= m_MaxItems) {
// wait until we can push
++m_PushersWaitingCount;
if (timeout == NPT_TIMEOUT_INFINITE) {
pthread_cond_wait(&m_CanPushCondition, &m_Mutex);
--m_PushersWaitingCount;
} else {
int wait_res = pthread_cond_timedwait(&m_CanPushCondition,
&m_Mutex,
&timed);
--m_PushersWaitingCount;
if (wait_res == ETIMEDOUT) {
result = NPT_ERROR_TIMEOUT;
break;
}
}
if (m_Aborting) {
result = NPT_ERROR_INTERRUPTED;
break;
}
}
}
// add the item to the list
if (result == NPT_SUCCESS) {
m_Items.Add(item);
// wake up any thread that may be waiting to pop
if (m_PoppersWaitingCount) {
pthread_cond_broadcast(&m_CanPopCondition);
}
}
// unlock the mutex
pthread_mutex_unlock(&m_Mutex);
return result;
}
示例7: printf
/*
* Presents a list to the user, allows the user to choose one item.
*
* Parameters:
* PLT_StringMap: A map that contains the set of items from
* which the user should choose. The key should be a unique ID,
* and the value should be a string describing the item.
* returns a NPT_String with the unique ID.
*/
const char*
PLT_MicroMediaController::ChooseIDFromTable(PLT_StringMap& table)
{
printf("Select one of the following:\n");
NPT_List<PLT_StringMapEntry*> entries = table.GetEntries();
if (entries.GetItemCount() == 0) {
printf("None available\n");
} else {
// display the list of entries
NPT_List<PLT_StringMapEntry*>::Iterator entry = entries.GetFirstItem();
int count = 0;
while (entry) {
printf("%d)\t%s (%s)\n", ++count, (const char*)(*entry)->GetValue(), (const char*)(*entry)->GetKey());
++entry;
}
int index, watchdog = 3;
char buffer[1024];
// wait for input
/*while (watchdog > 0) {
fgets(buffer, 1024, stdin);
strchomp(buffer);
if (1 != sscanf(buffer, "%d", &index)) {
printf("Please enter a number\n");
} else if (index < 0 || index > count) {
printf("Please choose one of the above, or 0 for none\n");
watchdog--;
index = 0;
} else {
watchdog = 0;
}
}*/
index = 1;
// find the entry back
if (index != 0) {
entry = entries.GetFirstItem();
while (entry && --index) {
++entry;
}
if (entry) {
return (*entry)->GetKey();
}
}
}
return NULL;
}
示例8: GetCurMediaRenderer
/*----------------------------------------------------------------------
| PLT_MicroMediaController::HandleCmd_seek
+---------------------------------------------------------------------*/
void
PLT_MicroMediaController::HandleCmd_seek(const char* command)
{
PLT_DeviceDataReference device;
GetCurMediaRenderer(device);
if (!device.IsNull()) {
// remove first part of command ("seek")
NPT_String target = command;
NPT_List<NPT_String> args = target.Split(" ");
if (args.GetItemCount() < 2) return;
args.Erase(args.GetFirstItem());
target = NPT_String::Join(args, " ");
Seek(device, 0, (target.Find(":")!=-1)?"REL_TIME":"X_DLNA_REL_BYTE", target, NULL);
}
}
示例9: Start
/*----------------------------------------------------------------------
| PLT_FileMediaServer::Start
+---------------------------------------------------------------------*/
NPT_Result
PLT_FileMediaServer::Start(PLT_SsdpListenTask* task)
{
// start our file server
m_FileServer = new PLT_HttpServer(m_FileServerPort);
NPT_CHECK_SEVERE(m_FileServer->Start());
m_FileServer->AddRequestHandler(m_FileServerHandler, "/", true);
// FIXME: hack for now: find the first valid non local ip address
// to use in item resources. TODO: we should advertise all ips as
// multiple resources instead.
NPT_List<NPT_String> ips;
PLT_UPnPMessageHelper::GetIPAddresses(ips);
if (ips.GetItemCount() == 0) return NPT_ERROR_INTERNAL;
// set the base paths for content and album arts
m_FileBaseUri = NPT_HttpUrl(*ips.GetFirstItem(), m_FileServer->GetPort(), "/content");
m_AlbumArtBaseUri = NPT_HttpUrl(*ips.GetFirstItem(), m_FileServer->GetPort(), "/albumart");
return PLT_MediaServer::Start(task);
}
示例10: if
/*----------------------------------------------------------------------
| CUPnP::CUPnP
+---------------------------------------------------------------------*/
CUPnP::CUPnP() :
m_MediaBrowser(NULL),
m_ServerHolder(new CDeviceHostReferenceHolder()),
m_RendererHolder(new CRendererReferenceHolder()),
m_CtrlPointHolder(new CCtrlPointReferenceHolder())
{
// initialize upnp context
m_UPnP = new PLT_UPnP();
// keep main IP around
m_IP = g_application.getNetworkManager().GetDefaultConnectionAddress().c_str();
NPT_List<NPT_IpAddress> list;
if (NPT_SUCCEEDED(PLT_UPnPMessageHelper::GetIPAddresses(list)) && list.GetItemCount()) {
m_IP = (*(list.GetFirstItem())).ToString();
}
else if(m_IP.IsEmpty())
m_IP = "localhost";
// start upnp monitoring
m_UPnP->Start();
}
示例11: SetupResponse
NPT_Result CHttpServer::SetupResponse(NPT_HttpRequest& request,
const NPT_HttpRequestContext& context,
NPT_HttpResponse& response)
{
NPT_String prefix = NPT_String::Format("PLT_HttpServer::SetupResponse %s request from %s for \"%s\"",
(const char*) request.GetMethod(),
(const char*) context.GetRemoteAddress().ToString(),
(const char*) request.GetUrl().ToString());
NPT_List<NPT_HttpRequestHandler*> handlers = FindRequestHandlers(request);
if (handlers.GetItemCount() == 0) return NPT_ERROR_NO_SUCH_ITEM;
// ask the handler to setup the response
NPT_Result result = (*handlers.GetFirstItem())->SetupResponse(request, context, response);
// DLNA compliance
UPNPMessageHelper::SetDate(response);
if (request.GetHeaders().GetHeader("Accept-Language")) {
response.GetHeaders().SetHeader("Content-Language", "en");
}
return result;
}
示例12: while
/*----------------------------------------------------------------------
| NPT_Win32Queue::Push
+---------------------------------------------------------------------*/
NPT_Result
NPT_Win32Queue::Push(NPT_QueueItem* item, NPT_Timeout timeout)
{
// lock the mutex that protects the list
NPT_CHECK(m_Mutex.Lock());
// check that we have not exceeded the max
if (m_MaxItems) {
while (m_Items.GetItemCount() >= m_MaxItems) {
// we must wait until some items have been removed
// reset the condition to indicate that the queue is full
m_CanPushCondition->Reset();
// unlock the mutex so that another thread can pop
m_Mutex.Unlock();
// wait for the condition to signal that we can push
NPT_Result result = m_CanPushCondition->Wait(timeout);
if (NPT_FAILED(result)) return result;
// relock the mutex so that we can check the list again
NPT_CHECK(m_Mutex.Lock());
}
}
// add the item to the list
m_Items.Add(item);
// wake up the threads waiting to pop
m_CanPopCondition->Signal();
// unlock the mutex
m_Mutex.Unlock();
return NPT_SUCCESS;
}
示例13: generateDidl
NPT_String RootContainer::generateDidl(const NPT_List<const Object*>& ls, const NPT_String& resUriTmpl)
{
NPT_StringOutputStream outputStream;
NPT_XmlSerializer xml(&outputStream, 0, true, true);
xml.StartDocument();
xml.StartElement(NULL, "DIDL-Lite");
xml.Attribute(NULL, "xmlns", "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/");
xml.Attribute("xmlns", "dc", "http://purl.org/dc/elements/1.1/");
xml.Attribute("xmlns", "upnp", "urn:schemas-upnp-org:metadata-1-0/upnp/");
for (NPT_Ordinal i = 0; i < ls.GetItemCount(); i++) {
const Object *obj = *ls.GetItem(i);
if (const Item *item = obj->asItem()) {
outputItem(xml, item, resUriTmpl);
} else if (const Container *container = obj->asContainer()) {
outputContainer(xml, container, resUriTmpl);
}
}
xml.EndElement(NULL, "DIDL-Lite");
xml.EndDocument();
return outputStream.GetString();
}
示例14: DoBrowse
/*----------------------------------------------------------------------
| PLT_MicroMediaController::HandleCmd_cd
+---------------------------------------------------------------------*/
void
PLT_MicroMediaController::HandleCmd_cd(const char* command)
{
NPT_String newobject_id;
PLT_StringMap containers;
// if command has parameter, push it to stack and return
NPT_String id = command;
NPT_List<NPT_String> args = id.Split(" ");
if (args.GetItemCount() >= 2) {
args.Erase(args.GetFirstItem());
id = NPT_String::Join(args, " ");
m_CurBrowseDirectoryStack.Push(id);
return;
}
// list current directory to let user choose
DoBrowse();
if (!m_MostRecentBrowseResults.IsNull()) {
NPT_List<PLT_MediaObject*>::Iterator item = m_MostRecentBrowseResults->GetFirstItem();
while (item) {
if ((*item)->IsContainer()) {
containers.Put((*item)->m_ObjectID, (*item)->m_Title);
}
++item;
}
newobject_id = ChooseIDFromTable(containers);
if (newobject_id.GetLength()) {
m_CurBrowseDirectoryStack.Push(newobject_id);
}
m_MostRecentBrowseResults = NULL;
}
}
示例15: start
NPT_Result FrontEnd::start()
{
WriteLocker locker(m_stateLock);
if (m_state != State_Stopped) {
return NPT_ERROR_INVALID_STATE;
}
NPT_Result nr;
NPT_List<NPT_NetworkInterface*> ifList;
nr = NPT_NetworkInterface::GetNetworkInterfaces(ifList);
if (NPT_FAILED(nr)) {
return nr;
}
for (NPT_Ordinal i = 0; i < ifList.GetItemCount(); i++) {
NPT_NetworkInterface *nif = *ifList.GetItem(i);
if (nif->GetAddresses().GetFirstItem() && (m_includeLoopback || ((nif->GetFlags() & NPT_NETWORK_INTERFACE_FLAG_LOOPBACK) == 0))) {
Interface *intf = new Interface();
intf->m_owner = this;
intf->m_nif = nif;
intf->m_context.m_ifAddr = nif->GetAddresses().GetFirstItem()->GetPrimaryAddress();
intf->m_httpConnector = new HttpConnector(intf, intf->m_context.m_ifAddr);
intf->m_ssdpConnector = new SsdpConnector(intf, intf->m_context.m_ifAddr);
intf->m_context.m_httpPort = 0;
intf->m_context.m_ssdpPort = 0;
m_ifList.Add(intf);
m_interfaceContextList.Add(&intf->m_context);
} else {
delete nif;
}
}
if (m_ifList.GetItemCount() == 0) {
return NPT_FAILURE;
}
for (NPT_Ordinal i = 0; i < m_ifList.GetItemCount(); i++) {
Interface *intf = *m_ifList.GetItem(i);
if (NPT_SUCCEEDED(intf->m_httpConnector->start())) {
intf->m_context.m_httpPort = intf->m_httpConnector->port();
}
if (NPT_SUCCEEDED(intf->m_ssdpConnector->start())) {
intf->m_context.m_ssdpPort = intf->m_ssdpConnector->port();
}
}
m_taskGroup->reset();
{
ReadLocker locker1(m_cpLock);
for (NPT_Ordinal i = 0; i < m_controlPointList.GetItemCount(); i++) {
ControlPointInfo *info = *m_controlPointList.GetItem(i);
info->m_controlPoint->implAttach(this, info->m_context);
}
for (NPT_Ordinal i = 0; i < m_deviceImplList.GetItemCount(); i++) {
DeviceImplInfo *info = *m_deviceImplList.GetItem(i);
info->m_deviceImpl->implAttach(this, info->m_context);
}
broadcastLocked(NULL, true);
}
m_taskGroup->startTask(new SsdpBroadcastTask(this));
m_state = State_Running;
return NPT_SUCCESS;
}