public Subclipping(CloudMediaContext context, MediaServiceContextForDynManifest contextdynmanifest, List <IAsset> assetlist, Mainform mainform) { InitializeComponent(); buttonJobOptions.Initialize(context); this.Icon = Bitmaps.Azure_Explorer_ico; _context = context; _contextdynmanifest = contextdynmanifest; _parentassetmanifestdata = new ManifestTimingData(); _selectedAssets = assetlist; _mainform = mainform; 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; textBoxOffset.Text = _parentassetmanifestdata.TimestampOffset.ToString(); labelOffset.Visible = textBoxOffset.Visible = true; textBoxFilterTimeScale.Text = _timescale.ToString(); textBoxFilterTimeScale.Visible = labelAssetTimescale.Visible = true; timeControlStart.Max = timeControlEnd.Max = new TimeSpan(AssetInfo.ReturnTimestampInTicks(_parentassetmanifestdata.AssetDuration, _parentassetmanifestdata.TimeScale)); 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.ScaledTotalDuration = timeControlEnd.ScaledTotalDuration = _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 DynManifestFilter_Load(object sender, EventArgs e) { _parentassetmanifestdata = new ManifestTimingData(); tabControl1.TabPages.Remove(tabPageTRRaw); FillComboBoxImportFilters(_parentAsset); ///////////////////////////////////////////// // New Global Filter ///////////////////////////////////////////// if (_filterToDisplay == null && _parentAsset == null) { newfilter = true; isGlobalFilter = true; _filter = new Filter(); _filter.SetContext(_contextdynman); _filter.PresentationTimeRange = new IFilterPresentationTimeRange(); _filter.Tracks = new List <IFilterTrackSelect>(); timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = timeControlDVR.TimeScale = _timescale; textBoxFilterTimeScale.Text = _filter.PresentationTimeRange.Timescale; } ///////////////////////////////////////////// // Existing Global Filter ///////////////////////////////////////////// else if (_filterToDisplay != null && _parentAsset == null) { newfilter = false; isGlobalFilter = true; _filter = _filterToDisplay; _timescale = long.Parse(_filter.PresentationTimeRange.Timescale); timeControlStart.TimeScale = timeControlEnd.TimeScale = timeControlDVR.TimeScale = _timescale; buttonOk.Text = "Update Filter"; buttonOk.Enabled = true; // we can enable the button toolTip1.SetToolTip(this.buttonOk, "It can take up to 2 minutes for streaming endpoint to refresh the rules"); textBoxFilterName.Enabled = false; // no way to change the filter name textBoxFilterName.Text = _filter.Name; textBoxFilterTimeScale.Text = _filter.PresentationTimeRange.Timescale; timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = false; checkBoxStartTime.Checked = !IsMin(_filter.PresentationTimeRange.StartTimestamp); checkBoxEndTime.Checked = !IsMax(_filter.PresentationTimeRange.EndTimestamp); checkBoxDVRWindow.Checked = !IsMax(_filter.PresentationTimeRange.PresentationWindowDuration); checkBoxLiveBackoff.Checked = !IsMin(_filter.PresentationTimeRange.LiveBackoffDuration); timeControlStart.SetScaledTimeStamp(_filter.PresentationTimeRange.StartTimestamp); timeControlEnd.SetScaledTimeStamp(IsMax(_filter.PresentationTimeRange.EndTimestamp) ? "0" : _filter.PresentationTimeRange.EndTimestamp); // we don't want to pass the max value to the control (overflow) timeControlDVR.SetScaledTimeStamp(IsMax(_filter.PresentationTimeRange.PresentationWindowDuration) ? "0" : _filter.PresentationTimeRange.PresentationWindowDuration); // we don't want to pass the max value to the control (overflow) numericUpDownBackoffSeconds.Value = (decimal)((double)(long.Parse(_filter.PresentationTimeRange.LiveBackoffDuration)) / (double)_timescale); } ///////////////////////////////////////////// // New Asset Filter ///////////////////////////////////////////// else if (_filterToDisplay == null && _parentAsset != null) { newfilter = true; isGlobalFilter = false; _filter = new Filter(); _filter.SetContext(_contextdynman); _filter.PresentationTimeRange = new IFilterPresentationTimeRange(); _filter.Tracks = new List <IFilterTrackSelect>(); labelFilterTitle.Text = "Asset Filter"; textBoxAssetName.Visible = true; labelassetname.Visible = true; textBoxAssetName.Text = _parentAsset != null ? _parentAsset.Name : string.Empty; // let's try to read asset timing _parentassetmanifestdata = AssetInfo.GetManifestTimingData(_parentAsset); if (!_parentassetmanifestdata.Error) // we were able to read asset timings and not live { // timescale _timescale = timeControlStart.TimeScale = timeControlEnd.TimeScale = timeControlDVR.TimeScale = _parentassetmanifestdata.TimeScale; timeControlStart.ScaledFirstTimestampOffset = timeControlEnd.ScaledFirstTimestampOffset = _parentassetmanifestdata.TimestampOffset; textBoxOffset.Text = _parentassetmanifestdata.TimestampOffset.ToString(); labelOffset.Visible = textBoxOffset.Visible = true; // let's disable trackbars if this is live (duration is not fixed) timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = !_parentassetmanifestdata.IsLive; TimeSpan duration = new TimeSpan(AssetInfo.ReturnTimestampInTicks(_parentassetmanifestdata.AssetDuration, _parentassetmanifestdata.TimeScale)); textBoxAssetDuration.Text = duration.ToString(@"d\.hh\:mm\:ss"); labelassetduration.Visible = textBoxAssetDuration.Visible = true; textBoxFilterName.Text = "filter" + new Random().Next(9999).ToString(); if (!_parentassetmanifestdata.IsLive) // Not a live content { // let set duration and active track bat timeControlStart.ScaledTotalDuration = timeControlEnd.ScaledTotalDuration = timeControlDVR.ScaledTotalDuration = _parentassetmanifestdata.AssetDuration; timeControlStart.Max = timeControlEnd.Max = timeControlDVR.Max = duration; timeControlEnd.SetTimeStamp(timeControlEnd.Max); } else { textBoxAssetDuration.Text += " (LIVE)"; } if (_subclipconfig != null && _subclipconfig.Trimming) // user used the subclip UI before and timings are passed { timeControlStart.SetTimeStamp(_subclipconfig.StartTimeForAssetFilter - timeControlStart.GetOffSetAsTimeSpan()); timeControlEnd.SetTimeStamp(_subclipconfig.EndTimeForAssetFilter - timeControlStart.GetOffSetAsTimeSpan()); checkBoxStartTime.Checked = checkBoxEndTime.Checked = true; textBoxFilterName.Text = "subclip" + new Random().Next(9999).ToString(); } } else // not able to read asset timings { timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = false; timeControlStart.TimeScale = timeControlEnd.TimeScale = timeControlDVR.TimeScale = _timescale; timeControlStart.Max = timeControlEnd.Max = timeControlDVR.Max = TimeSpan.MaxValue; timeControlEnd.SetTimeStamp(timeControlEnd.Max); labelassetduration.Visible = textBoxAssetDuration.Visible = false; } } ///////////////////////////////////////////// // Existing Asset Filter ///////////////////////////////////////////// else if (_filterToDisplay != null && _parentAsset != null) { newfilter = false; isGlobalFilter = false; _filter = _filterToDisplay; _timescale = long.Parse(_filter.PresentationTimeRange.Timescale); buttonOk.Text = "Update Filter"; buttonOk.Enabled = true; // we can enable the button toolTip1.SetToolTip(this.buttonOk, "It can take up to 2 minutes for streaming endpoint to refresh the rules"); labelFilterTitle.Text = "Asset Filter"; textBoxAssetName.Visible = true; labelassetname.Visible = true; textBoxAssetName.Text = _parentAsset != null ? _parentAsset.Name : string.Empty; textBoxFilterName.Enabled = false; // no way to change the filter name textBoxFilterName.Text = _filter.Name; // let's try to read asset timing _parentassetmanifestdata = AssetInfo.GetManifestTimingData(_parentAsset); _timescale = timeControlStart.TimeScale = timeControlEnd.TimeScale = timeControlDVR.TimeScale = long.Parse(_filter.PresentationTimeRange.Timescale); if (!_parentassetmanifestdata.Error && _timescale == _parentassetmanifestdata.TimeScale) // we were able to read asset timings and timescale between manifest and existing asset match { // let's disable trackbars if this is live (duration is not fixed) timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = !_parentassetmanifestdata.IsLive; timeControlStart.ScaledFirstTimestampOffset = timeControlEnd.ScaledFirstTimestampOffset = _parentassetmanifestdata.TimestampOffset; textBoxOffset.Text = _parentassetmanifestdata.TimestampOffset.ToString(); labelOffset.Visible = textBoxOffset.Visible = true; TimeSpan duration = new TimeSpan(AssetInfo.ReturnTimestampInTicks(_parentassetmanifestdata.AssetDuration, _parentassetmanifestdata.TimeScale)); textBoxAssetDuration.Text = duration.ToString(@"d\.hh\:mm\:ss"); labelassetduration.Visible = textBoxAssetDuration.Visible = true; if (!_parentassetmanifestdata.IsLive) { timeControlStart.Max = timeControlEnd.Max = timeControlDVR.Max = duration; // let set duration and active track bat timeControlStart.ScaledTotalDuration = timeControlEnd.ScaledTotalDuration = timeControlDVR.ScaledTotalDuration = _parentassetmanifestdata.AssetDuration; } else { textBoxAssetDuration.Text += " (LIVE)"; } } else // not able to read asset timings or mismatch in timescale { timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = timeControlDVR.DisplayTrackBar = false; timeControlStart.Max = timeControlEnd.Max = timeControlDVR.Max = TimeSpan.MaxValue; timeControlEnd.SetTimeStamp(timeControlEnd.Max); labelassetduration.Visible = textBoxAssetDuration.Visible = false; } checkBoxStartTime.Checked = !IsMin(_filter.PresentationTimeRange.StartTimestamp); checkBoxEndTime.Checked = !IsMax(_filter.PresentationTimeRange.EndTimestamp); checkBoxDVRWindow.Checked = !IsMax(_filter.PresentationTimeRange.PresentationWindowDuration); checkBoxLiveBackoff.Checked = !IsMin(_filter.PresentationTimeRange.LiveBackoffDuration); timeControlStart.SetScaledTimeStamp(_filter.PresentationTimeRange.StartTimestamp); timeControlEnd.SetScaledTimeStamp(IsMax(_filter.PresentationTimeRange.EndTimestamp) ? "0" : _filter.PresentationTimeRange.EndTimestamp); // we don't want to pass the max value to the control (overflow) timeControlDVR.SetScaledTimeStamp(IsMax(_filter.PresentationTimeRange.PresentationWindowDuration) ? "0" : _filter.PresentationTimeRange.PresentationWindowDuration); // we don't want to pass the max value to the control (overflow) numericUpDownBackoffSeconds.Value = (decimal)((double)(long.Parse(_filter.PresentationTimeRange.LiveBackoffDuration)) / (double)_timescale); } // Common code textBoxFilterTimeScale.Text = _timescale.ToString(); // dataPropertyType dataPropertyType = new DataTable(); dataPropertyType.Columns.Add(new DataColumn("Value", typeof(string))); dataPropertyType.Columns.Add(new DataColumn("Description", typeof(string))); dataPropertyType.Rows.Add(FilterPropertyTypeValue.audio, FilterPropertyTypeValue.audio); dataPropertyType.Rows.Add(FilterPropertyTypeValue.video, FilterPropertyTypeValue.video); dataPropertyType.Rows.Add(FilterPropertyTypeValue.text, FilterPropertyTypeValue.text); // FilterPropertyFourCCValue dataPropertyFourCC = new DataTable(); dataPropertyFourCC.Columns.Add(new DataColumn("Value", typeof(string))); dataPropertyFourCC.Columns.Add(new DataColumn("Description", typeof(string))); dataPropertyFourCC.Rows.Add(FilterPropertyFourCCValue.avc1, FilterPropertyFourCCValue.avc1); dataPropertyFourCC.Rows.Add(FilterPropertyFourCCValue.ec3, FilterPropertyFourCCValue.ec3); dataPropertyFourCC.Rows.Add(FilterPropertyFourCCValue.mp4a, FilterPropertyFourCCValue.mp4a); dataPropertyFourCC.Rows.Add(FilterPropertyFourCCValue.mp4v, FilterPropertyFourCCValue.mp4v); // dataProperty dataOperator dataProperty = new DataTable(); dataOperator = new DataTable(); dataProperty.Columns.Add(new DataColumn("Property", typeof(string))); dataProperty.Columns.Add(new DataColumn("Description", typeof(string))); dataOperator.Columns.Add(new DataColumn("Operator", typeof(string))); dataOperator.Columns.Add(new DataColumn("Description", typeof(string))); dataProperty.Rows.Add(FilterProperty.Type, FilterProperty.Type); dataProperty.Rows.Add(FilterProperty.Bitrate, FilterProperty.Bitrate); dataProperty.Rows.Add(FilterProperty.FourCC, FilterProperty.FourCC); dataProperty.Rows.Add(FilterProperty.Language, FilterProperty.Language); dataProperty.Rows.Add(FilterProperty.Name, FilterProperty.Name); dataOperator.Rows.Add(IOperator.Equal, IOperator.Equal); dataOperator.Rows.Add(IOperator.notEqual, IOperator.notEqual); var columnProperty = new DataGridViewComboBoxColumn(); columnProperty.DataSource = dataProperty; columnProperty.ValueMember = "Property"; columnProperty.DisplayMember = "Description"; dataGridViewTracks.Columns.Add(columnProperty); var columnOperator = new DataGridViewComboBoxColumn(); columnOperator.DataSource = dataOperator; columnOperator.ValueMember = "Operator"; columnOperator.DisplayMember = "Description"; dataGridViewTracks.Columns.Add(columnOperator); var columnValue = new DataGridViewTextBoxColumn(); dataGridViewTracks.Columns.Add(columnValue); moreinfoprofilelink.Links.Add(new LinkLabel.Link(0, moreinfoprofilelink.Text.Length, Constants.LinkHowIMoreInfoDynamicManifest)); RefreshTracks(); CheckIfErrorTimeControls(); }