Example #1
0
 public void Parse(XmlNodeEx node, string baseURL = "", string idPrefix = "")
 {
     segmentDuration    = (uint)(node.GetAttributeFloat("segmentDuration") * 1000);
     fragmentDuration   = (uint)(node.GetAttributeFloat("fragmentDuration") * 1000);
     maxForwardFetches  = (uint)node.GetAttributeInt("maxForwardFetches");
     maxBackwardFetches = (uint)node.GetAttributeInt("maxBackwardFetches");
 }
Example #2
0
        public void Parse(XmlNodeEx node, string baseURL = "", string idPrefix = "")
        {
            id  = node.GetAttributeStr("id", F4MUtils.GLOBAL_ELEMENT_ID);
            url = node.GetAttributeStr("url");
            url = URL.getAbsoluteUrl(baseURL, url);

            int majorVersion = F4MUtils.getVersion(node).Major;

            if (majorVersion <= 1)
            {
                beginOffset    = System.Math.Max(0, node.GetAttributeInt("beginOffset"));
                endOffset      = System.Math.Max(0, node.GetAttributeInt("endOffset"));
                windowDuration = -1;
            }
            else     // F4M 2.0
            {
                windowDuration = node.GetAttributeInt("windowDuration");
                if (windowDuration == 0)
                {
                    windowDuration = -1;
                }
            }

            offline = node.GetAttributeBoolean("offline");
        }
Example #3
0
 public void Parse(XmlNodeEx node, string rootURL = "", string idPrefix = "")
 {
     id             = idPrefix + node.GetAttributeStr("id", F4MUtils.GLOBAL_ELEMENT_ID);
     type           = node.GetAttributeStr("type"); // SHALL be “spliceOut”
     time           = (uint)node.GetAttributeInt("time");
     duration       = (uint)node.GetAttributeInt("duration");
     programId      = (uint)node.GetAttributeInt("programId");
     availNum       = (uint)node.GetAttributeInt("availNum");
     availsExpected = (uint)node.GetAttributeInt("availsExpected");
 }
Example #4
0
        public void Parse(XmlNodeEx nodeDRM, string baseURL = "", string idPrefix = "")
        {
            id = idPrefix + nodeDRM.GetAttributeStr("id", F4MUtils.GLOBAL_ELEMENT_ID);

            url = nodeDRM.GetAttributeStr("url");
            if (!string.IsNullOrEmpty(url))
            {
                // DRM Metadata - we may make this load on demand in the future.
                url = URL.getAbsoluteUrl(baseURL, url);
            }
            else
            {
                data = nodeDRM.GetOwnData();
            }
        }
Example #5
0
 // CONSTRUCTOR
 public BestEffortFetchInfo(XmlNodeEx node, string baseURL = "", string idPrefix = "")
 {
     Parse(node, baseURL, idPrefix);
 }
Example #6
0
 // CONSTRUCTOR
 public Cue(XmlNodeEx node, string rootURL = "", string idPrefix = "")
 {
     Parse(node, rootURL, idPrefix);
 }
