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"); }
/// <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; } } }