private void CheckListArchiveBlobs(Dictionary<string, string> storagekeys, IAsset SourceAsset, AssetInfo.ManifestSegmentsResponse manifestdata) { if (storagekeys.ContainsKey(SourceAsset.StorageAccountName)) { TextBoxLogWriteLine("Starting the integrity check for asset '{0}'.", SourceAsset.Name); bool Error = false; bool codeIssue = false; int nbErrorsAudioManifest = 0; int nbErrorsVideoManifest = 0; // Video segments in manifest TextBoxLogWriteLine("Checking video track segments in manifest..."); int index = 0; foreach (var seg in manifestdata.videoSegments) { if (seg.timestamp_mismatch) { if (nbErrorsVideoManifest < 10) { TextBoxLogWriteLine("Warning: Overlap or gap issue in video track. Timestamp {0} calculation mismatch in manifest, index {1}", seg.timestamp, index, true); Error = true; } nbErrorsVideoManifest++; } index++; } if (nbErrorsVideoManifest >= 10) { TextBoxLogWriteLine("Warning: Overlap or gap issue in video track. {0} more errors.", nbErrorsVideoManifest - 10, true); } // Audio segments in manifest TextBoxLogWriteLine("Checking audio track segments in manifest..."); index = 0; int a_index = 0; foreach (var audiotrack in manifestdata.audioSegments) { foreach (var seg in audiotrack) { if (seg.timestamp_mismatch) { if (nbErrorsAudioManifest < 10) { TextBoxLogWriteLine("Warning: Overlap or gap issue in audio track {0}. Timestamp {1} calculation mismatch in manifest, index {2}", a_index, seg.timestamp, index, true); Error = true; } nbErrorsAudioManifest++; } index++; } if (nbErrorsAudioManifest >= 10) { TextBoxLogWriteLine("Warning: Overlap or gap issue in audio track {0}. {1} more errors.", a_index, nbErrorsAudioManifest - 10, true); } a_index++; } TextBoxLogWriteLine("Checking blobs in storage..."); // let's get cloudblobcontainer for source CloudStorageAccount SourceCloudStorageAccount = new CloudStorageAccount(new StorageCredentials(SourceAsset.StorageAccountName, storagekeys[SourceAsset.StorageAccountName]), _credentials.ReturnStorageSuffix(), true); var SourceCloudBlobClient = SourceCloudStorageAccount.CreateCloudBlobClient(); IAccessPolicy readpolicy = _context.AccessPolicies.Create("readpolicy", TimeSpan.FromDays(1), AccessPermissions.Read); ILocator SourceLocator = _context.Locators.CreateLocator(LocatorType.Sas, SourceAsset, readpolicy); try { // Get the asset container URI and copy blobs from mediaContainer to assetContainer. Uri sourceUri = new Uri(SourceLocator.Path); CloudBlobContainer SourceCloudBlobContainer = SourceCloudBlobClient.GetContainerReference(sourceUri.Segments[1]); //var assetFilesLiveFolders = SourceAsset.AssetFiles.ToList().Where(af => af.Name.StartsWith("audio_") || af.Name.StartsWith("video_") || af.Name.StartsWith("scte35_")); List<CloudBlobDirectory> ListDirectories = new List<CloudBlobDirectory>(); var mediablobs = SourceCloudBlobContainer.ListBlobs(); if (mediablobs.ToList().Any(b => b.GetType() == typeof(CloudBlobDirectory))) // there are fragblobs { foreach (var blob in mediablobs) { if (blob.GetType() == typeof(CloudBlobDirectory)) { CloudBlobDirectory blobdir = (CloudBlobDirectory)blob; ListDirectories.Add(blobdir); TextBoxLogWriteLine("Fragblobs detected (live archive) '{0}'.", blobdir.Prefix); } } // let's check the presence of all audio_ and video_ directories var audiodir = ListDirectories.Where(d => d.Prefix.StartsWith("audio_")); var videodir = ListDirectories.Where(d => d.Prefix.StartsWith("video_")).Select(d => int.Parse(d.Prefix.Substring(6, d.Prefix.Length - 7))); if (videodir.Count() != manifestdata.videoBitrates.Count) { TextBoxLogWriteLine("Warning: {0} video tracks in the manifest but {1} video directories in storage", manifestdata.videoBitrates.Count(), videodir.Count(), true); Error = true; } if (audiodir.Count() != manifestdata.audioBitrates.GetLength(0)) { TextBoxLogWriteLine("Warning: {0} audio tracks in the manifest but {1} audio directories in storage", manifestdata.audioBitrates.GetLength(0), audiodir.Count(), true); Error = true; } var except = videodir.Except(manifestdata.videoBitrates); if (except.Count() > 0) { TextBoxLogWriteLine("Warning: Some video directories in storage are not referenced as bitrate in the manifest. Bitrates : {0}", string.Join(",", except), true); Error = true; } var exceptb = manifestdata.videoBitrates.Except(videodir); if (exceptb.Count() > 0) { TextBoxLogWriteLine("Issue: Some bitrates in manifest cannot be found in storage as video directories. Bitrates : {0}", string.Join(",", exceptb), true); Error = true; } // let's check the fragblobs foreach (var dir in ListDirectories) { if (dir.Prefix.StartsWith("audio_") || dir.Prefix.StartsWith("video_")) { TextBoxLogWriteLine("Checking fragblobs in directory '{0}'....", dir.Prefix); BlobResultSegment blobResultSegment = dir.ListBlobsSegmented(null); var listblobtimestampsTemp = blobResultSegment.Results.Select(b => b.Uri.LocalPath).ToList(); while (blobResultSegment.ContinuationToken != null) { TextBoxLogWriteLine("Checking fragblobs in directory '{0}' ({1} segments retrieved...)", dir.Prefix, listblobtimestampsTemp.Count); blobResultSegment = dir.ListBlobsSegmented(blobResultSegment.ContinuationToken); listblobtimestampsTemp.AddRange(blobResultSegment.Results.Select(b => b.Uri.LocalPath)); } TextBoxLogWriteLine("Checking fragblobs in directory '{0}' ({1} segments retrieved)", dir.Prefix, listblobtimestampsTemp.Count); var listblobtimestamps = listblobtimestampsTemp.Where(b => System.IO.Path.GetFileName(b) != "header").Select(b => ulong.Parse(System.IO.Path.GetFileName(b))).OrderBy(t => t).ToList(); List<AssetInfo.ManifestSegmentData> manifestdatacurrenttrack; if (dir.Prefix.StartsWith("video_")) { manifestdatacurrenttrack = manifestdata.videoSegments; } else // audio { if (dir.Prefix.StartsWith("audio__")) // let's get the index of audio track if it exists in directory name { var split = dir.Prefix.Split('_'); manifestdatacurrenttrack = manifestdata.audioSegments[int.Parse(split[2])].ToList(); } else { manifestdatacurrenttrack = manifestdata.audioSegments[0].ToList(); } } var timestampsinmanifest = manifestdatacurrenttrack.Select(a => a.timestamp).ToList(); var except2 = listblobtimestamps.Except(timestampsinmanifest); const int maxSegDisplayed = 20; if (except2.Count() > 0) { int count = except2.Count(); TextBoxLogWriteLine("Information: {0} segments in directory {1} are not in the manifest. This could occur if live is running. Segments with timestamp: {2}", count, dir.Prefix, string.Join(",", except2.Take(maxSegDisplayed)) + ((count > maxSegDisplayed) ? "..." : ""), true); } var except3 = timestampsinmanifest.Except(listblobtimestamps); if (except3.Count() > 0) { int count = except3.Count(); TextBoxLogWriteLine("Issue: {0} segments in manifest are not in directory '{1}'. Segments with timestamp: {2}", count, dir.Prefix, string.Join(",", except3.Take(maxSegDisplayed)) + ((count > maxSegDisplayed) ? "..." : ""), true); Error = true; } if (listblobtimestamps.Count < manifestdatacurrenttrack.Count) // mising blob in storage (header file) { TextBoxLogWriteLine("Issue: {0} segments in the manifest but only {1} segments in directory '{2}'", manifestdatacurrenttrack.Count, listblobtimestamps.Count, dir.Prefix, true); Error = true; } else if (manifestdatacurrenttrack.Count > 0) { index = 0; // list timestamps from blob ulong timestampinblob; foreach (var seg in manifestdatacurrenttrack) { timestampinblob = listblobtimestamps[index]; if (timestampinblob != seg.timestamp && !seg.calculated) { TextBoxLogWriteLine("Issue: Timestamp {0} in blob is different from defined timestamp {1} in manifest, in directory '{2}', index {3}", timestampinblob, seg.timestamp, dir.Prefix, index, true); Error = true; break; } else if (timestampinblob != seg.timestamp && seg.calculated) { TextBoxLogWriteLine("Issue: Timestamp {0} in blob is different from calculated timestamp {1} in manifest, in directory '{2}', index {3}", timestampinblob, seg.timestamp, dir.Prefix, index, true); Error = true; break; } index++; } } } } } } catch (Exception ex) { TextBoxLogWriteLine("Error when analyzing the archive.", true); TextBoxLogWriteLine(ex); codeIssue = true; } try { SourceLocator.Delete(); readpolicy.Delete(); } catch { } if (codeIssue) { TextBoxLogWriteLine("End of integrity check for asset '{0}'. Code fails.", SourceAsset.Name); } else if (Error) { TextBoxLogWriteLine("End of integrity check for asset '{0}'. Error(s) detected.", SourceAsset.Name); } else { TextBoxLogWriteLine("End of integrity check for asset '{0}'. No error detected.", SourceAsset.Name); } } else { TextBoxLogWriteLine("Error storage key not found for asset '{0}'.", SourceAsset.Name, true); } }
private void DoCopyOutputURLAssetOrProgramToClipboard() { IAsset asset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault(); if (asset != null) { AssetInfo AI = new AssetInfo(asset); IEnumerable<Uri> ValidURIs = AI.GetValidURIs(); if (ValidURIs != null && ValidURIs.FirstOrDefault() != null) { string url = ValidURIs.FirstOrDefault().AbsoluteUri; System.Windows.Forms.Clipboard.SetText(url); } else { MessageBox.Show(string.Format("No valid URL is available for asset '{0}'.", asset.Name), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void WorkerAnalyzeAssets_DoWork(object sender, DoWorkEventArgs e) { Debug.WriteLine("WorkerAnalyzeAssets_DoWork"); BackgroundWorker worker = sender as BackgroundWorker; IAsset asset = null; PublishStatus SASLoc; PublishStatus OrigLoc; var listae = _MyObservAsset.OrderBy(a => cacheAssetentries.ContainsKey(a.Id)).ToList(); // as priority, assets not yet analyzed foreach (AssetEntry AE in listae) { try { asset = _context.Assets.Where(a => a.Id == AE.Id).FirstOrDefault(); if (asset != null) { AssetInfo myAssetInfo = new AssetInfo(asset); AE.Name = asset.Name; AE.LastModified = asset.LastModified.ToLocalTime().ToString("G"); SASLoc = myAssetInfo.GetPublishedStatus(LocatorType.Sas); OrigLoc = myAssetInfo.GetPublishedStatus(LocatorType.OnDemandOrigin); AssetBitmapAndText assetBitmapAndText = ReturnStaticProtectedBitmap(asset); AE.StaticEncryption = assetBitmapAndText.bitmap; AE.StaticEncryptionMouseOver = assetBitmapAndText.MouseOverDesc; assetBitmapAndText = BuildBitmapPublication(asset); AE.Publication = assetBitmapAndText.bitmap; AE.PublicationMouseOver = assetBitmapAndText.MouseOverDesc; AE.Type = AssetInfo.GetAssetType(asset); AE.SizeLong = myAssetInfo.GetSize(); AE.Size = AssetInfo.FormatByteSize(AE.SizeLong); assetBitmapAndText = BuildBitmapDynEncryption(asset); AE.DynamicEncryption = assetBitmapAndText.bitmap; AE.DynamicEncryptionMouseOver = assetBitmapAndText.MouseOverDesc; DateTime? LocDate = asset.Locators.Any() ? (DateTime?)asset.Locators.Min(l => l.ExpirationDateTime).ToLocalTime() : null; AE.LocatorExpirationDate = LocDate.HasValue ? ((DateTime)LocDate).ToLocalTime().ToString() : null; AE.LocatorExpirationDateWarning = LocDate.HasValue ? (LocDate < DateTime.Now.ToLocalTime()) : false; assetBitmapAndText = BuildBitmapAssetFilters(asset); AE.Filters = assetBitmapAndText.bitmap; AE.FiltersMouseOver = assetBitmapAndText.MouseOverDesc; cacheAssetentries[asset.Id] = AE; // let's put it in cache (or update the cache) } } catch // in some case, we have a timeout on Assets.Where... { } if (worker.CancellationPending == true) { e.Cancel = true; return; } } this.BeginInvoke(new Action(() => this.Refresh()), null); }
public Subclipping(AMSClientV3 context, List <Asset> assetlist, Mainform mainform) { InitializeComponent(); this.Icon = Bitmaps.Azure_Explorer_ico; _amsClientV3 = context; _parentAssetManifestData = new ManifestTimingData(); _selectedAssets = assetlist; _mainform = mainform; buttonShowEDL.Initialize(); buttonShowEDL.EDLChanged += ButtonShowEDL_EDLChanged; buttonShowEDL.Offset = new TimeSpan(0); // temp locator creation if (_selectedAssets.Count == 1 && MessageBox.Show("A temporary clear locator of 1 hour is going to be created to stream the content in the player. It will be deleted when you close the subclipping window.", "Locator creation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { try { _tempStreamingLocator = Task.Run(() => AssetInfo.CreateTemporaryOnDemandLocatorAsync(_selectedAssets.First(), _amsClientV3)).GetAwaiter().GetResult(); } catch { } } if (_selectedAssets.Count == 1 && _selectedAssets.FirstOrDefault() != null) // one asset only { var myAsset = assetlist.FirstOrDefault(); textBoxAssetName.Text = myAsset.Name; // let's try to read asset timing XDocument manifest = null; try { manifest = Task.Run(() => AssetInfo.TryToGetClientManifestContentAsABlobAsync(myAsset, _amsClientV3)).GetAwaiter().GetResult(); } catch { } if (manifest == null) { try { manifest = Task.Run(() => AssetInfo.TryToGetClientManifestContentUsingStreamingLocatorAsync(myAsset, _amsClientV3, _tempStreamingLocator?.Name)).GetAwaiter().GetResult(); } catch { } } if (manifest != null) { _parentAssetManifestData = AssetInfo.GetManifestTimingData(manifest); } labelDiscountinuity.Visible = _parentAssetManifestData.DiscontinuityDetected; if (!_parentAssetManifestData.Error) // we were able to read asset timings and not live { _timescale = timeControlStart.TimeScale = timeControlEnd.TimeScale = _parentAssetManifestData.TimeScale; timeControlStart.ScaledFirstTimestampOffset = timeControlEnd.ScaledFirstTimestampOffset = _parentAssetManifestData.TimestampOffset; buttonShowEDL.Offset = timeControlStart.GetOffSetAsTimeSpan(); textBoxOffset.Text = _parentAssetManifestData.TimestampOffset.ToString(); labelOffset.Visible = textBoxOffset.Visible = true; textBoxFilterTimeScale.Text = _timescale.ToString(); textBoxFilterTimeScale.Visible = labelAssetTimescale.Visible = true; timeControlStart.Max = timeControlEnd.Max = _parentAssetManifestData.AssetDuration; labelassetduration.Visible = textBoxAssetDuration.Visible = true; textBoxAssetDuration.Text = timeControlStart.Max.ToString(@"d\.hh\:mm\:ss") + (_parentAssetManifestData.IsLive ? " (LIVE)" : ""); // let set duration and active track bat timeControlStart.TotalDuration = timeControlEnd.TotalDuration = _parentAssetManifestData.AssetDuration; timeControlStart.DisplayTrackBar = true; timeControlEnd.DisplayTrackBar = true; timeControlEnd.SetTimeStamp(timeControlEnd.Max); } else // one asset but not able to read asset timings { timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale; timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue; //timeControlEnd.SetTimeStamp(timeControlEnd.Max); } } else // several assets { groupBoxTrimming.Enabled = panelAssetInfo.Visible = false; // no trimming and no asset info radioButtonAssetFilter.Enabled = false; // no asset filter option timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale; timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue; //timeControlEnd.SetTimeStamp(timeControlEnd.Max); } }
private void WorkerAnalyzeAssets_DoWork(object sender, DoWorkEventArgs e) { Debug.WriteLine("WorkerAnalyzeAssets_DoWork"); BackgroundWorker worker = sender as BackgroundWorker; IAsset asset; PublishStatus SASLoc; PublishStatus OrigLoc; int i = 0; foreach (AssetEntry AE in _MyObservAsset) { asset = null; try { asset = _context.Assets.Where(a => a.Id == AE.Id).FirstOrDefault(); if (asset != null) { AssetInfo myAssetInfo = new AssetInfo(asset); SASLoc = myAssetInfo.GetPublishedStatus(LocatorType.Sas); OrigLoc = myAssetInfo.GetPublishedStatus(LocatorType.OnDemandOrigin); AssetBitmapAndText assetBitmapAndText = ReturnStaticProtectedBitmap(asset); AE.StaticEncryption = assetBitmapAndText.bitmap; AE.StaticEncryptionMouseOver = assetBitmapAndText.MouseOverDesc; assetBitmapAndText = BuildBitmapPublication(asset); AE.Publication = assetBitmapAndText.bitmap; AE.PublicationMouseOver = assetBitmapAndText.MouseOverDesc; AE.Type = AssetInfo.GetAssetType(asset); AE.SizeLong = myAssetInfo.GetSize(); AE.Size = AssetInfo.FormatByteSize(AE.SizeLong); assetBitmapAndText = BuildBitmapDynEncryption(asset); AE.DynamicEncryption = assetBitmapAndText.bitmap; AE.DynamicEncryptionMouseOver = assetBitmapAndText.MouseOverDesc; DateTime? LocDate = asset.Locators.Any() ? (DateTime?)asset.Locators.Min(l => l.ExpirationDateTime).ToLocalTime() : null; AE.LocatorExpirationDate = LocDate; AE.LocatorExpirationDateWarning = (LocDate < DateTime.Now); assetBitmapAndText = BuildBitmapAssetFilters(asset); AE.Filters = assetBitmapAndText.bitmap; AE.FiltersMouseOver = assetBitmapAndText.MouseOverDesc; i++; if (i % 5 == 0) { this.BeginInvoke(new Action(() => this.Refresh()), null); } } } catch // in some case, we have a timeout on Assets.Where... { } if (worker.CancellationPending == true) { e.Cancel = true; return; } } this.BeginInvoke(new Action(() => this.Refresh()), null); }
private void DoCopyOutputURLAssetOrProgramToClipboard() { IAsset asset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault(); if (asset != null) { AssetInfo AI = new AssetInfo(asset); IEnumerable<Uri> ValidURIs = AI.GetValidURIs(); if (ValidURIs != null && ValidURIs.FirstOrDefault() != null) { string url = ValidURIs.FirstOrDefault().AbsoluteUri; if (_context.StreamingEndpoints.Count() > 1 || (_context.StreamingEndpoints.FirstOrDefault() != null && _context.StreamingEndpoints.FirstOrDefault().CustomHostNames.Count > 0) || _context.Filters.Count() > 0 || (asset.AssetFilters.Count() > 0)) { var form = new ChooseStreamingEndpoint(_context, asset, url); if (form.ShowDialog() == DialogResult.OK) { url = AssetInfo.RW(new Uri(url), form.SelectStreamingEndpoint, form.SelectedFilters, form.ReturnHttps, form.ReturnSelectCustomHostName, form.ReturnStreamingProtocol, form.ReturnHLSAudioTrackName, form.ReturnHLSNoAudioOnlyMode).ToString(); } else { return; } } var tokenDisplayForm = new EditorXMLJSON("Output URL", url, false, false, false); tokenDisplayForm.Display(); } else { MessageBox.Show(string.Format("No valid URL is available for asset '{0}'.", asset.Name), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void DoAssetStats() { AssetInfo MyAssetReport = new AssetInfo(myAsset); MyAssetReport.CopyStatsToClipBoard(); }
private void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { label.Text = string.Format(label.Text, _asset.Name); // SE List IStreamingEndpoint BestSE = AssetInfo.GetBestStreamingEndpoint(_context); foreach (var se in _context.StreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se)), se.Id + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (var custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Id + "|" + custom)); } } // Filters // asset filters var afilters = _asset.AssetFilters.ToList(); var afiltersnames = afilters.Select(a => a.Name).ToList(); afilters.ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // global filters _context.Filters.ToList().ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > global filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); if (_playertype == PlayerType.DASHIFRefPlayer) { radioButtonDASH.Checked = true; } comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty)); if (_displayBrowserSelection) { // let's add the browser options to lplayback the content (IE, Edge, Chrome...) if (IsWindows10()) { comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1])); } comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1])); comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1])); comboBoxBrowser.SelectedIndex = 0; } comboBoxBrowser.Visible = _displayBrowserSelection; UpdatePreviewUrl(); }
private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime) { int index = 1; xlWorkSheet.Cells[row, index++] = asset.Name; xlWorkSheet.Cells[row, index++] = asset.Id; xlWorkSheet.Cells[row, index++] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified; xlWorkSheet.Cells[row, index++] = AssetInfo.GetAssetType(asset); xlWorkSheet.Cells[row, index++] = AssetInfo.GetSize(asset); int backindex = index; var urls = AssetInfo.GetURIs(asset); if (urls != null) { foreach (var url in urls) { xlWorkSheet.Cells[row, index++] = url != null?url.ToString() : string.Empty; } } index = backindex + _context.StreamingEndpoints.Count(); var streamlocators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); if (streamlocators.Any()) { if (localtime) { xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime).ToLocalTime(); } else { xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime); } } else { xlWorkSheet.Cells[row, index++] = string.Empty; } // SAS locator var saslocators = asset.Locators.Where(l => l.Type == LocatorType.Sas); var saslocator = saslocators.ToList().OrderByDescending(l => l.ExpirationDateTime).FirstOrDefault(); if (saslocator != null && asset.AssetFiles.Count() > 0) { var ProgressiveDownloadUri = asset.AssetFiles.ToList().OrderByDescending(af => af.ContentFileSize).FirstOrDefault().GetSasUri(saslocator); xlWorkSheet.Cells[row, index++] = ProgressiveDownloadUri.AbsoluteUri; if (localtime) { xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime.ToLocalTime(); } else { xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime; } } else { xlWorkSheet.Cells[row, index++] = string.Empty; xlWorkSheet.Cells[row, index++] = string.Empty; } if (detailed) { xlWorkSheet.Cells[row, index++] = asset.AlternateId; xlWorkSheet.Cells[row, index++] = asset.StorageAccount.Name; xlWorkSheet.Cells[row, index++] = asset.Uri == null ? string.Empty : asset.Uri.ToString(); var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin); xlWorkSheet.Cells[row, index++] = streamingloc.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null; } // SAS xlWorkSheet.Cells[row, index++] = saslocators.Count(); if (localtime) { xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime).ToLocalTime() : null; xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime).ToLocalTime() : null; } else { xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime) : null; xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime) : null; } xlWorkSheet.Cells[row, index++] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString(); xlWorkSheet.Cells[row, index++] = asset.AssetFilters.Count().ToString(); } }
private async void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { DpiUtils.InitPerMonitorDpi(this); label.Text = string.Format(label.Text, _asset.Name); // SE List await _amsClient.RefreshTokenIfNeededAsync(); // StreamingEndpoint BestSE = Task.Run(async () => await AssetInfo.GetBestStreamingEndpointAsync(_client)).Result; StreamingEndpoint BestSE = await AssetInfo.GetBestStreamingEndpointAsync(_amsClient); var myStreamingEndpoints = Task.Run(() => _amsClient.AMSclient.StreamingEndpoints.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName)).GetAwaiter().GetResult(); foreach (StreamingEndpoint se in myStreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se)), se.Name + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (string custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Name + "|" + custom)); } } // Filters // asset filters List <AssetFilter> assetFilters = new List <AssetFilter>(); IPage <AssetFilter> assetFiltersPage = await _amsClient.AMSclient.AssetFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName, _asset.Name); while (assetFiltersPage != null) { assetFilters.AddRange(assetFiltersPage); if (assetFiltersPage.NextPageLink != null) { assetFiltersPage = await _amsClient.AMSclient.AssetFilters.ListNextAsync(assetFiltersPage.NextPageLink); } else { assetFiltersPage = null; } } List <string> afiltersnames = assetFilters.Select(a => a.Name).ToList(); listViewFilters.BeginUpdate(); assetFilters.ToList().ForEach(f => { ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // account filters List <AccountFilter> acctFilters = new List <AccountFilter>(); IPage <AccountFilter> acctFiltersPage = await _amsClient.AMSclient.AccountFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName); while (acctFiltersPage != null) { acctFilters.AddRange(acctFiltersPage); if (acctFiltersPage.NextPageLink != null) { acctFiltersPage = await _amsClient.AMSclient.AccountFilters.ListNextAsync(acctFiltersPage.NextPageLink); } else { acctFiltersPage = null; } } acctFilters.ToList().ForEach(f => { ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > account filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); listViewFilters.EndUpdate(); if (_playertype == PlayerType.DASHIFRefPlayer) { radioButtonDASHCSF.Checked = true; } comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty)); if (_displayBrowserSelection) { // let's add the browser options to lplayback the content (IE, Edge, Chrome...) if (IsWindows10()) { comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1])); } comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1])); comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1])); comboBoxBrowser.SelectedIndex = 0; } comboBoxBrowser.Visible = _displayBrowserSelection; UpdatePreviewUrl(); FillLocatorComboInPolicyTab(); }
private void buttonSelectFolder_Click(object sender, EventArgs e) { CommonOpenFileDialog openFolderDialog = new CommonOpenFileDialog() { IsFolderPicker = true }; if (openFolderDialog.ShowDialog() == CommonFileDialogResult.Ok) { if (string.IsNullOrWhiteSpace(textBoxFolderPath.Text)) { textBoxFolderPath.Text = openFolderDialog.FileName + @"_Encrypted"; } var folders = Directory.GetDirectories(openFolderDialog.FileName).ToList(); var files = Directory.GetFiles(openFolderDialog.FileName).ToList(); if (files.Count > 0) { var listpb = AssetInfo.ReturnFilenamesWithProblem(files); if (listpb.Count > 0) { MessageBox.Show(AssetInfo.FileNameProblemMessage(listpb), AMSExplorer.Properties.Resources.AMSLogin_buttonExport_Click_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Guid g = Guid.NewGuid(); foreach (var file in files) { assetFiles.Add(new BulkAssetFile() { AssetGuid = g, AssetName = Path.GetFileName(openFolderDialog.FileName), FileName = file }); } } } folders.RemoveAll(f => Directory.GetFiles(f).Count() == 0); // we remove all folder with 0 file in it at the root foreach (var folder in folders) { var filesinfolder = Directory.GetFiles(folder).ToList(); if (filesinfolder.Count > 0) { var listpb = AssetInfo.ReturnFilenamesWithProblem(filesinfolder); if (listpb.Count > 0) { MessageBox.Show(AssetInfo.FileNameProblemMessage(listpb), AMSExplorer.Properties.Resources.AMSLogin_buttonExport_Click_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Guid g = Guid.NewGuid(); string thisassetname = Path.GetFileNameWithoutExtension(filesinfolder[0]); foreach (var file in filesinfolder) { assetFiles.Add(new BulkAssetFile() { AssetGuid = g, AssetName = Path.GetFileName(folder), FileName = file }); } } } } ReindexAssetListAndDoSomeChecks(); } }
public static string CheckSlateFile(string file) // return null if ok. Otherwise, error is the string. { string returnString = null; bool Error = false; FileInfo fileInfo = null; Image fileImage = null; double aspectRatioImage = 0d; try { fileInfo = new FileInfo(file); fileImage = Image.FromFile(file); aspectRatioImage = (double)fileImage.Size.Width / (double)fileImage.Size.Height; } catch { Error = true; returnString = string.Format("Error when accessing the file\n'{0}'.", file); } if (!Error) { if (fileInfo.Extension.ToLower() != Constants.SlateJPGExtension) // file has not an .jpg extension { returnString = string.Format("The file\n'{0}'\nhas not a {1} extension", file, Constants.SlateJPGExtension); } else if (!fileImage.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg)) // file is not a JPEG { returnString = string.Format("The file\n'{0}'\nis not a JPEG file", file); } else if (fileInfo.Length > Constants.maxSlateJPGFileSize) // file size > 3 MB, not ok { returnString = string.Format("The file\n'{0}'\nhas a size of {1} which is larger than {2}", file, AssetInfo.FormatByteSize(fileInfo.Length), AssetInfo.FormatByteSize(Constants.maxSlateJPGFileSize)); } else if (fileImage.Size.Width > Constants.maxSlateJPGHorizontalResolution || fileImage.Size.Height > Constants.maxSlateJPGVerticalResolution) { returnString = string.Format("The file\n'{0}'\nhas a resolution of {1}x{2} which is larger than {3}x{4}", file, fileImage.Size.Width, fileImage.Size.Height, Constants.maxSlateJPGHorizontalResolution, Constants.maxSlateJPGVerticalResolution); } else if (!AreClose(aspectRatioImage, Constants.SlateJPGAspectRatio)) { returnString = string.Format("The file\n'{0}'\nhas an aspect ratio of {1:0.000} which is different from {2:0.000} (16:9)", file, aspectRatioImage, Constants.SlateJPGAspectRatio); } } return(returnString); }
private void LoadWorkflows() // return true if no error or false if partial query was done { this.BeginUpdate(); this.Items.Clear(); // Server side request IAssetFile[] query = new IAssetFile[] { }; if (_context.Files.Count() < 1000000) { try { query = _context.Files.Where(f => ( f.Name.EndsWith(".workflow") )).ToArray(); } catch (Exception ex) { ErrorQuery = Program.GetErrorMessage(ex); } } else // to many files. In that case let's try to look up only the last two months { try { query = _context.Files.Where(f => (f.LastModified > DateTime.UtcNow.AddMonths(-2)) && (f.Name.EndsWith(".workflow")) ).ToArray(); PartialQueryLast2Months = true; } catch (Exception ex) { ErrorQuery = Program.GetErrorMessage(ex); } } if (ErrorQuery == null) { foreach (IAssetFile file in query) { if (file.Asset.AssetFiles.Count() == 1) { ListViewItem item = new ListViewItem(file.Name, 0); item.SubItems.Add(file.LastModified.ToLocalTime().ToString("G")); item.SubItems.Add(AssetInfo.FormatByteSize(file.ContentFileSize)); item.SubItems.Add(file.Asset.Name); item.SubItems.Add(file.Asset.Id); if (_selectedworkflow != null && _selectedworkflow.Id == file.Asset.Id) { item.Selected = true; } this.Items.Add(item); } } } this.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); this.EndUpdate(); }
public Subclipping(CloudMediaContext context, List <IAsset> assetlist, Mainform mainform) { InitializeComponent(); buttonJobOptions.Initialize(context); this.Icon = Bitmaps.Azure_Explorer_ico; _context = context; _parentassetmanifestdata = new ManifestTimingData(); _selectedAssets = assetlist; _mainform = mainform; buttonShowEDL.Initialize(); buttonShowEDL.EDLChanged += ButtonShowEDL_EDLChanged; buttonShowEDL.Offset = new TimeSpan(0); if (_selectedAssets.Count == 1 && _selectedAssets.FirstOrDefault() != null) // one asset only { var myAsset = assetlist.FirstOrDefault(); textBoxAssetName.Text = myAsset.Name; // let's try to read asset timing _parentassetmanifestdata = AssetInfo.GetManifestTimingData(myAsset); if (!_parentassetmanifestdata.Error) // we were able to read asset timings and not live { _timescale = timeControlStart.TimeScale = timeControlEnd.TimeScale = _parentassetmanifestdata.TimeScale; timeControlStart.ScaledFirstTimestampOffset = timeControlEnd.ScaledFirstTimestampOffset = _parentassetmanifestdata.TimestampOffset; buttonShowEDL.Offset = timeControlStart.GetOffSetAsTimeSpan(); textBoxOffset.Text = _parentassetmanifestdata.TimestampOffset.ToString(); labelOffset.Visible = textBoxOffset.Visible = true; textBoxFilterTimeScale.Text = _timescale.ToString(); textBoxFilterTimeScale.Visible = labelAssetTimescale.Visible = true; timeControlStart.Max = timeControlEnd.Max = _parentassetmanifestdata.AssetDuration; labelassetduration.Visible = textBoxAssetDuration.Visible = true; textBoxAssetDuration.Text = timeControlStart.Max.ToString(@"d\.hh\:mm\:ss") + (_parentassetmanifestdata.IsLive ? " (LIVE)" : ""); // let set duration and active track bat timeControlStart.TotalDuration = timeControlEnd.TotalDuration = _parentassetmanifestdata.AssetDuration; timeControlStart.DisplayTrackBar = true; timeControlEnd.DisplayTrackBar = true; timeControlEnd.SetTimeStamp(timeControlEnd.Max); } else // one asset but not able to read asset timings { timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale; timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue; //timeControlEnd.SetTimeStamp(timeControlEnd.Max); } } else // several assets { groupBoxTrimming.Enabled = panelAssetInfo.Visible = false; // no trimming and no asset info radioButtonAssetFilter.Enabled = false; // no asset filter option timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale; timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue; //timeControlEnd.SetTimeStamp(timeControlEnd.Max); } }
private void DoCreateAssetReportEmail() { AssetInfo AR = new AssetInfo(ReturnSelectedAssets()); AR.CreateOutlookMail(); }
public static Uri GetValidOnDemandURI(IAsset asset) { var ai = new AssetInfo(asset); return ai.GetValidURIs().FirstOrDefault(); }
private void DoCopyAssetReportToClipboard() { AssetInfo AR = new AssetInfo(ReturnSelectedAssets()); AR.CopyStatsToClipBoard(); }
private void DoCopyOutputURLAssetOrProgramToClipboard() { IAsset asset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault(); if (asset != null) { AssetInfo AI = new AssetInfo(asset); IEnumerable<Uri> ValidURIs = AI.GetValidURIs(); if (ValidURIs != null && ValidURIs.FirstOrDefault() != null) { string url = ValidURIs.FirstOrDefault().AbsoluteUri; if (_context.StreamingEndpoints.Count() > 1 || (_context.StreamingEndpoints.FirstOrDefault() != null && _context.StreamingEndpoints.FirstOrDefault().CustomHostNames.Count > 0) || _context.Filters.Count() > 0 || (asset.AssetFilters.Count() > 0)) { var form = new ChooseStreamingEndpoint(_context, asset, url); if (form.ShowDialog() == DialogResult.OK) { url = AssetInfo.RW(new Uri(url), form.SelectStreamingEndpoint, form.SelectedFilters, form.ReturnHttps, form.ReturnSelectCustomHostName, form.ReturnStreamingProtocol, form.ReturnHLSAudioTrackName, form.ReturnHLSNoAudioOnlyMode).ToString(); } else { return; } } System.Windows.Forms.Clipboard.SetText(url); TextBoxLogWriteLine("The following URL has been copied to the clipboard :"); TextBoxLogWriteLine("<" + url + ">"); } else { MessageBox.Show(string.Format("No valid URL is available for asset '{0}'.", asset.Name), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public static Uri GetValidOnDemandURI(IAsset asset) { var aivalidurls = new AssetInfo(asset).GetValidURIs(); if (aivalidurls != null) { return aivalidurls.FirstOrDefault(); } else { return null; } }
private void DoCopyOutputURLAssetOrProgramToClipboard() { IAsset asset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault(); if (asset != null) { AssetInfo AI = new AssetInfo(asset); IEnumerable<Uri> ValidURIs = AI.GetValidURIs(); if (ValidURIs.FirstOrDefault() != null) { string url = ValidURIs.FirstOrDefault().AbsoluteUri; /* if (selectedGlobalFilter != null) { url = AssetInfo.AddFilterToUrlString(url, selectedGlobalFilter); } */ System.Windows.Forms.Clipboard.SetText(url); } } }
private void DoAssetCreateMail() { AssetInfo MyAssetReport = new AssetInfo(myAsset); MyAssetReport.CreateOutlookMail(); }
private async Task PlaybackAssetAsync() { if (checkBoxPreviewStream.Checked && checkBoxTrimming.Checked && _tempStreamingLocator != null) { Asset myAsset = _selectedAssets.FirstOrDefault(); Uri myuri = await AssetInfo.GetValidOnDemandURIAsync(myAsset, _amsClientV3, _tempStreamingLocator.Name); if (myuri != null) { string myurl = await AssetInfo.DoPlayBackWithStreamingEndpointAsync(typeplayer : PlayerType.AzureMediaPlayerFrame, path : AssetInfo.RW(myuri, https : true).ToString(), DoNotRewriteURL : true, client : _amsClientV3, formatamp : AzureMediaPlayerFormats.Auto, technology : AzureMediaPlayerTechnologies.Auto, launchbrowser : false, UISelectSEFiltersAndProtocols : false, mainForm : _mainform); webBrowserPreview.Url = new Uri(myurl); } else { webBrowserPreview.Url = null; } } else { webBrowserPreview.Url = null; } }