[vlc-devel] [PATCH 5/5] dlna: add GetProtocolInfo action
Steve Lhomme
robux4 at ycbcr.xyz
Mon Oct 15 16:18:20 CEST 2018
On 15/10/2018 10:18, Shaleen Jain wrote:
> -int MediaRenderer::SetAVTransportURI(const char* uri)
> +std::vector<protocol_info_t> MediaRenderer::GetProtocolInfo()
> {
> + std::string protocol_csv;
> + std::vector<protocol_info_t> supported_protocols;
> + std::list<std::pair<const char*, const char*>> arg_list;
> +
> + IXML_Document *response = SendAction("GetProtocolInfo",
> + CONNECTION_MANAGER_SERVICE_TYPE, arg_list);
> + if(!response)
> + {
> + return supported_protocols;
> + }
> +
> + // Get the CSV list of protocols/profiles supported by the device
> + if( IXML_NodeList *protocol_list = ixmlDocument_getElementsByTagName( response , "Sink" ) )
> + {
> + if ( IXML_Node* protocol_node = ixmlNodeList_item( protocol_list, 0 ) )
> + {
> + IXML_Node* p_text_node = ixmlNode_getFirstChild( protocol_node );
> + if ( p_text_node )
> + {
> + protocol_csv.assign(ixmlNode_getNodeValue( p_text_node ));
> + }
> + }
> + ixmlNodeList_free( protocol_list);
> + }
> + ixmlDocument_free(response);
> +
> + msg_Dbg(parent, "Device supports protocols: %s", protocol_csv.c_str());
> + // parse the CSV list
> + // format: <transportProtocol>:<network>:<mime>:<additionalInfo>
> + std::vector<std::string> protocols = split(protocol_csv, ',');
> + for (std::string protocol : protocols ) {
> + std::vector<std::string> protocol_info = split(protocol, ':');
> +
> + // We only support http transport for now.
> + if (protocol_info.size() == 4 && protocol_info.at(0) == "http-get")
> + {
> + protocol_info_t proto;
> +
> + // Get the DLNA profile name
> + std::string profile_name;
> + std::string tag = "DLNA.ORG_PN=";
> +
> + if (protocol_info.at(3) == "*")
> + {
> + profile_name = "*";
> + }
> + else if (std::size_t index = protocol_info.at(3).find(tag) != std::string::npos)
> + {
> + std::size_t end = protocol_info.at(3).find(';', index + 1);
> + int start = index + tag.length() - 1;
> + int length = end - start;
> + profile_name = protocol_info.at(3).substr(start, length);
> + }
> +
> + // Match our supported profiles to device profiles
> + for (dlna_profile_t profile : dlna_profile_list) {
> + if (protocol_info.at(2) == profile.mime
> + && (profile_name == profile.name || profile_name == "*"))
> + {
> + proto.profile = std::move(profile);
> + supported_protocols.push_back(proto);
> + // we do not break here to account for wildcards
> + // as protocolInfo's fourth field aka <additionalInfo>
> + }
> + }
> + }
> + }
> +
> + msg_Dbg( parent , "Got %lu supported profiles", supported_protocols.size() );
Should be %zu
More information about the vlc-devel
mailing list