Example #7
0
        private void GetManifestAndSelectMedia(string manifestUrl, int nestedBitrate = 0, int level = 0)
        {
            if (level > MAX_LEVEL_NESTED_MANIFESTS)
            {
                throw new InvalidOperationException("Maximum nesting level reached of multi-level manifests.");
            }

            XmlNodeEx xmlManifest = LoadXml(manifestUrl);

            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = URL.ExtractBaseUrl(manifestUrl);
            }

            // parse the manifest
            manifest = new Manifest(xmlManifest, baseUrl, "", nestedBitrate);

            if (string.IsNullOrEmpty(manifest.baseURL))
            {
                throw new InvalidOperationException("Not found <c:Magenta>baseURL</c> value in manifest or in parameter <c:White>--urlbase</c>.");
            }

            if (manifest.media.Count < 1)
            {
                throw new InvalidOperationException("No media entry found in the manifest");
            }

            Program.DebugLog("Manifest entries:\n");
            Program.DebugLog(String.Format(" {0,-8}{1}", "Bitrate", "URL"));

            // TEST for alternate selection
            if (testalt)
            {
                manifest.alternativeMedia.AddRange(manifest.media);
            }

            // Quality selection
            selectedMedia = QualitySelectionForMedia(manifest.media, ref avaliableBitrates, level < 1);

            // Quality selection for alternative media
            selectedMediaAlt = QualitySelectionForMedia(manifest.alternativeMedia, ref avaliableAlt, level < 1, true);

            if (selectedMedia == null)
            {
                selectedMedia = manifest.media[0];
            }

            // check for multi-level manifest
            if (!string.IsNullOrEmpty(selectedMedia.href))
            {
                string nestedManifestUrl = URL.getAbsoluteUrl(manifest.baseURL, selectedMedia.href);
                baseUrl       = URL.ExtractBaseUrl(nestedManifestUrl);
                nestedBitrate = selectedMedia.bitrate;
                selectedMedia = null;
                GetManifestAndSelectMedia(nestedManifestUrl, nestedBitrate, level + 1);
                return;
            }

            string sQuality = selectedMedia.bitrate.ToString();
            int    n        = Math.Max(0, avaliableBitrates.IndexOf(sQuality));

            avaliableBitrates = avaliableBitrates.Replace(" " + sQuality + " ", " <c:Cyan>" + sQuality + "</c> ");
            Program.Message("Quality Selection:");
            Program.Message("Available:" + avaliableBitrates);
            Program.Message("Selected : <c:Cyan>" + sQuality.PadLeft(n + sQuality.Length - 1));
            if (manifest.alternativeMedia.Count > 0)
            {
                Program.Message("Alternatives:" + avaliableAlt);
                if (selectedMediaAlt != null)
                {
                    string label = selectedMediaAlt.label;
                    n            = avaliableAlt.IndexOf(label);
                    avaliableAlt = avaliableAlt.Replace(" " + label + " ", " <c:Cyan>" + label + "</c> ");
                    Program.Message("Selected    : <c:Cyan>" + label.PadLeft(n + label.Length - 1));
                    // get bootstrap for media from manifest by id
                    if (!string.IsNullOrEmpty(selectedMediaAlt.bootstrapInfo?.id) && (selectedMediaAlt.bootstrapInfo.data == null))
                    {
                        selectedMediaAlt.bootstrapInfo = manifest.bootstrapInfos.Find(i => i.id == selectedMediaAlt.bootstrapInfo.id);
                    }
                }
            }

            // get bootstrap for media from manifest by id
            if (!string.IsNullOrEmpty(selectedMedia.bootstrapInfo?.id) && (selectedMedia.bootstrapInfo.data == null))
            {
                selectedMedia.bootstrapInfo = manifest.bootstrapInfos.Find(i => i.id == selectedMedia.bootstrapInfo.id);
            }

            if (selectedMedia.bootstrapInfo == null)
            {
                throw new InvalidOperationException("No bootstrapInfo for selected media entry");
            }

            if (!Program.fproxy)
            {
                HTTP.notUseProxy = true;
            }

            // Use embedded auth information when available
            int idx = selectedMedia.url.IndexOf('?');

            if (idx > 0)
            {
                auth = selectedMedia.url.Substring(idx);
                selectedMedia.url = selectedMedia.url.Substring(0, idx);
            }

            if (selectedMedia.metadata != null)
            {
                FLVFile.onMetaData = new FLVTagScriptBody(selectedMedia.metadata);
            }

            selectedMedia.AfterUpdateBootstrap += Media_AfterUpdateBootstrap;

            selectedMedia.UpdateBootstrapInfo();

            if (selectedMedia.Bootstrap.live)
            {
                Program.Message("<c:Magenta>[Live stream]");
            }

            if (selectedMediaAlt == selectedMedia)
            {
                selectedMediaAlt = null;
            }

            if (selectedMediaAlt != null)
            {
                selectedMediaAlt.alternate = true;
                // Use embedded auth information when available
                idx = selectedMediaAlt.url.IndexOf('?');
                if (idx > 0)
                {
                    auth = selectedMediaAlt.url.Substring(idx);
                    selectedMediaAlt.url = selectedMediaAlt.url.Substring(0, idx);
                }
                selectedMediaAlt.AfterUpdateBootstrap += Media_AfterUpdateBootstrap;

                selectedMediaAlt.UpdateBootstrapInfo();
            }
        }
Example #8
0
 // Constructor
 public DVRInfo(XmlNodeEx node, string baseURL = "", string idPrefix = "")
 {
     Parse(node, baseURL, idPrefix);
 }
Example #9
0
 public DRMAdditionalHeader(XmlNodeEx node, string baseURL = "", string idPrefix = "")
 {
     Parse(node, baseURL, idPrefix);
 }
Example #10
0
 /// <summary>
 /// Encodes the specified text into an XML format.
 /// </summary>
 /// <param name="text">The text to decode.</param>
 /// <returns>Returns decoded value.</returns>
 public static string Encode(string text)
 {
     return(string.IsNullOrEmpty(text) ? EncodeNullValue : XmlNodeEx.XmlTextEncode(text));
 }