Exemplo n.º 1
0
        private void BuildLocatorsTree()
        {
            // LOCATORS TREE
            IAsset MyAsset = MyContext.Assets.Where(a => a.Id == MyProgram.AssetId).Single();
            var    ismFile = MyAsset.AssetFiles.AsEnumerable().FirstOrDefault(f => f.Name.EndsWith(".ism"));

            if (ismFile != null)
            {
                var locators = MyAsset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);

                var template = new UriTemplate("{contentAccessComponent}/{ismFileName}/manifest");

                TreeViewLocators.BeginUpdate();
                TreeViewLocators.Nodes.Clear();
                foreach (ILocator locator in locators)
                {
                    Color  colornode;
                    string locatorstatus = string.Empty;

                    switch (AssetInfo.GetPublishedStatusForLocator(locator))
                    {
                    case PublishStatus.PublishedActive:
                        colornode     = Color.Black;
                        locatorstatus = "Active";
                        break;

                    case PublishStatus.PublishedExpired:
                        colornode     = Color.Red;
                        locatorstatus = "Expired";
                        break;

                    case PublishStatus.PublishedFuture:
                        colornode     = Color.Blue;
                        locatorstatus = "Future";
                        break;

                    default:
                        colornode = Color.Black;
                        break;
                    }


                    TreeNode myLocNode = new TreeNode(string.Format("{0} ({1}) {2}", locator.Type.ToString(), locatorstatus, locator.Name));
                    myLocNode.ForeColor = colornode;

                    TreeViewLocators.Nodes.Add(myLocNode);

                    TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode("Locator information"));


                    TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                     string.Format("Name: {0}", locator.Name)
                                                                                                     ));

                    TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                     string.Format("Type: {0}", locator.Type.ToString())
                                                                                                     ));

                    TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                     string.Format("Path: {0}", (locator.Path))
                                                                                                     ));

                    if (locator.StartTime != null)
                    {
                        TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                         string.Format("Start time: {0}", (((DateTime)locator.StartTime).ToLocalTime().ToString()))
                                                                                                         ));
                    }

                    if (locator.ExpirationDateTime != null)
                    {
                        TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                         string.Format("Expiration date time: {0}", (((DateTime)locator.ExpirationDateTime).ToLocalTime().ToString()))
                                                                                                         ));
                    }

                    TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[0].Nodes.Add(new TreeNode(
                                                                                                     string.Format("ID: {0}", (locator.Id))
                                                                                                     ));

                    if (locator.Type == LocatorType.OnDemandOrigin)
                    {
                        int indexn = 1;

                        if (locator.GetSmoothStreamingUri() != null)
                        {
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode(AssetInfo._smooth));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[indexn].Nodes.Add(new TreeNode(locator.GetSmoothStreamingUri().ToString()));
                            // legacy smooth streaming without repeat tag (manifest v2.0)
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode(AssetInfo._smooth_legacy));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[indexn + 1].Nodes.Add(new TreeNode(AssetInfo.GetSmoothLegacy(locator.GetSmoothStreamingUri().ToString())));
                            indexn = indexn + 2;
                        }
                        if (locator.GetMpegDashUri() != null)
                        {
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode(AssetInfo._dash));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[indexn].Nodes.Add(new TreeNode(locator.GetMpegDashUri().ToString()));
                            indexn++;
                        }
                        if (locator.GetHlsUri() != null)
                        {
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode(AssetInfo._hls_v4));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[indexn].Nodes.Add(new TreeNode(locator.GetHlsUri().ToString()));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes.Add(new TreeNode(AssetInfo._hls_v3));
                            TreeViewLocators.Nodes[MyAsset.Locators.IndexOf(locator)].Nodes[indexn + 1].Nodes.Add(new TreeNode(locator.GetHlsUri().ToString().Replace("format=m3u8-aapl", "format=m3u8-aapl-v3")));
                            indexn = indexn + 2;
                        }
                    }
                }
                TreeViewLocators.EndUpdate();
            }
        }
