/*---------------------------------------------------------------------- | PLT_MediaServer::ParseSort +---------------------------------------------------------------------*/ NPT_Result PLT_MediaServer::ParseSort(const NPT_String& sort, NPT_List<NPT_String>& list) { // reset output params first list.Clear(); // easy out if (sort.GetLength() == 0 || sort == "*") return NPT_SUCCESS; list = sort.Split(","); // verify each property has a namespace NPT_List<NPT_String>::Iterator property = list.GetFirstItem(); while (property) { NPT_List<NPT_String> parsed_property = (*property).Split(":"); if (parsed_property.GetItemCount() != 2) parsed_property = (*property).Split("@"); if (parsed_property.GetItemCount() != 2 || (!(*property).StartsWith("-") && !(*property).StartsWith("+"))) { NPT_LOG_WARNING_1("Invalid SortCriteria property %s", (*property).GetChars()); return NPT_FAILURE; } property++; } return NPT_SUCCESS; }
/*---------------------------------------------------------------------- | PLT_MediaServer::ParseTagList +---------------------------------------------------------------------*/ NPT_Result PLT_MediaServer::ParseTagList(const NPT_String& updates, NPT_Map<NPT_String,NPT_String>& tags) { // reset output params first tags.Clear(); NPT_List<NPT_String> split = updates.Split(","); NPT_XmlNode* node = NULL; NPT_XmlElementNode* didl_partial = NULL; NPT_XmlParser parser; // as these are single name value pairs, separated by commas we wrap in a tag // to create a valid tree NPT_String xml("<TagValueList>"); for (NPT_List<NPT_String>::Iterator entry = split.GetFirstItem(); entry; entry++) { NPT_String& element = (*entry); if (element.IsEmpty()) xml.Append("<empty>empty</empty>"); else xml.Append(element); } xml.Append("</TagValueList>"); NPT_LOG_FINE("Parsing TagList..."); NPT_CHECK_LABEL_SEVERE(parser.Parse(xml, node), cleanup); if (!node || !node->AsElementNode()) { NPT_LOG_SEVERE("Invalid node type"); goto cleanup; } didl_partial = node->AsElementNode(); if (didl_partial->GetTag().Compare("TagValueList", true)) { NPT_LOG_SEVERE("Invalid node tag"); goto cleanup; } for (NPT_List<NPT_XmlNode*>::Iterator children = didl_partial->GetChildren().GetFirstItem(); children; children++) { NPT_XmlElementNode* child = (*children)->AsElementNode(); if (!child) continue; tags[child->GetTag()] = *child->GetText(); } return NPT_SUCCESS; cleanup: if (node) delete node; return NPT_FAILURE; }
/*---------------------------------------------------------------------- | 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); } }
/*---------------------------------------------------------------------- | PLT_MediaController::GetProtocolInfoSink +---------------------------------------------------------------------*/ NPT_Result PLT_MediaController::GetProtocolInfoSink(PLT_DeviceDataReference& device, NPT_List<NPT_String>& sinks) { PLT_DeviceDataReference renderer; NPT_CHECK_WARNING(FindRenderer(device->GetUUID(), renderer)); // look for ConnectionManager service PLT_Service* serviceCMR; NPT_CHECK_SEVERE(device->FindServiceByType( "urn:schemas-upnp-org:service:ConnectionManager:*", serviceCMR)); NPT_String value; NPT_CHECK_SEVERE(serviceCMR->GetStateVariableValue( "SinkProtocolInfo", value)); sinks = value.Split(","); return NPT_SUCCESS; }
/*---------------------------------------------------------------------- | 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; } }