Ejemplo n.º 1
0
        public List <XmlNodeEx> GetChildNodesByName(string nodeName)
        {
            List <XmlNodeEx> nodeList = new List <XmlNodeEx>();

            foreach (XmlNode node in ChildNodes)
            {
                if (node.Name == nodeName)
                {
                    XmlNodeEx nodeEx = node as XmlNodeEx;
                    if (nodeEx != null)
                    {
                        nodeList.Add(nodeEx);
                    }
                }
            }
            return(nodeList);
        }
Ejemplo n.º 2
0
        public void Parse(XmlNodeEx node, string baseURL = "", string idPrefix = "")
        {
            profile = node.GetAttributeStr("profile");
            id      = idPrefix + node.GetAttributeStr("id", F4MUtils.GLOBAL_ELEMENT_ID);
            url     = node.GetAttributeStr("url");

            if (!string.IsNullOrEmpty(url))
            {
                // We may make this load on demand in the future.
                url = URL.getAbsoluteUrl(baseURL, url);
            }
            else
            {
                data = node.GetOwnData();
            }

            fragmentDuration = node.GetAttributeFloat("fragmentDuration");
            segmentDuration  = node.GetAttributeFloat("segmentDuration");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the version based on the default namespace of the F4M example.
 /// <p>An example of a version 1.0 namespace: "http://ns.adobe.com/f4m/1.0"</p>
 /// </summary>
 public static Version getVersion(XmlNodeEx node)
 {
     return(getVersion(node.OwnerDocument.OuterXml));
 }
Ejemplo n.º 4
0
 // Constructor
 public Media(XmlNodeEx node, string serverBaseURL = "", string idPrefix = "", int nestedBitrate = 0)
 {
     Parse(node, serverBaseURL, idPrefix, nestedBitrate);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses media from XML node.
        /// </summary>
        public void Parse(XmlNodeEx node, string serverBaseURL = "", string idPrefix = "", int nestedBitrate = 0)
        {
            baseURL = serverBaseURL;

            url = node.GetAttributeStr("url");
            url = URL.getAbsoluteUrl(baseURL, url);

            streamId = node.GetAttributeStr("streamId");
            bitrate  = node.GetAttributeInt("bitrate");
            if (bitrate == 0)
            {
                bitrate = nestedBitrate;
            }
            if (bitrate == 0)
            {
                XmlNodeEx parentManifest = (XmlNodeEx)node.ParentNode;
                bitrate = parentManifest.GetAttributeInt("bitrate");
            }
            if (bitrate == 0)
            {
                bitrate = node.GetAttributeInt("width");
            }
            if (bitrate == 0)
            {
                if (!string.IsNullOrEmpty(streamId))
                {
                    var m = System.Text.RegularExpressions.Regex.Match(streamId, @"(\d+)", System.Text.RegularExpressions.RegexOptions.RightToLeft);
                    if (m.Success)
                    {
                        int.TryParse(m.Groups[1].Value, out bitrate);
                    }
                    else
                    {
                        // by index
                        int idx = 0;
                        foreach (XmlNodeEx n in node.ParentNode.ChildNodes)
                        {
                            if (n.Name != node.Name)
                            {
                                continue;
                            }
                            if (n == node)
                            {
                                bitrate = idx;
                                break;
                            }
                            idx++;
                        }
                    }
                }
            }

            drmAdditionalHeader = new DRMAdditionalHeader()
            {
                id = idPrefix + node.GetAttributeStr("drmAdditionalHeaderId", F4MUtils.GLOBAL_ELEMENT_ID)
            };
            bootstrapInfo = new BootstrapInfo()
            {
                id = idPrefix + node.GetAttributeStr("bootstrapInfoId", F4MUtils.GLOBAL_ELEMENT_ID)
            };
            height = node.GetAttributeInt("height");
            width  = node.GetAttributeInt("width");

            multicastGroupspec  = node.GetAttributeStr("groupspec");
            multicastStreamName = node.GetAttributeStr("multicastStreamName");
            label      = node.GetAttributeStr("label");
            type       = node.GetAttributeStr("type", StreamingItemType.VIDEO);
            lang       = node.GetAttributeStr("lang");
            audioCodec = node.GetAttributeStr("audioCodec");
            videoCodec = node.GetAttributeStr("videoCodec");
            cueInfoId  = node.GetAttributeStr("cueInfoId");
            href       = node.GetAttributeStr("href");
            alternate  = (node.GetAttributeStr("alternate").Length > 0);

            moov     = node.GetData("moov");
            metadata = node.GetData("metadata");
            if ((metadata != null) && metadata.Length > 0)
            {
                // if width and height are not already set by the media
                // attributes and they are already present in metadata
                // object, then copy their values to the media properties
                if (width == 0)
                {
                    width = node.GetChildNodeAttributeInt("metadata", "width");
                }
                if (height == 0)
                {
                    height = node.GetChildNodeAttributeInt("metadata", "height");
                }
            }

            xmp = node.GetData("xmpMetadata");

            if (string.IsNullOrEmpty(label))
            {
                if (!string.IsNullOrEmpty(lang))
                {
                    label = lang;
                }
                else
                {
                    label = string.IsNullOrEmpty(streamId) ? bitrate.ToString() : streamId;
                }
            }
        }
Ejemplo n.º 6
0
        public override XmlElement CreateElement(string prefix, string localname, string nsURI)
        {
            XmlNodeEx elem = new XmlNodeEx(prefix, localname, nsURI, this);

            return(elem);
        }
Ejemplo n.º 7
0
 public BootstrapInfo(XmlNodeEx node, string baseURL = "", string idPrefix = "")
 {
     Parse(node, baseURL, idPrefix);
 }
Ejemplo n.º 8
0
        public void Parse(XmlNodeEx nodeManifest, string rootURL = "", string idPrefix = "", int nestedBitrate = 0)
        {
            id           = nodeManifest.GetText("id");
            label        = nodeManifest.GetText("label");
            lang         = nodeManifest.GetText("lang");
            duration     = nodeManifest.GetFloat("duration");
            startTime    = nodeManifest.GetDateTime("startTime");
            mimeType     = nodeManifest.GetText("mimeType");
            streamType   = nodeManifest.GetText("streamType");
            deliveryType = nodeManifest.GetText("deliveryType");
            baseURL      = nodeManifest.GetText("baseURL");
            urlIncludesFMSApplicationInstance = nodeManifest.GetAttributeBoolean("urlIncludesFMSApplicationInstance");
            if (string.IsNullOrEmpty(baseURL))
            {
                baseURL = rootURL;
            }
            baseURL = URL.normalizePathForURL(baseURL, false);

            XmlNodeEx nodeDVR = nodeManifest.GetChildNode("dvrInfo") as XmlNodeEx;

            dvrInfo = (nodeDVR != null) ? new DVRInfo(nodeDVR) : null;

            // cueInfo
            cueInfos.Clear();
            List <XmlNodeEx> cueInfoNodes = nodeManifest.GetChildNodesByName("cueInfo");

            foreach (XmlNodeEx nodeCueInfo in cueInfoNodes)
            {
                string  cueInfoId = nodeCueInfo.GetAttributeStr("id", F4MUtils.GLOBAL_ELEMENT_ID);
                CueInfo cueInfo   = new CueInfo(cueInfoId);
                foreach (XmlNodeEx node in nodeCueInfo.GetChildNodesByName("cue"))
                {
                    cueInfo.Cues.Add(new Cue(node, baseURL, idPrefix));
                }
                cueInfos.Add(cueInfo);
            }

            media.Clear();
            alternativeMedia.Clear();
            drmAdditionalHeaders.Clear();
            bootstrapInfos.Clear();

            foreach (XmlNode childNode in nodeManifest.ChildNodes)
            {
                XmlNodeEx childNodeEx = childNode as XmlNodeEx;
                if (childNodeEx == null)
                {
                    continue;
                }
                switch (childNodeEx.Name)
                {
                case "media":
                    Media mediaItem = new Media(childNodeEx, baseURL, idPrefix, nestedBitrate);
                    if (mediaItem.bitrate == 0)
                    {
                        mediaItem.bitrate = nodeManifest.GetAttributeInt("bitrate");
                    }
                    if (mediaItem.alternate)
                    {
                        alternativeMedia.Add(mediaItem);
                    }
                    else
                    {
                        media.Add(mediaItem);
                    }
                    break;

                case "drmAdditionalHeader":
                    drmAdditionalHeaders.Add(new DRMAdditionalHeader(childNodeEx, baseURL, idPrefix));
                    break;

                case "bootstrapInfo":
                    bootstrapInfos.Add(new BootstrapInfo(childNodeEx, baseURL, idPrefix));
                    break;
                }
            }

            XmlNodeEx nodeBEF = nodeManifest.GetChildNode("bestEffortFetchInfo") as XmlNodeEx;

            bestEffortFetchInfo = (nodeBEF != null) ? new BestEffortFetchInfo(nodeBEF) : null;

            // Adaptive sets search
            List <XmlNodeEx> adaptiveSet = nodeManifest.GetChildNodesByName("adaptiveSet");

            foreach (XmlNodeEx nodeSet in adaptiveSet)
            {
                string           alternate  = nodeSet.GetAttributeStr("alternate");
                string           audioCodec = nodeSet.GetAttributeStr("audioCodec");
                string           label      = nodeSet.GetAttributeStr("label");
                string           lang       = nodeSet.GetAttributeStr("lang");
                string           type       = nodeSet.GetAttributeStr("type");
                List <XmlNodeEx> mediaInSet = nodeSet.GetChildNodesByName("media");
                foreach (XmlNodeEx nodeMedia in mediaInSet)
                {
                    Media mediaItem = new Media(nodeMedia, baseURL, idPrefix, nestedBitrate);
                    if (mediaItem.bitrate == 0)
                    {
                        mediaItem.bitrate = nodeManifest.GetAttributeInt("bitrate");
                    }
                    if (!string.IsNullOrEmpty(alternate))
                    {
                        mediaItem.alternate = true;
                    }
                    if (!string.IsNullOrEmpty(audioCodec) && string.IsNullOrEmpty(mediaItem.audioCodec))
                    {
                        mediaItem.audioCodec = audioCodec;
                    }
                    if (!string.IsNullOrEmpty(label) && string.IsNullOrEmpty(mediaItem.label))
                    {
                        mediaItem.label = label;
                    }
                    if (!string.IsNullOrEmpty(lang) && string.IsNullOrEmpty(mediaItem.lang))
                    {
                        mediaItem.lang = lang;
                    }
                    if (!string.IsNullOrEmpty(type) && string.IsNullOrEmpty(mediaItem.type))
                    {
                        mediaItem.type = type;
                    }

                    if (mediaItem.alternate)
                    {
                        alternativeMedia.Add(mediaItem);
                    }
                    else
                    {
                        media.Add(mediaItem);
                    }
                }
            }

            GenerateRTMPBaseURL();
        }
Ejemplo n.º 9
0
 // CONSTRUCTOR
 public Manifest(XmlNodeEx nodeManifest, string rootURL = "", string idPrefix = "", int nestedBitrate = 0)
 {
     Parse(nodeManifest, rootURL, idPrefix, nestedBitrate);
 }