Exemplo n.º 2
0
        private StringBuilder GetStats()
        {
            StringBuilder sb = new StringBuilder();

            if (SelectedAssets.Count > 0)
            {
                // Asset Stats
                foreach (IAsset theAsset in SelectedAssets)
                {
                    string MyAssetType  = AssetInfo.GetAssetType(theAsset);
                    bool   bfileinasset = (theAsset.AssetFiles.Count() == 0) ? false : true;
                    long   size         = -1;
                    if (bfileinasset)
                    {
                        size = 0;
                        foreach (IAssetFile file in theAsset.AssetFiles)
                        {
                            size += file.ContentFileSize;
                        }
                    }
                    sb.AppendLine("Asset Name        : " + theAsset.Name);
                    sb.AppendLine("Asset Type        : " + theAsset.AssetType);
                    sb.AppendLine("Asset Id          : " + theAsset.Id);
                    sb.AppendLine("Alternate ID      : " + theAsset.AlternateId);
                    if (size != -1)
                    {
                        sb.AppendLine("Size              : " + FormatByteSize(size));
                    }
                    sb.AppendLine("State             : " + theAsset.State);
                    sb.AppendLine("Created           : " + theAsset.Created.ToLongDateString() + " " + theAsset.Created.ToLongTimeString());
                    sb.AppendLine("Last Modified     : " + theAsset.LastModified.ToLongDateString() + " " + theAsset.LastModified.ToLongTimeString());
                    sb.AppendLine("Creations Options : " + theAsset.Options);

                    if (theAsset.State != AssetState.Deleted)
                    {
                        sb.AppendLine("IsStreamable      : " + theAsset.IsStreamable);
                        sb.AppendLine("SupportsDynEnc    : " + theAsset.SupportsDynamicEncryption);
                        sb.AppendLine("Uri               : " + theAsset.Uri.ToString());
                        sb.AppendLine("");
                        sb.AppendLine("Storage Name      : " + theAsset.StorageAccountName);
                        sb.AppendLine("Storage Bytes used: " + FormatByteSize(theAsset.StorageAccount.BytesUsed));
                        sb.AppendLine("Storage IsDefault : " + theAsset.StorageAccount.IsDefault);
                        sb.AppendLine("");

                        foreach (IAsset p_asset in theAsset.ParentAssets)
                        {
                            sb.AppendLine("Parent asset Name : " + p_asset.Name);
                            sb.AppendLine("Parent asset Id   : " + p_asset.Id);
                        }
                        sb.AppendLine("");
                        foreach (IContentKey key in theAsset.ContentKeys)
                        {
                            sb.AppendLine("Content key       : " + key.Name);
                            sb.AppendLine("Content key Id    : " + key.Id);
                            sb.AppendLine("Content key Type  : " + key.ContentKeyType);
                        }
                        sb.AppendLine("");
                        foreach (var pol in theAsset.DeliveryPolicies)
                        {
                            sb.AppendLine("Deliv policy Name : " + pol.Name);
                            sb.AppendLine("Deliv policy Id   : " + pol.Id);
                            sb.AppendLine("Deliv policy Type : " + pol.AssetDeliveryPolicyType);
                            sb.AppendLine("Deliv pol Protocol: " + pol.AssetDeliveryProtocol);
                        }
                        sb.AppendLine("");

                        foreach (IAssetFile fileItem in theAsset.AssetFiles)
                        {
                            if (fileItem.IsPrimary)
                            {
                                sb.AppendLine("Primary");
                            }
                            sb.AppendLine("Name                 : " + fileItem.Name);
                            sb.AppendLine("Id                   : " + fileItem.Id);
                            sb.AppendLine("File size            : " + fileItem.ContentFileSize + " Bytes");
                            sb.AppendLine("Mime type            : " + fileItem.MimeType);
                            sb.AppendLine("Init vector          : " + fileItem.InitializationVector);
                            sb.AppendLine("Created              : " + fileItem.Created);
                            sb.AppendLine("Last modified        : " + fileItem.LastModified);
                            sb.AppendLine("Encrypted            : " + fileItem.IsEncrypted);
                            sb.AppendLine("EncryptionScheme     : " + fileItem.EncryptionScheme);
                            sb.AppendLine("EncryptionVersion    : " + fileItem.EncryptionVersion);
                            sb.AppendLine("Encryption key id    : " + fileItem.EncryptionKeyId);
                            sb.AppendLine("InitializationVector : " + fileItem.InitializationVector);
                            sb.AppendLine("ParentAssetId        : " + fileItem.ParentAssetId);

                            sb.AppendLine("==============");
                            sb.AppendLine("");
                        }

                        foreach (ILocator locator in theAsset.Locators)
                        {
                            sb.AppendLine("Locator Name      : " + locator.Name);
                            sb.AppendLine("Locator Type      : " + locator.Type.ToString());
                            sb.AppendLine("Locator Id        : " + locator.Id);
                            sb.AppendLine("Locator Path      : " + locator.Path);
                            if (locator.StartTime != null)
                            {
                                sb.AppendLine("Start Time        : " + ((DateTime)locator.StartTime).ToLongDateString() + " " + ((DateTime)locator.StartTime).ToLongTimeString());
                            }
                            if (locator.ExpirationDateTime != null)
                            {
                                sb.AppendLine("Expiration Time   : " + ((DateTime)locator.ExpirationDateTime).ToLongDateString() + " " + ((DateTime)locator.ExpirationDateTime).ToLongTimeString());
                            }
                            sb.AppendLine("");

                            if (locator.Type == LocatorType.OnDemandOrigin)
                            {
                                sb.AppendLine(_prog_down_http + " : ");
                                foreach (IAssetFile IAF in theAsset.AssetFiles)
                                {
                                    sb.AppendLine(locator.Path + IAF.Name);
                                }
                                sb.AppendLine("");

                                if (MyAssetType.StartsWith("HLS")) // It is a static HLS asset, so let's propose only the standard HLS V3 locator
                                {
                                    sb.AppendLine(AssetInfo._hls_v3 + " : ");
                                    sb.AppendLine(locator.GetHlsUri().ToString().Replace("format=m3u8-aapl", "format=m3u8-aapl-v3"));
                                    sb.AppendLine("");
                                }
                                else // It's not Static HLS
                                {
                                    if (locator.GetSmoothStreamingUri() != null)
                                    {
                                        sb.AppendLine(AssetInfo._smooth + " : ");
                                        sb.AppendLine(locator.GetSmoothStreamingUri().ToString());
                                        sb.AppendLine(AssetInfo._smooth_legacy + " : ");
                                        sb.AppendLine(AssetInfo.GetSmoothLegacy(locator.GetSmoothStreamingUri().ToString()));
                                    }

                                    if (locator.GetMpegDashUri() != null)
                                    {
                                        sb.AppendLine(AssetInfo._dash + " : ");
                                        sb.AppendLine(locator.GetMpegDashUri().ToString());
                                    }

                                    if (locator.GetHlsUri() != null)
                                    {
                                        sb.AppendLine(AssetInfo._hls_v4 + " : ");
                                        sb.AppendLine(locator.GetHlsUri().ToString());
                                        sb.AppendLine(AssetInfo._hls_v3 + " : ");
                                        sb.AppendLine(locator.GetHlsv3Uri().ToString());
                                        sb.AppendLine("");
                                    }
                                }
                            }
                            if (locator.Type == LocatorType.Sas)
                            {
                                List <Uri> ProgressiveDownloadUris;
                                IEnumerable <IAssetFile> MyAssetFiles;
                                sb.AppendLine(AssetInfo._prog_down_https + " : ");
                                MyAssetFiles = theAsset.AssetFiles.ToList();
                                // Generate the Progressive Download URLs for each file.
                                ProgressiveDownloadUris = MyAssetFiles.Select(af => af.GetSasUri(locator)).ToList();
                                ProgressiveDownloadUris.ForEach(uri => sb.AppendLine(uri.ToString()));
                            }
                            sb.AppendLine("");
                            sb.AppendLine("==============================================================================");
                            sb.AppendLine("");
                        }
                    }
                    sb.AppendLine("");
                    sb.AppendLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                    sb.AppendLine("");
                }
            }
            return(sb);
        }