[vlc-devel] [PATCH 5/5] dlna: add GetProtocolInfo action

Shaleen Jain shaleen at jain.sh
Mon Oct 15 16:54:48 CEST 2018


On Mon, 2018-10-15 at 16:18 +0200, Steve Lhomme wrote:
> 
> 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",+                                CONNE
> > CTION_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_getNod
> > eValue( 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::vect
> > or<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_ba
> > ck(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

Done.

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel
-- 
Regards,
Shaleen Jain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20181015/05d14832/attachment.html>


More information about the vlc-devel mailing list