Beispiel #1
0
        } // ParseDidlMetaData()

        /// <summary>
        /// Parses DIDL container meta data.
        /// </summary>
        /// <param name="xcontainer">The parent.</param>
        /// <returns>A <see cref="BrowseMetaDataResult"/> object.</returns>
        private static BrowseMetaDataResult ParseDidlContainerMetaData(XElement xcontainer)
        {
            /*
             * <DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
             *   xmlns:dc="http://purl.org/dc/elements/1.1/"
             *   xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
             *   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             *   xsi:schemaLocation="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite-v2-20060531.xsd urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp-v2-20060531.xsd">
             *   <container id="AV_ALL" parentID="AV" restricted="0">
             *     <dc:title>Alle</dc:title>
             *     <upnp:writeStatus>NOT_WRITABLE</upnp:writeStatus>
             *     <upnp:recordable>0</upnp:recordable>
             *     <upnp:class name="container">object.container</upnp:class>
             *   </container>
             * </DIDL-Lite>
             */

            var result = new BrowseMetaDataResult();

            result.Id       = XmlSupport.GetAttributeValue(xcontainer, "id");
            result.ParentId = XmlSupport.GetAttributeValue(xcontainer, "parentID");

            result.Title       = XmlSupport.GetFirstSubNodeValue(xcontainer, "title");
            result.WriteStatus = XmlSupport.GetFirstSubNodeValue(xcontainer, "writeStatus", false);
            ////result.IsRecordable = XmlSupport.XmlSupport.ParseUpnpBoolean(XmlSupport.XmlSupport.GetFirstSubNodeValue(xcontainer, "recordable"));
            result.Class = XmlSupport.GetFirstSubNodeValue(xcontainer, "class");

            return(result);
        } // ParseDidlContainerMetaData
Beispiel #2
0
        } // ParseDidlContainerMetaData

        /// <summary>
        /// Parses DIDL item meta data.
        /// </summary>
        /// <param name="xitem">The parent.</param>
        /// <returns>A <see cref="BrowseMetaDataResult"/> object.</returns>
        private static BrowseMetaDataResult ParseDidlItemMetaData(XElement xitem)
        {
            var result = new BrowseMetaDataResult();

            result.Id       = XmlSupport.GetAttributeValue(xitem, "id");
            result.ParentId = XmlSupport.GetAttributeValue(xitem, "parentID");
            var help = XmlSupport.GetAttributeValue(xitem, "restricted");

            if (!string.IsNullOrEmpty(help))
            {
                result.Restricted = UPNP.ParseUpnpBoolean(help);
            } // if

            result.Title = XmlSupport.GetFirstSubNodeValue(xitem, "title");
            result.Class = XmlSupport.GetFirstSubNodeValue(xitem, "class");
            result.Date  = XmlSupport.GetFirstSubNodeValue(xitem, "date", false);

#if false
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "channelName", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "date", false); // iso8601
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "objectType", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "groupID", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "storageMedium", false);
#endif

            var res = XmlSupport.GetFirstSubNode(xitem, "res", false);
            if (res != null)
            {
                result.ProtocolInfo = XmlSupport.GetAttributeValue(res, "protocolInfo", false);
                result.Resolution   = XmlSupport.GetAttributeValue(res, "resolution", false);
                help = XmlSupport.GetAttributeValue(res, "size", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.Size = long.Parse(help);
                } // if

                help = XmlSupport.GetAttributeValue(res, "bitrate", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.Bitrate = int.Parse(help);
                } // if

                result.Duration = XmlSupport.GetAttributeValue(xitem, "duration", false);
                help            = XmlSupport.GetAttributeValue(res, "nrAudioChannels", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.NumAudioChannels = int.Parse(help);
                } // if

                help = XmlSupport.GetAttributeValue(res, "sampleFrequency", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.SampleFrequency = int.Parse(help);
                } // if

                result.Resource = res.Value;
            } // if

            return(result);
        } // ParseDidlItemMetaData()
Beispiel #3
0
        } // ParseChildData()

        /// <summary>
        /// Parses the DIDL meta data.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>A <see cref="BrowseMetaDataResult"/> object.</returns>
        private BrowseMetaDataResult ParseDidlMetaData(string text)
        {
            var result = new BrowseMetaDataResult();

            var document  = XDocument.Parse(text);
            var didl      = XmlSupport.GetFirstSubNode(document, "DIDL-Lite");
            var container = XmlSupport.GetFirstSubNode(didl, "container", false);

            if (container != null)
            {
                return(ParseDidlContainerMetaData(container));
            } // if

            var item = XmlSupport.GetFirstSubNode(didl, "item");

            if (item != null)
            {
                return(ParseDidlItemMetaData(item));
            } // if

            return(result);
        } // ParseDidlMetaData()